Skip to content

Commit 23e8b53

Browse files
authored
feat(db): add Weaviate support and improve network access control (#6301)
feat(db): add Weaviate support and improve network access control (#6299) * feat(db): add Weaviate support and improve network access control * update launchpad
1 parent 6f2452d commit 23e8b53

File tree

5 files changed

+32
-14
lines changed

5 files changed

+32
-14
lines changed

frontend/providers/applaunchpad/src/pages/app/edit/components/Header.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { useClientSideValue } from '@/hooks/useClientSideValue';
44
import { useGlobalStore } from '@/store/global';
55
import { useGuideStore } from '@/store/guide';
66
import type { YamlItemType } from '@/types/index';
7+
import type { AppEditType } from '@/types/app';
78
import { downLoadBold } from '@/utils/tools';
89
import { Box, Button, Center, Flex, Text } from '@chakra-ui/react';
910
import { track } from '@sealos/gtm';
@@ -12,17 +13,20 @@ import { Info, X } from 'lucide-react';
1213
import { useTranslation } from 'next-i18next';
1314
import { useRouter } from 'next/router';
1415
import { useCallback } from 'react';
16+
import { formData2Yamls } from '../index';
1517

1618
const Header = ({
1719
appName,
1820
title,
1921
yamlList,
22+
getFormData,
2023
applyCb,
2124
applyBtnText
2225
}: {
2326
appName: string;
2427
title: string;
2528
yamlList: YamlItemType[];
29+
getFormData?: () => AppEditType;
2630
applyCb: () => void;
2731
applyBtnText: string;
2832
}) => {
@@ -32,14 +36,22 @@ const Header = ({
3236
const isClientSide = useClientSideValue(true);
3337

3438
const handleExportYaml = useCallback(async () => {
35-
const exportYamlString = yamlList.map((i) => i.value).join('---\n');
39+
let exportYamlList: YamlItemType[];
40+
if (getFormData) {
41+
const formData = getFormData();
42+
exportYamlList = formData2Yamls(formData);
43+
} else {
44+
exportYamlList = yamlList;
45+
}
46+
47+
const exportYamlString = exportYamlList.map((i) => i.value).join('---\n');
3648
if (!exportYamlString) return;
3749
downLoadBold(
3850
exportYamlString,
3951
'application/yaml',
4052
appName ? `${appName}.yaml` : `yaml${dayjs().format('YYYYMMDDHHmmss')}.yaml`
4153
);
42-
}, [appName, yamlList]);
54+
}, [appName, yamlList, getFormData]);
4355

4456
const { createCompleted, startTimeMs } = useGuideStore();
4557

frontend/providers/applaunchpad/src/pages/app/edit/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,7 @@ const EditApp = ({ appName, tabType }: { appName?: string; tabType: string }) =>
397397
appName={formHook.getValues('appName')}
398398
title={title}
399399
yamlList={yamlList}
400+
getFormData={() => realTimeForm.current}
400401
applyBtnText={applyBtnText}
401402
applyCb={() => {
402403
formHook.handleSubmit(async (data) => {

frontend/providers/dbprovider/src/constants/db.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -228,12 +228,12 @@ export const DBTypeList = [
228228
{ id: DBTypeEnum.mysql, label: 'MySQL' },
229229
{ id: DBTypeEnum.redis, label: 'Redis' },
230230
{ id: DBTypeEnum.kafka, label: 'Kafka' },
231-
{ id: DBTypeEnum.milvus, label: 'Milvus' }
232-
// { id: DBTypeEnum.qdrant, label: 'qdrant' },
233-
// { id: DBTypeEnum.pulsar, label: 'pulsar' },
234-
// { id: DBTypeEnum.clickhouse, label: 'clickhouse' }
235-
// { id: DBTypeEnum.nebula, label: 'nebula' },
236-
// { id: DBTypeEnum.weaviate, label: 'weaviate' }
231+
{ id: DBTypeEnum.milvus, label: 'Milvus' },
232+
{ id: DBTypeEnum.weaviate, label: 'Weaviate' }
233+
// { id: DBTypeEnum.qdrant, label: 'Qdrant' },
234+
// { id: DBTypeEnum.pulsar, label: 'Pulsar' },
235+
// { id: DBTypeEnum.clickhouse, label: 'ClickHouse' },
236+
// { id: DBTypeEnum.nebula, label: 'Nebula' }
237237
];
238238

239239
export const DBComponentNameMap: Record<DBType, Array<DBComponentsName>> = {

frontend/providers/dbprovider/src/pages/db/detail/components/AppBaseInfo.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,10 @@ const AppBaseInfo = ({ db = defaultDBDetail }: { db: DBDetailType }) => {
157157
}, [applistCompleted, detailCompleted, router?.query?.guide, t]);
158158

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

165165
const { data: dbStatefulSet, refetch: refetchDBStatefulSet } = useQuery(
166166
['getDBStatefulSetByName', db.dbName, db.dbType],
@@ -182,15 +182,15 @@ const AppBaseInfo = ({ db = defaultDBDetail }: { db: DBDetailType }) => {
182182
})
183183
: null,
184184
{
185-
enabled: supportConnectDB
185+
enabled: !!db.dbName && !!db.dbType
186186
}
187187
);
188188

189189
const { data: service, refetch: refetchService } = useQuery(
190190
['getDBService', db.dbName, db.dbType],
191191
() => (db.dbName ? getDBServiceByName(`${db.dbName}-export`) : null),
192192
{
193-
enabled: supportConnectDB,
193+
enabled: !!db.dbName && !!db.dbType,
194194
retry: 3,
195195
onSuccess(data) {
196196
setIsChecked(!!data);
@@ -705,7 +705,7 @@ const AppBaseInfo = ({ db = defaultDBDetail }: { db: DBDetailType }) => {
705705
ml="12px"
706706
size="md"
707707
isChecked={isChecked}
708-
isDisabled={db.dbType === 'kafka'}
708+
isDisabled={!supportConnectDB}
709709
onChange={(e) => {
710710
if (isChecked) {
711711
closeNetWorkService();

frontend/providers/dbprovider/src/pages/db/edit/components/Form.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,11 @@ const Form = ({
448448
});
449449

450450
const filtered = DBTypeList.filter((dbType) => {
451+
// Exclude weaviate from create form
452+
if (dbType.id === DBTypeEnum.weaviate) {
453+
return false;
454+
}
455+
451456
const addonName = dbType.id;
452457
const addonStatus = addonStatusMap.get(addonName);
453458
const shouldInclude = addonStatus !== 'Disabled';

0 commit comments

Comments
 (0)