@aws-amplify/ui-react-storage 3.15.0 → 3.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.js +1 -1
- package/dist/{createStorageBrowser-CG-6mXiT.js → createStorageBrowser-De4hcP-u.js} +710 -158
- package/dist/esm/browser.mjs +1 -0
- package/dist/esm/components/StorageBrowser/ErrorBoundary/ErrorBoundary.mjs +1 -4
- package/dist/esm/components/StorageBrowser/actions/configs/defaults.mjs +13 -3
- package/dist/esm/components/StorageBrowser/actions/handlers/delete.mjs +39 -8
- package/dist/esm/components/StorageBrowser/components/ComponentsProvider.mjs +1 -4
- package/dist/esm/components/StorageBrowser/components/base/preview/DownloadButton.mjs +1 -4
- package/dist/esm/components/StorageBrowser/components/composables/ActionConfirmationModal.mjs +34 -0
- package/dist/esm/components/StorageBrowser/components/composables/defaults.mjs +2 -0
- package/dist/esm/components/StorageBrowser/components/elements/definitions.mjs +2 -2
- package/dist/esm/components/StorageBrowser/configuration/paginationContext.mjs +15 -0
- package/dist/esm/components/StorageBrowser/controls/ActionConfirmationModalControl.mjs +12 -0
- package/dist/esm/components/StorageBrowser/controls/DataTableControl.mjs +1 -4
- package/dist/esm/components/StorageBrowser/controls/hooks/useActionConfirmationModal.mjs +17 -0
- package/dist/esm/components/StorageBrowser/createStorageBrowser/StorageBrowserDefault.mjs +9 -4
- package/dist/esm/components/StorageBrowser/createStorageBrowser/createProvider.mjs +11 -9
- package/dist/esm/components/StorageBrowser/createStorageBrowser/createStorageBrowser.mjs +10 -5
- package/dist/esm/components/StorageBrowser/displayText/libraries/en/deleteView.mjs +117 -5
- package/dist/esm/components/StorageBrowser/displayText/libraries/en/locationDetailView.mjs +1 -0
- package/dist/esm/components/StorageBrowser/displayText/libraries/en/shared.mjs +1 -0
- package/dist/esm/components/StorageBrowser/locationItems/context.mjs +17 -14
- package/dist/esm/components/StorageBrowser/locationItems/utils.mjs +38 -0
- package/dist/esm/components/StorageBrowser/store/validateStoreProps.mjs +1 -1
- package/dist/esm/components/StorageBrowser/tasks/useProcessTasks.mjs +7 -4
- package/dist/esm/components/StorageBrowser/useAction/useHandler.mjs +1 -0
- package/dist/esm/components/StorageBrowser/useAction/useListFolderItems.mjs +1 -0
- package/dist/esm/components/StorageBrowser/useAction/useListLocationItems.mjs +1 -0
- package/dist/esm/components/StorageBrowser/useAction/utils.mjs +0 -5
- package/dist/esm/components/StorageBrowser/utils/validatePageSize.mjs +12 -0
- package/dist/esm/components/StorageBrowser/views/LocationActionView/CopyView/CopyView.mjs +1 -4
- package/dist/esm/components/StorageBrowser/views/LocationActionView/CopyView/CopyViewProvider.mjs +5 -4
- package/dist/esm/components/StorageBrowser/views/LocationActionView/CopyView/FoldersMessageControl.mjs +1 -4
- package/dist/esm/components/StorageBrowser/views/LocationActionView/CopyView/useCopyView.mjs +1 -4
- package/dist/esm/components/StorageBrowser/views/LocationActionView/CopyView/useFolders.mjs +1 -4
- package/dist/esm/components/StorageBrowser/views/LocationActionView/CreateFolderView/CreateFolderView.mjs +1 -4
- package/dist/esm/components/StorageBrowser/views/LocationActionView/CreateFolderView/useCreateFolderView.mjs +1 -4
- package/dist/esm/components/StorageBrowser/views/LocationActionView/DeleteView/DeleteView.mjs +6 -6
- package/dist/esm/components/StorageBrowser/views/LocationActionView/DeleteView/DeleteViewProvider.mjs +7 -6
- package/dist/esm/components/StorageBrowser/views/LocationActionView/DeleteView/useDeleteView.mjs +70 -7
- package/dist/esm/components/StorageBrowser/views/LocationActionView/DeleteView/utils.mjs +87 -0
- package/dist/esm/components/StorageBrowser/views/LocationActionView/DownloadView/DownloadView.mjs +1 -4
- package/dist/esm/components/StorageBrowser/views/LocationActionView/DownloadView/DownloadViewProvider.mjs +9 -0
- package/dist/esm/components/StorageBrowser/views/LocationActionView/DownloadView/useDownloadView.mjs +1 -4
- package/dist/esm/components/StorageBrowser/views/LocationActionView/UploadView/UploadView.mjs +3 -6
- package/dist/esm/components/StorageBrowser/views/LocationActionView/UploadView/UploadViewProvider.mjs +3 -0
- package/dist/esm/components/StorageBrowser/views/LocationActionView/UploadView/useUploadView.mjs +11 -12
- package/dist/esm/components/StorageBrowser/views/LocationDetailView/LocationDetailView.mjs +1 -4
- package/dist/esm/components/StorageBrowser/views/LocationDetailView/LocationDetailViewProvider.mjs +2 -1
- package/dist/esm/components/StorageBrowser/views/LocationDetailView/getLocationDetailViewTableData/getFolderRowContent.mjs +38 -27
- package/dist/esm/components/StorageBrowser/views/LocationDetailView/getLocationDetailViewTableData/getLocationDetailViewTableData.mjs +8 -1
- package/dist/esm/components/StorageBrowser/views/LocationDetailView/useLocationDetailView.mjs +24 -20
- package/dist/esm/components/StorageBrowser/views/LocationsView/LocationsView.mjs +1 -4
- package/dist/esm/components/StorageBrowser/views/LocationsView/LocationsViewProvider.mjs +1 -4
- package/dist/esm/components/StorageBrowser/views/LocationsView/useLocationsView.mjs +13 -10
- package/dist/esm/components/StorageBrowser/views/context/actionViews.mjs +12 -8
- package/dist/esm/components/StorageBrowser/views/context/primaryViews.mjs +9 -4
- package/dist/esm/components/StorageBrowser/views/hooks/usePaginate.mjs +18 -7
- package/dist/esm/components/StorageBrowser/views/utils/tableResolvers/constants.mjs +10 -1
- package/dist/esm/components/StorageBrowser/views/utils/tableResolvers/deleteResolvers.mjs +123 -13
- package/dist/esm/components/StorageBrowser/views/utils/tableResolvers/utils.mjs +3 -3
- package/dist/esm/version.mjs +1 -1
- package/dist/index.js +1 -1
- package/dist/styles.css +83 -1
- package/dist/types/components/StorageBrowser/StorageBrowserAmplify.d.ts +3 -1
- package/dist/types/components/StorageBrowser/actions/handlers/delete.d.ts +5 -3
- package/dist/types/components/StorageBrowser/actions/handlers/types.d.ts +15 -1
- package/dist/types/components/StorageBrowser/components/composables/ActionConfirmationModal.d.ts +12 -0
- package/dist/types/components/StorageBrowser/components/composables/types.d.ts +2 -0
- package/dist/types/components/StorageBrowser/configuration/index.d.ts +2 -0
- package/dist/types/components/StorageBrowser/configuration/paginationContext.d.ts +12 -0
- package/dist/types/components/StorageBrowser/controls/ActionConfirmationModalControl.d.ts +2 -0
- package/dist/types/components/StorageBrowser/controls/hooks/useActionConfirmationModal.d.ts +2 -0
- package/dist/types/components/StorageBrowser/controls/index.d.ts +1 -0
- package/dist/types/components/StorageBrowser/controls/types.d.ts +4 -0
- package/dist/types/components/StorageBrowser/createStorageBrowser/types.d.ts +7 -1
- package/dist/types/components/StorageBrowser/displayText/types.d.ts +7 -0
- package/dist/types/components/StorageBrowser/locationItems/context.d.ts +12 -3
- package/dist/types/components/StorageBrowser/locationItems/index.d.ts +1 -0
- package/dist/types/components/StorageBrowser/locationItems/utils.d.ts +27 -0
- package/dist/types/components/StorageBrowser/store/types.d.ts +7 -0
- package/dist/types/components/StorageBrowser/tasks/types.d.ts +7 -2
- package/dist/types/components/StorageBrowser/utils/index.d.ts +1 -0
- package/dist/types/components/StorageBrowser/utils/validatePageSize.d.ts +1 -0
- package/dist/types/components/StorageBrowser/views/LocationActionView/DeleteView/types.d.ts +5 -0
- package/dist/types/components/StorageBrowser/views/LocationActionView/DeleteView/utils.d.ts +26 -0
- package/dist/types/components/StorageBrowser/views/LocationActionView/UploadView/types.d.ts +7 -0
- package/dist/types/components/StorageBrowser/views/LocationDetailView/getLocationDetailViewTableData/getFolderRowContent.d.ts +4 -1
- package/dist/types/components/StorageBrowser/views/LocationDetailView/getLocationDetailViewTableData/getLocationDetailViewTableData.d.ts +3 -2
- package/dist/types/components/StorageBrowser/views/LocationDetailView/types.d.ts +10 -3
- package/dist/types/components/StorageBrowser/views/LocationsView/types.d.ts +2 -2
- package/dist/types/components/StorageBrowser/views/hooks/usePaginate.d.ts +1 -1
- package/dist/types/components/StorageBrowser/views/types.d.ts +6 -0
- package/dist/types/components/StorageBrowser/views/utils/index.d.ts +1 -1
- package/dist/types/components/StorageBrowser/views/utils/tableResolvers/constants.d.ts +1 -0
- package/dist/types/components/StorageBrowser/views/utils/tableResolvers/deleteResolvers.d.ts +5 -2
- package/dist/types/components/StorageBrowser/views/utils/tableResolvers/index.d.ts +1 -1
- package/dist/types/components/StorageBrowser/views/utils/tableResolvers/types.d.ts +4 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +7 -7
|
@@ -1,32 +1,43 @@
|
|
|
1
1
|
import { LOCATION_DETAIL_VIEW_HEADERS } from './constants.mjs';
|
|
2
2
|
|
|
3
|
-
const getFolderRowContent = ({ itemSubPath, rowId, onNavigate, }) =>
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
const getFolderRowContent = ({ itemSubPath, rowId, isSelected, selectFolderLabel, onNavigate, onSelect, }) => {
|
|
4
|
+
return LOCATION_DETAIL_VIEW_HEADERS.map((columnKey) => {
|
|
5
|
+
const key = `${columnKey}-${rowId}`;
|
|
6
|
+
switch (columnKey) {
|
|
7
|
+
case 'checkbox': {
|
|
8
|
+
return {
|
|
9
|
+
key,
|
|
10
|
+
type: 'checkbox',
|
|
11
|
+
content: {
|
|
12
|
+
checked: isSelected,
|
|
13
|
+
id: key,
|
|
14
|
+
label: `${selectFolderLabel} ${itemSubPath}`,
|
|
15
|
+
onSelect,
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
case 'name': {
|
|
20
|
+
return {
|
|
21
|
+
key,
|
|
22
|
+
type: 'button',
|
|
23
|
+
content: {
|
|
24
|
+
icon: 'folder',
|
|
25
|
+
ariaLabel: itemSubPath,
|
|
26
|
+
label: itemSubPath,
|
|
27
|
+
onClick: onNavigate,
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
case 'type': {
|
|
32
|
+
return { key, type: 'text', content: { text: 'Folder' } };
|
|
33
|
+
}
|
|
34
|
+
case 'last-modified':
|
|
35
|
+
case 'size':
|
|
36
|
+
case 'download': {
|
|
37
|
+
return { key, type: 'text', content: { text: '' } };
|
|
38
|
+
}
|
|
8
39
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
key,
|
|
12
|
-
type: 'button',
|
|
13
|
-
content: {
|
|
14
|
-
icon: 'folder',
|
|
15
|
-
ariaLabel: itemSubPath,
|
|
16
|
-
label: itemSubPath,
|
|
17
|
-
onClick: onNavigate,
|
|
18
|
-
},
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
case 'type': {
|
|
22
|
-
return { key, type: 'text', content: { text: 'Folder' } };
|
|
23
|
-
}
|
|
24
|
-
case 'last-modified':
|
|
25
|
-
case 'size':
|
|
26
|
-
case 'download': {
|
|
27
|
-
return { key, type: 'text', content: { text: '' } };
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
});
|
|
40
|
+
});
|
|
41
|
+
};
|
|
31
42
|
|
|
32
43
|
export { getFolderRowContent };
|
|
@@ -9,7 +9,7 @@ import { getFileRowContent } from './getFileRowContent.mjs';
|
|
|
9
9
|
import { getFolderRowContent } from './getFolderRowContent.mjs';
|
|
10
10
|
import { getHeaders } from './getHeaders.mjs';
|
|
11
11
|
|
|
12
|
-
const getLocationDetailViewTableData = ({ filePreviewEnabled, activeFile, onSelectActiveFile, areAllFilesSelected, displayText, location, fileDataItems, hasFiles, pageItems, selectFileLabel, selectAllFilesLabel, getDateDisplayValue, onDownload, onNavigate, onSelect, onSelectAll, }) => {
|
|
12
|
+
const getLocationDetailViewTableData = ({ filePreviewEnabled, activeFile, onSelectActiveFile, areAllFilesSelected, displayText, location, fileDataItems, dataItems, hasFiles, pageItems, selectFileLabel, selectAllFilesLabel, getDateDisplayValue, onDownload, onNavigate, onSelect, onSelectAll, }) => {
|
|
13
13
|
const { tableColumnLastModifiedHeader, tableColumnNameHeader, tableColumnSizeHeader, tableColumnTypeHeader, } = displayText;
|
|
14
14
|
const headers = getHeaders({
|
|
15
15
|
areAllFilesSelected,
|
|
@@ -67,6 +67,10 @@ const getLocationDetailViewTableData = ({ filePreviewEnabled, activeFile, onSele
|
|
|
67
67
|
}
|
|
68
68
|
onNavigate({ ...current, id }, itemLocationPath);
|
|
69
69
|
};
|
|
70
|
+
const isSelected = dataItems?.some((item) => item.id === id) ?? false;
|
|
71
|
+
const onFolderSelect = () => {
|
|
72
|
+
onSelect(isSelected, locationItem);
|
|
73
|
+
};
|
|
70
74
|
return {
|
|
71
75
|
key: id,
|
|
72
76
|
active: false,
|
|
@@ -74,6 +78,9 @@ const getLocationDetailViewTableData = ({ filePreviewEnabled, activeFile, onSele
|
|
|
74
78
|
itemSubPath,
|
|
75
79
|
rowId: id,
|
|
76
80
|
onNavigate: onFolderNavigate,
|
|
81
|
+
selectFolderLabel: selectFileLabel,
|
|
82
|
+
isSelected,
|
|
83
|
+
onSelect: onFolderSelect,
|
|
77
84
|
}),
|
|
78
85
|
};
|
|
79
86
|
}
|
package/dist/esm/components/StorageBrowser/views/LocationDetailView/useLocationDetailView.mjs
CHANGED
|
@@ -7,6 +7,10 @@ import 'jszip';
|
|
|
7
7
|
import 'aws-amplify/storage';
|
|
8
8
|
import { useActionConfigs } from '../../actions/configs/context.mjs';
|
|
9
9
|
import '../../actions/configs/defaults.mjs';
|
|
10
|
+
import '@aws-amplify/ui-react-core/elements';
|
|
11
|
+
import '../../credentials/context.mjs';
|
|
12
|
+
import '../../configuration/context.mjs';
|
|
13
|
+
import { usePaginationConfig } from '../../configuration/paginationContext.mjs';
|
|
10
14
|
import { useFileItems } from '../../fileItems/context.mjs';
|
|
11
15
|
import { useLocationItems } from '../../locationItems/context.mjs';
|
|
12
16
|
import { useStore } from '../../store/context.mjs';
|
|
@@ -16,30 +20,29 @@ import { useList } from '../../useAction/useList.mjs';
|
|
|
16
20
|
import { useSearch } from '../hooks/useSearch.mjs';
|
|
17
21
|
import { useFilePreview } from '../hooks/useFilePreview/useFilePreview.mjs';
|
|
18
22
|
|
|
19
|
-
const DEFAULT_PAGE_SIZE = 100;
|
|
20
|
-
const DEFAULT_LIST_OPTIONS = {
|
|
21
|
-
delimiter: '/',
|
|
22
|
-
pageSize: DEFAULT_PAGE_SIZE,
|
|
23
|
-
};
|
|
24
23
|
const getDownloadErrorMessageFromFailedDownloadTask = (task) => {
|
|
25
24
|
if (!task)
|
|
26
25
|
return;
|
|
27
26
|
return `Failed to download ${task.data.fileKey ?? task.data.key} due to error: ${task.message}.`;
|
|
28
27
|
};
|
|
29
28
|
const useLocationDetailView = (options) => {
|
|
30
|
-
const {
|
|
31
|
-
const
|
|
32
|
-
|
|
29
|
+
const { pageSize: configPageSize } = usePaginationConfig();
|
|
30
|
+
const { initialValues = {}, onExit, onNavigate, pageSize: propPageSize, } = options ?? {};
|
|
31
|
+
const pageSize = propPageSize ?? configPageSize;
|
|
32
|
+
const listOptions = React__default.useMemo(() => ({
|
|
33
33
|
...initialValues,
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
delimiter: '/',
|
|
35
|
+
pageSize,
|
|
36
|
+
}),
|
|
37
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
38
|
+
[pageSize, initialValues.delimiter, initialValues.pageSize]);
|
|
36
39
|
const [{ location, actionType }, storeDispatch] = useStore();
|
|
37
40
|
const [locationItems, locationItemsDispatch] = useLocationItems();
|
|
38
41
|
const fileItemsDispatch = useFileItems()[1];
|
|
39
42
|
const [activeFile, setActiveFile] = React__default.useState();
|
|
40
43
|
const { current, key } = location;
|
|
41
44
|
const { permissions, prefix } = current ?? {};
|
|
42
|
-
const { fileDataItems } = locationItems;
|
|
45
|
+
const { dataItems, fileDataItems } = locationItems;
|
|
43
46
|
const hasInvalidPrefix = isUndefined(prefix);
|
|
44
47
|
const [{ task }, handleDownload] = useAction('download');
|
|
45
48
|
const [{ value, isLoading, hasError, message }, handleList] = useList('locationItems');
|
|
@@ -166,13 +169,13 @@ const useLocationDetailView = (options) => {
|
|
|
166
169
|
actionType: type,
|
|
167
170
|
icon,
|
|
168
171
|
isDisabled: isFunction(disable)
|
|
169
|
-
? disable(
|
|
172
|
+
? disable(dataItems)
|
|
170
173
|
: disable ?? false,
|
|
171
174
|
isHidden: isFunction(hide) ? hide(permissions) : hide,
|
|
172
175
|
label,
|
|
173
176
|
};
|
|
174
177
|
});
|
|
175
|
-
}, [actionConfigs,
|
|
178
|
+
}, [actionConfigs, dataItems, permissions]);
|
|
176
179
|
return {
|
|
177
180
|
actionItems,
|
|
178
181
|
actionType,
|
|
@@ -183,6 +186,7 @@ const useLocationDetailView = (options) => {
|
|
|
183
186
|
page: currentPage,
|
|
184
187
|
pageItems,
|
|
185
188
|
location,
|
|
189
|
+
dataItems,
|
|
186
190
|
fileDataItems,
|
|
187
191
|
hasError,
|
|
188
192
|
hasDownloadError: task?.status === 'FAILED',
|
|
@@ -238,16 +242,16 @@ const useLocationDetailView = (options) => {
|
|
|
238
242
|
storeDispatch({ type: 'RESET_ACTION_TYPE' });
|
|
239
243
|
locationItemsDispatch({ type: 'RESET_LOCATION_ITEMS' });
|
|
240
244
|
},
|
|
241
|
-
onSelect: (isSelected,
|
|
245
|
+
onSelect: (isSelected, item) => {
|
|
242
246
|
locationItemsDispatch(isSelected
|
|
243
|
-
? { type: 'REMOVE_LOCATION_ITEM', id:
|
|
244
|
-
: { type: 'SET_LOCATION_ITEMS', items: [
|
|
247
|
+
? { type: 'REMOVE_LOCATION_ITEM', id: item.id }
|
|
248
|
+
: { type: 'SET_LOCATION_ITEMS', items: [item] });
|
|
245
249
|
},
|
|
246
250
|
onToggleSelectAll: () => {
|
|
247
|
-
const
|
|
248
|
-
locationItemsDispatch(
|
|
251
|
+
const selectableItems = pageItems;
|
|
252
|
+
locationItemsDispatch(selectableItems.length === dataItems?.length
|
|
249
253
|
? { type: 'RESET_LOCATION_ITEMS' }
|
|
250
|
-
: { type: 'SET_LOCATION_ITEMS', items:
|
|
254
|
+
: { type: 'SET_LOCATION_ITEMS', items: selectableItems });
|
|
251
255
|
},
|
|
252
256
|
onSearch: () => {
|
|
253
257
|
setActiveFile(undefined);
|
|
@@ -266,4 +270,4 @@ const useLocationDetailView = (options) => {
|
|
|
266
270
|
};
|
|
267
271
|
};
|
|
268
272
|
|
|
269
|
-
export {
|
|
273
|
+
export { useLocationDetailView };
|
|
@@ -11,10 +11,7 @@ import '@aws-amplify/ui-react-core/elements';
|
|
|
11
11
|
import '../../credentials/context.mjs';
|
|
12
12
|
import '@aws-amplify/storage/internals';
|
|
13
13
|
import '../../configuration/context.mjs';
|
|
14
|
-
import '
|
|
15
|
-
import 'jszip';
|
|
16
|
-
import 'aws-amplify/storage';
|
|
17
|
-
import '../../actions/configs/context.mjs';
|
|
14
|
+
import '../../configuration/paginationContext.mjs';
|
|
18
15
|
import '../../actions/configs/defaults.mjs';
|
|
19
16
|
import '../../displayText/context.mjs';
|
|
20
17
|
import '../../filePreview/context.mjs';
|
|
@@ -11,10 +11,7 @@ import '@aws-amplify/ui-react-core/elements';
|
|
|
11
11
|
import '../../credentials/context.mjs';
|
|
12
12
|
import '@aws-amplify/storage/internals';
|
|
13
13
|
import '../../configuration/context.mjs';
|
|
14
|
-
import '
|
|
15
|
-
import 'jszip';
|
|
16
|
-
import 'aws-amplify/storage';
|
|
17
|
-
import '../../actions/configs/context.mjs';
|
|
14
|
+
import '../../configuration/paginationContext.mjs';
|
|
18
15
|
import '../../actions/configs/defaults.mjs';
|
|
19
16
|
import { useDisplayText } from '../../displayText/context.mjs';
|
|
20
17
|
import '../../filePreview/context.mjs';
|
|
@@ -6,6 +6,10 @@ import 'jszip';
|
|
|
6
6
|
import 'aws-amplify/storage';
|
|
7
7
|
import '../../actions/configs/context.mjs';
|
|
8
8
|
import '../../actions/configs/defaults.mjs';
|
|
9
|
+
import '@aws-amplify/ui-react-core/elements';
|
|
10
|
+
import '../../credentials/context.mjs';
|
|
11
|
+
import '../../configuration/context.mjs';
|
|
12
|
+
import { usePaginationConfig } from '../../configuration/paginationContext.mjs';
|
|
9
13
|
import { useStore } from '../../store/context.mjs';
|
|
10
14
|
import '../../useAction/context.mjs';
|
|
11
15
|
import { useAction } from '../../useAction/useAction.mjs';
|
|
@@ -16,12 +20,8 @@ import { useSearch } from '../hooks/useSearch.mjs';
|
|
|
16
20
|
const DEFAULT_EXCLUDE = {
|
|
17
21
|
exactPermissions: ['delete', 'write'],
|
|
18
22
|
};
|
|
19
|
-
const DEFAULT_PAGE_SIZE = 100;
|
|
20
|
-
const DEFAULT_LIST_OPTIONS = {
|
|
21
|
-
exclude: DEFAULT_EXCLUDE,
|
|
22
|
-
pageSize: DEFAULT_PAGE_SIZE,
|
|
23
|
-
};
|
|
24
23
|
const useLocationsView = (options) => {
|
|
24
|
+
const { pageSize: configPageSize } = usePaginationConfig();
|
|
25
25
|
const handleDownload = useAction('download')[1];
|
|
26
26
|
const [state, handleList] = useList('locations');
|
|
27
27
|
const dispatchStoreAction = useStore()[1];
|
|
@@ -29,12 +29,15 @@ const useLocationsView = (options) => {
|
|
|
29
29
|
const { items, nextToken, hasExhaustedSearch = false } = value;
|
|
30
30
|
const hasNextToken = !!nextToken;
|
|
31
31
|
const onNavigate = options?.onNavigate;
|
|
32
|
+
const pageSize = options?.pageSize ?? configPageSize;
|
|
32
33
|
const initialValues = options?.initialValues ?? {};
|
|
33
|
-
const
|
|
34
|
-
...DEFAULT_LIST_OPTIONS,
|
|
34
|
+
const listOptions = React__default.useMemo(() => ({
|
|
35
35
|
...initialValues,
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
exclude: DEFAULT_EXCLUDE,
|
|
37
|
+
pageSize,
|
|
38
|
+
}),
|
|
39
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
40
|
+
[pageSize, initialValues.pageSize]);
|
|
38
41
|
// initial load
|
|
39
42
|
React__default.useEffect(() => {
|
|
40
43
|
handleList({ options: { ...listOptions, refresh: true } });
|
|
@@ -108,4 +111,4 @@ const useLocationsView = (options) => {
|
|
|
108
111
|
};
|
|
109
112
|
};
|
|
110
113
|
|
|
111
|
-
export {
|
|
114
|
+
export { useLocationsView };
|
|
@@ -1,23 +1,27 @@
|
|
|
1
1
|
import React__default from 'react';
|
|
2
2
|
import { UploadView } from '../LocationActionView/UploadView/UploadView.mjs';
|
|
3
|
-
import '../../fileItems/context.mjs';
|
|
4
|
-
import '@aws-amplify/ui';
|
|
5
|
-
import '../../store/context.mjs';
|
|
6
|
-
import '../../useAction/context.mjs';
|
|
7
3
|
import '@aws-amplify/ui-react-core/elements';
|
|
8
4
|
import '../../credentials/context.mjs';
|
|
9
5
|
import '@aws-amplify/storage/internals';
|
|
10
6
|
import '../../configuration/context.mjs';
|
|
7
|
+
import '../../configuration/paginationContext.mjs';
|
|
8
|
+
import '../../fileItems/context.mjs';
|
|
9
|
+
import '@aws-amplify/ui';
|
|
10
|
+
import '../../store/context.mjs';
|
|
11
|
+
import '../../useAction/context.mjs';
|
|
11
12
|
import '@aws-amplify/ui-react-core';
|
|
12
|
-
import 'aws-amplify';
|
|
13
|
-
import 'jszip';
|
|
14
|
-
import 'aws-amplify/storage';
|
|
15
|
-
import '../../actions/configs/context.mjs';
|
|
16
13
|
import '../../actions/configs/defaults.mjs';
|
|
17
14
|
import { CreateFolderView } from '../LocationActionView/CreateFolderView/CreateFolderView.mjs';
|
|
18
15
|
import { CopyView } from '../LocationActionView/CopyView/CopyView.mjs';
|
|
19
16
|
import '../../locationItems/context.mjs';
|
|
20
17
|
import { DeleteView } from '../LocationActionView/DeleteView/DeleteView.mjs';
|
|
18
|
+
import '../../displayText/context.mjs';
|
|
19
|
+
import '@aws-amplify/ui-react';
|
|
20
|
+
import '../../components/elements/definitions.mjs';
|
|
21
|
+
import '../../components/elements/IconElement.mjs';
|
|
22
|
+
import 'aws-amplify';
|
|
23
|
+
import 'jszip';
|
|
24
|
+
import 'aws-amplify/storage';
|
|
21
25
|
import { DownloadView } from '../LocationActionView/DownloadView/DownloadView.mjs';
|
|
22
26
|
|
|
23
27
|
const DEFAULT_ACTION_VIEWS = {
|
|
@@ -8,19 +8,24 @@ import '@aws-amplify/ui-react-core/elements';
|
|
|
8
8
|
import '../../credentials/context.mjs';
|
|
9
9
|
import '@aws-amplify/storage/internals';
|
|
10
10
|
import '../../configuration/context.mjs';
|
|
11
|
+
import '../../configuration/paginationContext.mjs';
|
|
11
12
|
import '@aws-amplify/ui-react-core';
|
|
12
|
-
import 'aws-amplify';
|
|
13
|
-
import 'jszip';
|
|
14
|
-
import 'aws-amplify/storage';
|
|
15
|
-
import '../../actions/configs/context.mjs';
|
|
16
13
|
import '../../actions/configs/defaults.mjs';
|
|
17
14
|
import '../LocationActionView/CreateFolderView/CreateFolderView.mjs';
|
|
18
15
|
import '../LocationActionView/DeleteView/DeleteView.mjs';
|
|
16
|
+
import '../../displayText/context.mjs';
|
|
17
|
+
import '@aws-amplify/ui-react';
|
|
18
|
+
import '../../components/elements/definitions.mjs';
|
|
19
|
+
import '../../components/elements/IconElement.mjs';
|
|
20
|
+
import 'aws-amplify';
|
|
21
|
+
import 'jszip';
|
|
22
|
+
import 'aws-amplify/storage';
|
|
19
23
|
import '../LocationActionView/DownloadView/DownloadView.mjs';
|
|
20
24
|
import { LocationActionView } from '../LocationActionView/LocationActionView.mjs';
|
|
21
25
|
import '../LocationActionView/UploadView/UploadView.mjs';
|
|
22
26
|
import '../../fileItems/context.mjs';
|
|
23
27
|
import { LocationDetailView } from '../LocationDetailView/LocationDetailView.mjs';
|
|
28
|
+
import '../../actions/configs/context.mjs';
|
|
24
29
|
import '../../filePreview/context.mjs';
|
|
25
30
|
import { LocationsView } from '../LocationsView/LocationsView.mjs';
|
|
26
31
|
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import React__default from 'react';
|
|
2
2
|
import { isFunction } from '@aws-amplify/ui';
|
|
3
3
|
|
|
4
|
-
const
|
|
5
|
-
const usePaginate = ({ items, onPaginate, page = 1, pageSize = DEFAULT_PAGE_SIZE, }) => {
|
|
4
|
+
const usePaginate = ({ items, onPaginate, page = 1, pageSize, }) => {
|
|
6
5
|
const [currentPage, setCurrentPage] = React__default.useState(page);
|
|
7
6
|
const visitedRef = React__default.useRef(page);
|
|
8
7
|
const handleReset = React__default.useRef(() => {
|
|
@@ -12,19 +11,31 @@ const usePaginate = ({ items, onPaginate, page = 1, pageSize = DEFAULT_PAGE_SIZE
|
|
|
12
11
|
}).current;
|
|
13
12
|
return React__default.useMemo(() => {
|
|
14
13
|
const hasItems = Array.isArray(items);
|
|
14
|
+
const totalItems = hasItems ? items.length : 0;
|
|
15
|
+
const totalPages = Math.max(1, Math.ceil(totalItems / pageSize));
|
|
16
|
+
// Auto-adjust current page if it's beyond available pages
|
|
17
|
+
// For server-side pagination, don't auto-adjust if onPaginate callback is provided
|
|
18
|
+
let adjustedCurrentPage = currentPage;
|
|
19
|
+
if (currentPage > totalPages && !isFunction(onPaginate)) {
|
|
20
|
+
adjustedCurrentPage = totalPages;
|
|
21
|
+
setCurrentPage(adjustedCurrentPage);
|
|
22
|
+
}
|
|
15
23
|
const highestPageVisited = visitedRef.current;
|
|
16
|
-
const isFirstPage =
|
|
17
|
-
const start = isFirstPage ? 0 : (
|
|
18
|
-
const end = isFirstPage ? pageSize :
|
|
24
|
+
const isFirstPage = adjustedCurrentPage === 1;
|
|
25
|
+
const start = isFirstPage ? 0 : (adjustedCurrentPage - 1) * pageSize;
|
|
26
|
+
const end = isFirstPage ? pageSize : adjustedCurrentPage * pageSize;
|
|
19
27
|
const pageItems = hasItems ? items.slice(start, end) : [];
|
|
20
28
|
return {
|
|
21
|
-
currentPage,
|
|
29
|
+
currentPage: adjustedCurrentPage,
|
|
22
30
|
handlePaginate: (page) => {
|
|
23
31
|
if (page < 1)
|
|
24
32
|
return;
|
|
33
|
+
// For server-side pagination, allow going beyond totalPages if onPaginate is provided
|
|
34
|
+
if (page > totalPages && !isFunction(onPaginate))
|
|
35
|
+
return;
|
|
25
36
|
if (isFunction(onPaginate))
|
|
26
37
|
onPaginate(page);
|
|
27
|
-
if (page >
|
|
38
|
+
if (page > adjustedCurrentPage && page > highestPageVisited)
|
|
28
39
|
visitedRef.current = page;
|
|
29
40
|
setCurrentPage(page);
|
|
30
41
|
},
|
|
@@ -26,5 +26,14 @@ const FILE_DATA_ITEM_TABLE_KEYS = [
|
|
|
26
26
|
'status',
|
|
27
27
|
'cancel',
|
|
28
28
|
];
|
|
29
|
+
const DELETE_TABLE_KEYS = [
|
|
30
|
+
'name',
|
|
31
|
+
'folder',
|
|
32
|
+
'type',
|
|
33
|
+
'size',
|
|
34
|
+
'status',
|
|
35
|
+
'progress',
|
|
36
|
+
'cancel',
|
|
37
|
+
];
|
|
29
38
|
|
|
30
|
-
export { FILE_DATA_ITEM_TABLE_KEYS, STATUS_ICONS, STATUS_LABELS };
|
|
39
|
+
export { DELETE_TABLE_KEYS, FILE_DATA_ITEM_TABLE_KEYS, STATUS_ICONS, STATUS_LABELS };
|
|
@@ -1,11 +1,95 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { capitalize } from '@aws-amplify/ui';
|
|
2
2
|
import '../../../displayText/context.mjs';
|
|
3
3
|
import { isDeleteViewDisplayTextKey } from '../../../displayText/utils.mjs';
|
|
4
|
-
import { STATUS_LABELS } from './constants.mjs';
|
|
5
|
-
import {
|
|
4
|
+
import { STATUS_ICONS, STATUS_LABELS } from './constants.mjs';
|
|
5
|
+
import { getFileSize, getFileType, getCellName } from './utils.mjs';
|
|
6
|
+
import '@aws-amplify/storage/internals';
|
|
7
|
+
import { getFileKey } from '../../../actions/handlers/utils.mjs';
|
|
8
|
+
import 'jszip';
|
|
9
|
+
import 'aws-amplify/storage';
|
|
10
|
+
import '../../../actions/configs/context.mjs';
|
|
11
|
+
import '../../../actions/configs/defaults.mjs';
|
|
12
|
+
import { getFolderName } from '../../LocationActionView/DeleteView/utils.mjs';
|
|
6
13
|
|
|
14
|
+
const getDeleteCellKey = (data) => `${data.key}-${data.item.data.id}`;
|
|
15
|
+
const getCellDataFolder = (data) => {
|
|
16
|
+
const { type, key } = data;
|
|
17
|
+
const fileKey = getFileKey(key);
|
|
18
|
+
const targetKey = data.key;
|
|
19
|
+
if (type === 'FOLDER') {
|
|
20
|
+
const pathWithoutTrailingSlash = targetKey.replace(/\/$/, '');
|
|
21
|
+
const lastSlashIndex = pathWithoutTrailingSlash.lastIndexOf('/');
|
|
22
|
+
return lastSlashIndex >= 0
|
|
23
|
+
? pathWithoutTrailingSlash.slice(0, lastSlashIndex + 1)
|
|
24
|
+
: '';
|
|
25
|
+
}
|
|
26
|
+
return targetKey.slice(0, -fileKey?.length);
|
|
27
|
+
};
|
|
28
|
+
const name = (data) => {
|
|
29
|
+
const key = getDeleteCellKey(data);
|
|
30
|
+
const { item } = data;
|
|
31
|
+
let text;
|
|
32
|
+
if (item.data.type === 'FOLDER') {
|
|
33
|
+
text = `${getFolderName(item.data.key)}/`;
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
text = item.data.fileKey ?? getCellName(item.data.key);
|
|
37
|
+
}
|
|
38
|
+
const icon = STATUS_ICONS[item.status];
|
|
39
|
+
return { key, type: 'text', content: { icon, text } };
|
|
40
|
+
};
|
|
41
|
+
const folder = (data) => {
|
|
42
|
+
const key = getDeleteCellKey(data);
|
|
43
|
+
const text = getCellDataFolder(data.item.data);
|
|
44
|
+
return { key, type: 'text', content: { text } };
|
|
45
|
+
};
|
|
46
|
+
const type = (data) => {
|
|
47
|
+
const key = getDeleteCellKey(data);
|
|
48
|
+
if (data.item.data.type === 'FOLDER') {
|
|
49
|
+
return { key, type: 'text', content: { text: 'Folder' } };
|
|
50
|
+
}
|
|
51
|
+
const text = getFileType(data.item.data.key);
|
|
52
|
+
return { key, type: 'text', content: { text } };
|
|
53
|
+
};
|
|
54
|
+
const size = (data) => {
|
|
55
|
+
const key = getDeleteCellKey(data);
|
|
56
|
+
const itemData = data.item.data;
|
|
57
|
+
if (data.item.data.type === 'FOLDER') {
|
|
58
|
+
return { key, type: 'text', content: { text: '-' } };
|
|
59
|
+
}
|
|
60
|
+
const value = 'size' in itemData ? itemData.size : 0;
|
|
61
|
+
const displayValue = getFileSize(value);
|
|
62
|
+
return { key, type: 'number', content: { value, displayValue } };
|
|
63
|
+
};
|
|
64
|
+
const getCancelCellContent = (data) => {
|
|
65
|
+
const { item, props } = data;
|
|
66
|
+
const { cancel, status } = item;
|
|
67
|
+
const { isProcessing, onTaskRemove } = props;
|
|
68
|
+
const isQueued = status === 'QUEUED';
|
|
69
|
+
const isRemovable = isQueued && !isProcessing;
|
|
70
|
+
const isCancelable = isProcessing && !!cancel;
|
|
71
|
+
const itemAriaValue = getCellName(item.data.fileKey ?? item.data.key);
|
|
72
|
+
const ariaLabel = `${isRemovable ? 'Remove' : 'Cancel'} item: ${itemAriaValue}`;
|
|
73
|
+
const isDisabled = !isRemovable && !isCancelable;
|
|
74
|
+
const onClick = !isCancelable && !isRemovable
|
|
75
|
+
? undefined
|
|
76
|
+
: () => {
|
|
77
|
+
if (isRemovable) {
|
|
78
|
+
onTaskRemove?.(item);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
if (isCancelable)
|
|
82
|
+
cancel();
|
|
83
|
+
};
|
|
84
|
+
return { ariaLabel, isDisabled, onClick, icon: 'cancel' };
|
|
85
|
+
};
|
|
86
|
+
const cancel = (data) => {
|
|
87
|
+
const key = getDeleteCellKey(data);
|
|
88
|
+
const content = getCancelCellContent(data);
|
|
89
|
+
return { key, type: 'button', content };
|
|
90
|
+
};
|
|
7
91
|
const status = (data) => {
|
|
8
|
-
const key =
|
|
92
|
+
const key = getDeleteCellKey(data);
|
|
9
93
|
const { item: { status }, props: { displayText }, } = data;
|
|
10
94
|
const statusLabelKey = STATUS_LABELS[status];
|
|
11
95
|
const text = isDeleteViewDisplayTextKey(statusLabelKey)
|
|
@@ -13,21 +97,47 @@ const status = (data) => {
|
|
|
13
97
|
: '';
|
|
14
98
|
return { key, type: 'text', content: { text } };
|
|
15
99
|
};
|
|
100
|
+
const progress = (data) => {
|
|
101
|
+
const key = getDeleteCellKey(data);
|
|
102
|
+
const { item } = data;
|
|
103
|
+
const itemIsFile = item.data.type === 'FILE';
|
|
104
|
+
if (itemIsFile) {
|
|
105
|
+
const text = item.status === 'COMPLETE' ? 'Deleted' : '-';
|
|
106
|
+
return { key, type: 'text', content: { text } };
|
|
107
|
+
}
|
|
108
|
+
if ((item.status === 'PENDING' ||
|
|
109
|
+
item.status === 'FAILED' ||
|
|
110
|
+
item.status === 'CANCELED') &&
|
|
111
|
+
item.data.totalCount !== undefined) {
|
|
112
|
+
const countDisplay = item.data.totalCount ?? '?';
|
|
113
|
+
const text = `${item.successCount ?? 0}/${countDisplay} files`;
|
|
114
|
+
return { key, type: 'text', content: { text } };
|
|
115
|
+
}
|
|
116
|
+
else if (item.status === 'COMPLETE') {
|
|
117
|
+
if (item.data.totalCount === null) {
|
|
118
|
+
const text = `${item.successCount ?? 0} files deleted`;
|
|
119
|
+
return { key, type: 'text', content: { text } };
|
|
120
|
+
}
|
|
121
|
+
const text = `${item.data.totalCount} files deleted`;
|
|
122
|
+
return { key, type: 'text', content: { text } };
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
const text = item.data.totalCount === null
|
|
126
|
+
? 'Count failed'
|
|
127
|
+
: item.data.totalCount !== undefined
|
|
128
|
+
? `${item.data.totalCount} files`
|
|
129
|
+
: 'Calculating...';
|
|
130
|
+
return { key, type: 'text', content: { text } };
|
|
131
|
+
}
|
|
132
|
+
};
|
|
16
133
|
const DELETE_CELL_RESOLVERS = {
|
|
17
134
|
name,
|
|
18
135
|
folder,
|
|
19
136
|
type,
|
|
20
137
|
size,
|
|
21
138
|
status,
|
|
139
|
+
progress,
|
|
22
140
|
cancel,
|
|
23
|
-
/**
|
|
24
|
-
* @deprecated
|
|
25
|
-
*
|
|
26
|
-
* non-upload view tables do not include "progress" headers but include here to
|
|
27
|
-
* keep TS happy as "progress" headers were included in display text interfaces
|
|
28
|
-
* and cannot be removed from the tables without a breaking change
|
|
29
|
-
*/
|
|
30
|
-
progress: noop,
|
|
31
141
|
};
|
|
32
142
|
const DELETE_TABLE_RESOLVERS = {
|
|
33
143
|
getCell: (data) => DELETE_CELL_RESOLVERS[data.key](data),
|
|
@@ -41,4 +151,4 @@ const DELETE_TABLE_RESOLVERS = {
|
|
|
41
151
|
getRowKey: ({ item }) => item.data.id,
|
|
42
152
|
};
|
|
43
153
|
|
|
44
|
-
export { DELETE_TABLE_RESOLVERS };
|
|
154
|
+
export { DELETE_TABLE_RESOLVERS, getCancelCellContent };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { humanFileSize } from '@aws-amplify/ui';
|
|
2
2
|
import { STATUS_ICONS } from './constants.mjs';
|
|
3
3
|
|
|
4
|
-
const getFileType = (value, fallback = '') => value
|
|
5
|
-
? value
|
|
4
|
+
const getFileType = (value, fallback = '') => value?.lastIndexOf?.('.') !== -1
|
|
5
|
+
? value?.slice(value?.lastIndexOf?.('.') + 1)
|
|
6
6
|
: fallback;
|
|
7
7
|
const getCellName = (value) =>
|
|
8
8
|
// `value.split` always returns an array with at least one entry
|
|
@@ -17,7 +17,7 @@ const getFileDataCellFolder = (task) => {
|
|
|
17
17
|
? task.data.sourceKey
|
|
18
18
|
: task.data.key;
|
|
19
19
|
const { fileKey } = task.data;
|
|
20
|
-
return targetKey.slice(0, -fileKey
|
|
20
|
+
return targetKey.slice(0, -fileKey?.length);
|
|
21
21
|
};
|
|
22
22
|
const getUploadCellProgress = ({ progress, status, }) => {
|
|
23
23
|
// prefer `progress` if available, 1 if status is complete, default 0
|
package/dist/esm/version.mjs
CHANGED
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ var uiReactCore = require('@aws-amplify/ui-react-core');
|
|
|
9
9
|
var auth = require('aws-amplify/auth');
|
|
10
10
|
var storage = require('aws-amplify/storage');
|
|
11
11
|
var internal = require('@aws-amplify/ui-react/internal');
|
|
12
|
-
var createStorageBrowser = require('./createStorageBrowser-
|
|
12
|
+
var createStorageBrowser = require('./createStorageBrowser-De4hcP-u.js');
|
|
13
13
|
require('@aws-amplify/storage/internals');
|
|
14
14
|
require('aws-amplify');
|
|
15
15
|
require('jszip');
|