mirror of
https://github.com/langgenius/dify.git
synced 2026-04-29 12:37:20 +08:00
feat: enhance child segment list with total count and input value handling
This commit is contained in:
parent
5a1159f9ab
commit
3dbd8f5d31
@ -15,6 +15,8 @@ type IChildSegmentCardProps = {
|
|||||||
enabled: boolean
|
enabled: boolean
|
||||||
onDelete?: (segId: string, childChunkId: string) => Promise<void>
|
onDelete?: (segId: string, childChunkId: string) => Promise<void>
|
||||||
onClickSlice?: (childChunk: ChildChunkDetail) => void
|
onClickSlice?: (childChunk: ChildChunkDetail) => void
|
||||||
|
total?: number
|
||||||
|
inputValue?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
const ChildSegmentList: FC<IChildSegmentCardProps> = ({
|
const ChildSegmentList: FC<IChildSegmentCardProps> = ({
|
||||||
@ -25,6 +27,8 @@ const ChildSegmentList: FC<IChildSegmentCardProps> = ({
|
|||||||
enabled,
|
enabled,
|
||||||
onDelete,
|
onDelete,
|
||||||
onClickSlice,
|
onClickSlice,
|
||||||
|
total,
|
||||||
|
inputValue,
|
||||||
}) => {
|
}) => {
|
||||||
const parentMode = useDocumentContext(s => s.parentMode)
|
const parentMode = useDocumentContext(s => s.parentMode)
|
||||||
|
|
||||||
@ -63,7 +67,7 @@ const ChildSegmentList: FC<IChildSegmentCardProps> = ({
|
|||||||
: (<RiArrowDownSLine className='w-4 h-4 text-text-secondary mr-0.5' />)
|
: (<RiArrowDownSLine className='w-4 h-4 text-text-secondary mr-0.5' />)
|
||||||
: null
|
: null
|
||||||
}
|
}
|
||||||
<span className='text-text-secondary system-sm-semibold-uppercase'>{`${childChunks.length} CHILD CHUNKS`}</span>
|
<span className='text-text-secondary system-sm-semibold-uppercase'>{`${total} CHILD CHUNKS`}</span>
|
||||||
<span className={classNames('text-text-quaternary text-xs font-medium pl-1.5', isParagraphMode ? 'hidden group-hover/card:inline-block' : '')}>·</span>
|
<span className={classNames('text-text-quaternary text-xs font-medium pl-1.5', isParagraphMode ? 'hidden group-hover/card:inline-block' : '')}>·</span>
|
||||||
<button
|
<button
|
||||||
className={classNames('px-1.5 py-1 text-components-button-secondary-accent-text system-xs-semibold', isParagraphMode ? 'hidden group-hover/card:inline-block' : '')}
|
className={classNames('px-1.5 py-1 text-components-button-secondary-accent-text system-xs-semibold', isParagraphMode ? 'hidden group-hover/card:inline-block' : '')}
|
||||||
@ -80,7 +84,7 @@ const ChildSegmentList: FC<IChildSegmentCardProps> = ({
|
|||||||
showLeftIcon
|
showLeftIcon
|
||||||
showClearIcon
|
showClearIcon
|
||||||
wrapperClassName='!w-52'
|
wrapperClassName='!w-52'
|
||||||
value={''}
|
value={inputValue}
|
||||||
onChange={e => handleInputChange?.(e.target.value)}
|
onChange={e => handleInputChange?.(e.target.value)}
|
||||||
onClear={() => handleInputChange?.('')}
|
onClear={() => handleInputChange?.('')}
|
||||||
/>
|
/>
|
||||||
@ -94,10 +98,14 @@ const ChildSegmentList: FC<IChildSegmentCardProps> = ({
|
|||||||
const edited = childChunk.updated_at !== childChunk.created_at
|
const edited = childChunk.updated_at !== childChunk.created_at
|
||||||
return <EditSlice
|
return <EditSlice
|
||||||
key={childChunk.id}
|
key={childChunk.id}
|
||||||
label={`C-${childChunk.position}${edited ? '·EDITED' : ''}`}
|
label={`C-${childChunk.position}${edited ? ' · EDITED' : ''}`}
|
||||||
text={childChunk.content}
|
text={childChunk.content}
|
||||||
onDelete={() => onDelete?.(childChunk.segment_id, childChunk.id)}
|
onDelete={() => onDelete?.(childChunk.segment_id, childChunk.id)}
|
||||||
onClick={() => onClickSlice?.(childChunk)}
|
className='line-clamp-3'
|
||||||
|
onClick={(e) => {
|
||||||
|
e.stopPropagation()
|
||||||
|
onClickSlice?.(childChunk)
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -125,8 +125,8 @@ const Completed: FC<ICompletedProps> = ({
|
|||||||
datasetId,
|
datasetId,
|
||||||
documentId,
|
documentId,
|
||||||
params: {
|
params: {
|
||||||
page: currentPage,
|
page: isFullDocMode ? 1 : currentPage,
|
||||||
limit,
|
limit: isFullDocMode ? 10 : limit,
|
||||||
keyword: isFullDocMode ? '' : searchValue,
|
keyword: isFullDocMode ? '' : searchValue,
|
||||||
enabled: selectedStatus === 'all' ? 'all' : !!selectedStatus,
|
enabled: selectedStatus === 'all' ? 'all' : !!selectedStatus,
|
||||||
},
|
},
|
||||||
@ -497,7 +497,7 @@ const Completed: FC<ICompletedProps> = ({
|
|||||||
{/* Segment list */}
|
{/* Segment list */}
|
||||||
{
|
{
|
||||||
isFullDocMode
|
isFullDocMode
|
||||||
? <div className='h-full flex flex-col'>
|
? <>
|
||||||
<SegmentCard
|
<SegmentCard
|
||||||
detail={segments[0]}
|
detail={segments[0]}
|
||||||
onClick={() => onClickCard(segments[0])}
|
onClick={() => onClickCard(segments[0])}
|
||||||
@ -511,8 +511,10 @@ const Completed: FC<ICompletedProps> = ({
|
|||||||
handleAddNewChildChunk={handleAddNewChildChunk}
|
handleAddNewChildChunk={handleAddNewChildChunk}
|
||||||
onClickSlice={onClickSlice}
|
onClickSlice={onClickSlice}
|
||||||
enabled={!archived}
|
enabled={!archived}
|
||||||
|
total={childChunkListData?.total || 0}
|
||||||
|
inputValue={inputValue}
|
||||||
/>
|
/>
|
||||||
</div>
|
</>
|
||||||
: <SegmentList
|
: <SegmentList
|
||||||
ref={segmentListRef}
|
ref={segmentListRef}
|
||||||
embeddingAvailable={embeddingAvailable}
|
embeddingAvailable={embeddingAvailable}
|
||||||
@ -533,9 +535,10 @@ const Completed: FC<ICompletedProps> = ({
|
|||||||
<Pagination
|
<Pagination
|
||||||
current={currentPage - 1}
|
current={currentPage - 1}
|
||||||
onChange={cur => setCurrentPage(cur + 1)}
|
onChange={cur => setCurrentPage(cur + 1)}
|
||||||
total={segmentListData?.total || 0}
|
total={(isFullDocMode ? childChunkListData?.total : segmentListData?.total) || 0}
|
||||||
limit={limit}
|
limit={limit}
|
||||||
onLimitChange={limit => setLimit(limit)}
|
onLimitChange={limit => setLimit(limit)}
|
||||||
|
className={isFullDocMode ? 'px-3' : ''}
|
||||||
/>
|
/>
|
||||||
{/* Edit or view segment detail */}
|
{/* Edit or view segment detail */}
|
||||||
<FullScreenDrawer
|
<FullScreenDrawer
|
||||||
|
|||||||
@ -207,7 +207,7 @@ const SegmentCard: FC<ISegmentCardProps> = ({
|
|||||||
<>
|
<>
|
||||||
<div className={cn('text-text-secondary body-md-regular -tracking-[0.07px] mt-0.5',
|
<div className={cn('text-text-secondary body-md-regular -tracking-[0.07px] mt-0.5',
|
||||||
textOpacity,
|
textOpacity,
|
||||||
isCollapsed ? 'line-clamp-2' : 'line-clamp-20',
|
isFullDocMode ? 'line-clamp-3' : isCollapsed ? 'line-clamp-2' : 'line-clamp-20',
|
||||||
)}>
|
)}>
|
||||||
{renderContent()}
|
{renderContent()}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -10,11 +10,10 @@ import ActionButton, { ActionButtonState } from '@/app/components/base/action-bu
|
|||||||
type EditSliceProps = SliceProps<{
|
type EditSliceProps = SliceProps<{
|
||||||
label: ReactNode
|
label: ReactNode
|
||||||
onDelete: () => void
|
onDelete: () => void
|
||||||
onClick?: () => void
|
|
||||||
}>
|
}>
|
||||||
|
|
||||||
export const EditSlice: FC<EditSliceProps> = (props) => {
|
export const EditSlice: FC<EditSliceProps> = (props) => {
|
||||||
const { label, className, text, onDelete, onClick, ...rest } = props
|
const { label, className, text, onDelete, ...rest } = props
|
||||||
const [delBtnShow, setDelBtnShow] = useState(false)
|
const [delBtnShow, setDelBtnShow] = useState(false)
|
||||||
const [isDelBtnHover, setDelBtnHover] = useState(false)
|
const [isDelBtnHover, setDelBtnHover] = useState(false)
|
||||||
|
|
||||||
@ -36,10 +35,7 @@ export const EditSlice: FC<EditSliceProps> = (props) => {
|
|||||||
const isDestructive = delBtnShow && isDelBtnHover
|
const isDestructive = delBtnShow && isDelBtnHover
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div onClick={(e) => {
|
<div>
|
||||||
e.stopPropagation()
|
|
||||||
onClick?.()
|
|
||||||
}}>
|
|
||||||
<SliceContainer {...rest}
|
<SliceContainer {...rest}
|
||||||
className={className}
|
className={className}
|
||||||
ref={refs.setReference}
|
ref={refs.setReference}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user