@aws-amplify/ui-react-storage 3.11.0 → 3.12.1
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-CVfazB4S.js → createStorageBrowser-C7xCWNpG.js} +279 -89
- package/dist/esm/components/StorageBrowser/actions/configs/defaults.mjs +12 -3
- package/dist/esm/components/StorageBrowser/actions/handlers/listLocationItems.mjs +1 -1
- package/dist/esm/components/StorageBrowser/createStorageBrowser/StorageBrowserDefault.mjs +1 -0
- package/dist/esm/components/StorageBrowser/createStorageBrowser/createProvider.mjs +1 -0
- package/dist/esm/components/StorageBrowser/createStorageBrowser/createStorageBrowser.mjs +2 -0
- package/dist/esm/components/StorageBrowser/displayText/context.mjs +5 -1
- package/dist/esm/components/StorageBrowser/displayText/libraries/en/default.mjs +2 -0
- package/dist/esm/components/StorageBrowser/displayText/libraries/en/downloadView.mjs +23 -0
- package/dist/esm/components/StorageBrowser/displayText/libraries/en/locationDetailView.mjs +2 -0
- package/dist/esm/components/StorageBrowser/displayText/utils.mjs +3 -1
- package/dist/esm/components/StorageBrowser/useAction/utils.mjs +2 -2
- package/dist/esm/components/StorageBrowser/views/LocationActionView/DownloadView/DownloadView.mjs +47 -0
- package/dist/esm/components/StorageBrowser/views/LocationActionView/DownloadView/DownloadViewProvider.mjs +38 -0
- package/dist/esm/components/StorageBrowser/views/LocationActionView/DownloadView/useDownloadView.mjs +66 -0
- package/dist/esm/components/StorageBrowser/views/LocationActionView/UploadView/UploadView.mjs +3 -0
- package/dist/esm/components/StorageBrowser/views/LocationActionView/UploadView/UploadViewProvider.mjs +7 -2
- package/dist/esm/components/StorageBrowser/views/LocationActionView/UploadView/useUploadView.mjs +10 -1
- package/dist/esm/components/StorageBrowser/views/context/actionViews.mjs +2 -0
- package/dist/esm/components/StorageBrowser/views/context/primaryViews.mjs +1 -0
- package/dist/esm/components/StorageBrowser/views/hooks/usePaginate.mjs +1 -1
- package/dist/esm/components/StorageBrowser/views/useView.mjs +3 -0
- package/dist/esm/components/StorageBrowser/views/utils/tableResolvers/downloadResolvers.mjs +36 -0
- package/dist/esm/version.mjs +1 -1
- package/dist/index.js +1 -1
- package/dist/styles.css +17 -2
- package/dist/types/components/StorageBrowser/actions/configs/defaults.d.ts +4 -3
- package/dist/types/components/StorageBrowser/actions/configs/types.d.ts +3 -1
- package/dist/types/components/StorageBrowser/actions/handlers/download.d.ts +2 -2
- package/dist/types/components/StorageBrowser/createStorageBrowser/types.d.ts +2 -1
- package/dist/types/components/StorageBrowser/displayText/index.d.ts +2 -2
- package/dist/types/components/StorageBrowser/displayText/libraries/en/downloadView.d.ts +2 -0
- package/dist/types/components/StorageBrowser/displayText/types.d.ts +7 -1
- package/dist/types/components/StorageBrowser/displayText/utils.d.ts +2 -1
- package/dist/types/components/StorageBrowser/views/LocationActionView/DownloadView/DownloadView.d.ts +2 -0
- package/dist/types/components/StorageBrowser/views/LocationActionView/DownloadView/DownloadViewProvider.d.ts +3 -0
- package/dist/types/components/StorageBrowser/views/LocationActionView/DownloadView/index.d.ts +3 -0
- package/dist/types/components/StorageBrowser/views/LocationActionView/DownloadView/types.d.ts +22 -0
- package/dist/types/components/StorageBrowser/views/LocationActionView/DownloadView/useDownloadView.d.ts +2 -0
- package/dist/types/components/StorageBrowser/views/LocationActionView/UploadView/types.d.ts +5 -0
- package/dist/types/components/StorageBrowser/views/LocationActionView/index.d.ts +2 -0
- package/dist/types/components/StorageBrowser/views/index.d.ts +2 -2
- package/dist/types/components/StorageBrowser/views/types.d.ts +5 -3
- package/dist/types/components/StorageBrowser/views/useView.d.ts +2 -1
- package/dist/types/components/StorageBrowser/views/utils/index.d.ts +1 -1
- package/dist/types/components/StorageBrowser/views/utils/tableResolvers/__testUtils__/tasks.d.ts +1 -1
- package/dist/types/components/StorageBrowser/views/utils/tableResolvers/downloadResolvers.d.ts +2 -0
- package/dist/types/components/StorageBrowser/views/utils/tableResolvers/index.d.ts +2 -1
- package/dist/types/components/StorageBrowser/views/utils/tableResolvers/types.d.ts +6 -2
- package/dist/types/version.d.ts +1 -1
- package/package.json +4 -4
|
@@ -10,7 +10,7 @@ function resolveDisplayText(displayText) {
|
|
|
10
10
|
if (!displayText)
|
|
11
11
|
return DEFAULT_STORAGE_BROWSER_DISPLAY_TEXT;
|
|
12
12
|
// override
|
|
13
|
-
const { CopyView, CreateFolderView, DeleteView, LocationDetailView, LocationsView, UploadView, } = displayText;
|
|
13
|
+
const { CopyView, CreateFolderView, DeleteView, DownloadView, LocationDetailView, LocationsView, UploadView, } = displayText;
|
|
14
14
|
return {
|
|
15
15
|
CopyView: { ...DEFAULT_STORAGE_BROWSER_DISPLAY_TEXT.CopyView, ...CopyView },
|
|
16
16
|
CreateFolderView: {
|
|
@@ -21,6 +21,10 @@ function resolveDisplayText(displayText) {
|
|
|
21
21
|
...DEFAULT_STORAGE_BROWSER_DISPLAY_TEXT.DeleteView,
|
|
22
22
|
...DeleteView,
|
|
23
23
|
},
|
|
24
|
+
DownloadView: {
|
|
25
|
+
...DEFAULT_STORAGE_BROWSER_DISPLAY_TEXT.DownloadView,
|
|
26
|
+
...DownloadView,
|
|
27
|
+
},
|
|
24
28
|
LocationDetailView: {
|
|
25
29
|
...DEFAULT_STORAGE_BROWSER_DISPLAY_TEXT.LocationDetailView,
|
|
26
30
|
...LocationDetailView,
|
|
@@ -4,11 +4,13 @@ import { DEFAULT_DELETE_VIEW_DISPLAY_TEXT } from './deleteView.mjs';
|
|
|
4
4
|
import { DEFAULT_LOCATION_DETAIL_VIEW_DISPLAY_TEXT } from './locationDetailView.mjs';
|
|
5
5
|
import { DEFAULT_LOCATIONS_VIEW_DISPLAY_TEXT } from './locationsView.mjs';
|
|
6
6
|
import { DEFAULT_UPLOAD_VIEW_DISPLAY_TEXT } from './uploadView.mjs';
|
|
7
|
+
import { DEFAULT_DOWNLOAD_VIEW_DISPLAY_TEXT } from './downloadView.mjs';
|
|
7
8
|
|
|
8
9
|
const DEFAULT_STORAGE_BROWSER_DISPLAY_TEXT = {
|
|
9
10
|
CopyView: DEFAULT_COPY_VIEW_DISPLAY_TEXT,
|
|
10
11
|
CreateFolderView: DEFAULT_CREATE_FOLDER_VIEW_DISPLAY_TEXT,
|
|
11
12
|
DeleteView: DEFAULT_DELETE_VIEW_DISPLAY_TEXT,
|
|
13
|
+
DownloadView: DEFAULT_DOWNLOAD_VIEW_DISPLAY_TEXT,
|
|
12
14
|
LocationDetailView: DEFAULT_LOCATION_DETAIL_VIEW_DISPLAY_TEXT,
|
|
13
15
|
LocationsView: DEFAULT_LOCATIONS_VIEW_DISPLAY_TEXT,
|
|
14
16
|
UploadView: DEFAULT_UPLOAD_VIEW_DISPLAY_TEXT,
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { DEFAULT_ACTION_VIEW_DISPLAY_TEXT } from './shared.mjs';
|
|
2
|
+
|
|
3
|
+
const DEFAULT_DOWNLOAD_VIEW_DISPLAY_TEXT = {
|
|
4
|
+
...DEFAULT_ACTION_VIEW_DISPLAY_TEXT,
|
|
5
|
+
title: 'Download',
|
|
6
|
+
actionStartLabel: 'Download',
|
|
7
|
+
getActionCompleteMessage: (data) => {
|
|
8
|
+
const { counts } = data ?? {};
|
|
9
|
+
const { COMPLETE, FAILED, TOTAL } = counts ?? {};
|
|
10
|
+
if (COMPLETE === TOTAL) {
|
|
11
|
+
return { content: 'All files downloaded.', type: 'success' };
|
|
12
|
+
}
|
|
13
|
+
if (FAILED === TOTAL) {
|
|
14
|
+
return { content: 'All files failed to download.', type: 'error' };
|
|
15
|
+
}
|
|
16
|
+
return {
|
|
17
|
+
content: `${COMPLETE} files downloaded, ${FAILED} files failed to download.`,
|
|
18
|
+
type: 'error',
|
|
19
|
+
};
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export { DEFAULT_DOWNLOAD_VIEW_DISPLAY_TEXT };
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { DEFAULT_COPY_VIEW_DISPLAY_TEXT } from './libraries/en/copyView.mjs';
|
|
2
2
|
import { DEFAULT_DELETE_VIEW_DISPLAY_TEXT } from './libraries/en/deleteView.mjs';
|
|
3
|
+
import { DEFAULT_DOWNLOAD_VIEW_DISPLAY_TEXT } from './libraries/en/downloadView.mjs';
|
|
3
4
|
|
|
4
5
|
const isCopyViewDisplayTextKey = (value) => !!DEFAULT_COPY_VIEW_DISPLAY_TEXT[value];
|
|
5
6
|
const isDeleteViewDisplayTextKey = (value) => !!DEFAULT_DELETE_VIEW_DISPLAY_TEXT[value];
|
|
7
|
+
const isDownloadViewDisplayTextKey = (value) => !!DEFAULT_DOWNLOAD_VIEW_DISPLAY_TEXT[value];
|
|
6
8
|
|
|
7
|
-
export { isCopyViewDisplayTextKey, isDeleteViewDisplayTextKey };
|
|
9
|
+
export { isCopyViewDisplayTextKey, isDeleteViewDisplayTextKey, isDownloadViewDisplayTextKey };
|
|
@@ -6,12 +6,12 @@ import { isDefaultActionViewType } from '../actions/configs/defaults.mjs';
|
|
|
6
6
|
|
|
7
7
|
const resolveHandler = (value) => (isFunction(value) ? value : value.handler);
|
|
8
8
|
const getActionHandlers = (configs) => {
|
|
9
|
-
const { copy: copyConfig, createFolder: createFolderConfig, delete: deleteConfig, download, upload: uploadConfig, listLocationItems, listLocations, } = configs.default;
|
|
9
|
+
const { copy: copyConfig, createFolder: createFolderConfig, delete: deleteConfig, download: downloadConfig, upload: uploadConfig, listLocationItems, listLocations, } = configs.default;
|
|
10
10
|
const defaultHandlers = {
|
|
11
11
|
copy: copyConfig.handler,
|
|
12
12
|
createFolder: createFolderConfig.handler,
|
|
13
13
|
delete: deleteConfig.handler,
|
|
14
|
-
download,
|
|
14
|
+
download: 'handler' in downloadConfig ? downloadConfig.handler : downloadConfig,
|
|
15
15
|
listLocationItems,
|
|
16
16
|
listLocations,
|
|
17
17
|
upload: uploadConfig.handler,
|
package/dist/esm/components/StorageBrowser/views/LocationActionView/DownloadView/DownloadView.mjs
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
import '@aws-amplify/ui-react';
|
|
3
|
+
import { ViewElement } from '../../../components/elements/definitions.mjs';
|
|
4
|
+
import '../../../components/elements/IconElement.mjs';
|
|
5
|
+
import { ActionCancelControl } from '../../../controls/ActionCancelControl.mjs';
|
|
6
|
+
import { ActionExitControl } from '../../../controls/ActionExitControl.mjs';
|
|
7
|
+
import { ActionStartControl } from '../../../controls/ActionStartControl.mjs';
|
|
8
|
+
import { DataTableControl } from '../../../controls/DataTableControl.mjs';
|
|
9
|
+
import { MessageControl } from '../../../controls/MessageControl.mjs';
|
|
10
|
+
import { StatusDisplayControl } from '../../../controls/StatusDisplayControl.mjs';
|
|
11
|
+
import { TitleControl } from '../../../controls/TitleControl.mjs';
|
|
12
|
+
import { classNames } from '@aws-amplify/ui';
|
|
13
|
+
import { STORAGE_BROWSER_BLOCK } from '../../../components/base/constants.mjs';
|
|
14
|
+
import '../../../components/composables/context.mjs';
|
|
15
|
+
import '@aws-amplify/ui-react-core';
|
|
16
|
+
import '@aws-amplify/ui-react-core/elements';
|
|
17
|
+
import { DownloadViewProvider } from './DownloadViewProvider.mjs';
|
|
18
|
+
import { useDownloadView } from './useDownloadView.mjs';
|
|
19
|
+
|
|
20
|
+
const DownloadView = ({ className, ...props }) => {
|
|
21
|
+
const state = useDownloadView(props);
|
|
22
|
+
return (React__default.createElement(ViewElement, { className: classNames(STORAGE_BROWSER_BLOCK, className) },
|
|
23
|
+
React__default.createElement(DownloadViewProvider, { ...state },
|
|
24
|
+
React__default.createElement(ActionExitControl, null),
|
|
25
|
+
React__default.createElement(TitleControl, null),
|
|
26
|
+
React__default.createElement(ViewElement, { className: `${STORAGE_BROWSER_BLOCK}__data-table` },
|
|
27
|
+
React__default.createElement(DataTableControl, null)),
|
|
28
|
+
React__default.createElement(ViewElement, { className: `${STORAGE_BROWSER_BLOCK}__summary` },
|
|
29
|
+
React__default.createElement(StatusDisplayControl, null)),
|
|
30
|
+
React__default.createElement(ViewElement, { className: `${STORAGE_BROWSER_BLOCK}__footer` },
|
|
31
|
+
React__default.createElement(ViewElement, { className: `${STORAGE_BROWSER_BLOCK}__message` },
|
|
32
|
+
React__default.createElement(MessageControl, null)),
|
|
33
|
+
React__default.createElement(ViewElement, { className: `${STORAGE_BROWSER_BLOCK}__buttons` },
|
|
34
|
+
React__default.createElement(ActionCancelControl, null),
|
|
35
|
+
React__default.createElement(ActionStartControl, null))))));
|
|
36
|
+
};
|
|
37
|
+
DownloadView.displayName = 'DownloadView';
|
|
38
|
+
DownloadView.Provider = DownloadViewProvider;
|
|
39
|
+
DownloadView.Cancel = ActionCancelControl;
|
|
40
|
+
DownloadView.Exit = ActionExitControl;
|
|
41
|
+
DownloadView.Message = MessageControl;
|
|
42
|
+
DownloadView.Start = ActionStartControl;
|
|
43
|
+
DownloadView.Statuses = StatusDisplayControl;
|
|
44
|
+
DownloadView.TasksTable = DataTableControl;
|
|
45
|
+
DownloadView.Title = TitleControl;
|
|
46
|
+
|
|
47
|
+
export { DownloadView };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
import { ControlsContextProvider } from '../../../controls/context.mjs';
|
|
3
|
+
import { useDisplayText } from '../../../displayText/context.mjs';
|
|
4
|
+
import useResolveTableData from '../../hooks/useResolveTableData/useResolveTableData.mjs';
|
|
5
|
+
import '@aws-amplify/ui';
|
|
6
|
+
import { FILE_DATA_ITEM_TABLE_KEYS } from '../../utils/tableResolvers/constants.mjs';
|
|
7
|
+
import { DOWNLOAD_TABLE_RESOLVERS } from '../../utils/tableResolvers/downloadResolvers.mjs';
|
|
8
|
+
|
|
9
|
+
function DownloadViewProvider({ children, ...props }) {
|
|
10
|
+
const { DownloadView: displayText } = useDisplayText();
|
|
11
|
+
const { actionCancelLabel, actionExitLabel, actionStartLabel, title, statusDisplayCanceledLabel, statusDisplayCompletedLabel, statusDisplayFailedLabel, statusDisplayQueuedLabel, getActionCompleteMessage, } = displayText;
|
|
12
|
+
const { isProcessing, isProcessingComplete, statusCounts, tasks: items, onActionCancel, onActionStart, onActionExit, onTaskRemove, } = props;
|
|
13
|
+
const message = isProcessingComplete
|
|
14
|
+
? getActionCompleteMessage({ counts: statusCounts })
|
|
15
|
+
: undefined;
|
|
16
|
+
const tableData = useResolveTableData(FILE_DATA_ITEM_TABLE_KEYS, DOWNLOAD_TABLE_RESOLVERS, {
|
|
17
|
+
items,
|
|
18
|
+
props: { displayText, isProcessing, onTaskRemove },
|
|
19
|
+
});
|
|
20
|
+
return (React__default.createElement(ControlsContextProvider, { data: {
|
|
21
|
+
actionCancelLabel,
|
|
22
|
+
actionExitLabel,
|
|
23
|
+
actionStartLabel,
|
|
24
|
+
isActionCancelDisabled: !isProcessing || isProcessingComplete,
|
|
25
|
+
isActionExitDisabled: isProcessing,
|
|
26
|
+
isActionStartDisabled: isProcessing || isProcessingComplete,
|
|
27
|
+
statusDisplayCanceledLabel,
|
|
28
|
+
statusDisplayCompletedLabel,
|
|
29
|
+
statusDisplayFailedLabel,
|
|
30
|
+
statusDisplayQueuedLabel,
|
|
31
|
+
statusCounts,
|
|
32
|
+
tableData,
|
|
33
|
+
title,
|
|
34
|
+
message,
|
|
35
|
+
}, onActionStart: onActionStart, onActionExit: onActionExit, onActionCancel: onActionCancel }, children));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export { DownloadViewProvider };
|
package/dist/esm/components/StorageBrowser/views/LocationActionView/DownloadView/useDownloadView.mjs
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
import { isFunction } from '@aws-amplify/ui';
|
|
3
|
+
import { useLocationItems } from '../../../locationItems/context.mjs';
|
|
4
|
+
import { useStore } from '../../../store/context.mjs';
|
|
5
|
+
import '../../../useAction/context.mjs';
|
|
6
|
+
import { useAction } from '../../../useAction/useAction.mjs';
|
|
7
|
+
import '@aws-amplify/ui-react-core';
|
|
8
|
+
import '@aws-amplify/ui-react-core/elements';
|
|
9
|
+
import '../../../credentials/context.mjs';
|
|
10
|
+
import '@aws-amplify/storage/internals';
|
|
11
|
+
import '../../../configuration/context.mjs';
|
|
12
|
+
import 'aws-amplify/storage';
|
|
13
|
+
import '../../../actions/configs/context.mjs';
|
|
14
|
+
import '../../../actions/configs/defaults.mjs';
|
|
15
|
+
|
|
16
|
+
// assign to constant to ensure referential equality
|
|
17
|
+
const EMPTY_ITEMS = [];
|
|
18
|
+
const useDownloadView = (options) => {
|
|
19
|
+
const { onExit: _onExit } = options ?? {};
|
|
20
|
+
const [{ location }, storeDispatch] = useStore();
|
|
21
|
+
const [locationItems, locationItemsDispatch] = useLocationItems();
|
|
22
|
+
const { current } = location;
|
|
23
|
+
const { fileDataItems: items = EMPTY_ITEMS } = locationItems;
|
|
24
|
+
const [processState, handleProcess] = useAction('download', {
|
|
25
|
+
items,
|
|
26
|
+
});
|
|
27
|
+
const { isProcessing, isProcessingComplete, statusCounts, tasks } = processState;
|
|
28
|
+
const onActionStart = () => {
|
|
29
|
+
if (!current)
|
|
30
|
+
return;
|
|
31
|
+
handleProcess();
|
|
32
|
+
};
|
|
33
|
+
const onActionCancel = () => {
|
|
34
|
+
tasks.forEach((task) => {
|
|
35
|
+
// Calling cancel on task works only on queued tasks.
|
|
36
|
+
// In case of download, all download presigned url open at once
|
|
37
|
+
// When certain threshold is reached for queuing inside StorageBrowser, cancel might be possible.
|
|
38
|
+
if (isFunction(task.cancel))
|
|
39
|
+
task.cancel();
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
const onActionExit = () => {
|
|
43
|
+
// clear files state
|
|
44
|
+
locationItemsDispatch({ type: 'RESET_LOCATION_ITEMS' });
|
|
45
|
+
// clear selected action
|
|
46
|
+
storeDispatch({ type: 'RESET_ACTION_TYPE' });
|
|
47
|
+
if (isFunction(_onExit))
|
|
48
|
+
_onExit(current);
|
|
49
|
+
};
|
|
50
|
+
const onTaskRemove = React__default.useCallback(({ data }) => {
|
|
51
|
+
locationItemsDispatch({ type: 'REMOVE_LOCATION_ITEM', id: data.id });
|
|
52
|
+
}, [locationItemsDispatch]);
|
|
53
|
+
return {
|
|
54
|
+
isProcessing,
|
|
55
|
+
isProcessingComplete,
|
|
56
|
+
location,
|
|
57
|
+
statusCounts,
|
|
58
|
+
tasks,
|
|
59
|
+
onActionCancel,
|
|
60
|
+
onActionExit,
|
|
61
|
+
onActionStart,
|
|
62
|
+
onTaskRemove,
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export { useDownloadView };
|
package/dist/esm/components/StorageBrowser/views/LocationActionView/UploadView/UploadView.mjs
CHANGED
|
@@ -18,6 +18,7 @@ import { DataTableControl } from '../../../controls/DataTableControl.mjs';
|
|
|
18
18
|
import { DropZoneControl } from '../../../controls/DropZoneControl.mjs';
|
|
19
19
|
import { MessageControl } from '../../../controls/MessageControl.mjs';
|
|
20
20
|
import { OverwriteToggleControl } from '../../../controls/OverwriteToggleControl.mjs';
|
|
21
|
+
import { PaginationControl } from '../../../controls/PaginationControl.mjs';
|
|
21
22
|
import { StatusDisplayControl } from '../../../controls/StatusDisplayControl.mjs';
|
|
22
23
|
import { TitleControl } from '../../../controls/TitleControl.mjs';
|
|
23
24
|
import { UploadViewProvider } from './UploadViewProvider.mjs';
|
|
@@ -32,6 +33,7 @@ const UploadView = ({ className, ...props }) => {
|
|
|
32
33
|
React__default.createElement(ViewElement, { className: `${STORAGE_BROWSER_BLOCK}__controls` },
|
|
33
34
|
React__default.createElement(OverwriteToggleControl, null),
|
|
34
35
|
React__default.createElement(ViewElement, { className: `${STORAGE_BROWSER_BLOCK}__buttons` },
|
|
36
|
+
React__default.createElement(PaginationControl, null),
|
|
35
37
|
React__default.createElement(AddFolderControl, null),
|
|
36
38
|
React__default.createElement(AddFilesControl, null))),
|
|
37
39
|
React__default.createElement(DropZoneControl, null,
|
|
@@ -51,6 +53,7 @@ UploadView.displayName = 'UploadView';
|
|
|
51
53
|
UploadView.Provider = UploadViewProvider;
|
|
52
54
|
UploadView.AddFiles = AddFilesControl;
|
|
53
55
|
UploadView.AddFolder = AddFolderControl;
|
|
56
|
+
UploadView.Pagination = PaginationControl;
|
|
54
57
|
UploadView.Cancel = ActionCancelControl;
|
|
55
58
|
UploadView.Destination = ActionDestinationControl;
|
|
56
59
|
UploadView.DropZone = DropZoneControl;
|
|
@@ -13,7 +13,7 @@ import { UPLOAD_TABLE_RESOLVERS, UPLOAD_TABLE_KEYS } from '../../utils/tableReso
|
|
|
13
13
|
function UploadViewProvider({ children, ...props }) {
|
|
14
14
|
const { UploadView: displayText } = useDisplayText();
|
|
15
15
|
const { actionCancelLabel, actionDestinationLabel, actionExitLabel, actionStartLabel, addFilesLabel, addFolderLabel, statusDisplayCanceledLabel, statusDisplayCompletedLabel, statusDisplayFailedLabel, statusDisplayQueuedLabel, overwriteToggleLabel, title, getActionCompleteMessage, getFilesValidationMessage, } = displayText;
|
|
16
|
-
const { isOverwritingEnabled, isProcessing, isProcessingComplete, location, tasks: items, statusCounts, invalidFiles, onActionStart, onActionCancel, onDropFiles, onActionExit, onTaskRemove, onSelectFiles, onToggleOverwrite, } = props;
|
|
16
|
+
const { hasNextPage, highestPageVisited, page, isOverwritingEnabled, isProcessing, isProcessingComplete, location, tasks: items, statusCounts, invalidFiles, onActionStart, onActionCancel, onDropFiles, onPaginate, onActionExit, onTaskRemove, onSelectFiles, onToggleOverwrite, } = props;
|
|
17
17
|
const isActionStartDisabled = isProcessing || isProcessingComplete || statusCounts.TOTAL === 0;
|
|
18
18
|
const isActionCancelDisabled = !isProcessing || isProcessingComplete;
|
|
19
19
|
const isAddFilesDisabled = isProcessing || isProcessingComplete;
|
|
@@ -47,6 +47,11 @@ function UploadViewProvider({ children, ...props }) {
|
|
|
47
47
|
isOverwriteToggleDisabled: isProcessing || isProcessingComplete,
|
|
48
48
|
isOverwritingEnabled,
|
|
49
49
|
overwriteToggleLabel,
|
|
50
|
+
paginationData: {
|
|
51
|
+
page,
|
|
52
|
+
hasNextPage,
|
|
53
|
+
highestPageVisited,
|
|
54
|
+
},
|
|
50
55
|
destination: location,
|
|
51
56
|
message: actionCompleteMessage ?? filesValidationMessage,
|
|
52
57
|
statusCounts,
|
|
@@ -56,7 +61,7 @@ function UploadViewProvider({ children, ...props }) {
|
|
|
56
61
|
statusDisplayQueuedLabel,
|
|
57
62
|
tableData,
|
|
58
63
|
title,
|
|
59
|
-
}, onActionCancel: onActionCancel, onActionExit: onActionExit, onActionStart: onActionStart, onAddFiles: () => {
|
|
64
|
+
}, onActionCancel: onActionCancel, onActionExit: onActionExit, onActionStart: onActionStart, onPaginate: onPaginate, onAddFiles: () => {
|
|
60
65
|
onSelectFiles('FILE');
|
|
61
66
|
}, onAddFolder: () => {
|
|
62
67
|
onSelectFiles('FOLDER');
|
package/dist/esm/components/StorageBrowser/views/LocationActionView/UploadView/useUploadView.mjs
CHANGED
|
@@ -13,7 +13,9 @@ import 'aws-amplify/storage';
|
|
|
13
13
|
import '../../../actions/configs/context.mjs';
|
|
14
14
|
import '../../../actions/configs/defaults.mjs';
|
|
15
15
|
import { DEFAULT_OVERWRITE_ENABLED } from './constants.mjs';
|
|
16
|
+
import { usePaginate } from '../../hooks/usePaginate.mjs';
|
|
16
17
|
|
|
18
|
+
const DEFAULT_PAGE_SIZE = 100;
|
|
17
19
|
const useUploadView = (options) => {
|
|
18
20
|
const { onExit: _onExit } = options ?? {};
|
|
19
21
|
const [{ location }, storeDispatch] = useStore();
|
|
@@ -26,6 +28,9 @@ const useUploadView = (options) => {
|
|
|
26
28
|
preventOverwrite: !isOverwritingEnabled,
|
|
27
29
|
})), [validItems, isOverwritingEnabled, location.key]);
|
|
28
30
|
const [{ isProcessing, isProcessingComplete, statusCounts, tasks }, handleUploads,] = useAction('upload', { items });
|
|
31
|
+
const { currentPage, handlePaginate, pageItems: pageTasks, } = usePaginate({
|
|
32
|
+
items: tasks,
|
|
33
|
+
});
|
|
29
34
|
const onDropFiles = (files) => {
|
|
30
35
|
if (files) {
|
|
31
36
|
fileItemsDispatch({ type: 'ADD_FILES', files });
|
|
@@ -60,11 +65,15 @@ const useUploadView = (options) => {
|
|
|
60
65
|
location,
|
|
61
66
|
invalidFiles,
|
|
62
67
|
statusCounts,
|
|
63
|
-
tasks,
|
|
68
|
+
tasks: pageTasks,
|
|
69
|
+
page: currentPage,
|
|
70
|
+
hasNextPage: currentPage * DEFAULT_PAGE_SIZE < items.length,
|
|
71
|
+
highestPageVisited: Math.ceil(items.length / DEFAULT_PAGE_SIZE),
|
|
64
72
|
onActionCancel,
|
|
65
73
|
onActionExit,
|
|
66
74
|
onActionStart,
|
|
67
75
|
onDropFiles,
|
|
76
|
+
onPaginate: handlePaginate,
|
|
68
77
|
onTaskRemove,
|
|
69
78
|
onSelectFiles,
|
|
70
79
|
onToggleOverwrite,
|
|
@@ -16,11 +16,13 @@ import { CreateFolderView } from '../LocationActionView/CreateFolderView/CreateF
|
|
|
16
16
|
import { CopyView } from '../LocationActionView/CopyView/CopyView.mjs';
|
|
17
17
|
import '../../locationItems/context.mjs';
|
|
18
18
|
import { DeleteView } from '../LocationActionView/DeleteView/DeleteView.mjs';
|
|
19
|
+
import { DownloadView } from '../LocationActionView/DownloadView/DownloadView.mjs';
|
|
19
20
|
|
|
20
21
|
const DEFAULT_ACTION_VIEWS = {
|
|
21
22
|
createFolder: CreateFolderView,
|
|
22
23
|
copy: CopyView,
|
|
23
24
|
delete: DeleteView,
|
|
25
|
+
download: DownloadView,
|
|
24
26
|
upload: UploadView,
|
|
25
27
|
};
|
|
26
28
|
const ActionViewsContext = React__default.createContext({
|
|
@@ -14,6 +14,7 @@ import '../../actions/configs/context.mjs';
|
|
|
14
14
|
import '../../actions/configs/defaults.mjs';
|
|
15
15
|
import '../LocationActionView/CreateFolderView/CreateFolderView.mjs';
|
|
16
16
|
import '../LocationActionView/DeleteView/DeleteView.mjs';
|
|
17
|
+
import '../LocationActionView/DownloadView/DownloadView.mjs';
|
|
17
18
|
import { LocationActionView } from '../LocationActionView/LocationActionView.mjs';
|
|
18
19
|
import '../LocationActionView/UploadView/UploadView.mjs';
|
|
19
20
|
import '../../fileItems/context.mjs';
|
|
@@ -24,7 +24,7 @@ const usePaginate = ({ items, onPaginate, page = 1, pageSize = DEFAULT_PAGE_SIZE
|
|
|
24
24
|
return;
|
|
25
25
|
if (isFunction(onPaginate))
|
|
26
26
|
onPaginate(page);
|
|
27
|
-
if (page > currentPage)
|
|
27
|
+
if (page > currentPage && page > highestPageVisited)
|
|
28
28
|
visitedRef.current = page;
|
|
29
29
|
setCurrentPage(page);
|
|
30
30
|
},
|
|
@@ -4,6 +4,8 @@ import './LocationActionView/CreateFolderView/CreateFolderView.mjs';
|
|
|
4
4
|
import { useCreateFolderView } from './LocationActionView/CreateFolderView/useCreateFolderView.mjs';
|
|
5
5
|
import './LocationActionView/DeleteView/DeleteView.mjs';
|
|
6
6
|
import { useDeleteView } from './LocationActionView/DeleteView/useDeleteView.mjs';
|
|
7
|
+
import './LocationActionView/DownloadView/DownloadView.mjs';
|
|
8
|
+
import { useDownloadView } from './LocationActionView/DownloadView/useDownloadView.mjs';
|
|
7
9
|
import 'react';
|
|
8
10
|
import '../store/context.mjs';
|
|
9
11
|
import './context/actionViews.mjs';
|
|
@@ -17,6 +19,7 @@ import { useLocationsView } from './LocationsView/useLocationsView.mjs';
|
|
|
17
19
|
const USE_VIEW_HOOKS = {
|
|
18
20
|
Copy: useCopyView,
|
|
19
21
|
CreateFolder: useCreateFolderView,
|
|
22
|
+
Download: useDownloadView,
|
|
20
23
|
Delete: useDeleteView,
|
|
21
24
|
LocationDetail: useLocationDetailView,
|
|
22
25
|
Locations: useLocationsView,
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { capitalize } from '@aws-amplify/ui';
|
|
2
|
+
import '../../../displayText/context.mjs';
|
|
3
|
+
import { isDownloadViewDisplayTextKey } from '../../../displayText/utils.mjs';
|
|
4
|
+
import { STATUS_LABELS } from './constants.mjs';
|
|
5
|
+
import { cancel, size, type, folder, name, getFileDataCellKey } from './utils.mjs';
|
|
6
|
+
|
|
7
|
+
const status = (data) => {
|
|
8
|
+
const key = getFileDataCellKey(data);
|
|
9
|
+
const { item: { status }, props: { displayText }, } = data;
|
|
10
|
+
const statusLabelKey = STATUS_LABELS[status];
|
|
11
|
+
const text = isDownloadViewDisplayTextKey(statusLabelKey)
|
|
12
|
+
? displayText[statusLabelKey]
|
|
13
|
+
: '';
|
|
14
|
+
return { key, type: 'text', content: { text } };
|
|
15
|
+
};
|
|
16
|
+
const DOWNLOAD_CELL_RESOLVERS = {
|
|
17
|
+
name,
|
|
18
|
+
folder,
|
|
19
|
+
type,
|
|
20
|
+
size,
|
|
21
|
+
status,
|
|
22
|
+
cancel,
|
|
23
|
+
};
|
|
24
|
+
const DOWNLOAD_TABLE_RESOLVERS = {
|
|
25
|
+
getCell: (data) => DOWNLOAD_CELL_RESOLVERS[data.key](data),
|
|
26
|
+
getHeader: ({ key, props: { displayText } }) => {
|
|
27
|
+
const text = displayText[`tableColumn${capitalize(key)}Header`];
|
|
28
|
+
if (key === 'cancel') {
|
|
29
|
+
return { key, type: 'text', content: { text } };
|
|
30
|
+
}
|
|
31
|
+
return { key, type: 'sort', content: { label: text } };
|
|
32
|
+
},
|
|
33
|
+
getRowKey: ({ item }) => item.data.id,
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export { DOWNLOAD_TABLE_RESOLVERS };
|
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-C7xCWNpG.js');
|
|
13
13
|
require('@aws-amplify/storage/internals');
|
|
14
14
|
require('aws-amplify');
|
|
15
15
|
require('aws-amplify/utils');
|
package/dist/styles.css
CHANGED
|
@@ -4250,11 +4250,26 @@ html[dir=rtl] .amplify-field-group__inner-start {
|
|
|
4250
4250
|
z-index: 1;
|
|
4251
4251
|
}
|
|
4252
4252
|
|
|
4253
|
-
.amplify-liveness-loader {
|
|
4253
|
+
.amplify-liveness-loader .amplify-liveness-centered-loader {
|
|
4254
|
+
transform: translate(-50%, -50%);
|
|
4255
|
+
}
|
|
4256
|
+
|
|
4257
|
+
.amplify-liveness-centered-loader {
|
|
4254
4258
|
position: absolute;
|
|
4255
4259
|
left: 50%;
|
|
4256
4260
|
top: 50%;
|
|
4257
|
-
|
|
4261
|
+
}
|
|
4262
|
+
|
|
4263
|
+
.amplify-liveness-connecting-loader {
|
|
4264
|
+
display: flex;
|
|
4265
|
+
position: absolute;
|
|
4266
|
+
flex-direction: column;
|
|
4267
|
+
justify-content: center;
|
|
4268
|
+
align-items: center;
|
|
4269
|
+
z-index: 3;
|
|
4270
|
+
width: 100%;
|
|
4271
|
+
height: 100%;
|
|
4272
|
+
background-color: var(--amplify-colors-background-primary);
|
|
4258
4273
|
}
|
|
4259
4274
|
|
|
4260
4275
|
.amplify-liveness-oval-canvas {
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import type { CopyActionConfig, CreateFolderActionConfig, DeleteActionConfig, UploadActionConfig } from './types';
|
|
1
|
+
import type { CopyActionConfig, CreateFolderActionConfig, DeleteActionConfig, DownloadActionConfig, UploadActionConfig } from './types';
|
|
2
2
|
export declare const copyActionConfig: CopyActionConfig;
|
|
3
3
|
export declare const deleteActionConfig: DeleteActionConfig;
|
|
4
4
|
export declare const createFolderActionConfig: CreateFolderActionConfig;
|
|
5
5
|
export declare const uploadActionConfig: UploadActionConfig;
|
|
6
|
+
export declare const downloadActionConfig: DownloadActionConfig;
|
|
6
7
|
export declare const defaultActionViewConfigs: {
|
|
7
8
|
copy: CopyActionConfig;
|
|
8
9
|
createFolder: CreateFolderActionConfig;
|
|
9
|
-
download:
|
|
10
|
+
download: DownloadActionConfig;
|
|
10
11
|
delete: DeleteActionConfig;
|
|
11
12
|
upload: UploadActionConfig;
|
|
12
13
|
};
|
|
@@ -17,7 +18,7 @@ export declare const defaultActionConfigs: {
|
|
|
17
18
|
listLocationItems: import("../handlers").ListLocationItemsHandler;
|
|
18
19
|
copy: CopyActionConfig;
|
|
19
20
|
createFolder: CreateFolderActionConfig;
|
|
20
|
-
download:
|
|
21
|
+
download: DownloadActionConfig;
|
|
21
22
|
delete: DeleteActionConfig;
|
|
22
23
|
upload: UploadActionConfig;
|
|
23
24
|
};
|
|
@@ -87,6 +87,8 @@ export interface CopyActionConfig extends ActionViewConfig<CopyHandler, 'CopyVie
|
|
|
87
87
|
}
|
|
88
88
|
export interface CreateFolderActionConfig extends ActionViewConfig<CreateFolderHandler, 'CreateFolderView'> {
|
|
89
89
|
}
|
|
90
|
+
export interface DownloadActionConfig extends ActionViewConfig<DownloadHandler, 'DownloadView'> {
|
|
91
|
+
}
|
|
90
92
|
export interface ListActionConfig<T> {
|
|
91
93
|
/**
|
|
92
94
|
* action handler
|
|
@@ -98,7 +100,7 @@ export interface DefaultActionConfigs {
|
|
|
98
100
|
listLocationItems?: ListLocationItemsHandler;
|
|
99
101
|
upload?: UploadActionConfig;
|
|
100
102
|
delete?: DeleteActionConfig;
|
|
101
|
-
download?: DownloadHandler;
|
|
103
|
+
download?: DownloadHandler | DownloadActionConfig;
|
|
102
104
|
copy?: CopyActionConfig;
|
|
103
105
|
}
|
|
104
106
|
export interface ExtendedDefaultActionConfigs extends Required<DefaultActionConfigs> {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { TaskData, TaskHandler, TaskHandlerInput, TaskHandlerOptions, TaskHandlerOutput } from './types';
|
|
2
|
-
export interface DownloadHandlerData extends TaskData {
|
|
1
|
+
import type { OptionalFileData, TaskData, TaskHandler, TaskHandlerInput, TaskHandlerOptions, TaskHandlerOutput } from './types';
|
|
2
|
+
export interface DownloadHandlerData extends OptionalFileData, TaskData {
|
|
3
3
|
fileKey: string;
|
|
4
4
|
}
|
|
5
5
|
export interface DownloadHandlerOptions extends TaskHandlerOptions {
|
|
@@ -6,7 +6,7 @@ import type { StorageBrowserDisplayText } from '../displayText';
|
|
|
6
6
|
import type { ErrorBoundaryType } from '../ErrorBoundary';
|
|
7
7
|
import type { StorageBrowserEventValue, StorageBrowserValue, StoreProviderProps } from '../store';
|
|
8
8
|
import type { DerivedActionHandlers, UseAction } from '../useAction';
|
|
9
|
-
import type { CopyViewType, CreateFolderViewType, DeleteViewType, UploadViewType, LocationActionViewType, LocationDetailViewType, LocationsViewType, UseView, StorageBrowserViews } from '../views';
|
|
9
|
+
import type { CopyViewType, CreateFolderViewType, DeleteViewType, DownloadViewType, UploadViewType, LocationActionViewType, LocationDetailViewType, LocationsViewType, UseView, StorageBrowserViews } from '../views';
|
|
10
10
|
/**
|
|
11
11
|
* @description configuration properties
|
|
12
12
|
*/
|
|
@@ -235,6 +235,7 @@ export interface StorageBrowserType<TActionType = string, TViews = {}> {
|
|
|
235
235
|
CopyView: CopyViewType;
|
|
236
236
|
CreateFolderView: CreateFolderViewType;
|
|
237
237
|
DeleteView: DeleteViewType;
|
|
238
|
+
DownloadView: DownloadViewType;
|
|
238
239
|
UploadView: UploadViewType;
|
|
239
240
|
}
|
|
240
241
|
type NonDefaultActionType<T = string> = Exclude<T, keyof DefaultActionConfigs>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { DisplayTextProvider, useDisplayText } from './context';
|
|
2
2
|
export { DEFAULT_STORAGE_BROWSER_DISPLAY_TEXT as DefaultStorageBrowserDisplayText } from './libraries';
|
|
3
|
-
export type { LocationDetailViewDisplayText, LocationsViewDisplayText, CreateFolderViewDisplayText, CopyViewDisplayText, UploadViewDisplayText, DeleteViewDisplayText, StorageBrowserDisplayText, } from './types';
|
|
4
|
-
export { isCopyViewDisplayTextKey, isDeleteViewDisplayTextKey } from './utils';
|
|
3
|
+
export type { LocationDetailViewDisplayText, LocationsViewDisplayText, CreateFolderViewDisplayText, CopyViewDisplayText, UploadViewDisplayText, DeleteViewDisplayText, DownloadViewDisplayText, StorageBrowserDisplayText, } from './types';
|
|
4
|
+
export { isCopyViewDisplayTextKey, isDeleteViewDisplayTextKey, isDownloadViewDisplayTextKey, } from './utils';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { StatusCounts, Task } from '../tasks';
|
|
2
|
-
import type { CopyHandlerData, CreateFolderHandlerData, DeleteHandlerData, FolderData, LocationData, LocationItemData, TaskData, UploadHandlerData, LocationPermissions } from '../actions';
|
|
2
|
+
import type { CopyHandlerData, CreateFolderHandlerData, DeleteHandlerData, FolderData, LocationData, LocationItemData, TaskData, UploadHandlerData, LocationPermissions, DownloadHandlerData } from '../actions';
|
|
3
3
|
import type { MessageType } from '../components';
|
|
4
4
|
import type { FileItems } from '../fileItems';
|
|
5
5
|
import type { LocationState } from '../store';
|
|
@@ -115,6 +115,8 @@ export interface DefaultDeleteViewDisplayText extends DefaultActionViewDisplayTe
|
|
|
115
115
|
*/
|
|
116
116
|
tableColumnProgressHeader?: string;
|
|
117
117
|
}
|
|
118
|
+
export interface DefaultDownloadViewDisplayText extends DefaultActionViewDisplayText<DownloadHandlerData> {
|
|
119
|
+
}
|
|
118
120
|
export interface DefaultUploadViewDisplayText extends DefaultActionViewDisplayText<UploadHandlerData> {
|
|
119
121
|
addFilesLabel: string;
|
|
120
122
|
addFolderLabel: string;
|
|
@@ -132,6 +134,7 @@ export interface DefaultStorageBrowserDisplayText {
|
|
|
132
134
|
CopyView: DefaultCopyViewDisplayText;
|
|
133
135
|
CreateFolderView: DefaultCreateFolderViewDisplayText;
|
|
134
136
|
DeleteView: DefaultDeleteViewDisplayText;
|
|
137
|
+
DownloadView: DefaultDownloadViewDisplayText;
|
|
135
138
|
LocationsView: DefaultLocationsViewDisplayText;
|
|
136
139
|
LocationDetailView: DefaultLocationDetailViewDisplayText;
|
|
137
140
|
UploadView: DefaultUploadViewDisplayText;
|
|
@@ -142,6 +145,8 @@ export interface CopyViewDisplayText extends Partial<DefaultCopyViewDisplayText>
|
|
|
142
145
|
}
|
|
143
146
|
export interface DeleteViewDisplayText extends Partial<DefaultDeleteViewDisplayText> {
|
|
144
147
|
}
|
|
148
|
+
export interface DownloadViewDisplayText extends Partial<DefaultDownloadViewDisplayText> {
|
|
149
|
+
}
|
|
145
150
|
export interface LocationsViewDisplayText extends Partial<DefaultLocationsViewDisplayText> {
|
|
146
151
|
}
|
|
147
152
|
export interface LocationDetailViewDisplayText extends Partial<DefaultLocationDetailViewDisplayText> {
|
|
@@ -156,6 +161,7 @@ export interface StorageBrowserDisplayText {
|
|
|
156
161
|
LocationDetailView?: LocationDetailViewDisplayText;
|
|
157
162
|
UploadView?: UploadViewDisplayText;
|
|
158
163
|
DeleteView?: DeleteViewDisplayText;
|
|
164
|
+
DownloadView?: DownloadViewDisplayText;
|
|
159
165
|
CopyView?: CopyViewDisplayText;
|
|
160
166
|
CreateFolderView?: CreateFolderViewDisplayText;
|
|
161
167
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import type { CopyViewDisplayText, DeleteViewDisplayText } from './types';
|
|
1
|
+
import type { CopyViewDisplayText, DeleteViewDisplayText, DownloadViewDisplayText } from './types';
|
|
2
2
|
export declare const isCopyViewDisplayTextKey: (value: string) => value is keyof CopyViewDisplayText;
|
|
3
3
|
export declare const isDeleteViewDisplayTextKey: (value: string) => value is keyof DeleteViewDisplayText;
|
|
4
|
+
export declare const isDownloadViewDisplayTextKey: (value: string) => value is keyof DownloadViewDisplayText;
|