feat: upgrade knowledge metadata (#16063)
Support filter knowledge by metadata. Co-authored-by: Joel <iamjoel007@gmail.com> Co-authored-by: NFish <douxc512@gmail.com>
This commit is contained in:
@@ -45,6 +45,8 @@ import Pagination from '@/app/components/base/pagination'
|
||||
import Checkbox from '@/app/components/base/checkbox'
|
||||
import { useDocumentArchive, useDocumentDelete, useDocumentDisable, useDocumentEnable, useDocumentUnArchive, useSyncDocument, useSyncWebsite } from '@/service/knowledge/use-document'
|
||||
import { extensionToFileType } from '@/app/components/datasets/hit-testing/utils/extension-to-file-type'
|
||||
import useBatchEditDocumentMetadata from '../metadata/hooks/use-batch-edit-document-metadata'
|
||||
import EditMetadataBatchModal from '@/app/components/datasets/metadata/edit-metadata-batch/modal'
|
||||
|
||||
export const useIndexStatus = () => {
|
||||
const { t } = useTranslation()
|
||||
@@ -107,7 +109,8 @@ export const StatusItem: FC<{
|
||||
const [e] = await asyncRunSafe<CommonResponse>(opApi({ datasetId, documentId: id }) as Promise<CommonResponse>)
|
||||
if (!e) {
|
||||
notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') })
|
||||
onUpdate?.(operationName)
|
||||
onUpdate?.()
|
||||
// onUpdate?.(operationName)
|
||||
}
|
||||
else { notify({ type: 'error', message: t('common.actionMsg.modifiedUnsuccessfully') }) }
|
||||
}
|
||||
@@ -401,6 +404,7 @@ type IDocumentListProps = {
|
||||
datasetId: string
|
||||
pagination: PaginationProps
|
||||
onUpdate: () => void
|
||||
onManageMetadata: () => void
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -414,6 +418,7 @@ const DocumentList: FC<IDocumentListProps> = ({
|
||||
datasetId,
|
||||
pagination,
|
||||
onUpdate,
|
||||
onManageMetadata,
|
||||
}) => {
|
||||
const { t } = useTranslation()
|
||||
const { formatTime } = useTimestamp()
|
||||
@@ -424,6 +429,17 @@ const DocumentList: FC<IDocumentListProps> = ({
|
||||
const isQAMode = chunkingMode === ChunkingMode.qa
|
||||
const [localDocs, setLocalDocs] = useState<LocalDoc[]>(documents)
|
||||
const [enableSort, setEnableSort] = useState(true)
|
||||
const {
|
||||
isShowEditModal,
|
||||
showEditModal,
|
||||
hideEditModal,
|
||||
originalList,
|
||||
handleSave,
|
||||
} = useBatchEditDocumentMetadata({
|
||||
datasetId,
|
||||
docList: documents.filter(item => selectedIds.includes(item.id)),
|
||||
onUpdate,
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
setLocalDocs(documents)
|
||||
@@ -501,18 +517,20 @@ const DocumentList: FC<IDocumentListProps> = ({
|
||||
|
||||
return (
|
||||
<div className='flex flex-col relative w-full h-full'>
|
||||
<div className='grow overflow-x-auto'>
|
||||
<div className='relative grow overflow-x-auto'>
|
||||
<table className={`min-w-[700px] max-w-full w-full border-collapse border-0 text-sm mt-3 ${s.documentTable}`}>
|
||||
<thead className="h-8 leading-8 border-b border-divider-subtle text-text-tertiary font-medium text-xs uppercase">
|
||||
<tr>
|
||||
<td className='w-12'>
|
||||
<div className='flex items-center' onClick={e => e.stopPropagation()}>
|
||||
<Checkbox
|
||||
className='shrink-0 mr-2'
|
||||
checked={isAllSelected}
|
||||
mixed={!isAllSelected && isSomeSelected}
|
||||
onCheck={onSelectedAll}
|
||||
/>
|
||||
{embeddingAvailable && (
|
||||
<Checkbox
|
||||
className='shrink-0 mr-2'
|
||||
checked={isAllSelected}
|
||||
mixed={!isAllSelected && isSomeSelected}
|
||||
onCheck={onSelectedAll}
|
||||
/>
|
||||
)}
|
||||
#
|
||||
</div>
|
||||
</td>
|
||||
@@ -625,6 +643,7 @@ const DocumentList: FC<IDocumentListProps> = ({
|
||||
onBatchEnable={handleAction(DocumentActionType.enable)}
|
||||
onBatchDisable={handleAction(DocumentActionType.disable)}
|
||||
onBatchDelete={handleAction(DocumentActionType.delete)}
|
||||
onEditMetadata={showEditModal}
|
||||
onCancel={() => {
|
||||
onSelectedIdChange([])
|
||||
}}
|
||||
@@ -647,6 +666,20 @@ const DocumentList: FC<IDocumentListProps> = ({
|
||||
onSaved={handleRenamed}
|
||||
/>
|
||||
)}
|
||||
|
||||
{isShowEditModal && (
|
||||
<EditMetadataBatchModal
|
||||
datasetId={datasetId}
|
||||
documentNum={selectedIds.length}
|
||||
list={originalList}
|
||||
onSave={handleSave}
|
||||
onHide={hideEditModal}
|
||||
onShowManage={() => {
|
||||
hideEditModal()
|
||||
onManageMetadata()
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
Reference in New Issue
Block a user