mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-08-13 04:13:35 +08:00
Fix: Deleting a record from the knowledge base table should remove the corresponding selected record. (#18142)
This commit is contained in:
@@ -6,6 +6,7 @@ import {
|
||||
HoverCardTrigger,
|
||||
} from '@/components/ui/hover-card';
|
||||
import { DocumentType } from '@/constants/knowledge';
|
||||
import { UseRowSelectionType } from '@/hooks/logic-hooks/use-row-selection';
|
||||
import { useRemoveDocument } from '@/hooks/use-document-request';
|
||||
import { IDocumentInfo } from '@/interfaces/database/document';
|
||||
import { downloadDatasetDocument } from '@/services/file-manager-service';
|
||||
@@ -13,6 +14,7 @@ import { formatFileSize } from '@/utils/common-util';
|
||||
import { formatDate } from '@/utils/date';
|
||||
import { downloadFileFromBlob } from '@/utils/file-util';
|
||||
import { Download, Eye, PenLine, Trash2 } from 'lucide-react';
|
||||
import { omit } from 'lodash';
|
||||
import { useCallback } from 'react';
|
||||
import { UseRenameDocumentShowType } from './use-rename-document';
|
||||
import { isParserRunning } from './utils';
|
||||
@@ -28,7 +30,9 @@ const FunctionMap = {
|
||||
export function DatasetActionCell({
|
||||
record,
|
||||
showRenameModal,
|
||||
}: { record: IDocumentInfo } & UseRenameDocumentShowType) {
|
||||
setRowSelection,
|
||||
}: { record: IDocumentInfo } & UseRenameDocumentShowType &
|
||||
Pick<UseRowSelectionType, 'setRowSelection'>) {
|
||||
const { id, run, type } = record;
|
||||
const isRunning = isParserRunning(run);
|
||||
const isVirtualDocument = type === DocumentType.Virtual;
|
||||
@@ -52,9 +56,12 @@ export function DatasetActionCell({
|
||||
}
|
||||
}, [id, record.dataset_id, record.name]);
|
||||
|
||||
const handleRemove = useCallback(() => {
|
||||
removeDocument(id);
|
||||
}, [id, removeDocument]);
|
||||
const handleRemove = useCallback(async () => {
|
||||
const code = await removeDocument(id);
|
||||
if (code === 0) {
|
||||
setRowSelection((prev) => omit(prev, [id]));
|
||||
}
|
||||
}, [id, removeDocument, setRowSelection]);
|
||||
|
||||
const handleRename = useCallback(() => {
|
||||
showRenameModal(record);
|
||||
|
||||
@@ -84,13 +84,6 @@ export function DatasetTable({
|
||||
initialName,
|
||||
} = useRenameDocument();
|
||||
|
||||
// const {
|
||||
// hideSetMetaModal,
|
||||
// setMetaVisible,
|
||||
// setMetaLoading,
|
||||
// onSetMetaModalOk,
|
||||
// metaRecord,
|
||||
// } = useSaveMeta();
|
||||
const { showLog, logInfo, logVisible, hideLog } = useShowLog(documents);
|
||||
|
||||
const columns = useDatasetTableColumns({
|
||||
@@ -98,6 +91,7 @@ export function DatasetTable({
|
||||
showRenameModal,
|
||||
showManageMetadataModal,
|
||||
showLog,
|
||||
setRowSelection,
|
||||
});
|
||||
|
||||
const currentPagination = useMemo(() => {
|
||||
@@ -231,14 +225,6 @@ export function DatasetTable({
|
||||
></RenameDialog>
|
||||
)}
|
||||
|
||||
{/* {setMetaVisible && (
|
||||
<SetMetaDialog
|
||||
hideModal={hideSetMetaModal}
|
||||
loading={setMetaLoading}
|
||||
onOk={onSetMetaModalOk}
|
||||
initialMetaData={metaRecord.meta_fields}
|
||||
></SetMetaDialog>
|
||||
)} */}
|
||||
{logVisible && (
|
||||
<ProcessLogModal
|
||||
title={t('knowledgeDetails.fileLogs')}
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
TooltipTrigger,
|
||||
} from '@/components/ui/tooltip';
|
||||
import { useNavigatePage } from '@/hooks/logic-hooks/navigate-hooks';
|
||||
import { UseRowSelectionType } from '@/hooks/logic-hooks/use-row-selection';
|
||||
import { useSetDocumentStatus } from '@/hooks/use-document-request';
|
||||
import { IDocumentInfo } from '@/interfaces/database/document';
|
||||
import { cn } from '@/lib/utils';
|
||||
@@ -24,7 +25,8 @@ import { UseChangeDocumentParserShowType } from './use-change-document-parser';
|
||||
import { UseRenameDocumentShowType } from './use-rename-document';
|
||||
|
||||
type UseDatasetTableColumnsType = UseChangeDocumentParserShowType &
|
||||
UseRenameDocumentShowType & {
|
||||
UseRenameDocumentShowType &
|
||||
Pick<UseRowSelectionType, 'setRowSelection'> & {
|
||||
showLog: (record: IDocumentInfo) => void;
|
||||
showManageMetadataModal: (config: ShowManageMetadataModalProps) => void;
|
||||
};
|
||||
@@ -34,6 +36,7 @@ export function useDatasetTableColumns({
|
||||
showRenameModal,
|
||||
showManageMetadataModal,
|
||||
showLog,
|
||||
setRowSelection,
|
||||
}: UseDatasetTableColumnsType) {
|
||||
const { t } = useTranslation('translation', {
|
||||
keyPrefix: 'knowledgeDetails',
|
||||
@@ -138,30 +141,6 @@ export function useDatasetTableColumns({
|
||||
</time>
|
||||
),
|
||||
},
|
||||
/*
|
||||
{
|
||||
accessorKey: 'source_from',
|
||||
header: t('source'),
|
||||
cell: ({ row }) => (
|
||||
<div className="text-text-primary">
|
||||
{row.original.source_type === 'local' ||
|
||||
row.original.source_type === '' ? (
|
||||
<div className="bg-accent-primary-5 w-6 h-6 rounded-full flex items-center justify-center">
|
||||
<MonitorUp className="text-accent-primary" size={16} />
|
||||
</div>
|
||||
) : (
|
||||
<div className="w-6 h-6 flex items-center justify-center">
|
||||
{
|
||||
dataSourceInfo[
|
||||
row.original.source_type as keyof typeof dataSourceInfo
|
||||
]?.icon
|
||||
}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
),
|
||||
},
|
||||
*/
|
||||
{
|
||||
accessorKey: 'status',
|
||||
header: t('enabled'),
|
||||
@@ -199,9 +178,6 @@ export function useDatasetTableColumns({
|
||||
size="auto"
|
||||
onClick={() => {
|
||||
showManageMetadataModal({
|
||||
// metadata: util.JSONToMetaDataTableData(
|
||||
// row.original.meta_fields || {},
|
||||
// ),
|
||||
isEditField: false,
|
||||
isCanAdd: true,
|
||||
isAddValue: true,
|
||||
@@ -212,10 +188,6 @@ export function useDatasetTableColumns({
|
||||
<div className="text-base font-normal">
|
||||
{t('metadata.editMetadata')}
|
||||
</div>
|
||||
{/* <div className="text-sm text-text-secondary w-full truncate">
|
||||
{t('metadata.editMetadataForDataset')}
|
||||
{row.original.name}
|
||||
</div> */}
|
||||
</div>
|
||||
),
|
||||
secondTitle: (
|
||||
@@ -237,7 +209,6 @@ export function useDatasetTableColumns({
|
||||
{
|
||||
accessorKey: 'run',
|
||||
header: t('Parse'),
|
||||
// meta: { cellClassName: 'min-w-[20vw]' },
|
||||
cell: ({ row }) => {
|
||||
return (
|
||||
<ParseDropdownButton
|
||||
@@ -271,6 +242,7 @@ export function useDatasetTableColumns({
|
||||
<DatasetActionCell
|
||||
record={record}
|
||||
showRenameModal={showRenameModal}
|
||||
setRowSelection={setRowSelection}
|
||||
/>
|
||||
);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user