From c281950b5d2b987fdc8789d92c8119602459e504 Mon Sep 17 00:00:00 2001 From: katherinehhh Date: Mon, 22 Jan 2024 20:55:55 +0800 Subject: [PATCH] refactor: createDatabaseConnection --- .../component/CreateDatabaseConnectAction.tsx | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/packages/plugins/@nocobase/plugin-data-source-manager/src/client/component/CreateDatabaseConnectAction.tsx b/packages/plugins/@nocobase/plugin-data-source-manager/src/client/component/CreateDatabaseConnectAction.tsx index 7976fc9d31..62a1db459a 100644 --- a/packages/plugins/@nocobase/plugin-data-source-manager/src/client/component/CreateDatabaseConnectAction.tsx +++ b/packages/plugins/@nocobase/plugin-data-source-manager/src/client/component/CreateDatabaseConnectAction.tsx @@ -17,10 +17,11 @@ export const CreateDatabaseConnectAction = () => { const { t } = useTranslation(); const [dialect, setDialect] = useState(null); const useDialectDataSource = (field) => { - const options = [...plugin.databaseTypes.values()].map((storageType) => { + const options = [...plugin.databaseTypes.keys()].map((key) => { + const databaseType = plugin.databaseTypes.get(key); return { - value: storageType.name, - label: compile(storageType.title), + value: databaseType.name, + label: compile(databaseType.label), }; }); field.dataSource = options; @@ -43,12 +44,15 @@ export const CreateDatabaseConnectAction = () => { 'x-decorator': 'Form', 'x-decorator-props': { initialValue: { - dialect: databaseType.name, + dialect: info.key, }, }, - title: compile("{{t('Add new')}}") + ' - ' + compile(databaseType.title), + title: compile("{{t('Add new')}}") + ' - ' + compile(databaseType.label), properties: { - ..._.cloneDeep(databaseType.properties), + body: { + type: 'void', + 'x-component': databaseType.DataSourceSettingsForm, + }, footer: { type: 'void', 'x-component': 'Action.Drawer.Footer', @@ -82,10 +86,11 @@ export const CreateDatabaseConnectAction = () => { }, }); }, - items: [...plugin.databaseTypes.values()].map((storageType) => { + items: [...plugin.databaseTypes.keys()].map((key) => { + const databaseType = plugin.databaseTypes.get(key); return { - key: storageType.name, - label: compile(storageType.title), + key: key, + label: compile(databaseType?.label), }; }), }}