Skip to content

Commit 3540d4c

Browse files
committed
fix(FR-1007): Allow to create a new folder in folder explorer (#3678)
# Fix FolderExplorerActions TypeScript issues and update folder creation functionality This PR improves the FolderExplorerActions component by: 1. Adding proper TypeScript typing for the FolderExplorerElement interface 2. Replacing LegacyRef with RefObject for better type safety 3. Removing unnecessary @ts-ignore comments 4. Fixing the "Create" button functionality to call openMkdirDialog() instead of openCreateFileDialog() **Checklist:** - [ ] Documentation - [ ] Minium required manager version - [ ] Specific setting for review (eg., KB link, endpoint or how to setup) - [ ] Minimum requirements to check during review - [ ] Test case(s) to demonstrate the difference of before/after
1 parent a1483dc commit 3540d4c

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

react/src/components/FolderExplorerActions.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1+
import { FolderExplorerElement } from './LegacyFolderExplorer';
12
import {
23
DeleteOutlined,
34
FileAddOutlined,
45
FolderAddOutlined,
56
UploadOutlined,
67
} from '@ant-design/icons';
78
import { Button, Dropdown, Tooltip, Flex, theme } from 'antd';
8-
import React, { LegacyRef } from 'react';
9+
import React, { RefObject } from 'react';
910
import { useTranslation } from 'react-i18next';
1011

1112
interface FolderExplorerActionsProps {
1213
isSelected: boolean;
1314
isWritable: boolean;
14-
folderExplorerRef: LegacyRef<HTMLDivElement>;
15+
folderExplorerRef: RefObject<FolderExplorerElement | null>;
1516
size?: 'small' | 'default';
1617
}
1718

@@ -38,7 +39,6 @@ const FolderExplorerActions: React.FC<FolderExplorerActionsProps> = ({
3839
disabled={!isSelected || !isWritable}
3940
icon={<DeleteOutlined />}
4041
onClick={() => {
41-
// @ts-ignore
4242
folderExplorerRef.current?._openDeleteMultipleFileDialog();
4343
}}
4444
>
@@ -50,8 +50,7 @@ const FolderExplorerActions: React.FC<FolderExplorerActionsProps> = ({
5050
disabled={!isWritable}
5151
icon={<FileAddOutlined />}
5252
onClick={() => {
53-
// @ts-ignore
54-
folderExplorerRef.current?.openCreateFileDialog();
53+
folderExplorerRef.current?.openMkdirDialog();
5554
}}
5655
>
5756
{size !== 'small' && t('button.Create')}
@@ -66,7 +65,6 @@ const FolderExplorerActions: React.FC<FolderExplorerActionsProps> = ({
6665
label: t('data.explorer.UploadFiles'),
6766
icon: <FileAddOutlined />,
6867
onClick: () => {
69-
// @ts-ignore
7068
folderExplorerRef.current?.handleUpload('file');
7169
},
7270
},
@@ -75,7 +73,6 @@ const FolderExplorerActions: React.FC<FolderExplorerActionsProps> = ({
7573
label: t('data.explorer.UploadFolder'),
7674
icon: <FolderAddOutlined />,
7775
onClick: () => {
78-
// @ts-ignore
7976
folderExplorerRef.current?.handleUpload('folder');
8077
},
8178
},

react/src/components/LegacyFolderExplorer.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,11 @@ interface LegacyFolderExplorerProps extends BAIModalProps {
2626
vfolderID: string;
2727
onRequestClose: () => void;
2828
}
29-
interface FolderExplorerElement extends HTMLDivElement {
29+
export interface FolderExplorerElement extends HTMLDivElement {
3030
_fetchVFolder: () => void;
31+
_openDeleteMultipleFileDialog: () => void;
32+
openMkdirDialog: () => void;
33+
handleUpload: (name: 'file' | 'folder') => void;
3134
}
3235

3336
const LegacyFolderExplorer: React.FC<LegacyFolderExplorerProps> = ({

0 commit comments

Comments
 (0)