Skip to content

Commit 072ccea

Browse files
committed
feat(Header): add upload folder option to the upload menu
1 parent 066bd67 commit 072ccea

1 file changed

Lines changed: 32 additions & 20 deletions

File tree

  • web/src/pages/FileExplorerPage/components

web/src/pages/FileExplorerPage/components/Header.tsx

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,12 @@ export const Header: React.FC<HeaderProps> = ({
145145
icon: <FileAddOutlined />,
146146
onClick: onCreateFile,
147147
},
148+
{
149+
key: 'upload-folder',
150+
label: t('Upload Folder'),
151+
icon: <UploadOutlined />,
152+
onClick: onUploadDirectory,
153+
},
148154
{
149155
key: 'sort',
150156
label: t('Sort By') + `: ${t(sortBy === 'mtime' ? 'Modified Time' : sortBy === 'size' ? 'Size' : 'Name')}`,
@@ -162,6 +168,20 @@ export const Header: React.FC<HeaderProps> = ({
162168
},
163169
];
164170

171+
const uploadMenu = {
172+
items: [
173+
{ key: 'file', label: t('Upload Files') },
174+
{ key: 'folder', label: t('Upload Folder') },
175+
],
176+
onClick: ({ key }: { key: string }) => {
177+
if (key === 'folder') {
178+
onUploadDirectory();
179+
} else {
180+
onUploadFile();
181+
}
182+
},
183+
};
184+
165185
return (
166186
<Flex vertical={isMobile} gap={isMobile ? 10 : 12} style={{ padding: isMobile ? '10px 12px' : '10px 16px', borderBottom: `1px solid ${token.colorBorderSecondary}` }}>
167187
<Flex align="center" gap={8} style={{ minWidth: 0 }}>
@@ -179,26 +199,18 @@ export const Header: React.FC<HeaderProps> = ({
179199
<Button size="small" icon={<PlusOutlined />} onClick={onCreateDir} aria-label={t('New Folder')}>
180200
{!isMobile && t('New Folder')}
181201
</Button>
182-
<Dropdown.Button
183-
size="small"
184-
icon={<UploadOutlined />}
185-
onClick={onUploadFile}
186-
menu={{
187-
items: [
188-
{ key: 'file', label: t('Upload Files') },
189-
{ key: 'folder', label: t('Upload Folder') },
190-
],
191-
onClick: ({ key }) => {
192-
if (key === 'folder') {
193-
onUploadDirectory();
194-
} else {
195-
onUploadFile();
196-
}
197-
},
198-
}}
199-
>
200-
{!isMobile && t('Upload')}
201-
</Dropdown.Button>
202+
{isMobile ? (
203+
<Button size="small" icon={<UploadOutlined />} onClick={onUploadFile} aria-label={t('Upload Files')} />
204+
) : (
205+
<Dropdown.Button
206+
size="small"
207+
icon={<UploadOutlined />}
208+
onClick={onUploadFile}
209+
menu={uploadMenu}
210+
>
211+
{t('Upload')}
212+
</Dropdown.Button>
213+
)}
202214
{isMobile && (
203215
<Dropdown menu={{ items: mobileMoreItems }}>
204216
<Button size="small" icon={<MoreOutlined />} aria-label={t('More')} />

0 commit comments

Comments
 (0)