mirror of
https://github.com/langgenius/dify.git
synced 2026-05-06 10:28:10 +08:00
feat: Introduce CredentialSelector component and remove WorkspaceSelector
This commit is contained in:
@ -1,16 +1,26 @@
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { preImportNotionPages } from '../datasets'
|
||||
import { get } from '../base'
|
||||
import type { DataSourceNotionWorkspace } from '@/models/common'
|
||||
|
||||
type PreImportNotionPagesParams = {
|
||||
url: string
|
||||
datasetId?: string
|
||||
credentialId: string
|
||||
datasetId: string
|
||||
}
|
||||
|
||||
export const usePreImportNotionPages = ({ datasetId }: PreImportNotionPagesParams) => {
|
||||
export const usePreImportNotionPages = ({
|
||||
credentialId,
|
||||
datasetId,
|
||||
}: PreImportNotionPagesParams) => {
|
||||
return useQuery({
|
||||
queryKey: ['notion-pre-import-pages'],
|
||||
queryKey: ['notion-pre-import-pages', credentialId, datasetId],
|
||||
queryFn: async () => {
|
||||
return preImportNotionPages({ url: '/notion/pre-import/pages', datasetId })
|
||||
return get<{ notion_info: DataSourceNotionWorkspace[] }>('/notion/pre-import/pages', {
|
||||
params: {
|
||||
dataset_id: datasetId,
|
||||
credential_id: credentialId,
|
||||
},
|
||||
})
|
||||
},
|
||||
retry: 0,
|
||||
})
|
||||
}
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
import { get, post } from './base'
|
||||
import type {
|
||||
DataSourceNotion,
|
||||
FileUploadConfigResponse,
|
||||
Member,
|
||||
StructuredOutputRulesRequestBody,
|
||||
@ -37,17 +36,6 @@ export const useFileSupportTypes = () => {
|
||||
})
|
||||
}
|
||||
|
||||
type DataSourcesResponse = {
|
||||
data: DataSourceNotion[]
|
||||
}
|
||||
|
||||
export const useDataSources = () => {
|
||||
return useQuery<DataSourcesResponse>({
|
||||
queryKey: [NAME_SPACE, 'data-sources'],
|
||||
queryFn: () => get<DataSourcesResponse>('/data-source/integrates'),
|
||||
})
|
||||
}
|
||||
|
||||
type MemberResponse = {
|
||||
accounts: Member[] | null
|
||||
}
|
||||
|
||||
@ -17,3 +17,17 @@ export const useInvalidDataSourceListAuth = (
|
||||
) => {
|
||||
return useInvalid([NAME_SPACE, 'list'])
|
||||
}
|
||||
|
||||
// !This hook is used for fetching the default data source list, which will be legacy and deprecated in the near future.
|
||||
export const useGetDefaultDataSourceListAuth = () => {
|
||||
return useQuery({
|
||||
queryKey: [NAME_SPACE, 'default-list'],
|
||||
queryFn: () => get<{ result: DataSourceAuth[] }>('/auth/plugin/datasource/default-list'),
|
||||
retry: 0,
|
||||
})
|
||||
}
|
||||
|
||||
export const useInvalidDefaultDataSourceListAuth = (
|
||||
) => {
|
||||
return useInvalid([NAME_SPACE, 'default-list'])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user