refactor: reorganize BatchAction import paths and enhance child segment scrolling behavior

pull/12097/head
twwu 1 year ago
parent a8254c29c5
commit 1641638523

@ -9,7 +9,7 @@ import { ProcessStatus } from '../segment-add'
import s from './style.module.css' import s from './style.module.css'
import SegmentList from './segment-list' import SegmentList from './segment-list'
import DisplayToggle from './display-toggle' import DisplayToggle from './display-toggle'
import BatchAction from './batch-action' import BatchAction from './common/batch-action'
import SegmentDetail from './segment-detail' import SegmentDetail from './segment-detail'
import SegmentCard from './segment-card' import SegmentCard from './segment-card'
import ChildSegmentList from './child-segment-list' import ChildSegmentList from './child-segment-list'
@ -101,6 +101,7 @@ const Completed: FC<ICompletedProps> = ({
const [showNewChildSegmentModal, setShowNewChildSegmentModal] = useState(false) const [showNewChildSegmentModal, setShowNewChildSegmentModal] = useState(false)
const segmentListRef = useRef<HTMLDivElement>(null) const segmentListRef = useRef<HTMLDivElement>(null)
const childSegmentListRef = useRef<HTMLDivElement>(null)
const needScrollToBottom = useRef(false) const needScrollToBottom = useRef(false)
const { run: handleSearch } = useDebounceFn(() => { const { run: handleSearch } = useDebounceFn(() => {
@ -165,6 +166,13 @@ const Completed: FC<ICompletedProps> = ({
) )
const invalidChildSegmentList = useInvalid(useChildSegmentListKey) const invalidChildSegmentList = useInvalid(useChildSegmentListKey)
useEffect(() => {
if (childSegmentListRef.current && needScrollToBottom.current) {
childSegmentListRef.current.scrollTo({ top: childSegmentListRef.current.scrollHeight, behavior: 'smooth' })
needScrollToBottom.current = false
}
}, [childSegments])
useEffect(() => { useEffect(() => {
if (childChunkListData) if (childChunkListData)
setChildSegments(childChunkListData.data || []) setChildSegments(childChunkListData.data || [])

@ -187,14 +187,16 @@ const DocumentDetail: FC<Props> = ({ datasetId, documentId }) => {
/> />
<div className='flex items-center flex-wrap'> <div className='flex items-center flex-wrap'>
{embeddingAvailable && documentDetail && !documentDetail.archived && !isFullDocMode && ( {embeddingAvailable && documentDetail && !documentDetail.archived && !isFullDocMode && (
<>
<SegmentAdd <SegmentAdd
importStatus={importStatus} importStatus={importStatus}
clearProcessStatus={resetProcessStatus} clearProcessStatus={resetProcessStatus}
showNewSegmentModal={showNewSegmentModal} showNewSegmentModal={showNewSegmentModal}
showBatchModal={showBatchModal} showBatchModal={showBatchModal}
/> />
)}
<Divider type='vertical' className='!bg-divider-regular !h-[14px] !mx-3' /> <Divider type='vertical' className='!bg-divider-regular !h-[14px] !mx-3' />
</>
)}
<StatusItem <StatusItem
status={documentDetail?.display_status || 'available'} status={documentDetail?.display_status || 'available'}
scene='detail' scene='detail'

@ -21,7 +21,7 @@ import { Globe01 } from '../../base/icons/src/vender/line/mapsAndTravel'
import ChunkingModeLabel from '../common/chunking-mode-label' import ChunkingModeLabel from '../common/chunking-mode-label'
import s from './style.module.css' import s from './style.module.css'
import RenameModal from './rename-modal' import RenameModal from './rename-modal'
import BatchAction from './detail/completed/batch-action' import BatchAction from './detail/completed/common/batch-action'
import cn from '@/utils/classnames' import cn from '@/utils/classnames'
import Switch from '@/app/components/base/switch' import Switch from '@/app/components/base/switch'
import Divider from '@/app/components/base/divider' import Divider from '@/app/components/base/divider'

Loading…
Cancel
Save