Skip to content

Commit e205bfe

Browse files
authored
chore(storage-browser): add 'folder' column to uploads controls table (#5643)
* chore(storage-browser): use humanFileSize util to pretty print the size * add default cases * chore(storage-browser): add file extension as column type * chore(storage-browser): add 'folder' column to uploads controls table * revert useHandleUpload * use custom column for upload controls table * remove toUpperCase * update file type after merge * update tests
1 parent 71d9f55 commit e205bfe

File tree

1 file changed

+24
-6
lines changed
  • packages/react-storage/src/components/StorageBrowser/Views/LocationActionView

1 file changed

+24
-6
lines changed

packages/react-storage/src/components/StorageBrowser/Views/LocationActionView/UploadControls.tsx

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,18 @@ const { Cancel, Exit, Primary, Summary, Table } = Controls;
2929

3030
interface LocationActionViewColumns extends CancelableTask {
3131
type: string;
32+
folder: string;
3233
}
3334

3435
const LOCATION_ACTION_VIEW_COLUMNS: Column<LocationActionViewColumns>[] = [
3536
{
3637
key: 'key',
3738
header: 'Name',
3839
},
40+
{
41+
key: 'folder',
42+
header: 'Folder',
43+
},
3944
{
4045
key: 'type',
4146
header: 'Type',
@@ -114,6 +119,7 @@ const LocationActionViewColumnSortMap = {
114119
status: compareStrings,
115120
progress: compareNumbers,
116121
type: compareStrings,
122+
folder: compareStrings,
117123
};
118124

119125
const renderRowItem: RenderRowItem<LocationActionViewColumns> = (
@@ -125,13 +131,20 @@ const renderRowItem: RenderRowItem<LocationActionViewColumns> = (
125131
row: LocationActionViewColumns
126132
) => {
127133
switch (columnKey) {
128-
case 'key':
134+
case 'key': {
135+
// Render the key without the parent folders
136+
const folder = row.key.lastIndexOf('/') + 1;
137+
129138
return (
130139
<TableDataText>
131140
<ActionIcon status={row.status} />
132-
{row.key}
141+
{row.key.slice(folder, row.key.length)}
133142
</TableDataText>
134143
);
144+
}
145+
case 'folder': {
146+
return <TableDataText>{row.folder}</TableDataText>;
147+
}
135148
case 'type': {
136149
return <TableDataText>{row.type}</TableDataText>;
137150
}
@@ -198,10 +211,15 @@ export const UploadControls = (): JSX.Element => {
198211
files,
199212
});
200213

201-
let tableData = tasks.map((task) => ({
202-
...task,
203-
type: task.data.type ?? '-',
204-
}));
214+
let tableData = tasks.map((task) => {
215+
const folder = task.data.webkitRelativePath.lastIndexOf('/') + 1;
216+
217+
return {
218+
...task,
219+
type: task.data.type ?? '-',
220+
folder: folder > -1 ? task.data.webkitRelativePath.slice(0, folder) : '/',
221+
};
222+
});
205223

206224
const { options } = actions[selected.type!];
207225
const { selectionData } = options ?? {};

0 commit comments

Comments
 (0)