@aws-amplify/ui-react-storage 3.4.1 → 3.5.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 +35 -2
- package/dist/{createAmplifyAuthAdapter-BRctUWdR.js → createAmplifyAuthAdapter-BUDNgORg.js} +3045 -2921
- package/dist/esm/browser.mjs +2 -0
- package/dist/esm/components/StorageBrowser/StorageBrowserAmplify.mjs +2 -7
- package/dist/esm/components/StorageBrowser/StorageBrowserDefault.mjs +3 -16
- package/dist/esm/components/StorageBrowser/actions/configs/context.mjs +4 -9
- package/dist/esm/components/StorageBrowser/actions/configs/defaults.mjs +14 -39
- package/dist/esm/components/StorageBrowser/actions/configs/utils.mjs +8 -0
- package/dist/esm/components/StorageBrowser/actions/handlers/copy.mjs +13 -13
- package/dist/esm/components/StorageBrowser/actions/handlers/createFolder.mjs +9 -6
- package/dist/esm/components/StorageBrowser/actions/handlers/delete.mjs +9 -7
- package/dist/esm/components/StorageBrowser/actions/handlers/download.mjs +7 -11
- package/dist/esm/components/StorageBrowser/actions/handlers/listLocationItems.mjs +3 -3
- package/dist/esm/components/StorageBrowser/actions/handlers/upload.mjs +11 -7
- package/dist/esm/components/StorageBrowser/actions/handlers/utils.mjs +1 -11
- package/dist/esm/components/StorageBrowser/adapters/createManagedAuthAdapter/createManagedAuthAdapter.mjs +1 -3
- package/dist/esm/components/StorageBrowser/controls/PaginationControl.mjs +3 -3
- package/dist/esm/components/StorageBrowser/controls/SearchFieldControl.mjs +12 -0
- package/dist/esm/components/StorageBrowser/controls/hooks/usePagination.mjs +9 -0
- package/dist/esm/components/StorageBrowser/controls/hooks/useSearchField.mjs +17 -0
- package/dist/esm/components/StorageBrowser/createStorageBrowser.mjs +36 -27
- package/dist/esm/components/StorageBrowser/displayText/libraries/en/locationDetailView.mjs +6 -0
- package/dist/esm/components/StorageBrowser/displayText/libraries/en/locationsView.mjs +2 -2
- package/dist/esm/components/StorageBrowser/providers/configuration/createConfigurationProvider.mjs +4 -10
- package/dist/esm/components/StorageBrowser/providers/configuration/useGetActionInputCallback.mjs +7 -7
- package/dist/esm/components/StorageBrowser/providers/store/locationItems/context.mjs +1 -1
- package/dist/esm/components/StorageBrowser/tasks/useProcessTasks.mjs +27 -6
- package/dist/esm/components/StorageBrowser/useAction/constants.mjs +4 -0
- package/dist/esm/components/StorageBrowser/useAction/context.mjs +8 -0
- package/dist/esm/components/StorageBrowser/useAction/useAction.mjs +18 -0
- package/dist/esm/components/StorageBrowser/useAction/useHandler.mjs +40 -0
- package/dist/esm/components/StorageBrowser/useAction/useList.mjs +19 -0
- package/dist/esm/components/StorageBrowser/useAction/useListFolderItems.mjs +23 -0
- package/dist/esm/components/StorageBrowser/useAction/useListLocationItems.mjs +23 -0
- package/dist/esm/components/StorageBrowser/{actions/useAction → useAction}/useListLocations.mjs +7 -6
- package/dist/esm/components/StorageBrowser/useAction/utils.mjs +26 -0
- package/dist/esm/components/StorageBrowser/views/LocationActionView/CopyView/CopyView.mjs +3 -3
- package/dist/esm/components/StorageBrowser/views/LocationActionView/CopyView/useCopyView.mjs +32 -17
- package/dist/esm/components/StorageBrowser/views/LocationActionView/CopyView/useFolders.mjs +12 -17
- package/dist/esm/components/StorageBrowser/views/LocationActionView/CreateFolderView/useCreateFolderView.mjs +18 -15
- package/dist/esm/components/StorageBrowser/views/LocationActionView/DeleteView/useDeleteView.mjs +17 -12
- package/dist/esm/components/StorageBrowser/views/LocationActionView/LocationActionView.mjs +9 -16
- package/dist/esm/components/StorageBrowser/views/LocationActionView/UploadView/useUploadView.mjs +44 -49
- package/dist/esm/components/StorageBrowser/views/LocationActionView/getActionViewTableData.mjs +2 -4
- package/dist/esm/components/StorageBrowser/views/LocationDetailView/LocationDetailView.mjs +3 -3
- package/dist/esm/components/StorageBrowser/views/LocationDetailView/LocationDetailViewProvider.mjs +12 -8
- package/dist/esm/components/StorageBrowser/views/LocationDetailView/getLocationDetailViewTableData/getLocationDetailViewTableData.mjs +1 -0
- package/dist/esm/components/StorageBrowser/views/LocationDetailView/useLocationDetailView.mjs +50 -69
- package/dist/esm/components/StorageBrowser/views/LocationsView/LocationsView.mjs +3 -3
- package/dist/esm/components/StorageBrowser/views/LocationsView/LocationsViewProvider.mjs +2 -3
- package/dist/esm/components/StorageBrowser/views/LocationsView/useLocationsView.mjs +22 -29
- package/dist/esm/components/StorageBrowser/views/context/actionViews.mjs +33 -0
- package/dist/esm/components/StorageBrowser/views/context/getViews.mjs +32 -0
- package/dist/esm/components/StorageBrowser/views/context/primaryViews.mjs +32 -0
- package/dist/esm/components/StorageBrowser/views/context/views.mjs +19 -0
- package/dist/esm/components/StorageBrowser/views/{createUseView.mjs → useView.mjs} +19 -28
- package/dist/esm/version.mjs +1 -1
- package/dist/index.js +3 -6
- package/dist/styles.css +6 -2
- package/dist/types/components/StorageBrowser/actions/configs/context.d.ts +4 -5
- package/dist/types/components/StorageBrowser/actions/configs/defaults.d.ts +6 -7
- package/dist/types/components/StorageBrowser/actions/configs/index.d.ts +3 -2
- package/dist/types/components/StorageBrowser/actions/configs/types.d.ts +39 -69
- package/dist/types/components/StorageBrowser/actions/configs/utils.d.ts +2 -0
- package/dist/types/components/StorageBrowser/actions/handlers/copy.d.ts +12 -5
- package/dist/types/components/StorageBrowser/actions/handlers/createFolder.d.ts +7 -4
- package/dist/types/components/StorageBrowser/actions/handlers/delete.d.ts +6 -3
- package/dist/types/components/StorageBrowser/actions/handlers/download.d.ts +6 -3
- package/dist/types/components/StorageBrowser/actions/handlers/types.d.ts +11 -2
- package/dist/types/components/StorageBrowser/actions/handlers/upload.d.ts +8 -4
- package/dist/types/components/StorageBrowser/actions/handlers/utils.d.ts +0 -1
- package/dist/types/components/StorageBrowser/actions/index.d.ts +2 -4
- package/dist/types/components/StorageBrowser/adapters/permissionParsers.d.ts +1 -1
- package/dist/types/components/StorageBrowser/composables/ActionsList.d.ts +2 -2
- package/dist/types/components/StorageBrowser/controls/SearchFieldControl.d.ts +2 -0
- package/dist/types/components/StorageBrowser/controls/hooks/usePagination.d.ts +2 -0
- package/dist/types/components/StorageBrowser/controls/hooks/useSearchField.d.ts +2 -0
- package/dist/types/components/StorageBrowser/controls/types.d.ts +3 -3
- package/dist/types/components/StorageBrowser/createStorageBrowser.d.ts +3 -7
- package/dist/types/components/StorageBrowser/displayText/index.d.ts +1 -1
- package/dist/types/components/StorageBrowser/displayText/types.d.ts +1 -1
- package/dist/types/components/StorageBrowser/index.d.ts +3 -1
- package/dist/types/components/StorageBrowser/providers/configuration/index.d.ts +1 -1
- package/dist/types/components/StorageBrowser/providers/configuration/types.d.ts +2 -2
- package/dist/types/components/StorageBrowser/providers/store/files/types.d.ts +10 -1
- package/dist/types/components/StorageBrowser/providers/store/files/utils.d.ts +1 -2
- package/dist/types/components/StorageBrowser/tasks/types.d.ts +16 -13
- package/dist/types/components/StorageBrowser/tasks/useProcessTasks.d.ts +2 -3
- package/dist/types/components/StorageBrowser/types.d.ts +42 -12
- package/dist/types/components/StorageBrowser/useAction/constants.d.ts +3 -0
- package/dist/types/components/StorageBrowser/useAction/context.d.ts +5 -0
- package/dist/types/components/StorageBrowser/{actions/useAction → useAction}/createEnhancedListHandler.d.ts +3 -3
- package/dist/types/components/StorageBrowser/useAction/index.d.ts +6 -0
- package/dist/types/components/StorageBrowser/useAction/types.d.ts +76 -0
- package/dist/types/components/StorageBrowser/useAction/useAction.d.ts +3 -0
- package/dist/types/components/StorageBrowser/useAction/useHandler.d.ts +3 -0
- package/dist/types/components/StorageBrowser/useAction/useList.d.ts +9 -0
- package/dist/types/components/StorageBrowser/useAction/useListFolderItems.d.ts +13 -0
- package/dist/types/components/StorageBrowser/useAction/useListLocationItems.d.ts +10 -0
- package/dist/types/components/StorageBrowser/useAction/useListLocations.d.ts +8 -0
- package/dist/types/components/StorageBrowser/useAction/utils.d.ts +6 -0
- package/dist/types/components/StorageBrowser/views/LocationActionView/CopyView/useFolders.d.ts +1 -4
- package/dist/types/components/StorageBrowser/views/LocationActionView/CreateFolderView/types.d.ts +2 -2
- package/dist/types/components/StorageBrowser/views/LocationActionView/LocationActionView.d.ts +2 -6
- package/dist/types/components/StorageBrowser/views/LocationActionView/getActionViewTableData.d.ts +2 -4
- package/dist/types/components/StorageBrowser/views/LocationActionView/index.d.ts +6 -6
- package/dist/types/components/StorageBrowser/views/LocationActionView/types.d.ts +4 -8
- package/dist/types/components/StorageBrowser/views/LocationDetailView/getLocationDetailViewTableData/getLocationDetailViewTableData.d.ts +1 -3
- package/dist/types/components/StorageBrowser/views/LocationDetailView/types.d.ts +16 -17
- package/dist/types/components/StorageBrowser/views/LocationsView/types.d.ts +8 -12
- package/dist/types/components/StorageBrowser/views/context/actionViews.d.ts +6 -0
- package/dist/types/components/StorageBrowser/views/context/getViews.d.ts +4 -0
- package/dist/types/components/StorageBrowser/views/context/index.d.ts +1 -0
- package/dist/types/components/StorageBrowser/views/context/primaryViews.d.ts +6 -0
- package/dist/types/components/StorageBrowser/views/context/types.d.ts +9 -0
- package/dist/types/components/StorageBrowser/views/context/views.d.ts +10 -0
- package/dist/types/components/StorageBrowser/views/index.d.ts +2 -2
- package/dist/types/components/StorageBrowser/views/types.d.ts +22 -0
- package/dist/types/components/StorageBrowser/views/useView.d.ts +16 -0
- package/dist/types/version.d.ts +1 -1
- package/package.json +4 -4
- package/dist/esm/components/StorageBrowser/controls/SearchControl.mjs +0 -13
- package/dist/esm/components/StorageBrowser/views/LocationActionView/constants.mjs +0 -3
- package/dist/esm/components/StorageBrowser/views/LocationActionView/useActionView.mjs +0 -20
- package/dist/esm/components/StorageBrowser/views/context.mjs +0 -43
- package/dist/types/components/StorageBrowser/actions/createUseAction.d.ts +0 -2
- package/dist/types/components/StorageBrowser/actions/types.d.ts +0 -8
- package/dist/types/components/StorageBrowser/actions/useAction/index.d.ts +0 -1
- package/dist/types/components/StorageBrowser/actions/useAction/useListLocations.d.ts +0 -8
- package/dist/types/components/StorageBrowser/controls/SearchControl.d.ts +0 -2
- package/dist/types/components/StorageBrowser/views/LocationActionView/constants.d.ts +0 -1
- package/dist/types/components/StorageBrowser/views/context.d.ts +0 -16
- package/dist/types/components/StorageBrowser/views/createUseView.d.ts +0 -19
- /package/dist/esm/components/StorageBrowser/{actions/useAction → useAction}/createEnhancedListHandler.mjs +0 -0
|
@@ -1,28 +1,21 @@
|
|
|
1
1
|
import React__default from 'react';
|
|
2
|
-
import '../../actions/configs/context.mjs';
|
|
3
|
-
import { isDefaultActionViewType } from '../../actions/configs/defaults.mjs';
|
|
4
|
-
import '@aws-amplify/storage/internals';
|
|
5
|
-
import '@aws-amplify/ui';
|
|
6
|
-
import 'aws-amplify/storage';
|
|
7
|
-
import '@aws-amplify/ui-react-core';
|
|
8
2
|
import '../../providers/store/location/context.mjs';
|
|
9
3
|
import '../../providers/store/files/context.mjs';
|
|
10
4
|
import '../../providers/store/actionType/context.mjs';
|
|
11
5
|
import '../../providers/store/locationItems/context.mjs';
|
|
12
6
|
import { useStore } from '../../providers/store/useStore.mjs';
|
|
13
|
-
import {
|
|
14
|
-
import '../../providers/configuration/context.mjs';
|
|
15
|
-
import '@aws-amplify/ui-react-core/elements';
|
|
16
|
-
import '../../providers/configuration/credentials/context.mjs';
|
|
17
|
-
import { CopyView } from './CopyView/CopyView.mjs';
|
|
18
|
-
import { DeleteView } from './DeleteView/DeleteView.mjs';
|
|
19
|
-
import { UploadView } from './UploadView/UploadView.mjs';
|
|
7
|
+
import { useActionViews } from '../context/actionViews.mjs';
|
|
20
8
|
|
|
21
9
|
const LocationActionView = ({ type, ...props }) => {
|
|
22
10
|
const [{ actionType = type }] = useStore();
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
11
|
+
const views = useActionViews().action;
|
|
12
|
+
const ActionView = actionType
|
|
13
|
+
? views[actionType]
|
|
14
|
+
: undefined;
|
|
15
|
+
if (ActionView) {
|
|
16
|
+
return React__default.createElement(ActionView, { ...props });
|
|
17
|
+
}
|
|
18
|
+
return null;
|
|
26
19
|
};
|
|
27
20
|
|
|
28
21
|
export { LocationActionView };
|
package/dist/esm/components/StorageBrowser/views/LocationActionView/UploadView/useUploadView.mjs
CHANGED
|
@@ -1,85 +1,80 @@
|
|
|
1
1
|
import React__default from 'react';
|
|
2
|
-
import '../../../actions/configs/context.mjs';
|
|
3
|
-
import '@aws-amplify/storage/internals';
|
|
4
2
|
import { isUndefined } from '@aws-amplify/ui';
|
|
5
|
-
import { isFileTooBig } from '../../../validators/isFileTooBig.mjs';
|
|
6
|
-
import { uploadHandler } from '../../../actions/handlers/upload.mjs';
|
|
7
|
-
import '@aws-amplify/ui-react-core';
|
|
8
|
-
import { useGetActionInput } from '../../../providers/configuration/context.mjs';
|
|
9
|
-
import '@aws-amplify/ui-react-core/elements';
|
|
10
|
-
import '../../../providers/configuration/credentials/context.mjs';
|
|
11
3
|
import '../../../providers/store/location/context.mjs';
|
|
12
4
|
import '../../../providers/store/files/context.mjs';
|
|
13
5
|
import '../../../providers/store/actionType/context.mjs';
|
|
14
6
|
import '../../../providers/store/locationItems/context.mjs';
|
|
15
7
|
import { useStore } from '../../../providers/store/useStore.mjs';
|
|
16
|
-
import
|
|
17
|
-
import {
|
|
8
|
+
import '../../../useAction/context.mjs';
|
|
9
|
+
import { useAction } from '../../../useAction/useAction.mjs';
|
|
10
|
+
import '@aws-amplify/ui-react-core';
|
|
11
|
+
import '@aws-amplify/ui-react-core/elements';
|
|
12
|
+
import '../../../providers/configuration/credentials/context.mjs';
|
|
13
|
+
import '../../../providers/configuration/context.mjs';
|
|
14
|
+
import '@aws-amplify/storage/internals';
|
|
15
|
+
import { isFileTooBig } from '../../../validators/isFileTooBig.mjs';
|
|
16
|
+
import 'aws-amplify/storage';
|
|
17
|
+
import '../../../actions/configs/context.mjs';
|
|
18
18
|
import { DEFAULT_OVERWRITE_ENABLED } from './constants.mjs';
|
|
19
19
|
|
|
20
20
|
const useUploadView = (options) => {
|
|
21
21
|
const { onExit: _onExit } = options ?? {};
|
|
22
|
-
const getInput = useGetActionInput();
|
|
23
22
|
const [{ files, location }, dispatchStoreAction] = useStore();
|
|
24
|
-
const { current
|
|
25
|
-
const
|
|
26
|
-
|
|
23
|
+
const { current } = location;
|
|
24
|
+
const [isOverwritingEnabled, setIsOverwritingEnabled] = React__default.useState(DEFAULT_OVERWRITE_ENABLED);
|
|
25
|
+
const filesData = React__default.useMemo(() => (files ?? [])?.reduce((curr, item) => {
|
|
26
|
+
if (isFileTooBig(item.file)) {
|
|
27
27
|
curr.invalidFiles = isUndefined(curr.invalidFiles)
|
|
28
|
-
? [
|
|
29
|
-
: curr.invalidFiles.concat(
|
|
28
|
+
? [item]
|
|
29
|
+
: curr.invalidFiles.concat(item);
|
|
30
30
|
}
|
|
31
31
|
else {
|
|
32
32
|
curr.validFiles = isUndefined(curr.validFiles)
|
|
33
|
-
? [
|
|
34
|
-
: curr.validFiles.concat(
|
|
33
|
+
? [item]
|
|
34
|
+
: curr.validFiles.concat(item);
|
|
35
|
+
const parsedFileItem = {
|
|
36
|
+
...item,
|
|
37
|
+
key: `${location.key}${item.key}`,
|
|
38
|
+
};
|
|
39
|
+
curr.data = curr.data.concat({
|
|
40
|
+
...parsedFileItem,
|
|
41
|
+
preventOverwrite: !isOverwritingEnabled,
|
|
42
|
+
});
|
|
35
43
|
}
|
|
36
44
|
return curr;
|
|
37
|
-
}, {}), [files]);
|
|
38
|
-
const
|
|
39
|
-
const [{ isProcessing, isProcessingComplete, statusCounts, tasks },
|
|
40
|
-
|
|
41
|
-
});
|
|
42
|
-
const onDropFiles = React__default.useCallback((files) => {
|
|
45
|
+
}, { invalidFiles: undefined, validFiles: undefined, data: [] }), [files, isOverwritingEnabled, location.key]);
|
|
46
|
+
const { data, invalidFiles } = filesData;
|
|
47
|
+
const [{ isProcessing, isProcessingComplete, statusCounts, tasks }, handleUploads,] = useAction('upload', { items: data });
|
|
48
|
+
const onDropFiles = (files) => {
|
|
43
49
|
if (files) {
|
|
44
50
|
dispatchStoreAction({ type: 'ADD_FILE_ITEMS', files });
|
|
45
51
|
}
|
|
46
|
-
}
|
|
47
|
-
const onSelectFiles =
|
|
52
|
+
};
|
|
53
|
+
const onSelectFiles = (type) => {
|
|
48
54
|
dispatchStoreAction({ type: 'SELECT_FILES', selectionType: type });
|
|
49
|
-
}
|
|
50
|
-
const onActionStart =
|
|
55
|
+
};
|
|
56
|
+
const onActionStart = () => {
|
|
51
57
|
invalidFiles?.forEach((file) => {
|
|
52
58
|
dispatchStoreAction({ type: 'REMOVE_FILE_ITEM', id: file.id });
|
|
53
59
|
});
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
options: { preventOverwrite: !isOverwritingEnabled },
|
|
58
|
-
});
|
|
59
|
-
}, [
|
|
60
|
-
isOverwritingEnabled,
|
|
61
|
-
key,
|
|
62
|
-
getInput,
|
|
63
|
-
handleProcess,
|
|
64
|
-
invalidFiles,
|
|
65
|
-
dispatchStoreAction,
|
|
66
|
-
]);
|
|
67
|
-
const onActionCancel = React__default.useCallback(() => {
|
|
60
|
+
handleUploads();
|
|
61
|
+
};
|
|
62
|
+
const onActionCancel = () => {
|
|
68
63
|
tasks.forEach((task) => task.cancel?.());
|
|
69
|
-
}
|
|
70
|
-
const onActionExit =
|
|
64
|
+
};
|
|
65
|
+
const onActionExit = () => {
|
|
71
66
|
// clear files state
|
|
72
67
|
dispatchStoreAction({ type: 'RESET_FILE_ITEMS' });
|
|
73
68
|
// clear selected action
|
|
74
69
|
dispatchStoreAction({ type: 'RESET_ACTION_TYPE' });
|
|
75
70
|
_onExit?.(current);
|
|
76
|
-
}
|
|
77
|
-
const onToggleOverwrite =
|
|
71
|
+
};
|
|
72
|
+
const onToggleOverwrite = () => {
|
|
78
73
|
setIsOverwritingEnabled((prev) => !prev);
|
|
79
|
-
}
|
|
80
|
-
const onTaskRemove =
|
|
74
|
+
};
|
|
75
|
+
const onTaskRemove = ({ data }) => {
|
|
81
76
|
dispatchStoreAction({ type: 'REMOVE_FILE_ITEM', id: data.id });
|
|
82
|
-
}
|
|
77
|
+
};
|
|
83
78
|
return {
|
|
84
79
|
isProcessing,
|
|
85
80
|
isProcessingComplete,
|
package/dist/esm/components/StorageBrowser/views/LocationActionView/getActionViewTableData.mjs
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { humanFileSize } from '@aws-amplify/ui';
|
|
2
|
-
import '../../actions/configs/context.mjs';
|
|
3
2
|
import '@aws-amplify/storage/internals';
|
|
4
3
|
import { isFileDataItem, isFileItem } from '../../actions/handlers/utils.mjs';
|
|
5
4
|
import 'aws-amplify/storage';
|
|
6
|
-
import '
|
|
7
|
-
import '@aws-amplify/ui-react-core';
|
|
5
|
+
import '../../actions/configs/context.mjs';
|
|
8
6
|
import { getActionIcon } from './getActionIcon.mjs';
|
|
9
7
|
import { getFileTypeDisplayValue } from './getFileTypeDisplayValue.mjs';
|
|
10
8
|
import { getPercentValue } from './getPercentValue.mjs';
|
|
@@ -152,4 +150,4 @@ const getActionViewTableData = ({ tasks, displayText, isProcessing, locationKey,
|
|
|
152
150
|
return { headers, rows };
|
|
153
151
|
};
|
|
154
152
|
|
|
155
|
-
export { getActionViewTableData
|
|
153
|
+
export { getActionViewTableData };
|
|
@@ -11,7 +11,7 @@ import { LoadingIndicatorControl } from '../../controls/LoadingIndicatorControl.
|
|
|
11
11
|
import { MessageControl } from '../../controls/MessageControl.mjs';
|
|
12
12
|
import { NavigationControl } from '../../controls/NavigationControl.mjs';
|
|
13
13
|
import { PaginationControl } from '../../controls/PaginationControl.mjs';
|
|
14
|
-
import {
|
|
14
|
+
import { SearchFieldControl } from '../../controls/SearchFieldControl.mjs';
|
|
15
15
|
import { SearchSubfoldersToggleControl } from '../../controls/SearchSubfoldersToggleControl.mjs';
|
|
16
16
|
import { TitleControl } from '../../controls/TitleControl.mjs';
|
|
17
17
|
import { useLocationDetailView } from './useLocationDetailView.mjs';
|
|
@@ -27,7 +27,7 @@ const LocationDetailView = ({ className, ...props }) => {
|
|
|
27
27
|
React__default.createElement(TitleControl, null),
|
|
28
28
|
React__default.createElement(ViewElement, { className: `${STORAGE_BROWSER_BLOCK}__controls` },
|
|
29
29
|
React__default.createElement(ViewElement, { className: `${STORAGE_BROWSER_BLOCK}__search` },
|
|
30
|
-
React__default.createElement(
|
|
30
|
+
React__default.createElement(SearchFieldControl, null),
|
|
31
31
|
React__default.createElement(SearchSubfoldersToggleControl, null)),
|
|
32
32
|
React__default.createElement(PaginationControl, null),
|
|
33
33
|
React__default.createElement(DataRefreshControl, null),
|
|
@@ -49,7 +49,7 @@ LocationDetailView.Message = MessageControl;
|
|
|
49
49
|
LocationDetailView.Navigation = NavigationControl;
|
|
50
50
|
LocationDetailView.Pagination = PaginationControl;
|
|
51
51
|
LocationDetailView.Refresh = DataRefreshControl;
|
|
52
|
-
LocationDetailView.Search =
|
|
52
|
+
LocationDetailView.Search = SearchFieldControl;
|
|
53
53
|
LocationDetailView.SearchSubfoldersToggle = SearchSubfoldersToggleControl;
|
|
54
54
|
LocationDetailView.Title = TitleControl;
|
|
55
55
|
|
package/dist/esm/components/StorageBrowser/views/LocationDetailView/LocationDetailViewProvider.mjs
CHANGED
|
@@ -6,11 +6,14 @@ import { getLocationDetailViewTableData } from './getLocationDetailViewTableData
|
|
|
6
6
|
|
|
7
7
|
function LocationDetailViewProvider({ children, ...props }) {
|
|
8
8
|
const { LocationDetailView: { loadingIndicatorLabel, searchSubfoldersToggleLabel, selectFileLabel, selectAllFilesLabel, searchPlaceholder, searchSubmitLabel, searchClearLabel, getActionListItemLabel, getDateDisplayValue, getTitle, getListItemsResultMessage, }, } = useDisplayText();
|
|
9
|
-
const {
|
|
10
|
-
const actionsWithDisplayText =
|
|
9
|
+
const { actionItems, page, pageItems, hasNextPage, highestPageVisited, isLoading, isSearchSubfoldersEnabled, location, fileDataItems, hasError, hasDownloadError, message, downloadErrorMessage, searchQuery, hasExhaustedSearch, onActionSelect, onDropFiles, onRefresh, onPaginate, onDownload, onNavigate, onNavigateHome, onSelect, onToggleSelectAll, onSearch, onSearchQueryChange, onSearchClear, onToggleSearchSubfolders, } = props;
|
|
10
|
+
const actionsWithDisplayText = actionItems.map((item) => ({
|
|
11
11
|
...item,
|
|
12
12
|
label: getActionListItemLabel(item.label),
|
|
13
13
|
}));
|
|
14
|
+
const fileItems = pageItems.filter((item) => item.type === 'FILE');
|
|
15
|
+
const areAllFilesSelected = fileDataItems?.length === fileItems.length;
|
|
16
|
+
const hasFiles = fileItems.length > 0;
|
|
14
17
|
const messageControlContent = getListItemsResultMessage({
|
|
15
18
|
isLoading,
|
|
16
19
|
items: pageItems,
|
|
@@ -18,20 +21,21 @@ function LocationDetailViewProvider({ children, ...props }) {
|
|
|
18
21
|
hasExhaustedSearch,
|
|
19
22
|
message: hasError ? message : downloadErrorMessage,
|
|
20
23
|
});
|
|
21
|
-
const
|
|
24
|
+
const isActionsListDisabled = isLoading ||
|
|
25
|
+
!actionItems?.length ||
|
|
26
|
+
actionItems.every(({ isHidden }) => isHidden);
|
|
22
27
|
return (React__default.createElement(ControlsContextProvider, { data: {
|
|
23
28
|
actions: actionsWithDisplayText,
|
|
24
|
-
isActionsListDisabled
|
|
29
|
+
isActionsListDisabled,
|
|
25
30
|
isDataRefreshDisabled: isLoading,
|
|
26
31
|
isLoading,
|
|
27
|
-
isSearchingSubfolders,
|
|
32
|
+
isSearchingSubfolders: isSearchSubfoldersEnabled,
|
|
28
33
|
loadingIndicatorLabel,
|
|
29
34
|
location,
|
|
30
35
|
paginationData: {
|
|
31
36
|
page,
|
|
32
37
|
hasNextPage,
|
|
33
38
|
highestPageVisited,
|
|
34
|
-
onPaginate,
|
|
35
39
|
},
|
|
36
40
|
searchPlaceholder,
|
|
37
41
|
searchSubfoldersToggleLabel,
|
|
@@ -50,11 +54,11 @@ function LocationDetailViewProvider({ children, ...props }) {
|
|
|
50
54
|
onDownload,
|
|
51
55
|
onNavigate,
|
|
52
56
|
onSelect,
|
|
53
|
-
onSelectAll,
|
|
57
|
+
onSelectAll: onToggleSelectAll,
|
|
54
58
|
}),
|
|
55
59
|
title: getTitle(location),
|
|
56
60
|
message: messageControlContent,
|
|
57
|
-
}, onActionSelect: onActionSelect, onDropFiles: onDropFiles, onNavigate: onNavigate, onNavigateHome: onNavigateHome, onRefresh: onRefresh, onSearch: onSearch, onSearchQueryChange: onSearchQueryChange, onSearchClear: onSearchClear, onToggleSearchSubfolders: onToggleSearchSubfolders }, children));
|
|
61
|
+
}, onActionSelect: onActionSelect, onDropFiles: onDropFiles, onNavigate: onNavigate, onNavigateHome: onNavigateHome, onPaginate: onPaginate, onRefresh: onRefresh, onSearch: onSearch, onSearchQueryChange: onSearchQueryChange, onSearchClear: onSearchClear, onToggleSearchSubfolders: onToggleSearchSubfolders }, children));
|
|
58
62
|
}
|
|
59
63
|
|
|
60
64
|
export { LocationDetailViewProvider };
|
|
@@ -2,6 +2,7 @@ import '@aws-amplify/storage/internals';
|
|
|
2
2
|
import { createFileDataItem } from '../../../actions/handlers/utils.mjs';
|
|
3
3
|
import '@aws-amplify/ui';
|
|
4
4
|
import 'aws-amplify/storage';
|
|
5
|
+
import '../../../actions/configs/context.mjs';
|
|
5
6
|
import { getFileRowContent } from './getFileRowContent.mjs';
|
|
6
7
|
import { getFolderRowContent } from './getFolderRowContent.mjs';
|
|
7
8
|
import { LOCATION_DETAIL_VIEW_HEADERS } from './constants.mjs';
|
package/dist/esm/components/StorageBrowser/views/LocationDetailView/useLocationDetailView.mjs
CHANGED
|
@@ -1,52 +1,43 @@
|
|
|
1
1
|
import React__default from 'react';
|
|
2
2
|
import { isUndefined, isFunction } from '@aws-amplify/ui';
|
|
3
|
-
import { useDataState } from '@aws-amplify/ui-react-core';
|
|
4
3
|
import { usePaginate } from '../hooks/usePaginate.mjs';
|
|
5
4
|
import '../../providers/store/location/context.mjs';
|
|
6
5
|
import '../../providers/store/files/context.mjs';
|
|
7
6
|
import '../../providers/store/actionType/context.mjs';
|
|
8
7
|
import '../../providers/store/locationItems/context.mjs';
|
|
9
8
|
import { useStore } from '../../providers/store/useStore.mjs';
|
|
10
|
-
import '../../actions/configs/context.mjs';
|
|
11
|
-
import { defaultActionViewConfigs } from '../../actions/configs/defaults.mjs';
|
|
12
9
|
import '@aws-amplify/storage/internals';
|
|
13
|
-
import { downloadHandler } from '../../actions/handlers/download.mjs';
|
|
14
|
-
import { listLocationItemsHandler } from '../../actions/handlers/listLocationItems.mjs';
|
|
15
10
|
import 'aws-amplify/storage';
|
|
16
|
-
import {
|
|
17
|
-
import
|
|
18
|
-
import '
|
|
19
|
-
import '../../
|
|
11
|
+
import { useActionConfigs } from '../../actions/configs/context.mjs';
|
|
12
|
+
import '../../useAction/context.mjs';
|
|
13
|
+
import { useAction } from '../../useAction/useAction.mjs';
|
|
14
|
+
import { useList } from '../../useAction/useList.mjs';
|
|
20
15
|
import { useSearch } from '../hooks/useSearch.mjs';
|
|
21
|
-
import { useProcessTasks } from '../../tasks/useProcessTasks.mjs';
|
|
22
16
|
|
|
23
17
|
const DEFAULT_PAGE_SIZE = 100;
|
|
24
18
|
const DEFAULT_LIST_OPTIONS = {
|
|
25
19
|
delimiter: '/',
|
|
26
20
|
pageSize: DEFAULT_PAGE_SIZE,
|
|
27
21
|
};
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
return `Failed to download ${tasks[0].data.fileKey ?? tasks[0].data.key} due to error: ${tasks[0].message}.`;
|
|
22
|
+
const getDownloadErrorMessageFromFailedDownloadTask = (task) => {
|
|
23
|
+
if (!task)
|
|
24
|
+
return;
|
|
25
|
+
return `Failed to download ${task.data.fileKey ?? task.data.key} due to error: ${task.message}.`;
|
|
34
26
|
};
|
|
35
27
|
const useLocationDetailView = (options) => {
|
|
36
|
-
const getConfig = useGetActionInput();
|
|
37
28
|
const { initialValues, onExit, onNavigate } = options ?? {};
|
|
38
29
|
const listOptionsRef = React__default.useRef({
|
|
39
30
|
...DEFAULT_LIST_OPTIONS,
|
|
40
31
|
...initialValues,
|
|
41
32
|
});
|
|
42
33
|
const listOptions = listOptionsRef.current;
|
|
43
|
-
const [{ location, locationItems }, dispatchStoreAction] = useStore();
|
|
34
|
+
const [{ location, locationItems, actionType }, dispatchStoreAction] = useStore();
|
|
44
35
|
const { current, key } = location;
|
|
45
36
|
const { permissions, prefix } = current ?? {};
|
|
46
37
|
const { fileDataItems } = locationItems;
|
|
47
38
|
const hasInvalidPrefix = isUndefined(prefix);
|
|
48
|
-
const [
|
|
49
|
-
const [{ data, isLoading, hasError, message }, handleList] =
|
|
39
|
+
const [{ task }, handleDownload] = useAction('download');
|
|
40
|
+
const [{ data, isLoading, hasError, message }, handleList] = useList('locationItems');
|
|
50
41
|
// set up pagination
|
|
51
42
|
const { items, nextToken, search } = data;
|
|
52
43
|
const { hasExhaustedSearch = false } = search ?? {};
|
|
@@ -56,7 +47,6 @@ const useLocationDetailView = (options) => {
|
|
|
56
47
|
return;
|
|
57
48
|
dispatchStoreAction({ type: 'RESET_LOCATION_ITEMS' });
|
|
58
49
|
handleList({
|
|
59
|
-
config: getConfig(),
|
|
60
50
|
prefix: key,
|
|
61
51
|
options: { ...listOptions, nextToken },
|
|
62
52
|
});
|
|
@@ -80,17 +70,16 @@ const useLocationDetailView = (options) => {
|
|
|
80
70
|
},
|
|
81
71
|
};
|
|
82
72
|
handleReset();
|
|
83
|
-
handleList({
|
|
73
|
+
handleList({ prefix: key, options: searchOptions });
|
|
84
74
|
dispatchStoreAction({ type: 'RESET_LOCATION_ITEMS' });
|
|
85
75
|
};
|
|
86
|
-
const { searchQuery, isSearchingSubfolders, onSearchQueryChange, onSearchSubmit, onToggleSearchSubfolders, resetSearch, } = useSearch({ onSearch });
|
|
76
|
+
const { searchQuery, isSearchingSubfolders: isSearchSubfoldersEnabled, onSearchQueryChange, onSearchSubmit, onToggleSearchSubfolders, resetSearch, } = useSearch({ onSearch });
|
|
87
77
|
const onRefresh = () => {
|
|
88
78
|
if (hasInvalidPrefix)
|
|
89
79
|
return;
|
|
90
80
|
handleReset();
|
|
91
81
|
resetSearch();
|
|
92
82
|
handleList({
|
|
93
|
-
config: getConfig(),
|
|
94
83
|
prefix: key,
|
|
95
84
|
options: { ...listOptions, refresh: true },
|
|
96
85
|
});
|
|
@@ -100,63 +89,60 @@ const useLocationDetailView = (options) => {
|
|
|
100
89
|
if (hasInvalidPrefix)
|
|
101
90
|
return;
|
|
102
91
|
handleList({
|
|
103
|
-
config: getConfig(),
|
|
104
92
|
prefix: key,
|
|
105
93
|
options: { ...listOptions, refresh: true },
|
|
106
94
|
});
|
|
107
95
|
handleReset();
|
|
108
|
-
}, [
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
listOptions,
|
|
112
|
-
hasInvalidPrefix,
|
|
113
|
-
getConfig,
|
|
114
|
-
prefix,
|
|
115
|
-
key,
|
|
116
|
-
]);
|
|
117
|
-
// Logic for Select All Files functionality
|
|
118
|
-
const fileItems = React__default.useMemo(() => pageItems.filter((item) => item.type === 'FILE'), [pageItems]);
|
|
119
|
-
const areAllFilesSelected = fileDataItems?.length === fileItems.length;
|
|
120
|
-
const shouldShowEmptyMessage = pageItems.length === 0 && !isLoading && !hasError;
|
|
121
|
-
const actions = React__default.useMemo(() => {
|
|
96
|
+
}, [handleList, handleReset, listOptions, hasInvalidPrefix, key]);
|
|
97
|
+
const { actionConfigs } = useActionConfigs();
|
|
98
|
+
const actionItems = React__default.useMemo(() => {
|
|
122
99
|
if (!permissions) {
|
|
123
100
|
return [];
|
|
124
101
|
}
|
|
125
|
-
return
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
102
|
+
return !actionConfigs
|
|
103
|
+
? []
|
|
104
|
+
: Object.entries(actionConfigs).map(([type, { actionListItem }]) => {
|
|
105
|
+
const { icon, hide, disable, label } = actionListItem ?? {};
|
|
106
|
+
return {
|
|
107
|
+
actionType: type,
|
|
108
|
+
icon,
|
|
109
|
+
isDisabled: isFunction(disable)
|
|
110
|
+
? disable(fileDataItems)
|
|
111
|
+
: disable ?? false,
|
|
112
|
+
isHidden: isFunction(hide) ? hide(permissions) : hide,
|
|
113
|
+
label,
|
|
114
|
+
};
|
|
115
|
+
});
|
|
116
|
+
}, [actionConfigs, fileDataItems, permissions]);
|
|
139
117
|
return {
|
|
140
|
-
|
|
118
|
+
actionItems,
|
|
119
|
+
actionType,
|
|
141
120
|
page: currentPage,
|
|
142
121
|
pageItems,
|
|
143
122
|
location,
|
|
144
|
-
areAllFilesSelected,
|
|
145
123
|
fileDataItems,
|
|
146
|
-
hasFiles: fileItems.length > 0,
|
|
147
124
|
hasError,
|
|
148
|
-
hasDownloadError:
|
|
125
|
+
hasDownloadError: task?.status === 'FAILED',
|
|
149
126
|
hasNextPage: hasNextToken,
|
|
150
127
|
highestPageVisited,
|
|
151
128
|
message,
|
|
152
|
-
downloadErrorMessage: getDownloadErrorMessageFromFailedDownloadTask(
|
|
153
|
-
shouldShowEmptyMessage,
|
|
129
|
+
downloadErrorMessage: getDownloadErrorMessageFromFailedDownloadTask(task),
|
|
154
130
|
isLoading,
|
|
155
|
-
|
|
131
|
+
isSearchSubfoldersEnabled,
|
|
156
132
|
onPaginate,
|
|
157
133
|
searchQuery,
|
|
158
134
|
hasExhaustedSearch,
|
|
159
135
|
onRefresh,
|
|
136
|
+
onActionExit: () => {
|
|
137
|
+
dispatchStoreAction({ type: 'RESET_ACTION_TYPE' });
|
|
138
|
+
},
|
|
139
|
+
onActionSelect: (nextActionType) => {
|
|
140
|
+
options?.onActionSelect?.(nextActionType);
|
|
141
|
+
dispatchStoreAction({
|
|
142
|
+
type: 'SET_ACTION_TYPE',
|
|
143
|
+
actionType: nextActionType,
|
|
144
|
+
});
|
|
145
|
+
},
|
|
160
146
|
onNavigate: (location, path) => {
|
|
161
147
|
onNavigate?.(location, path);
|
|
162
148
|
resetSearch();
|
|
@@ -170,13 +156,12 @@ const useLocationDetailView = (options) => {
|
|
|
170
156
|
options?.onActionSelect?.(actionType);
|
|
171
157
|
},
|
|
172
158
|
onDownload: (data) => {
|
|
173
|
-
handleDownload({
|
|
159
|
+
handleDownload({ data });
|
|
174
160
|
},
|
|
175
161
|
onNavigateHome: () => {
|
|
176
162
|
onExit?.();
|
|
177
163
|
dispatchStoreAction({ type: 'RESET_LOCATION' });
|
|
178
164
|
handleList({
|
|
179
|
-
config: getConfig(),
|
|
180
165
|
// @todo: prefix should not be required to refresh
|
|
181
166
|
prefix: prefix ?? '',
|
|
182
167
|
options: { reset: true },
|
|
@@ -184,17 +169,14 @@ const useLocationDetailView = (options) => {
|
|
|
184
169
|
dispatchStoreAction({ type: 'RESET_ACTION_TYPE' });
|
|
185
170
|
dispatchStoreAction({ type: 'RESET_LOCATION_ITEMS' });
|
|
186
171
|
},
|
|
187
|
-
onActionSelect: (actionType) => {
|
|
188
|
-
options?.onActionSelect?.(actionType);
|
|
189
|
-
dispatchStoreAction({ type: 'SET_ACTION_TYPE', actionType });
|
|
190
|
-
},
|
|
191
172
|
onSelect: (isSelected, fileItem) => {
|
|
192
173
|
dispatchStoreAction(isSelected
|
|
193
174
|
? { type: 'REMOVE_LOCATION_ITEM', id: fileItem.id }
|
|
194
175
|
: { type: 'SET_LOCATION_ITEMS', items: [fileItem] });
|
|
195
176
|
},
|
|
196
|
-
|
|
197
|
-
|
|
177
|
+
onToggleSelectAll: () => {
|
|
178
|
+
const fileItems = pageItems.filter((item) => item.type === 'FILE');
|
|
179
|
+
dispatchStoreAction(fileItems.length === fileDataItems?.length
|
|
198
180
|
? { type: 'RESET_LOCATION_ITEMS' }
|
|
199
181
|
: { type: 'SET_LOCATION_ITEMS', items: fileItems });
|
|
200
182
|
},
|
|
@@ -204,7 +186,6 @@ const useLocationDetailView = (options) => {
|
|
|
204
186
|
if (hasInvalidPrefix)
|
|
205
187
|
return;
|
|
206
188
|
handleList({
|
|
207
|
-
config: getConfig(),
|
|
208
189
|
prefix: key,
|
|
209
190
|
options: { ...listOptions, refresh: true },
|
|
210
191
|
});
|
|
@@ -8,7 +8,7 @@ import { DataTableControl } from '../../controls/DataTableControl.mjs';
|
|
|
8
8
|
import { LoadingIndicatorControl } from '../../controls/LoadingIndicatorControl.mjs';
|
|
9
9
|
import { MessageControl } from '../../controls/MessageControl.mjs';
|
|
10
10
|
import { PaginationControl } from '../../controls/PaginationControl.mjs';
|
|
11
|
-
import {
|
|
11
|
+
import { SearchFieldControl } from '../../controls/SearchFieldControl.mjs';
|
|
12
12
|
import { TitleControl } from '../../controls/TitleControl.mjs';
|
|
13
13
|
import { LocationsViewProvider } from './LocationsViewProvider.mjs';
|
|
14
14
|
import { useLocationsView } from './useLocationsView.mjs';
|
|
@@ -22,7 +22,7 @@ const LocationsView = ({ className, ...props }) => {
|
|
|
22
22
|
React__default.createElement(TitleControl, null),
|
|
23
23
|
React__default.createElement(ViewElement, { className: `${STORAGE_BROWSER_BLOCK}__controls` },
|
|
24
24
|
React__default.createElement(ViewElement, { className: `${STORAGE_BROWSER_BLOCK}__search` },
|
|
25
|
-
React__default.createElement(
|
|
25
|
+
React__default.createElement(SearchFieldControl, null)),
|
|
26
26
|
React__default.createElement(PaginationControl, null),
|
|
27
27
|
React__default.createElement(DataRefreshControl, null)),
|
|
28
28
|
React__default.createElement(ViewElement, { className: `${STORAGE_BROWSER_BLOCK}__data-table` },
|
|
@@ -38,7 +38,7 @@ LocationsView.LocationsTable = DataTableControl;
|
|
|
38
38
|
LocationsView.Message = MessageControl;
|
|
39
39
|
LocationsView.Pagination = PaginationControl;
|
|
40
40
|
LocationsView.Refresh = DataRefreshControl;
|
|
41
|
-
LocationsView.Search =
|
|
41
|
+
LocationsView.Search = SearchFieldControl;
|
|
42
42
|
LocationsView.Title = TitleControl;
|
|
43
43
|
|
|
44
44
|
export { LocationsView };
|
|
@@ -11,7 +11,7 @@ function LocationsViewProvider({ children, ...props }) {
|
|
|
11
11
|
const messageControlContent = getListLocationsResultMessage({
|
|
12
12
|
hasExhaustedSearch,
|
|
13
13
|
isLoading,
|
|
14
|
-
|
|
14
|
+
items: pageItems,
|
|
15
15
|
hasError,
|
|
16
16
|
message,
|
|
17
17
|
});
|
|
@@ -28,7 +28,6 @@ function LocationsViewProvider({ children, ...props }) {
|
|
|
28
28
|
page,
|
|
29
29
|
hasNextPage,
|
|
30
30
|
highestPageVisited,
|
|
31
|
-
onPaginate,
|
|
32
31
|
},
|
|
33
32
|
title,
|
|
34
33
|
searchPlaceholder,
|
|
@@ -37,7 +36,7 @@ function LocationsViewProvider({ children, ...props }) {
|
|
|
37
36
|
searchQuery,
|
|
38
37
|
message: messageControlContent,
|
|
39
38
|
isLoading,
|
|
40
|
-
},
|
|
39
|
+
}, onPaginate: onPaginate, onRefresh: onRefresh, onSearch: onSearch, onSearchQueryChange: onSearchQueryChange, onSearchClear: onSearchClear }, children));
|
|
41
40
|
}
|
|
42
41
|
|
|
43
42
|
export { LocationsViewProvider };
|