feat: Introduce CredentialSelector component and remove WorkspaceSelector

This commit is contained in:
twwu
2025-07-30 15:19:10 +08:00
parent c70a7e832e
commit f8d7d07c13
16 changed files with 398 additions and 351 deletions

View File

@ -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,
})
}

View File

@ -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
}

View File

@ -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'])
}