mirror of
https://github.com/langgenius/dify.git
synced 2026-05-03 17:08:03 +08:00
refactor: refactor navigation components to use Link for improved routing
This commit is contained in:
@ -1,10 +1,11 @@
|
||||
import React, { useCallback } from 'react'
|
||||
import React from 'react'
|
||||
import { RiArrowLeftLine } from '@remixicon/react'
|
||||
import Button from '@/app/components/base/button'
|
||||
import { useParams, useRouter } from 'next/navigation'
|
||||
import { useParams } from 'next/navigation'
|
||||
import Effect from '@/app/components/base/effect'
|
||||
import type { Step } from './step-indicator'
|
||||
import StepIndicator from './step-indicator'
|
||||
import Link from 'next/link'
|
||||
|
||||
type LeftHeaderProps = {
|
||||
steps: Array<Step>
|
||||
@ -18,12 +19,6 @@ const LeftHeader = ({
|
||||
currentStep,
|
||||
}: LeftHeaderProps) => {
|
||||
const { datasetId } = useParams()
|
||||
const { push } = useRouter()
|
||||
|
||||
const goBack = useCallback(() => {
|
||||
if (datasetId)
|
||||
push(`/datasets/${datasetId}/documents`)
|
||||
}, [datasetId, push])
|
||||
|
||||
return (
|
||||
<div className='relative flex flex-col gap-y-0.5 pb-2 pt-4'>
|
||||
@ -38,13 +33,17 @@ const LeftHeader = ({
|
||||
{steps[currentStep - 1]?.label}
|
||||
</div>
|
||||
{currentStep !== steps.length && (
|
||||
<Button
|
||||
variant='secondary-accent'
|
||||
className='absolute -left-11 top-3.5 size-9 rounded-full p-0'
|
||||
onClick={goBack}
|
||||
<Link
|
||||
href={`/datasets/${datasetId}/documents`}
|
||||
replace
|
||||
>
|
||||
<RiArrowLeftLine className='size-5 ' />
|
||||
</Button>
|
||||
<Button
|
||||
variant='secondary-accent'
|
||||
className='absolute -left-11 top-3.5 size-9 rounded-full p-0'
|
||||
>
|
||||
<RiArrowLeftLine className='size-5 ' />
|
||||
</Button>
|
||||
</Link>
|
||||
)}
|
||||
<Effect className='left-8 top-[-34px] opacity-20' />
|
||||
</div>
|
||||
|
||||
@ -322,6 +322,7 @@ const Documents: FC<IDocumentsProps> = ({ datasetId }) => {
|
||||
</div>
|
||||
{isListLoading
|
||||
? <Loading type='app' />
|
||||
// eslint-disable-next-line sonarjs/no-nested-conditional
|
||||
: total > 0
|
||||
? <List
|
||||
embeddingAvailable={embeddingAvailable}
|
||||
|
||||
Reference in New Issue
Block a user