mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
### What problem does this PR solve? Feat: Rename document name #3221 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
@ -4,26 +4,49 @@ import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuLabel,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger,
|
||||
} from '@/components/ui/dropdown-menu';
|
||||
import { useDownloadFile } from '@/hooks/file-manager-hooks';
|
||||
import { IFile } from '@/interfaces/database/file-manager';
|
||||
import { CellContext } from '@tanstack/react-table';
|
||||
import { EllipsisVertical, Link2, Trash2 } from 'lucide-react';
|
||||
import { useCallback } from 'react';
|
||||
import { UseHandleConnectToKnowledgeReturnType } from './hooks';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import {
|
||||
UseHandleConnectToKnowledgeReturnType,
|
||||
UseRenameCurrentFileReturnType,
|
||||
} from './hooks';
|
||||
|
||||
type IProps = Pick<CellContext<IFile, unknown>, 'row'> &
|
||||
Pick<UseHandleConnectToKnowledgeReturnType, 'showConnectToKnowledgeModal'>;
|
||||
Pick<UseHandleConnectToKnowledgeReturnType, 'showConnectToKnowledgeModal'> &
|
||||
Pick<UseRenameCurrentFileReturnType, 'showFileRenameModal'>;
|
||||
|
||||
export function ActionCell({ row, showConnectToKnowledgeModal }: IProps) {
|
||||
export function ActionCell({
|
||||
row,
|
||||
showConnectToKnowledgeModal,
|
||||
showFileRenameModal,
|
||||
}: IProps) {
|
||||
const { t } = useTranslation();
|
||||
const record = row.original;
|
||||
const documentId = record.id;
|
||||
const { downloadFile } = useDownloadFile();
|
||||
|
||||
const handleShowConnectToKnowledgeModal = useCallback(() => {
|
||||
showConnectToKnowledgeModal(record);
|
||||
}, [record, showConnectToKnowledgeModal]);
|
||||
|
||||
const onDownloadDocument = useCallback(() => {
|
||||
downloadFile({
|
||||
id: documentId,
|
||||
filename: record.name,
|
||||
});
|
||||
}, [documentId, downloadFile, record.name]);
|
||||
|
||||
const handleShowFileRenameModal = useCallback(() => {
|
||||
showFileRenameModal(record);
|
||||
}, [record, showFileRenameModal]);
|
||||
|
||||
return (
|
||||
<section className="flex gap-4 items-center">
|
||||
<Button
|
||||
@ -45,15 +68,19 @@ export function ActionCell({ row, showConnectToKnowledgeModal }: IProps) {
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end">
|
||||
<DropdownMenuLabel>Actions</DropdownMenuLabel>
|
||||
<DropdownMenuItem
|
||||
onClick={() => navigator.clipboard.writeText(record.id)}
|
||||
>
|
||||
Copy payment ID
|
||||
{t('common.move')}
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuSeparator />
|
||||
<DropdownMenuItem>View customer</DropdownMenuItem>
|
||||
<DropdownMenuItem>View payment details</DropdownMenuItem>
|
||||
<DropdownMenuItem onClick={handleShowFileRenameModal}>
|
||||
{t('common.rename')}
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuSeparator />
|
||||
<DropdownMenuItem onClick={onDownloadDocument}>
|
||||
{t('common.download')}
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</section>
|
||||
|
||||
@ -14,6 +14,7 @@ import {
|
||||
import { ArrowUpDown } from 'lucide-react';
|
||||
import * as React from 'react';
|
||||
|
||||
import { RenameDialog } from '@/components/rename-dialog';
|
||||
import SvgIcon from '@/components/svg-icon';
|
||||
import { TableEmpty, TableSkeleton } from '@/components/table-skeleton';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
@ -41,7 +42,11 @@ import { getExtension } from '@/utils/document-util';
|
||||
import { useMemo } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { ActionCell } from './action-cell';
|
||||
import { useHandleConnectToKnowledge, useNavigateToOtherFolder } from './hooks';
|
||||
import {
|
||||
useHandleConnectToKnowledge,
|
||||
useNavigateToOtherFolder,
|
||||
useRenameCurrentFile,
|
||||
} from './hooks';
|
||||
import { LinkToDatasetDialog } from './link-to-dataset-dialog';
|
||||
|
||||
export function FilesTable() {
|
||||
@ -64,6 +69,14 @@ export function FilesTable() {
|
||||
onConnectToKnowledgeOk,
|
||||
connectToKnowledgeLoading,
|
||||
} = useHandleConnectToKnowledge();
|
||||
const {
|
||||
fileRenameVisible,
|
||||
showFileRenameModal,
|
||||
hideFileRenameModal,
|
||||
onFileRenameOk,
|
||||
initialFileName,
|
||||
fileRenameLoading,
|
||||
} = useRenameCurrentFile();
|
||||
|
||||
const { pagination, data, loading, setPagination } = useFetchFileList();
|
||||
|
||||
@ -208,6 +221,7 @@ export function FilesTable() {
|
||||
<ActionCell
|
||||
row={row}
|
||||
showConnectToKnowledgeModal={showConnectToKnowledgeModal}
|
||||
showFileRenameModal={showFileRenameModal}
|
||||
></ActionCell>
|
||||
);
|
||||
},
|
||||
@ -341,6 +355,14 @@ export function FilesTable() {
|
||||
loading={connectToKnowledgeLoading}
|
||||
></LinkToDatasetDialog>
|
||||
)}
|
||||
{fileRenameVisible && (
|
||||
<RenameDialog
|
||||
hideModal={hideFileRenameModal}
|
||||
onOk={onFileRenameOk}
|
||||
initialName={initialFileName}
|
||||
loading={fileRenameLoading}
|
||||
></RenameDialog>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@ -90,6 +90,10 @@ export const useRenameCurrentFile = () => {
|
||||
};
|
||||
};
|
||||
|
||||
export type UseRenameCurrentFileReturnType = ReturnType<
|
||||
typeof useRenameCurrentFile
|
||||
>;
|
||||
|
||||
export const useSelectBreadcrumbItems = () => {
|
||||
const parentFolderList = useFetchParentFolderList();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user