From a7fa5044e34b4643c085d48d2b6635166132dc5d Mon Sep 17 00:00:00 2001 From: zxhlyh Date: Wed, 4 Jun 2025 18:09:03 +0800 Subject: [PATCH] datasource --- web/app/components/tools/types.ts | 1 + web/app/components/workflow/nodes/data-source/panel.tsx | 6 +++--- web/service/use-pipeline.ts | 8 ++++---- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/web/app/components/tools/types.ts b/web/app/components/tools/types.ts index 94718b3469..0828506ccd 100644 --- a/web/app/components/tools/types.ts +++ b/web/app/components/tools/types.ts @@ -52,6 +52,7 @@ export type Collection = { plugin_id?: string letter?: string is_authorized?: boolean + provider?: string } export type ToolParameter = { diff --git a/web/app/components/workflow/nodes/data-source/panel.tsx b/web/app/components/workflow/nodes/data-source/panel.tsx index b9c5348bb7..f28e19d919 100644 --- a/web/app/components/workflow/nodes/data-source/panel.tsx +++ b/web/app/components/workflow/nodes/data-source/panel.tsx @@ -71,8 +71,8 @@ const Panel: FC> = ({ id, data }) => { const { mutateAsync } = useUpdateDataSourceCredentials() const handleAuth = useCallback(async (value: any) => { await mutateAsync({ - provider: currentDataSourceItem?.provider, - pluginId: currentDataSourceItem?.plugin_id, + provider: currentDataSource?.provider || '', + pluginId: currentDataSource?.plugin_id || '', credentials: value, }) @@ -81,7 +81,7 @@ const Panel: FC> = ({ id, data }) => { message: t('common.api.actionSuccess'), }) hideAuthModal() - }, [currentDataSourceItem, mutateAsync, notify, t, hideAuthModal]) + }, [currentDataSource, mutateAsync, notify, t, hideAuthModal]) return (
diff --git a/web/service/use-pipeline.ts b/web/service/use-pipeline.ts index 98bb21e19c..f864bd844b 100644 --- a/web/service/use-pipeline.ts +++ b/web/service/use-pipeline.ts @@ -212,12 +212,12 @@ export const useRunPublishedPipeline = ( } export const useDataSourceCredentials = (provider: string, pluginId: string, onSuccess: (value: ToolCredential[]) => void) => { - return useQuery({ + return useQuery({ queryKey: [NAME_SPACE, 'datasource-credentials', provider, pluginId], queryFn: async () => { - const result = await get(`/auth/plugin/datasource?provider=${provider}&plugin_id=${pluginId}`) - onSuccess(result) - return result + const result = await get<{ result: ToolCredential[] }>(`/auth/plugin/datasource?provider=${provider}&plugin_id=${pluginId}`) + onSuccess(result.result) + return result.result }, enabled: !!provider && !!pluginId, retry: 2,