Fix: The files in the knowledge base folder on the file management page should not be deleted #9975 (#9976)

### What problem does this PR solve?

Fix: The files in the knowledge base folder on the file management page
should not be deleted #9975

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
balibabu
2025-09-08 12:48:58 +08:00
committed by GitHub
parent b524cf0ec8
commit f48aed6d4a
3 changed files with 59 additions and 38 deletions

View File

@ -21,8 +21,9 @@ import {
UseHandleConnectToKnowledgeReturnType,
UseRenameCurrentFileReturnType,
} from './hooks';
import { useHandleDeleteFile } from './use-delete-file';
import { UseMoveDocumentShowType } from './use-move-file';
import { isFolderType } from './util';
import { isFolderType, isKnowledgeBaseType } from './util';
type IProps = Pick<CellContext<IFile, unknown>, 'row'> &
Pick<UseHandleConnectToKnowledgeReturnType, 'showConnectToKnowledgeModal'> &
@ -40,6 +41,7 @@ export function ActionCell({
const { downloadFile } = useDownloadFile();
const isFolder = isFolderType(record.type);
const extension = getExtension(record.name);
const isKnowledgeBase = isKnowledgeBaseType(record.source_type);
const handleShowConnectToKnowledgeModal = useCallback(() => {
showConnectToKnowledgeModal(record);
@ -60,34 +62,44 @@ export function ActionCell({
showMoveFileModal([record.id]);
}, [record, showMoveFileModal]);
const { handleRemoveFile } = useHandleDeleteFile();
const onRemoveFile = useCallback(() => {
handleRemoveFile([documentId]);
}, [handleRemoveFile, documentId]);
return (
<section className="flex gap-4 items-center text-text-sub-title-invert opacity-0 group-hover:opacity-100 transition-opacity">
<Button
variant="transparent"
className="border-none hover:bg-bg-card text-text-primary"
size={'sm'}
onClick={handleShowConnectToKnowledgeModal}
>
<Link2 />
</Button>
<Button
variant="transparent"
className="border-none hover:bg-bg-card text-text-primary"
size={'sm'}
onClick={handleShowMoveFileModal}
>
<FolderInput />
</Button>
<Button
variant="transparent"
className="border-none hover:bg-bg-card text-text-primary"
size={'sm'}
onClick={handleShowFileRenameModal}
>
<FolderPen />
</Button>
{isKnowledgeBase || (
<Button
variant="transparent"
className="border-none hover:bg-bg-card text-text-primary"
size={'sm'}
onClick={handleShowConnectToKnowledgeModal}
>
<Link2 />
</Button>
)}
{isKnowledgeBase || (
<Button
variant="transparent"
className="border-none hover:bg-bg-card text-text-primary"
size={'sm'}
onClick={handleShowMoveFileModal}
>
<FolderInput />
</Button>
)}
{isKnowledgeBase || (
<Button
variant="transparent"
className="border-none hover:bg-bg-card text-text-primary"
size={'sm'}
onClick={handleShowFileRenameModal}
>
<FolderPen />
</Button>
)}
{isFolder || (
<Button
variant="transparent"
@ -138,15 +150,17 @@ export function ActionCell({
)}
</DropdownMenuContent>
</DropdownMenu> */}
<ConfirmDeleteDialog>
<Button
variant="transparent"
className="border-none hover:bg-bg-card text-text-primary"
size={'sm'}
>
<Trash2 />
</Button>
</ConfirmDeleteDialog>
{isKnowledgeBase || (
<ConfirmDeleteDialog onOk={onRemoveFile}>
<Button
variant="transparent"
className="border-none hover:bg-bg-card text-text-primary"
size={'sm'}
>
<Trash2 />
</Button>
</ConfirmDeleteDialog>
)}
</section>
);
}