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 3fa3dff8bd..e978148e32 100644 --- a/web/service/use-pipeline.ts +++ b/web/service/use-pipeline.ts @@ -214,12 +214,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,