mirror of https://github.com/langgenius/dify.git
feat: enhance batch action confirmation and segment management
This commit is contained in:
parent
01e363f33f
commit
55ed41520f
|
|
@ -80,7 +80,10 @@ const BatchAction: FC<IBatchActionProps> = ({
|
|||
title={t('datasetDocuments.list.delete.title')}
|
||||
content={t('datasetDocuments.list.delete.content')}
|
||||
confirmText={t('common.operation.sure')}
|
||||
onConfirm={onBatchDelete}
|
||||
onConfirm={() => {
|
||||
onBatchDelete()
|
||||
hideDeleteConfirm()
|
||||
}}
|
||||
onCancel={hideDeleteConfirm}
|
||||
/>
|
||||
)
|
||||
|
|
|
|||
|
|
@ -161,6 +161,7 @@ const Completed: FC<ICompletedProps> = ({
|
|||
|
||||
const resetList = useCallback(() => {
|
||||
setSegments([])
|
||||
setSelectedSegmentIds([])
|
||||
refreshSegmentList()
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [])
|
||||
|
|
@ -188,6 +189,7 @@ const Completed: FC<ICompletedProps> = ({
|
|||
seg.enabled = enable
|
||||
}
|
||||
setSegments([...segments])
|
||||
!segId && setSelectedSegmentIds([])
|
||||
},
|
||||
onError: () => {
|
||||
notify({ type: 'error', message: t('common.actionMsg.modifiedUnsuccessfully') })
|
||||
|
|
@ -256,8 +258,8 @@ const Completed: FC<ICompletedProps> = ({
|
|||
seg.keywords = res.data.keywords
|
||||
seg.word_count = res.data.word_count
|
||||
seg.hit_count = res.data.hit_count
|
||||
seg.index_node_hash = res.data.index_node_hash
|
||||
seg.enabled = res.data.enabled
|
||||
seg.updated_at = res.data.updated_at
|
||||
}
|
||||
}
|
||||
setSegments([...segments])
|
||||
|
|
@ -396,9 +398,9 @@ const Completed: FC<ICompletedProps> = ({
|
|||
&& <BatchAction
|
||||
className='absolute left-0 bottom-16 z-20'
|
||||
selectedIds={selectedSegmentIds}
|
||||
onBatchEnable={onChangeSwitch.bind(null, true)}
|
||||
onBatchDisable={onChangeSwitch.bind(null, false)}
|
||||
onBatchDelete={onDelete}
|
||||
onBatchEnable={onChangeSwitch.bind(null, true, '')}
|
||||
onBatchDisable={onChangeSwitch.bind(null, false, '')}
|
||||
onBatchDelete={onDelete.bind(null, '')}
|
||||
onCancel={onCancelBatchOperation}
|
||||
/>}
|
||||
</SegmentListContext.Provider>
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ export const useEnableSegment = () => {
|
|||
mutationFn: (payload: { datasetId: string; documentId: string; segmentIds: string[] }) => {
|
||||
const { datasetId, documentId, segmentIds } = payload
|
||||
const query = segmentIds.map(id => `segment_id=${id}`).join('&')
|
||||
return patch<CommonResponse>(`/datasets/${datasetId}/documents/${documentId}/segments/enable?${query}`)
|
||||
return patch<CommonResponse>(`/datasets/${datasetId}/documents/${documentId}/segment/enable?${query}`)
|
||||
},
|
||||
})
|
||||
}
|
||||
|
|
@ -49,7 +49,7 @@ export const useDisableSegment = () => {
|
|||
mutationFn: (payload: { datasetId: string; documentId: string; segmentIds: string[] }) => {
|
||||
const { datasetId, documentId, segmentIds } = payload
|
||||
const query = segmentIds.map(id => `segment_id=${id}`).join('&')
|
||||
return patch<CommonResponse>(`/datasets/${datasetId}/documents/${documentId}/segments/disable?${query}`)
|
||||
return patch<CommonResponse>(`/datasets/${datasetId}/documents/${documentId}/segment/disable?${query}`)
|
||||
},
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue