Merge branch 'feat/dataSource-manager' of github.com:nocobase/nocobase into feat/dataSource-manager

This commit is contained in:
katherinehhh 2024-01-22 21:09:22 +08:00
commit 51dbe7e20a

View File

@ -17,10 +17,11 @@ export const CreateDatabaseConnectAction = () => {
const { t } = useTranslation(); const { t } = useTranslation();
const [dialect, setDialect] = useState(null); const [dialect, setDialect] = useState(null);
const useDialectDataSource = (field) => { const useDialectDataSource = (field) => {
const options = [...plugin.databaseTypes.values()].map((storageType) => { const options = [...plugin.databaseTypes.keys()].map((key) => {
const databaseType = plugin.databaseTypes.get(key);
return { return {
value: storageType.name, value: databaseType.name,
label: compile(storageType.title), label: compile(databaseType.label),
}; };
}); });
field.dataSource = options; field.dataSource = options;
@ -43,12 +44,15 @@ export const CreateDatabaseConnectAction = () => {
'x-decorator': 'Form', 'x-decorator': 'Form',
'x-decorator-props': { 'x-decorator-props': {
initialValue: { initialValue: {
dialect: databaseType.name, dialect: info.key,
}, },
}, },
title: compile("{{t('Add new')}}") + ' - ' + compile(databaseType.title), title: compile("{{t('Add new')}}") + ' - ' + compile(databaseType.label),
properties: { properties: {
..._.cloneDeep(databaseType.properties), body: {
type: 'void',
'x-component': databaseType.DataSourceSettingsForm,
},
footer: { footer: {
type: 'void', type: 'void',
'x-component': 'Action.Drawer.Footer', '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 { return {
key: storageType.name, key: key,
label: compile(storageType.title), label: compile(databaseType?.label),
}; };
}), }),
}} }}