feat: Move files in file manager #1826 (#1837)

### What problem does this PR solve?

feat: Move files in file manager #1826

### Type of change

- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
balibabu
2024-08-07 10:12:11 +08:00
committed by GitHub
parent 4c2906d6fd
commit c55e9d16da
14 changed files with 292 additions and 24 deletions

View File

@ -1,6 +1,12 @@
import NewDocumentLink from '@/components/new-document-link';
import SvgIcon from '@/components/svg-icon';
import { useTranslate } from '@/hooks/common-hooks';
import { IFile } from '@/interfaces/database/file-manager';
import { api_host } from '@/utils/api';
import {
getExtension,
isSupportedPreviewDocumentType,
} from '@/utils/document-util';
import { downloadFile } from '@/utils/file-util';
import {
DeleteOutlined,
@ -11,18 +17,13 @@ import {
} from '@ant-design/icons';
import { Button, Space, Tooltip } from 'antd';
import { useHandleDeleteFile } from '../hooks';
import NewDocumentLink from '@/components/new-document-link';
import {
getExtension,
isSupportedPreviewDocumentType,
} from '@/utils/document-util';
import styles from './index.less';
interface IProps {
record: IFile;
setCurrentRecord: (record: any) => void;
showRenameModal: (record: IFile) => void;
showMoveFileModal: (ids: string[]) => void;
showConnectToKnowledgeModal: (record: IFile) => void;
setSelectedRowKeys(keys: string[]): void;
}
@ -33,6 +34,7 @@ const ActionCell = ({
showRenameModal,
showConnectToKnowledgeModal,
setSelectedRowKeys,
showMoveFileModal,
}: IProps) => {
const documentId = record.id;
const beingUsed = false;
@ -64,6 +66,10 @@ const ActionCell = ({
showConnectToKnowledgeModal(record);
};
const onShowMoveFileModal = () => {
showMoveFileModal([documentId]);
};
return (
<Space size={0}>
{isKnowledgeBase || (
@ -90,6 +96,18 @@ const ActionCell = ({
</Button>
</Tooltip>
)}
{isKnowledgeBase || (
<Tooltip title={t('move', { keyPrefix: 'common' })}>
<Button
type="text"
disabled={beingUsed}
onClick={onShowMoveFileModal}
className={styles.iconButton}
>
<SvgIcon name={`move`} width={16}></SvgIcon>
</Button>
</Tooltip>
)}
{isKnowledgeBase || (
<Tooltip title={t('delete', { keyPrefix: 'common' })}>
<Button