refactor: enhance document upload flow with step indicators and file preview handling

This commit is contained in:
twwu 2025-05-29 10:18:11 +08:00
parent c4169f8aa0
commit 11dfe3713f
4 changed files with 8 additions and 4 deletions

View File

@ -80,7 +80,7 @@ export const useLocalFile = () => {
const [fileList, setFileList] = useState<FileItem[]>([]) const [fileList, setFileList] = useState<FileItem[]>([])
const [currentFile, setCurrentFile] = useState<File | undefined>() const [currentFile, setCurrentFile] = useState<File | undefined>()
const previewFile = useRef<DocumentItem>(fileList[0]?.file as DocumentItem) const previewFile = useRef<DocumentItem>()
const allFileLoaded = useMemo(() => (fileList.length > 0 && fileList.every(file => file.file.id)), [fileList]) const allFileLoaded = useMemo(() => (fileList.length > 0 && fileList.every(file => file.file.id)), [fileList])
@ -93,6 +93,7 @@ export const useLocalFile = () => {
} }
}) })
setFileList(newList) setFileList(newList)
previewFile.current = newList[0].file as DocumentItem
} }
const updateFileList = useCallback((preparedFiles: FileItem[]) => { const updateFileList = useCallback((preparedFiles: FileItem[]) => {

View File

@ -44,6 +44,7 @@ const TestRunPanel = () => {
const { data: pipelineInfo, isFetching: isFetchingPipelineInfo } = usePublishedPipelineInfo(pipelineId || '') const { data: pipelineInfo, isFetching: isFetchingPipelineInfo } = usePublishedPipelineInfo(pipelineId || '')
const { const {
steps,
currentStep, currentStep,
handleNextStep, handleNextStep,
handleBackStep, handleBackStep,
@ -233,6 +234,7 @@ const TestRunPanel = () => {
> >
<div className='flex h-full min-w-[760px] flex-1 flex-col px-14'> <div className='flex h-full min-w-[760px] flex-1 flex-col px-14'>
<LeftHeader <LeftHeader
steps={steps}
title={t('datasetPipeline.addDocuments.title')} title={t('datasetPipeline.addDocuments.title')}
currentStep={currentStep} currentStep={currentStep}
/> />

View File

@ -3,20 +3,21 @@ import { RiArrowLeftLine } from '@remixicon/react'
import Button from '@/app/components/base/button' import Button from '@/app/components/base/button'
import { useParams } from 'next/navigation' import { useParams } from 'next/navigation'
import Effect from '@/app/components/base/effect' import Effect from '@/app/components/base/effect'
import { useAddDocumentsSteps } from './hooks' import type { Step } from './step-indicator'
import StepIndicator from './step-indicator' import StepIndicator from './step-indicator'
type LeftHeaderProps = { type LeftHeaderProps = {
steps: Array<Step>
title: string title: string
currentStep: number currentStep: number
} }
const LeftHeader = ({ const LeftHeader = ({
steps,
title, title,
currentStep, currentStep,
}: LeftHeaderProps) => { }: LeftHeaderProps) => {
const { datasetId } = useParams() const { datasetId } = useParams()
const steps = useAddDocumentsSteps()
return ( return (
<div className='relative flex flex-col gap-y-0.5 pb-2 pt-4'> <div className='relative flex flex-col gap-y-0.5 pb-2 pt-4'>

View File

@ -1,7 +1,7 @@
import cn from '@/utils/classnames' import cn from '@/utils/classnames'
import React from 'react' import React from 'react'
type Step = { export type Step = {
label: string label: string
value: string value: string
} }