Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useClientSideValue } from '@/hooks/useClientSideValue';
import { useGlobalStore } from '@/store/global';
import { useGuideStore } from '@/store/guide';
import type { YamlItemType } from '@/types/index';
import type { AppEditType } from '@/types/app';
import { downLoadBold } from '@/utils/tools';
import { Box, Button, Center, Flex, Text } from '@chakra-ui/react';
import { track } from '@sealos/gtm';
Expand All @@ -12,17 +13,20 @@ import { Info, X } from 'lucide-react';
import { useTranslation } from 'next-i18next';
import { useRouter } from 'next/router';
import { useCallback } from 'react';
import { formData2Yamls } from '../index';

const Header = ({
appName,
title,
yamlList,
getFormData,
applyCb,
applyBtnText
}: {
appName: string;
title: string;
yamlList: YamlItemType[];
getFormData?: () => AppEditType;
applyCb: () => void;
applyBtnText: string;
}) => {
Expand All @@ -32,14 +36,22 @@ const Header = ({
const isClientSide = useClientSideValue(true);

const handleExportYaml = useCallback(async () => {
const exportYamlString = yamlList.map((i) => i.value).join('---\n');
let exportYamlList: YamlItemType[];
if (getFormData) {
const formData = getFormData();
exportYamlList = formData2Yamls(formData);
} else {
exportYamlList = yamlList;
}

const exportYamlString = exportYamlList.map((i) => i.value).join('---\n');
if (!exportYamlString) return;
downLoadBold(
exportYamlString,
'application/yaml',
appName ? `${appName}.yaml` : `yaml${dayjs().format('YYYYMMDDHHmmss')}.yaml`
);
}, [appName, yamlList]);
}, [appName, yamlList, getFormData]);

const { createCompleted, startTimeMs } = useGuideStore();

Expand Down
13 changes: 7 additions & 6 deletions frontend/providers/applaunchpad/src/pages/app/edit/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,21 +171,21 @@ const EditApp = ({ appName, tabType }: { appName?: string; tabType: string }) =>
(formHook.formState.defaultValues?.hpa?.use
? formHook.formState.defaultValues?.hpa?.maxReplicas
: Number.isSafeInteger(formHook.formState.defaultValues?.replicas)
? (formHook.formState.defaultValues?.replicas as number)
: 1) ?? 1;
? (formHook.formState.defaultValues?.replicas as number)
: 1) ?? 1;

const newReplicas = realTimeForm.current.hpa.use
? realTimeForm.current.hpa.maxReplicas
: Number.isSafeInteger(realTimeForm.current.replicas)
? (realTimeForm.current.replicas as number)
: 1;
? (realTimeForm.current.replicas as number)
: 1;

const oldGpuCount =
formHook.formState.defaultValues?.gpu?.type === ''
? 0
: formHook.formState.defaultValues?.gpu?.amount ?? 0;
: (formHook.formState.defaultValues?.gpu?.amount ?? 0);
const newGpuCount =
realTimeForm.current.gpu?.type === '' ? 0 : realTimeForm.current.gpu?.amount ?? 0;
realTimeForm.current.gpu?.type === '' ? 0 : (realTimeForm.current.gpu?.amount ?? 0);

return checkExceededQuotas({
cpu: isEdit
Expand Down Expand Up @@ -538,6 +538,7 @@ const EditApp = ({ appName, tabType }: { appName?: string; tabType: string }) =>
appName={formHook.getValues('appName')}
title={title}
yamlList={yamlList}
getFormData={() => realTimeForm.current}
applyBtnText={applyBtnText}
applyCb={handleSubmit}
/>
Expand Down
12 changes: 6 additions & 6 deletions frontend/providers/dbprovider/src/constants/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,12 +231,12 @@ export const DBTypeList = [
{ id: DBTypeEnum.mysql, label: 'MySQL' },
{ id: DBTypeEnum.redis, label: 'Redis' },
{ id: DBTypeEnum.kafka, label: 'Kafka' },
{ id: DBTypeEnum.milvus, label: 'Milvus' }
// { id: DBTypeEnum.qdrant, label: 'qdrant' },
// { id: DBTypeEnum.pulsar, label: 'pulsar' },
// { id: DBTypeEnum.clickhouse, label: 'clickhouse' }
// { id: DBTypeEnum.nebula, label: 'nebula' },
// { id: DBTypeEnum.weaviate, label: 'weaviate' }
{ id: DBTypeEnum.milvus, label: 'Milvus' },
{ id: DBTypeEnum.weaviate, label: 'Weaviate' }
// { id: DBTypeEnum.qdrant, label: 'Qdrant' },
// { id: DBTypeEnum.pulsar, label: 'Pulsar' },
// { id: DBTypeEnum.clickhouse, label: 'ClickHouse' },
// { id: DBTypeEnum.nebula, label: 'Nebula' }
];

export const DBComponentNameMap: Record<DBType, Array<DBComponentsName>> = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,10 @@ const AppBaseInfo = ({ db = defaultDBDetail }: { db: DBDetailType }) => {
}, [applistCompleted, detailCompleted, router?.query?.guide, t]);

const supportConnectDB = useMemo(() => {
return !!['postgresql', 'mongodb', 'apecloud-mysql', 'redis', 'milvus', 'kafka'].find(
(item) => item === db.dbType
return !!['postgresql', 'mongodb', 'apecloud-mysql', 'redis', 'milvus'].find(
(item) => item === db?.dbType
);
}, [db.dbType]);
}, [db?.dbType]);

// load user quota on component mount
useEffect(() => {
Expand Down Expand Up @@ -198,15 +198,15 @@ const AppBaseInfo = ({ db = defaultDBDetail }: { db: DBDetailType }) => {
})
: null,
{
enabled: supportConnectDB
enabled: !!db.dbName && !!db.dbType
}
);

const { data: service, refetch: refetchService } = useQuery(
['getDBService', db.dbName, db.dbType],
() => (db.dbName ? getDBServiceByName(`${db.dbName}-export`) : null),
{
enabled: supportConnectDB,
enabled: !!db.dbName && !!db.dbType,
retry: 3,
onSuccess(data) {
setIsChecked(!!data);
Expand Down Expand Up @@ -747,7 +747,7 @@ const AppBaseInfo = ({ db = defaultDBDetail }: { db: DBDetailType }) => {
ml="12px"
size="md"
isChecked={isChecked}
isDisabled={db.dbType === 'kafka'}
isDisabled={!supportConnectDB}
onChange={(e) => {
if (isChecked) {
closeNetWorkService();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,11 @@ const Form = ({
});

const filtered = DBTypeList.filter((dbType) => {
// Exclude weaviate from create form
if (dbType.id === DBTypeEnum.weaviate) {
return false;
}

const addonName = dbType.id;
const addonStatus = addonStatusMap.get(addonName);
const shouldInclude = addonStatus !== 'Disabled';
Expand Down
Loading