### What problem does this PR solve? Fix: Files being parsed are not allowed to be deleted in batches #7065 ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)tags/v0.18.0
| @@ -379,6 +379,8 @@ This auto-tagging feature enhances retrieval by adding another layer of domain-s | |||
| community: 'Community reports generation', | |||
| communityTip: | |||
| 'In a knowledge graph, a community is a cluster of entities linked by relationships. You can have the LLM generate an abstract for each community, known as a community report. See here for more information: https://www.microsoft.com/en-us/research/blog/graphrag-improving-global-search-via-dynamic-community-selection/', | |||
| theDocumentBeingParsedCannotBeDeleted: | |||
| 'The document being parsed cannot be deleted', | |||
| }, | |||
| chunk: { | |||
| chunk: 'Chunk', | |||
| @@ -196,6 +196,7 @@ export default { | |||
| '該文件與知識圖譜相關聯。刪除後,相關節點和關係資訊將被刪除,但圖不會立即更新。更新圖動作是在解析承載知識圖譜提取任務的新文件的過程中執行的。 ', | |||
| plainText: 'Naive', | |||
| reRankModelWaring: '重排序模型非常耗時。', | |||
| theDocumentBeingParsedCannotBeDeleted: '正在解析的文檔不能被刪除', | |||
| }, | |||
| knowledgeConfiguration: { | |||
| titleDescription: '在這裡更新您的知識庫詳細信息,尤其是切片方法。', | |||
| @@ -196,6 +196,7 @@ export default { | |||
| '该文档与知识图谱相关联。删除后,相关节点和关系信息将被删除,但图不会立即更新。更新图动作是在解析承载知识图谱提取任务的新文档的过程中执行的。', | |||
| plainText: 'Naive', | |||
| reRankModelWaring: '重排序模型非常耗时。', | |||
| theDocumentBeingParsedCannotBeDeleted: '正在解析的文档不能被删除', | |||
| }, | |||
| knowledgeConfiguration: { | |||
| titleDescription: '在这里更新您的知识库详细信息,尤其是切片方法。', | |||
| @@ -9,6 +9,7 @@ import { | |||
| useRunNextDocument, | |||
| useSetNextDocumentStatus, | |||
| } from '@/hooks/document-hooks'; | |||
| import { IDocumentInfo } from '@/interfaces/database/document'; | |||
| import { | |||
| DownOutlined, | |||
| FileOutlined, | |||
| @@ -18,6 +19,8 @@ import { | |||
| } from '@ant-design/icons'; | |||
| import { Button, Dropdown, Flex, Input, MenuProps, Space } from 'antd'; | |||
| import { useCallback, useMemo } from 'react'; | |||
| import { toast } from 'sonner'; | |||
| import { RunningStatus } from './constant'; | |||
| import styles from './index.less'; | |||
| @@ -28,6 +31,7 @@ interface IProps { | |||
| showDocumentUploadModal(): void; | |||
| searchString: string; | |||
| handleInputChange: React.ChangeEventHandler<HTMLInputElement>; | |||
| documents: IDocumentInfo[]; | |||
| } | |||
| const DocumentToolbar = ({ | |||
| @@ -36,6 +40,7 @@ const DocumentToolbar = ({ | |||
| showCreateModal, | |||
| showDocumentUploadModal, | |||
| handleInputChange, | |||
| documents, | |||
| }: IProps) => { | |||
| const { t } = useTranslate('knowledgeDetails'); | |||
| const { removeDocument } = useRemoveNextDocument(); | |||
| @@ -76,18 +81,29 @@ const DocumentToolbar = ({ | |||
| }, [showDocumentUploadModal, showCreateModal, t]); | |||
| const handleDelete = useCallback(() => { | |||
| const deletedKeys = selectedRowKeys.filter( | |||
| (x) => | |||
| !documents | |||
| .filter((y) => y.run === RunningStatus.RUNNING) | |||
| .some((y) => y.id === x), | |||
| ); | |||
| if (deletedKeys.length === 0) { | |||
| toast.error(t('theDocumentBeingParsedCannotBeDeleted')); | |||
| return; | |||
| } | |||
| showDeleteConfirm({ | |||
| onOk: () => { | |||
| removeDocument(selectedRowKeys); | |||
| removeDocument(deletedKeys); | |||
| }, | |||
| }); | |||
| }, [removeDocument, showDeleteConfirm, selectedRowKeys]); | |||
| }, [selectedRowKeys, showDeleteConfirm, documents, t, removeDocument]); | |||
| const runDocument = useCallback( | |||
| (run: number) => { | |||
| runDocumentByIds({ | |||
| documentIds: selectedRowKeys, | |||
| run, | |||
| shouldDelete: false, | |||
| }); | |||
| }, | |||
| [runDocumentByIds, selectedRowKeys], | |||
| @@ -9,8 +9,10 @@ import { | |||
| useUploadNextDocument, | |||
| } from '@/hooks/document-hooks'; | |||
| import { useGetKnowledgeSearchParams } from '@/hooks/route-hook'; | |||
| import { IDocumentInfo } from '@/interfaces/database/document'; | |||
| import { IChangeParserConfigRequestBody } from '@/interfaces/request/document'; | |||
| import { UploadFile } from 'antd'; | |||
| import { TableRowSelection } from 'antd/es/table/interface'; | |||
| import { useCallback, useState } from 'react'; | |||
| import { useNavigate } from 'umi'; | |||
| import { KnowledgeRouteKey } from './constant'; | |||
| @@ -126,7 +128,7 @@ export const useChangeDocumentParser = (documentId: string) => { | |||
| export const useGetRowSelection = () => { | |||
| const [selectedRowKeys, setSelectedRowKeys] = useState<React.Key[]>([]); | |||
| const rowSelection = { | |||
| const rowSelection: TableRowSelection<IDocumentInfo> = { | |||
| selectedRowKeys, | |||
| onChange: (newSelectedRowKeys: React.Key[]) => { | |||
| setSelectedRowKeys(newSelectedRowKeys); | |||
| @@ -195,6 +195,7 @@ const KnowledgeFile = () => { | |||
| showDocumentUploadModal={showDocumentUploadModal} | |||
| searchString={searchString} | |||
| handleInputChange={handleInputChange} | |||
| documents={documents} | |||
| ></DocumentToolbar> | |||
| <Table | |||
| rowKey="id" | |||