mirror of
https://github.com/langgenius/dify.git
synced 2026-04-29 20:48:01 +08:00
refactor: enhance document upload flow with step indicators and file preview handling
This commit is contained in:
parent
c4169f8aa0
commit
11dfe3713f
@ -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[]) => {
|
||||||
|
|||||||
@ -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}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@ -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'>
|
||||||
|
|||||||
@ -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
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user