From 100a95450be0b6eb0778a37d18f64d7ef3c55553 Mon Sep 17 00:00:00 2001 From: katherinehhh Date: Fri, 26 Jan 2024 10:22:32 +0800 Subject: [PATCH 1/2] refactor: refactor dataSource manager --- .../client/component/CollectionsManager/CollectionFields.tsx | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/plugins/@nocobase/plugin-data-source-manager/src/client/component/CollectionsManager/CollectionFields.tsx b/packages/plugins/@nocobase/plugin-data-source-manager/src/client/component/CollectionsManager/CollectionFields.tsx index 4e3481aee2..1e81820396 100644 --- a/packages/plugins/@nocobase/plugin-data-source-manager/src/client/component/CollectionsManager/CollectionFields.tsx +++ b/packages/plugins/@nocobase/plugin-data-source-manager/src/client/component/CollectionsManager/CollectionFields.tsx @@ -109,10 +109,7 @@ export const CollectionFields = () => { const { targetScope } = options; const isFieldInherits = field.props?.name === 'inherits'; const { data } = await api.request({ - url: 'dataSourcesCollections:list', - headers: { - 'X-Database': dataSourceKey, - }, + url: `dataSources/${dataSourceKey}/collections:list`, params: { paginate: false, appends: ['fields'], From 26f0efecc38e20803b3974d89b4b97600f9b4e3d Mon Sep 17 00:00:00 2001 From: katherinehhh Date: Fri, 26 Jan 2024 10:28:13 +0800 Subject: [PATCH 2/2] refactor: refactor dataSource manager --- .../CollectionsManager/components/index.tsx | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/packages/plugins/@nocobase/plugin-data-source-manager/src/client/component/CollectionsManager/components/index.tsx b/packages/plugins/@nocobase/plugin-data-source-manager/src/client/component/CollectionsManager/components/index.tsx index 015962cb68..fcda9d406b 100644 --- a/packages/plugins/@nocobase/plugin-data-source-manager/src/client/component/CollectionsManager/components/index.tsx +++ b/packages/plugins/@nocobase/plugin-data-source-manager/src/client/component/CollectionsManager/components/index.tsx @@ -42,10 +42,10 @@ export const ForeignKey = observer( const { value, disabled } = props; const api = useAPIClient(); const [options, setOptions] = useState([]); - const { connectionName, name: collectionName, fields } = useRecord(); + const { name: dataSourceKey } = useParams(); + const { name: collectionName, fields } = useRecord(); const compile = useCompile(); const form = useForm(); - const { name } = useParams(); const { target, type, through } = form.values; const [initialValue, setInitialValue] = useState(value); const field: any = useField(); @@ -86,8 +86,7 @@ export const ForeignKey = observer( : target; if (effectField && open) { const { data } = await api.request({ - url: `remoteCollections/${effectField}/fields:list`, - headers: { 'X-Database': connectionName || name }, + url: `dataSourcesCollections/${dataSourceKey}.${effectField}/fields:list`, params: { paginate: false, filter: { @@ -123,12 +122,12 @@ export const ForeignKey = observer( export const TargetKey = observer( (props: any) => { const { value, disabled } = props; - const { connectionName, targetKey } = useRecord(); + const { targetKey } = useRecord(); + const { name: dataSourceKey } = useParams(); const api = useAPIClient(); const [options, setOptions] = useState([]); const [initialValue, setInitialValue] = useState(value || targetKey); const form = useForm(); - const { name } = useParams(); const compile = useCompile(); const field: any = useField(); field.required = true; @@ -140,8 +139,7 @@ export const TargetKey = observer( const { target } = form.values; if (target && open) { const { data } = await api.request({ - url: `remoteCollections/${target}/fields:list`, - headers: { 'X-Database': connectionName || name }, + url: `dataSourcesCollections/${dataSourceKey}.${target}/fields:list`, params: { paginate: false, filter: {