2025-05-21 16:37:02 +08:00
|
|
|
'use client'
|
2025-05-23 10:29:59 +08:00
|
|
|
import { useCallback, useMemo, useRef, useState } from 'react'
|
2025-05-22 14:49:40 +08:00
|
|
|
import DataSourceOptions from './data-source-options'
|
2025-05-28 18:34:26 +08:00
|
|
|
import type { CrawlResultItem, DocumentItem, CustomFile as File, FileIndexingEstimateResponse } from '@/models/datasets'
|
2025-07-02 14:56:29 +08:00
|
|
|
import LocalFile from '@/app/components/datasets/documents/create-from-pipeline/data-source/local-file'
|
2025-05-21 16:37:02 +08:00
|
|
|
import { useProviderContextSelector } from '@/context/provider-context'
|
2025-05-27 11:01:38 +08:00
|
|
|
import type { NotionPage } from '@/models/common'
|
2025-07-02 14:56:29 +08:00
|
|
|
import OnlineDocuments from '@/app/components/datasets/documents/create-from-pipeline/data-source/online-documents'
|
2025-05-22 14:49:40 +08:00
|
|
|
import VectorSpaceFull from '@/app/components/billing/vector-space-full'
|
2025-07-02 14:56:29 +08:00
|
|
|
import WebsiteCrawl from '@/app/components/datasets/documents/create-from-pipeline/data-source/website-crawl'
|
|
|
|
import OnlineDrive from '@/app/components/datasets/documents/create-from-pipeline/data-source/online-drive'
|
2025-07-01 16:32:21 +08:00
|
|
|
import Actions from './actions'
|
2025-05-22 14:49:40 +08:00
|
|
|
import { useTranslation } from 'react-i18next'
|
|
|
|
import type { Datasource } from '@/app/components/rag-pipeline/components/panel/test-run/types'
|
2025-05-21 16:37:02 +08:00
|
|
|
import LeftHeader from './left-header'
|
2025-05-27 11:01:38 +08:00
|
|
|
import { usePublishedPipelineInfo, useRunPublishedPipeline } from '@/service/use-pipeline'
|
2025-05-22 14:49:40 +08:00
|
|
|
import { useDatasetDetailContextWithSelector } from '@/context/dataset-detail'
|
|
|
|
import Loading from '@/app/components/base/loading'
|
|
|
|
import type { Node } from '@/app/components/workflow/types'
|
|
|
|
import type { DataSourceNodeType } from '@/app/components/workflow/nodes/data-source/types'
|
|
|
|
import FilePreview from './preview/file-preview'
|
2025-06-13 10:54:31 +08:00
|
|
|
import OnlineDocumentPreview from './preview/online-document-preview'
|
2025-05-22 14:49:40 +08:00
|
|
|
import WebsitePreview from './preview/web-preview'
|
2025-05-22 17:39:39 +08:00
|
|
|
import ProcessDocuments from './process-documents'
|
2025-05-22 23:05:58 +08:00
|
|
|
import ChunkPreview from './preview/chunk-preview'
|
|
|
|
import Processing from './processing'
|
2025-06-03 17:42:40 +08:00
|
|
|
import type { InitialDocumentDetail, PublishedPipelineRunPreviewResponse, PublishedPipelineRunResponse } from '@/models/pipeline'
|
2025-05-27 11:01:38 +08:00
|
|
|
import { DatasourceType } from '@/models/pipeline'
|
2025-05-28 14:51:10 +08:00
|
|
|
import { TransferMethod } from '@/types/app'
|
2025-07-01 16:54:44 +08:00
|
|
|
import { useAddDocumentsSteps, useLocalFile, useOnlineDocuments, useOnlineDrive, useWebsiteCrawl } from './hooks'
|
2025-05-21 16:37:02 +08:00
|
|
|
|
2025-05-29 14:06:12 +08:00
|
|
|
const CreateFormPipeline = () => {
|
2025-05-21 16:37:02 +08:00
|
|
|
const { t } = useTranslation()
|
|
|
|
const plan = useProviderContextSelector(state => state.plan)
|
|
|
|
const enableBilling = useProviderContextSelector(state => state.enableBilling)
|
2025-05-22 14:49:40 +08:00
|
|
|
const pipelineId = useDatasetDetailContextWithSelector(s => s.dataset?.pipeline_id)
|
2025-05-28 18:34:26 +08:00
|
|
|
const [datasource, setDatasource] = useState<Datasource>()
|
|
|
|
const [estimateData, setEstimateData] = useState<FileIndexingEstimateResponse | undefined>(undefined)
|
2025-06-03 17:42:40 +08:00
|
|
|
const [batchId, setBatchId] = useState('')
|
|
|
|
const [documents, setDocuments] = useState<InitialDocumentDetail[]>([])
|
2025-05-21 16:37:02 +08:00
|
|
|
|
2025-05-23 10:29:59 +08:00
|
|
|
const isPreview = useRef(false)
|
|
|
|
const formRef = useRef<any>(null)
|
|
|
|
|
2025-05-22 14:49:40 +08:00
|
|
|
const { data: pipelineInfo, isFetching: isFetchingPipelineInfo } = usePublishedPipelineInfo(pipelineId || '')
|
2025-05-21 16:37:02 +08:00
|
|
|
|
2025-05-28 18:34:26 +08:00
|
|
|
const {
|
2025-05-29 10:18:11 +08:00
|
|
|
steps,
|
2025-05-28 18:34:26 +08:00
|
|
|
currentStep,
|
|
|
|
handleNextStep,
|
|
|
|
handleBackStep,
|
|
|
|
} = useAddDocumentsSteps()
|
|
|
|
const {
|
|
|
|
fileList,
|
|
|
|
previewFile,
|
|
|
|
allFileLoaded,
|
|
|
|
updateFile,
|
|
|
|
updateFileList,
|
|
|
|
currentFile,
|
|
|
|
updateCurrentFile,
|
|
|
|
hideFilePreview,
|
|
|
|
} = useLocalFile()
|
|
|
|
const {
|
2025-07-01 16:32:21 +08:00
|
|
|
documentsData,
|
|
|
|
setDocumentsData,
|
|
|
|
searchValue,
|
|
|
|
setSearchValue,
|
|
|
|
currentWorkspaceId,
|
|
|
|
setCurrentWorkspaceId,
|
|
|
|
PagesMapAndSelectedPagesId,
|
|
|
|
selectedPagesId,
|
|
|
|
setSelectedPagesId,
|
2025-06-06 10:08:19 +08:00
|
|
|
onlineDocuments,
|
|
|
|
previewOnlineDocument,
|
|
|
|
updateOnlineDocuments,
|
2025-06-23 16:31:09 +08:00
|
|
|
currentDocument,
|
2025-05-28 18:34:26 +08:00
|
|
|
updateCurrentPage,
|
2025-06-06 10:08:19 +08:00
|
|
|
hideOnlineDocumentPreview,
|
|
|
|
} = useOnlineDocuments()
|
2025-05-28 18:34:26 +08:00
|
|
|
const {
|
|
|
|
websitePages,
|
2025-06-23 15:38:24 +08:00
|
|
|
crawlResult,
|
|
|
|
setCrawlResult,
|
|
|
|
step,
|
|
|
|
setStep,
|
2025-05-28 18:34:26 +08:00
|
|
|
previewWebsitePage,
|
2025-06-06 17:00:34 +08:00
|
|
|
updataCheckedCrawlResultChange,
|
2025-05-28 18:34:26 +08:00
|
|
|
currentWebsite,
|
|
|
|
updateCurrentWebsite,
|
2025-06-23 15:38:24 +08:00
|
|
|
previewIndex,
|
2025-05-28 18:34:26 +08:00
|
|
|
hideWebsitePreview,
|
|
|
|
} = useWebsiteCrawl()
|
2025-07-01 16:54:44 +08:00
|
|
|
const {
|
|
|
|
prefix,
|
|
|
|
setPrefix,
|
|
|
|
keywords,
|
|
|
|
setKeywords,
|
|
|
|
startAfter,
|
|
|
|
setStartAfter,
|
|
|
|
selectedFileList,
|
|
|
|
setSelectedFileList,
|
|
|
|
fileList: onlineDriveFileList,
|
|
|
|
setFileList,
|
|
|
|
} = useOnlineDrive()
|
2025-05-28 18:34:26 +08:00
|
|
|
|
2025-05-21 16:37:02 +08:00
|
|
|
const isVectorSpaceFull = plan.usage.vectorSpace >= plan.total.vectorSpace
|
|
|
|
const isShowVectorSpaceFull = allFileLoaded && isVectorSpaceFull && enableBilling
|
|
|
|
const notSupportBatchUpload = enableBilling && plan.type === 'sandbox'
|
2025-06-26 13:46:12 +08:00
|
|
|
const datasourceType = datasource?.nodeData.provider_type
|
2025-05-21 16:37:02 +08:00
|
|
|
|
|
|
|
const nextBtnDisabled = useMemo(() => {
|
|
|
|
if (!datasource) return true
|
2025-06-26 13:46:12 +08:00
|
|
|
if (datasourceType === DatasourceType.localFile)
|
2025-05-28 18:34:26 +08:00
|
|
|
return isShowVectorSpaceFull || !fileList.length || fileList.some(file => !file.file.id)
|
2025-06-26 13:46:12 +08:00
|
|
|
if (datasourceType === DatasourceType.onlineDocument)
|
2025-06-06 10:08:19 +08:00
|
|
|
return isShowVectorSpaceFull || !onlineDocuments.length
|
2025-06-26 13:46:12 +08:00
|
|
|
if (datasourceType === DatasourceType.websiteCrawl)
|
2025-05-21 16:37:02 +08:00
|
|
|
return isShowVectorSpaceFull || !websitePages.length
|
|
|
|
return false
|
2025-06-26 13:46:12 +08:00
|
|
|
}, [datasource, datasourceType, isShowVectorSpaceFull, fileList, onlineDocuments.length, websitePages.length])
|
2025-05-21 16:37:02 +08:00
|
|
|
|
2025-05-27 11:01:38 +08:00
|
|
|
const { mutateAsync: runPublishedPipeline, isIdle, isPending } = useRunPublishedPipeline()
|
2025-05-22 23:05:58 +08:00
|
|
|
|
2025-05-27 11:01:38 +08:00
|
|
|
const handlePreviewChunks = useCallback(async (data: Record<string, any>) => {
|
2025-05-21 16:37:02 +08:00
|
|
|
if (!datasource)
|
|
|
|
return
|
2025-05-27 11:01:38 +08:00
|
|
|
const datasourceInfoList: Record<string, any>[] = []
|
2025-06-26 13:46:12 +08:00
|
|
|
if (datasourceType === DatasourceType.localFile) {
|
2025-05-28 13:44:37 +08:00
|
|
|
const { id, name, type, size, extension, mime_type } = previewFile.current as File
|
2025-05-27 11:01:38 +08:00
|
|
|
const documentInfo = {
|
2025-05-28 14:51:10 +08:00
|
|
|
related_id: id,
|
2025-05-27 11:01:38 +08:00
|
|
|
name,
|
|
|
|
type,
|
|
|
|
size,
|
|
|
|
extension,
|
|
|
|
mime_type,
|
2025-05-28 14:51:10 +08:00
|
|
|
url: '',
|
|
|
|
transfer_method: TransferMethod.local_file,
|
2025-05-27 11:01:38 +08:00
|
|
|
}
|
|
|
|
datasourceInfoList.push(documentInfo)
|
2025-05-21 16:37:02 +08:00
|
|
|
}
|
2025-06-26 13:46:12 +08:00
|
|
|
if (datasourceType === DatasourceType.onlineDocument) {
|
2025-06-06 10:08:19 +08:00
|
|
|
const { workspace_id, ...rest } = previewOnlineDocument.current
|
2025-05-27 11:01:38 +08:00
|
|
|
const documentInfo = {
|
|
|
|
workspace_id,
|
|
|
|
page: rest,
|
|
|
|
}
|
|
|
|
datasourceInfoList.push(documentInfo)
|
|
|
|
}
|
2025-06-26 13:46:12 +08:00
|
|
|
if (datasourceType === DatasourceType.websiteCrawl)
|
2025-06-06 17:00:34 +08:00
|
|
|
datasourceInfoList.push(previewWebsitePage.current)
|
2025-05-27 11:01:38 +08:00
|
|
|
await runPublishedPipeline({
|
|
|
|
pipeline_id: pipelineId!,
|
|
|
|
inputs: data,
|
|
|
|
start_node_id: datasource.nodeId,
|
2025-06-26 13:46:12 +08:00
|
|
|
datasource_type: datasourceType as DatasourceType,
|
2025-05-27 11:01:38 +08:00
|
|
|
datasource_info_list: datasourceInfoList,
|
|
|
|
is_preview: true,
|
|
|
|
}, {
|
|
|
|
onSuccess: (res) => {
|
2025-06-03 10:14:48 +08:00
|
|
|
setEstimateData((res as PublishedPipelineRunPreviewResponse).data.outputs)
|
2025-05-27 11:01:38 +08:00
|
|
|
},
|
|
|
|
})
|
2025-06-26 13:46:12 +08:00
|
|
|
}, [datasource, datasourceType, pipelineId, previewFile, previewOnlineDocument, previewWebsitePage, runPublishedPipeline])
|
2025-05-27 11:01:38 +08:00
|
|
|
|
|
|
|
const handleProcess = useCallback(async (data: Record<string, any>) => {
|
|
|
|
if (!datasource)
|
|
|
|
return
|
|
|
|
const datasourceInfoList: Record<string, any>[] = []
|
2025-06-26 13:46:12 +08:00
|
|
|
if (datasourceType === DatasourceType.localFile) {
|
2025-05-27 11:01:38 +08:00
|
|
|
fileList.forEach((file) => {
|
|
|
|
const { id, name, type, size, extension, mime_type } = file.file
|
|
|
|
const documentInfo = {
|
2025-05-28 14:51:10 +08:00
|
|
|
related_id: id,
|
2025-05-27 11:01:38 +08:00
|
|
|
name,
|
|
|
|
type,
|
|
|
|
size,
|
|
|
|
extension,
|
|
|
|
mime_type,
|
2025-05-28 14:51:10 +08:00
|
|
|
url: '',
|
|
|
|
transfer_method: TransferMethod.local_file,
|
2025-05-27 11:01:38 +08:00
|
|
|
}
|
|
|
|
datasourceInfoList.push(documentInfo)
|
|
|
|
})
|
|
|
|
}
|
2025-06-26 13:46:12 +08:00
|
|
|
if (datasourceType === DatasourceType.onlineDocument) {
|
2025-06-06 10:08:19 +08:00
|
|
|
onlineDocuments.forEach((page) => {
|
2025-05-21 16:37:02 +08:00
|
|
|
const { workspace_id, ...rest } = page
|
2025-05-27 11:01:38 +08:00
|
|
|
const documentInfo = {
|
|
|
|
workspace_id,
|
|
|
|
page: rest,
|
|
|
|
}
|
|
|
|
datasourceInfoList.push(documentInfo)
|
2025-05-21 16:37:02 +08:00
|
|
|
})
|
|
|
|
}
|
2025-06-26 13:46:12 +08:00
|
|
|
if (datasourceType === DatasourceType.websiteCrawl) {
|
2025-06-06 17:00:34 +08:00
|
|
|
websitePages.forEach((websitePage) => {
|
|
|
|
datasourceInfoList.push(websitePage)
|
|
|
|
})
|
2025-05-21 16:37:02 +08:00
|
|
|
}
|
2025-05-27 11:01:38 +08:00
|
|
|
await runPublishedPipeline({
|
|
|
|
pipeline_id: pipelineId!,
|
|
|
|
inputs: data,
|
|
|
|
start_node_id: datasource.nodeId,
|
2025-06-26 13:46:12 +08:00
|
|
|
datasource_type: datasourceType as DatasourceType,
|
2025-05-27 11:01:38 +08:00
|
|
|
datasource_info_list: datasourceInfoList,
|
2025-05-27 17:54:39 +08:00
|
|
|
is_preview: false,
|
2025-05-27 11:01:38 +08:00
|
|
|
}, {
|
2025-06-03 10:14:48 +08:00
|
|
|
onSuccess: (res) => {
|
2025-06-03 17:42:40 +08:00
|
|
|
setBatchId((res as PublishedPipelineRunResponse).batch || '')
|
|
|
|
setDocuments((res as PublishedPipelineRunResponse).documents || [])
|
2025-05-27 11:01:38 +08:00
|
|
|
handleNextStep()
|
|
|
|
},
|
|
|
|
})
|
2025-06-26 13:46:12 +08:00
|
|
|
}, [datasource, datasourceType, fileList, handleNextStep, onlineDocuments, pipelineId, runPublishedPipeline, websitePages])
|
2025-05-21 16:37:02 +08:00
|
|
|
|
2025-05-23 10:29:59 +08:00
|
|
|
const onClickProcess = useCallback(() => {
|
|
|
|
isPreview.current = false
|
|
|
|
formRef.current?.submit()
|
|
|
|
}, [])
|
|
|
|
|
|
|
|
const onClickPreview = useCallback(() => {
|
|
|
|
isPreview.current = true
|
|
|
|
formRef.current?.submit()
|
|
|
|
}, [])
|
|
|
|
|
|
|
|
const handleSubmit = useCallback((data: Record<string, any>) => {
|
|
|
|
isPreview.current ? handlePreviewChunks(data) : handleProcess(data)
|
|
|
|
}, [handlePreviewChunks, handleProcess])
|
|
|
|
|
2025-05-28 13:44:37 +08:00
|
|
|
const handlePreviewFileChange = useCallback((file: DocumentItem) => {
|
|
|
|
previewFile.current = file
|
|
|
|
onClickPreview()
|
2025-05-28 18:34:26 +08:00
|
|
|
}, [onClickPreview, previewFile])
|
2025-05-28 13:44:37 +08:00
|
|
|
|
2025-06-06 10:08:19 +08:00
|
|
|
const handlePreviewOnlineDocumentChange = useCallback((page: NotionPage) => {
|
|
|
|
previewOnlineDocument.current = page
|
2025-05-28 13:44:37 +08:00
|
|
|
onClickPreview()
|
2025-06-06 10:08:19 +08:00
|
|
|
}, [onClickPreview, previewOnlineDocument])
|
2025-05-28 13:44:37 +08:00
|
|
|
|
|
|
|
const handlePreviewWebsiteChange = useCallback((website: CrawlResultItem) => {
|
|
|
|
previewWebsitePage.current = website
|
|
|
|
onClickPreview()
|
2025-05-28 18:34:26 +08:00
|
|
|
}, [onClickPreview, previewWebsitePage])
|
2025-05-28 13:44:37 +08:00
|
|
|
|
2025-05-22 14:49:40 +08:00
|
|
|
if (isFetchingPipelineInfo) {
|
|
|
|
return (
|
|
|
|
<Loading type='app' />
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2025-05-21 16:37:02 +08:00
|
|
|
return (
|
|
|
|
<div
|
2025-06-13 11:38:26 +08:00
|
|
|
className='relative flex h-[calc(100vh-56px)] w-full min-w-[1024px] overflow-x-auto rounded-t-2xl border-t border-effects-highlight bg-background-default-subtle'
|
2025-05-21 16:37:02 +08:00
|
|
|
>
|
2025-06-23 15:38:24 +08:00
|
|
|
<div className='h-full min-w-0 flex-1'>
|
|
|
|
<div className='flex h-full flex-col px-14'>
|
|
|
|
<LeftHeader
|
|
|
|
steps={steps}
|
|
|
|
title={t('datasetPipeline.addDocuments.title')}
|
|
|
|
currentStep={currentStep}
|
|
|
|
/>
|
|
|
|
<div className='grow overflow-y-auto'>
|
|
|
|
{
|
|
|
|
currentStep === 1 && (
|
|
|
|
<div className='flex flex-col gap-y-5 pt-4'>
|
|
|
|
<DataSourceOptions
|
|
|
|
datasourceNodeId={datasource?.nodeId || ''}
|
|
|
|
onSelect={setDatasource}
|
|
|
|
pipelineNodes={(pipelineInfo?.graph.nodes || []) as Node<DataSourceNodeType>[]}
|
2025-05-22 14:49:40 +08:00
|
|
|
/>
|
2025-06-26 13:46:12 +08:00
|
|
|
{datasourceType === DatasourceType.localFile && (
|
2025-06-23 15:38:24 +08:00
|
|
|
<LocalFile
|
2025-06-27 16:29:30 +08:00
|
|
|
fileList={fileList}
|
2025-06-26 13:46:12 +08:00
|
|
|
allowedExtensions={datasource!.nodeData.fileExtensions || []}
|
2025-06-27 16:29:30 +08:00
|
|
|
prepareFileList={updateFileList}
|
|
|
|
onFileListUpdate={updateFileList}
|
|
|
|
onFileUpdate={updateFile}
|
2025-06-23 15:38:24 +08:00
|
|
|
onPreview={updateCurrentFile}
|
|
|
|
notSupportBatchUpload={notSupportBatchUpload}
|
|
|
|
/>
|
|
|
|
)}
|
2025-06-26 13:46:12 +08:00
|
|
|
{datasourceType === DatasourceType.onlineDocument && (
|
2025-06-23 15:38:24 +08:00
|
|
|
<OnlineDocuments
|
2025-07-01 16:32:21 +08:00
|
|
|
documentsData={documentsData}
|
|
|
|
setDocumentsData={setDocumentsData}
|
|
|
|
searchValue={searchValue}
|
|
|
|
setSearchValue={setSearchValue}
|
|
|
|
currentWorkspaceId={currentWorkspaceId}
|
|
|
|
setCurrentWorkspaceId={setCurrentWorkspaceId}
|
|
|
|
PagesMapAndSelectedPagesId={PagesMapAndSelectedPagesId}
|
|
|
|
selectedPagesId={selectedPagesId}
|
|
|
|
setSelectedPagesId={setSelectedPagesId}
|
2025-06-26 13:46:12 +08:00
|
|
|
nodeId={datasource!.nodeId}
|
|
|
|
nodeData={datasource!.nodeData}
|
2025-06-27 16:29:30 +08:00
|
|
|
onSelect={updateOnlineDocuments}
|
2025-06-23 15:38:24 +08:00
|
|
|
onPreview={updateCurrentPage}
|
|
|
|
/>
|
|
|
|
)}
|
2025-06-26 13:46:12 +08:00
|
|
|
{datasourceType === DatasourceType.websiteCrawl && (
|
2025-06-23 15:38:24 +08:00
|
|
|
<WebsiteCrawl
|
2025-06-26 13:46:12 +08:00
|
|
|
nodeId={datasource!.nodeId}
|
|
|
|
nodeData={datasource!.nodeData}
|
2025-06-23 15:38:24 +08:00
|
|
|
crawlResult={crawlResult}
|
|
|
|
setCrawlResult={setCrawlResult}
|
|
|
|
step={step}
|
|
|
|
setStep={setStep}
|
|
|
|
checkedCrawlResult={websitePages}
|
|
|
|
onCheckedCrawlResultChange={updataCheckedCrawlResultChange}
|
|
|
|
onPreview={updateCurrentWebsite}
|
|
|
|
previewIndex={previewIndex}
|
|
|
|
/>
|
|
|
|
)}
|
2025-06-30 18:31:52 +08:00
|
|
|
{datasourceType === DatasourceType.onlineDrive && (
|
|
|
|
<OnlineDrive
|
|
|
|
nodeData={datasource!.nodeData}
|
2025-07-01 16:54:44 +08:00
|
|
|
prefix={prefix}
|
|
|
|
setPrefix={setPrefix}
|
|
|
|
keywords={keywords}
|
|
|
|
setKeywords={setKeywords}
|
|
|
|
startAfter={startAfter}
|
|
|
|
setStartAfter={setStartAfter}
|
|
|
|
selectedFileList={selectedFileList}
|
|
|
|
setSelectedFileList={setSelectedFileList}
|
|
|
|
fileList={onlineDriveFileList}
|
|
|
|
setFileList={setFileList}
|
2025-06-30 18:31:52 +08:00
|
|
|
/>
|
|
|
|
)}
|
2025-06-23 15:38:24 +08:00
|
|
|
{isShowVectorSpaceFull && (
|
|
|
|
<VectorSpaceFull />
|
|
|
|
)}
|
|
|
|
<Actions disabled={nextBtnDisabled} handleNextStep={handleNextStep} />
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
{
|
|
|
|
currentStep === 2 && (
|
|
|
|
<ProcessDocuments
|
|
|
|
ref={formRef}
|
2025-06-26 13:46:12 +08:00
|
|
|
dataSourceNodeId={datasource!.nodeId}
|
2025-06-23 15:38:24 +08:00
|
|
|
onProcess={onClickProcess}
|
|
|
|
onPreview={onClickPreview}
|
|
|
|
onSubmit={handleSubmit}
|
|
|
|
onBack={handleBackStep}
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
{
|
|
|
|
currentStep === 3 && (
|
|
|
|
<Processing
|
|
|
|
batchId={batchId}
|
|
|
|
documents={documents}
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
</div>
|
2025-05-21 16:37:02 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{/* Preview */}
|
2025-05-22 23:05:58 +08:00
|
|
|
{
|
|
|
|
currentStep === 1 && (
|
2025-06-23 15:38:24 +08:00
|
|
|
<div className='h-full min-w-0 flex-1'>
|
|
|
|
<div className='flex h-full flex-col pl-2 pt-2'>
|
|
|
|
{currentFile && <FilePreview file={currentFile} hidePreview={hideFilePreview} />}
|
2025-06-25 11:36:56 +08:00
|
|
|
{currentDocument && (
|
|
|
|
<OnlineDocumentPreview
|
|
|
|
datasourceNodeId={datasource!.nodeId}
|
|
|
|
currentPage={currentDocument}
|
|
|
|
hidePreview={hideOnlineDocumentPreview}
|
|
|
|
/>
|
|
|
|
)}
|
2025-06-23 15:38:24 +08:00
|
|
|
{currentWebsite && <WebsitePreview payload={currentWebsite} hidePreview={hideWebsitePreview} />}
|
|
|
|
</div>
|
2025-05-22 23:05:58 +08:00
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
{
|
|
|
|
currentStep === 2 && (
|
2025-06-23 15:38:24 +08:00
|
|
|
<div className='h-full min-w-0 flex-1'>
|
|
|
|
<div className='flex h-full flex-col pl-2 pt-2'>
|
|
|
|
<ChunkPreview
|
2025-06-26 13:46:12 +08:00
|
|
|
dataSourceType={datasourceType as DatasourceType}
|
2025-06-23 15:38:24 +08:00
|
|
|
files={fileList.map(file => file.file)}
|
|
|
|
onlineDocuments={onlineDocuments}
|
|
|
|
websitePages={websitePages}
|
|
|
|
isIdle={isIdle}
|
|
|
|
isPending={isPending && isPreview.current}
|
|
|
|
estimateData={estimateData}
|
|
|
|
onPreview={onClickPreview}
|
|
|
|
handlePreviewFileChange={handlePreviewFileChange}
|
|
|
|
handlePreviewOnlineDocumentChange={handlePreviewOnlineDocumentChange}
|
|
|
|
handlePreviewWebsitePageChange={handlePreviewWebsiteChange}
|
|
|
|
/>
|
|
|
|
</div>
|
2025-05-27 11:01:38 +08:00
|
|
|
</div>
|
2025-05-22 23:05:58 +08:00
|
|
|
)
|
|
|
|
}
|
2025-05-21 16:37:02 +08:00
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2025-05-29 14:06:12 +08:00
|
|
|
export default CreateFormPipeline
|