datasource

pull/21398/head
zxhlyh 11 months ago
parent 0bf0c7dbe8
commit a7fa5044e3

@ -52,6 +52,7 @@ export type Collection = {
plugin_id?: string plugin_id?: string
letter?: string letter?: string
is_authorized?: boolean is_authorized?: boolean
provider?: string
} }
export type ToolParameter = { export type ToolParameter = {

@ -71,8 +71,8 @@ const Panel: FC<NodePanelProps<DataSourceNodeType>> = ({ id, data }) => {
const { mutateAsync } = useUpdateDataSourceCredentials() const { mutateAsync } = useUpdateDataSourceCredentials()
const handleAuth = useCallback(async (value: any) => { const handleAuth = useCallback(async (value: any) => {
await mutateAsync({ await mutateAsync({
provider: currentDataSourceItem?.provider, provider: currentDataSource?.provider || '',
pluginId: currentDataSourceItem?.plugin_id, pluginId: currentDataSource?.plugin_id || '',
credentials: value, credentials: value,
}) })
@ -81,7 +81,7 @@ const Panel: FC<NodePanelProps<DataSourceNodeType>> = ({ id, data }) => {
message: t('common.api.actionSuccess'), message: t('common.api.actionSuccess'),
}) })
hideAuthModal() hideAuthModal()
}, [currentDataSourceItem, mutateAsync, notify, t, hideAuthModal]) }, [currentDataSource, mutateAsync, notify, t, hideAuthModal])
return ( return (
<div > <div >

@ -212,12 +212,12 @@ export const useRunPublishedPipeline = (
} }
export const useDataSourceCredentials = (provider: string, pluginId: string, onSuccess: (value: ToolCredential[]) => void) => { export const useDataSourceCredentials = (provider: string, pluginId: string, onSuccess: (value: ToolCredential[]) => void) => {
return useQuery<ToolCredential[]>({ return useQuery({
queryKey: [NAME_SPACE, 'datasource-credentials', provider, pluginId], queryKey: [NAME_SPACE, 'datasource-credentials', provider, pluginId],
queryFn: async () => { queryFn: async () => {
const result = await get<ToolCredential[]>(`/auth/plugin/datasource?provider=${provider}&plugin_id=${pluginId}`) const result = await get<{ result: ToolCredential[] }>(`/auth/plugin/datasource?provider=${provider}&plugin_id=${pluginId}`)
onSuccess(result) onSuccess(result.result)
return result return result.result
}, },
enabled: !!provider && !!pluginId, enabled: !!provider && !!pluginId,
retry: 2, retry: 2,

Loading…
Cancel
Save