@aws-amplify/ui-react-storage 3.4.1 → 3.5.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 +35 -2
- package/dist/{createAmplifyAuthAdapter-BRctUWdR.js → createAmplifyAuthAdapter-0MaHde-Z.js} +3053 -2919
- 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 +42 -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 +5 -5
- 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 +5 -10
- 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 +5 -5
- 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
package/dist/esm/browser.mjs
CHANGED
|
@@ -2,3 +2,5 @@ export { componentsDefault } from './components/StorageBrowser/componentsDefault
|
|
|
2
2
|
export { createStorageBrowser } from './components/StorageBrowser/createStorageBrowser.mjs';
|
|
3
3
|
export { createAmplifyAuthAdapter } from './components/StorageBrowser/adapters/createAmplifyAuthAdapter/createAmplifyAuthAdapter.mjs';
|
|
4
4
|
export { createManagedAuthAdapter } from './components/StorageBrowser/adapters/createManagedAuthAdapter/createManagedAuthAdapter.mjs';
|
|
5
|
+
import './components/StorageBrowser/displayText/context.mjs';
|
|
6
|
+
export { DEFAULT_STORAGE_BROWSER_DISPLAY_TEXT as DefaultStorageBrowserDisplayText } from './components/StorageBrowser/displayText/libraries/en/default.mjs';
|
|
@@ -2,17 +2,12 @@ import React__default from 'react';
|
|
|
2
2
|
import { createStorageBrowser } from './createStorageBrowser.mjs';
|
|
3
3
|
import { createAmplifyAuthAdapter } from './adapters/createAmplifyAuthAdapter/createAmplifyAuthAdapter.mjs';
|
|
4
4
|
import '@aws-amplify/storage/internals';
|
|
5
|
-
import './actions/configs/context.mjs';
|
|
6
5
|
import '@aws-amplify/ui';
|
|
7
6
|
import 'aws-amplify/storage';
|
|
8
|
-
import '
|
|
9
|
-
import { componentsDefault } from './componentsDefault.mjs';
|
|
7
|
+
import './actions/configs/context.mjs';
|
|
10
8
|
|
|
11
9
|
const StorageBrowser = ({ views, displayText, }) => {
|
|
12
|
-
const { StorageBrowser } = React__default.useRef(createStorageBrowser({
|
|
13
|
-
components: componentsDefault,
|
|
14
|
-
config: createAmplifyAuthAdapter(),
|
|
15
|
-
})).current;
|
|
10
|
+
const { StorageBrowser } = React__default.useRef(createStorageBrowser({ config: createAmplifyAuthAdapter() })).current;
|
|
16
11
|
return React__default.createElement(StorageBrowser, { views: views, displayText: displayText });
|
|
17
12
|
};
|
|
18
13
|
|
|
@@ -1,24 +1,10 @@
|
|
|
1
1
|
import React__default from 'react';
|
|
2
|
-
import './views/
|
|
3
|
-
import '@aws-amplify/ui';
|
|
4
|
-
import '@aws-amplify/storage/internals';
|
|
5
|
-
import 'aws-amplify/storage';
|
|
6
|
-
import './providers/configuration/context.mjs';
|
|
7
|
-
import '@aws-amplify/ui-react-core/elements';
|
|
8
|
-
import './actions/configs/context.mjs';
|
|
9
|
-
import '@aws-amplify/ui-react-core';
|
|
10
|
-
import './providers/configuration/credentials/context.mjs';
|
|
2
|
+
import { useViews } from './views/context/views.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 './views/LocationActionView/CreateFolderView/CreateFolderView.mjs';
|
|
17
|
-
import './views/LocationActionView/DeleteView/DeleteView.mjs';
|
|
18
|
-
import './views/LocationActionView/UploadView/UploadView.mjs';
|
|
19
|
-
import './views/LocationDetailView/LocationDetailView.mjs';
|
|
20
|
-
import './views/LocationsView/LocationsView.mjs';
|
|
21
|
-
import { useViews } from './views/context.mjs';
|
|
22
8
|
|
|
23
9
|
/**
|
|
24
10
|
* Handles default `StorageBrowser` behavior:
|
|
@@ -27,7 +13,8 @@ import { useViews } from './views/context.mjs';
|
|
|
27
13
|
* - render `ActionView` on action selection
|
|
28
14
|
*/
|
|
29
15
|
function StorageBrowserDefault() {
|
|
30
|
-
const {
|
|
16
|
+
const { primary } = useViews();
|
|
17
|
+
const { LocationActionView, LocationDetailView, LocationsView } = primary;
|
|
31
18
|
const [{ actionType, location }] = useStore();
|
|
32
19
|
const { current } = location;
|
|
33
20
|
if (actionType) {
|
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
import { createContextUtilities } from '@aws-amplify/ui-react-core';
|
|
2
2
|
|
|
3
|
-
const defaultValue = {
|
|
3
|
+
const defaultValue = {
|
|
4
|
+
actionConfigs: undefined,
|
|
5
|
+
};
|
|
4
6
|
const { useActionConfigs, ActionConfigsProvider } = createContextUtilities({ contextName: 'ActionConfigs', defaultValue });
|
|
5
|
-
function useActionConfig(type) {
|
|
6
|
-
const { actions } = useActionConfigs();
|
|
7
|
-
const config = actions?.[type];
|
|
8
|
-
if (!config)
|
|
9
|
-
throw new Error('No action!');
|
|
10
|
-
return config;
|
|
11
|
-
}
|
|
12
7
|
|
|
13
|
-
export { ActionConfigsProvider,
|
|
8
|
+
export { ActionConfigsProvider, useActionConfigs };
|
|
@@ -1,78 +1,54 @@
|
|
|
1
1
|
import { copyHandler } from '../handlers/copy.mjs';
|
|
2
2
|
import { createFolderHandler } from '../handlers/createFolder.mjs';
|
|
3
3
|
import { deleteHandler } from '../handlers/delete.mjs';
|
|
4
|
-
import '
|
|
4
|
+
import { downloadHandler } from '../handlers/download.mjs';
|
|
5
5
|
import { listLocationItemsHandler } from '../handlers/listLocationItems.mjs';
|
|
6
|
-
import
|
|
6
|
+
import '@aws-amplify/storage/internals';
|
|
7
|
+
import '@aws-amplify/ui';
|
|
7
8
|
import { uploadHandler } from '../handlers/upload.mjs';
|
|
8
9
|
|
|
9
10
|
const copyActionConfig = {
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
viewName: 'CopyView',
|
|
12
|
+
actionListItem: {
|
|
12
13
|
disable: (selected) => !selected || selected.length === 0,
|
|
13
14
|
hide: (permissions) => !permissions.includes('write'),
|
|
14
15
|
icon: 'copy-file',
|
|
15
16
|
label: 'Copy',
|
|
16
17
|
},
|
|
17
|
-
displayName: 'Copy',
|
|
18
18
|
handler: copyHandler,
|
|
19
19
|
};
|
|
20
20
|
const deleteActionConfig = {
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
viewName: 'DeleteView',
|
|
22
|
+
actionListItem: {
|
|
23
23
|
disable: (selected) => !selected || selected.length === 0,
|
|
24
24
|
hide: (permissions) => !permissions.includes('delete'),
|
|
25
25
|
icon: 'delete-file',
|
|
26
26
|
label: 'Delete',
|
|
27
27
|
},
|
|
28
|
-
displayName: 'Delete',
|
|
29
28
|
handler: deleteHandler,
|
|
30
29
|
};
|
|
31
30
|
const createFolderActionConfig = {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
disable: () => false,
|
|
31
|
+
viewName: 'CreateFolderView',
|
|
32
|
+
actionListItem: {
|
|
35
33
|
hide: (permissions) => !permissions.includes('write'),
|
|
36
34
|
icon: 'create-folder',
|
|
37
35
|
label: 'Create folder',
|
|
38
36
|
},
|
|
39
37
|
handler: createFolderHandler,
|
|
40
|
-
isCancelable: false,
|
|
41
|
-
displayName: 'Create Folder',
|
|
42
|
-
};
|
|
43
|
-
const listLocationItemsActionConfig = {
|
|
44
|
-
componentName: 'LocationDetailView',
|
|
45
|
-
handler: listLocationItemsHandler,
|
|
46
|
-
displayName: (bucket, prefix) => {
|
|
47
|
-
if (bucket && prefix) {
|
|
48
|
-
const prefixes = prefix.split('/');
|
|
49
|
-
return `${bucket}: ${prefixes.length > 2 ? `../${prefixes[prefixes.length - 2]}/` : prefix}`;
|
|
50
|
-
}
|
|
51
|
-
return !bucket ? '-' : bucket;
|
|
52
|
-
},
|
|
53
|
-
};
|
|
54
|
-
const listLocationsActionConfig = {
|
|
55
|
-
componentName: 'LocationsView',
|
|
56
|
-
handler: listLocationsHandler,
|
|
57
|
-
displayName: 'Home',
|
|
58
38
|
};
|
|
59
39
|
const uploadActionConfig = {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
disable: () => false,
|
|
63
|
-
fileSelection: 'FILE',
|
|
40
|
+
viewName: 'UploadView',
|
|
41
|
+
actionListItem: {
|
|
64
42
|
hide: (permissions) => !permissions.includes('write'),
|
|
65
43
|
icon: 'upload-file',
|
|
66
44
|
label: 'Upload',
|
|
67
45
|
},
|
|
68
|
-
isCancelable: true,
|
|
69
|
-
includeProgress: true,
|
|
70
46
|
handler: uploadHandler,
|
|
71
|
-
displayName: 'Upload',
|
|
72
47
|
};
|
|
73
48
|
const defaultActionViewConfigs = {
|
|
74
49
|
copy: copyActionConfig,
|
|
75
50
|
createFolder: createFolderActionConfig,
|
|
51
|
+
download: downloadHandler,
|
|
76
52
|
delete: deleteActionConfig,
|
|
77
53
|
upload: uploadActionConfig,
|
|
78
54
|
};
|
|
@@ -80,8 +56,7 @@ const DEFAULT_ACTION_VIEW_TYPES = Object.keys(defaultActionViewConfigs);
|
|
|
80
56
|
const isDefaultActionViewType = (value) => DEFAULT_ACTION_VIEW_TYPES.some((type) => type === value);
|
|
81
57
|
const defaultActionConfigs = {
|
|
82
58
|
...defaultActionViewConfigs,
|
|
83
|
-
listLocationItems:
|
|
84
|
-
listLocations: listLocationsActionConfig,
|
|
59
|
+
listLocationItems: listLocationItemsHandler,
|
|
85
60
|
};
|
|
86
61
|
|
|
87
|
-
export { DEFAULT_ACTION_VIEW_TYPES, copyActionConfig, createFolderActionConfig, defaultActionConfigs, defaultActionViewConfigs, deleteActionConfig, isDefaultActionViewType,
|
|
62
|
+
export { DEFAULT_ACTION_VIEW_TYPES, copyActionConfig, createFolderActionConfig, defaultActionConfigs, defaultActionViewConfigs, deleteActionConfig, isDefaultActionViewType, uploadActionConfig };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { isObject } from '@aws-amplify/ui';
|
|
2
|
+
|
|
3
|
+
const isActionConfig = (value) => isObject(value);
|
|
4
|
+
const getActionConfigs = (configs) => {
|
|
5
|
+
return Object.entries({ ...configs.default, ...configs.custom }).reduce((configs, [type, config]) => !isActionConfig(config) ? configs : { ...configs, [type]: config }, {});
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export { getActionConfigs };
|
|
@@ -2,29 +2,26 @@ import { copy } from '@aws-amplify/storage/internals';
|
|
|
2
2
|
import { constructBucket } from './utils.mjs';
|
|
3
3
|
|
|
4
4
|
const copyHandler = (input) => {
|
|
5
|
-
const { config,
|
|
5
|
+
const { config, data } = input;
|
|
6
6
|
const { accountId: expectedBucketOwner, credentials, customEndpoint, } = config;
|
|
7
|
-
const { key
|
|
7
|
+
const { key, sourceKey, lastModified, eTag } = data;
|
|
8
8
|
const bucket = constructBucket(config);
|
|
9
|
-
const destinationPath = `${path}${fileKey}`;
|
|
10
9
|
const source = {
|
|
11
10
|
bucket,
|
|
12
11
|
expectedBucketOwner,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
*/
|
|
20
|
-
path: sourcePath.split('/').map(encodeURIComponent).join('/'),
|
|
12
|
+
// Per S3 requirement, copy source must the URI encoded.
|
|
13
|
+
// This is NOT added to Amplify JS v6 because it will be a breaking
|
|
14
|
+
// change to suddenly introduce URI encode to copy API source.
|
|
15
|
+
//
|
|
16
|
+
// see: https://docs.aws.amazon.com/AmazonS3/latest/API/API_CopyObject.html#API_CopyObject_RequestSyntax
|
|
17
|
+
path: sourceKey.split('/').map(encodeURIComponent).join('/'),
|
|
21
18
|
notModifiedSince: lastModified,
|
|
22
19
|
eTag,
|
|
23
20
|
};
|
|
24
21
|
const destination = {
|
|
25
22
|
bucket,
|
|
26
23
|
expectedBucketOwner,
|
|
27
|
-
path:
|
|
24
|
+
path: key,
|
|
28
25
|
};
|
|
29
26
|
const result = copy({
|
|
30
27
|
source,
|
|
@@ -33,7 +30,10 @@ const copyHandler = (input) => {
|
|
|
33
30
|
});
|
|
34
31
|
return {
|
|
35
32
|
result: result
|
|
36
|
-
.then(() => ({
|
|
33
|
+
.then(({ path }) => ({
|
|
34
|
+
status: 'COMPLETE',
|
|
35
|
+
value: { key: path },
|
|
36
|
+
}))
|
|
37
37
|
.catch(({ message }) => ({ message, status: 'FAILED' })),
|
|
38
38
|
};
|
|
39
39
|
};
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { uploadData } from '@aws-amplify/storage/internals';
|
|
2
1
|
import { isFunction } from '@aws-amplify/ui';
|
|
2
|
+
import { uploadData } from '@aws-amplify/storage/internals';
|
|
3
3
|
import { getProgress, constructBucket } from './utils.mjs';
|
|
4
4
|
|
|
5
5
|
const createFolderHandler = (input) => {
|
|
6
|
-
const {
|
|
6
|
+
const { config, data, options } = input;
|
|
7
7
|
const { accountId, credentials, customEndpoint } = config;
|
|
8
|
-
const { onProgress
|
|
9
|
-
const { key } = data;
|
|
8
|
+
const { onProgress } = options ?? {};
|
|
9
|
+
const { key, preventOverwrite } = data;
|
|
10
10
|
const bucket = constructBucket(config);
|
|
11
11
|
const { result } = uploadData({
|
|
12
|
-
path:
|
|
12
|
+
path: key,
|
|
13
13
|
data: '',
|
|
14
14
|
options: {
|
|
15
15
|
bucket,
|
|
@@ -25,7 +25,10 @@ const createFolderHandler = (input) => {
|
|
|
25
25
|
});
|
|
26
26
|
return {
|
|
27
27
|
result: result
|
|
28
|
-
.then(() => ({
|
|
28
|
+
.then(({ path }) => ({
|
|
29
|
+
status: 'COMPLETE',
|
|
30
|
+
value: { key: path },
|
|
31
|
+
}))
|
|
29
32
|
.catch(({ message, name }) => {
|
|
30
33
|
if (name === 'PreconditionFailed') {
|
|
31
34
|
return { message, status: 'OVERWRITE_PREVENTED' };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { remove } from '@aws-amplify/storage/internals';
|
|
2
2
|
import { constructBucket } from './utils.mjs';
|
|
3
3
|
|
|
4
|
-
const deleteHandler = ({ config, data
|
|
4
|
+
const deleteHandler = ({ config, data, }) => {
|
|
5
|
+
const { key } = data;
|
|
5
6
|
const { accountId, credentials, customEndpoint } = config;
|
|
6
7
|
const result = remove({
|
|
7
8
|
path: key,
|
|
@@ -11,12 +12,13 @@ const deleteHandler = ({ config, data: { key }, }) => {
|
|
|
11
12
|
expectedBucketOwner: accountId,
|
|
12
13
|
customEndpoint,
|
|
13
14
|
},
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
})
|
|
16
|
+
.then(({ path }) => ({
|
|
17
|
+
status: 'COMPLETE',
|
|
18
|
+
value: { key: path },
|
|
19
|
+
}))
|
|
20
|
+
.catch(({ message }) => ({ message, status: 'FAILED' }));
|
|
21
|
+
return { result };
|
|
20
22
|
};
|
|
21
23
|
|
|
22
24
|
export { deleteHandler };
|
|
@@ -22,17 +22,13 @@ const downloadHandler = ({ config, data: { key }, }) => {
|
|
|
22
22
|
contentDisposition: 'attachment',
|
|
23
23
|
expectedBucketOwner: accountId,
|
|
24
24
|
},
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return { status: 'COMPLETE' };
|
|
33
|
-
})
|
|
34
|
-
.catch(({ message }) => ({ message, status: 'FAILED' })),
|
|
35
|
-
};
|
|
25
|
+
})
|
|
26
|
+
.then(({ url }) => {
|
|
27
|
+
downloadFromUrl(key, url.toString());
|
|
28
|
+
return { status: 'COMPLETE', value: { url } };
|
|
29
|
+
})
|
|
30
|
+
.catch(({ message }) => ({ message, status: 'FAILED' }));
|
|
31
|
+
return { result };
|
|
36
32
|
};
|
|
37
33
|
|
|
38
34
|
export { downloadHandler };
|
|
@@ -39,9 +39,9 @@ const listLocationItemsHandler = async (input) => {
|
|
|
39
39
|
delimiter,
|
|
40
40
|
strategy: delimiter ? 'exclude' : 'include',
|
|
41
41
|
};
|
|
42
|
-
// `ListObjectsV2` returns the root `key` on initial request
|
|
43
|
-
// filtered from `results` by `parseResult`,
|
|
44
|
-
// return count of `results`
|
|
42
|
+
// `ListObjectsV2` returns the root `key` on initial request which, when from
|
|
43
|
+
// filtered from `results` by `parseResult`, creates a scenario where the
|
|
44
|
+
// return count of `results` is one item less than the provided `pageSize`.
|
|
45
45
|
// To mitigate, if a `pageSize` is provided and there are no previous `results`
|
|
46
46
|
// or `refresh` is `true` increment the provided `pageSize` by `1`
|
|
47
47
|
const hasOffset = !nextToken;
|
|
@@ -6,17 +6,18 @@ import { constructBucket, getProgress } from './utils.mjs';
|
|
|
6
6
|
// 5MB for multipart upload
|
|
7
7
|
// https://github.com/aws-amplify/amplify-js/blob/1a5366d113c9af4ce994168653df3aadb142c581/packages/storage/src/providers/s3/utils/constants.ts#L16
|
|
8
8
|
const MULTIPART_UPLOAD_THRESHOLD_BYTES = 5 * 1024 * 1024;
|
|
9
|
+
const DEFAULT_CHECKSUM_ALGORITHM = 'crc-32';
|
|
9
10
|
const UNDEFINED_CALLBACKS = {
|
|
10
11
|
cancel: undefined,
|
|
11
12
|
pause: undefined,
|
|
12
13
|
resume: undefined,
|
|
13
14
|
};
|
|
14
|
-
const uploadHandler = ({ config, data,
|
|
15
|
+
const uploadHandler = ({ config, data, options }) => {
|
|
15
16
|
const { accountId, credentials, customEndpoint } = config;
|
|
16
|
-
const { key, file } = data;
|
|
17
|
-
const { onProgress
|
|
17
|
+
const { key, file, preventOverwrite } = data;
|
|
18
|
+
const { onProgress } = options ?? {};
|
|
18
19
|
const input = {
|
|
19
|
-
path:
|
|
20
|
+
path: key,
|
|
20
21
|
data: file,
|
|
21
22
|
options: {
|
|
22
23
|
bucket: constructBucket(config),
|
|
@@ -28,7 +29,7 @@ const uploadHandler = ({ config, data, destinationPrefix, options, }) => {
|
|
|
28
29
|
},
|
|
29
30
|
preventOverwrite,
|
|
30
31
|
customEndpoint,
|
|
31
|
-
checksumAlgorithm:
|
|
32
|
+
checksumAlgorithm: DEFAULT_CHECKSUM_ALGORITHM,
|
|
32
33
|
},
|
|
33
34
|
};
|
|
34
35
|
const { cancel, pause, resume, result } = uploadData(input);
|
|
@@ -37,7 +38,10 @@ const uploadHandler = ({ config, data, destinationPrefix, options, }) => {
|
|
|
37
38
|
? { cancel, pause, resume }
|
|
38
39
|
: UNDEFINED_CALLBACKS),
|
|
39
40
|
result: result
|
|
40
|
-
.then(() => ({
|
|
41
|
+
.then((output) => ({
|
|
42
|
+
status: 'COMPLETE',
|
|
43
|
+
value: { key: output.path },
|
|
44
|
+
}))
|
|
41
45
|
.catch((error) => {
|
|
42
46
|
const { message } = error;
|
|
43
47
|
if (error.name === 'PreconditionFailed') {
|
|
@@ -51,4 +55,4 @@ const uploadHandler = ({ config, data, destinationPrefix, options, }) => {
|
|
|
51
55
|
};
|
|
52
56
|
};
|
|
53
57
|
|
|
54
|
-
export { MULTIPART_UPLOAD_THRESHOLD_BYTES, UNDEFINED_CALLBACKS, uploadHandler };
|
|
58
|
+
export { DEFAULT_CHECKSUM_ALGORITHM, MULTIPART_UPLOAD_THRESHOLD_BYTES, UNDEFINED_CALLBACKS, uploadHandler };
|
|
@@ -82,18 +82,8 @@ const createFileDataItem = (data) => ({
|
|
|
82
82
|
...data,
|
|
83
83
|
fileKey: getFileKey(data.key),
|
|
84
84
|
});
|
|
85
|
-
const createFileDataItemFromLocation = (data) => ({
|
|
86
|
-
id: data.id,
|
|
87
|
-
type: 'FILE',
|
|
88
|
-
key: data.prefix,
|
|
89
|
-
fileKey: getFileKey(data.prefix),
|
|
90
|
-
// `lastModified` and `size` included to satisfy
|
|
91
|
-
// expected shape of `FileDataItem`
|
|
92
|
-
lastModified: new Date(),
|
|
93
|
-
size: 0,
|
|
94
|
-
});
|
|
95
85
|
const isFileItem = (value) => !!value.file;
|
|
96
86
|
const isFileDataItem = (item) => !!item.fileKey;
|
|
97
87
|
const getProgress = ({ totalBytes, transferredBytes, }) => totalBytes ? transferredBytes / totalBytes : undefined;
|
|
98
88
|
|
|
99
|
-
export { constructBucket, createFileDataItem,
|
|
89
|
+
export { constructBucket, createFileDataItem, getFileKey, getFilteredLocations, getProgress, isFileDataItem, isFileItem, parseAccessGrantLocation, shouldExcludeLocation };
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { createLocationCredentialsHandler } from './createLocationCredentialsHandler.mjs';
|
|
2
|
-
import '../../actions/configs/context.mjs';
|
|
3
2
|
import '@aws-amplify/storage/internals';
|
|
4
3
|
import '@aws-amplify/ui';
|
|
5
4
|
import { listLocationsHandler } from '../../actions/handlers/listLocations.mjs';
|
|
6
5
|
import 'aws-amplify/storage';
|
|
7
|
-
import '
|
|
8
|
-
import '@aws-amplify/ui-react-core';
|
|
6
|
+
import '../../actions/configs/context.mjs';
|
|
9
7
|
|
|
10
8
|
/**
|
|
11
9
|
* Create configuration including handlers to call S3 Access Grant APIs to list and get
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import React__default from 'react';
|
|
2
2
|
import { Pagination } from '../composables/Pagination.mjs';
|
|
3
3
|
import { useResolvedComposable } from './hooks/useResolvedComposable.mjs';
|
|
4
|
-
import {
|
|
4
|
+
import { usePagination } from './hooks/usePagination.mjs';
|
|
5
5
|
|
|
6
6
|
const PaginationControl = () => {
|
|
7
|
-
const
|
|
7
|
+
const props = usePagination();
|
|
8
8
|
const Resolved = useResolvedComposable(Pagination, 'Pagination');
|
|
9
|
-
return React__default.createElement(Resolved, { ...
|
|
9
|
+
return React__default.createElement(Resolved, { ...props });
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
export { PaginationControl };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
import { SearchField } from '../composables/SearchField.mjs';
|
|
3
|
+
import { useResolvedComposable } from './hooks/useResolvedComposable.mjs';
|
|
4
|
+
import { useSearchField } from './hooks/useSearchField.mjs';
|
|
5
|
+
|
|
6
|
+
const SearchFieldControl = () => {
|
|
7
|
+
const props = useSearchField();
|
|
8
|
+
const Resolved = useResolvedComposable(SearchField, 'SearchField');
|
|
9
|
+
return React__default.createElement(Resolved, { ...props });
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export { SearchFieldControl };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { useControlsContext } from '../context.mjs';
|
|
2
|
+
|
|
3
|
+
const useSearchField = () => {
|
|
4
|
+
const { data, onSearch, onSearchClear, onSearchQueryChange } = useControlsContext();
|
|
5
|
+
const { searchPlaceholder, searchClearLabel, searchQuery, searchSubmitLabel, } = data;
|
|
6
|
+
return {
|
|
7
|
+
clearLabel: searchClearLabel,
|
|
8
|
+
placeholder: searchPlaceholder,
|
|
9
|
+
query: searchQuery,
|
|
10
|
+
submitLabel: searchSubmitLabel,
|
|
11
|
+
onClear: onSearchClear,
|
|
12
|
+
onQueryChange: onSearchQueryChange,
|
|
13
|
+
onSearch,
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export { useSearchField };
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
import React__default from 'react';
|
|
2
|
+
import { setUserAgent } from '@aws-amplify/ui';
|
|
3
|
+
import { VERSION } from '../../version.mjs';
|
|
4
|
+
import '@aws-amplify/storage/internals';
|
|
5
|
+
import { assertRegisterAuthListener } from './validators/assertRegisterAuthListener.mjs';
|
|
6
|
+
import 'aws-amplify/storage';
|
|
7
|
+
import { ActionConfigsProvider } from './actions/configs/context.mjs';
|
|
8
|
+
import { defaultActionConfigs } from './actions/configs/defaults.mjs';
|
|
9
|
+
import { getActionConfigs } from './actions/configs/utils.mjs';
|
|
2
10
|
import './composables/context.mjs';
|
|
3
11
|
import { DEFAULT_COMPOSABLES } from './composables/defaults.mjs';
|
|
4
12
|
import { elementsDefault } from './context/elements/defaults.mjs';
|
|
@@ -7,45 +15,50 @@ import './context/elements/IconElement.mjs';
|
|
|
7
15
|
import { ComponentsProvider } from './ComponentsProvider.mjs';
|
|
8
16
|
import { componentsDefault } from './componentsDefault.mjs';
|
|
9
17
|
import { ErrorBoundary } from './ErrorBoundary/ErrorBoundary.mjs';
|
|
10
|
-
import './providers/configuration/context.mjs';
|
|
11
18
|
import { createConfigurationProvider } from './providers/configuration/createConfigurationProvider.mjs';
|
|
19
|
+
import './providers/configuration/context.mjs';
|
|
12
20
|
import { StoreProvider } from './providers/store/StoreProvider.mjs';
|
|
13
21
|
import './providers/store/actionType/context.mjs';
|
|
14
22
|
import './providers/store/files/context.mjs';
|
|
15
23
|
import './providers/store/location/context.mjs';
|
|
16
24
|
import './providers/store/locationItems/context.mjs';
|
|
17
25
|
import { StorageBrowserDefault } from './StorageBrowserDefault.mjs';
|
|
18
|
-
import '@aws-amplify/ui';
|
|
19
|
-
import { assertRegisterAuthListener } from './validators/assertRegisterAuthListener.mjs';
|
|
20
26
|
import { CopyView } from './views/LocationActionView/CopyView/CopyView.mjs';
|
|
21
|
-
import '
|
|
22
|
-
import '
|
|
27
|
+
import { ActionHandlersProvider } from './useAction/context.mjs';
|
|
28
|
+
import { useAction } from './useAction/useAction.mjs';
|
|
23
29
|
import '@aws-amplify/ui-react-core';
|
|
24
|
-
import './
|
|
25
|
-
import { defaultActionConfigs } from './actions/configs/defaults.mjs';
|
|
30
|
+
import { getActionHandlers } from './useAction/utils.mjs';
|
|
26
31
|
import { CreateFolderView } from './views/LocationActionView/CreateFolderView/CreateFolderView.mjs';
|
|
27
32
|
import { DeleteView } from './views/LocationActionView/DeleteView/DeleteView.mjs';
|
|
28
|
-
import { UploadView } from './views/LocationActionView/UploadView/UploadView.mjs';
|
|
29
33
|
import { LocationActionView } from './views/LocationActionView/LocationActionView.mjs';
|
|
34
|
+
import { UploadView } from './views/LocationActionView/UploadView/UploadView.mjs';
|
|
30
35
|
import { LocationDetailView } from './views/LocationDetailView/LocationDetailView.mjs';
|
|
31
36
|
import { LocationsView } from './views/LocationsView/LocationsView.mjs';
|
|
32
|
-
import {
|
|
37
|
+
import { useView } from './views/useView.mjs';
|
|
38
|
+
import { ViewsProvider } from './views/context/views.mjs';
|
|
33
39
|
import { DisplayTextProvider } from './displayText/context.mjs';
|
|
34
|
-
import { createUseView } from './views/createUseView.mjs';
|
|
35
40
|
|
|
36
41
|
function createStorageBrowser(input) {
|
|
37
42
|
assertRegisterAuthListener(input.config.registerAuthListener);
|
|
38
43
|
const { accountId, customEndpoint, registerAuthListener, getLocationCredentials, region, } = input.config;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
44
|
+
setUserAgent({
|
|
45
|
+
componentName: 'StorageBrowser',
|
|
46
|
+
packageName: 'react-storage',
|
|
47
|
+
version: VERSION,
|
|
48
|
+
});
|
|
49
|
+
const actions = {
|
|
50
|
+
default: {
|
|
42
51
|
...defaultActionConfigs,
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
handler: input.config.listLocations,
|
|
47
|
-
},
|
|
52
|
+
...input.actions?.default,
|
|
53
|
+
// always last
|
|
54
|
+
listLocations: input.config.listLocations,
|
|
48
55
|
},
|
|
56
|
+
custom: input.actions?.custom,
|
|
57
|
+
};
|
|
58
|
+
const handlers = getActionHandlers(actions);
|
|
59
|
+
const actionConfigs = getActionConfigs(actions);
|
|
60
|
+
const ConfigurationProvider = createConfigurationProvider({
|
|
61
|
+
accountId,
|
|
49
62
|
customEndpoint,
|
|
50
63
|
displayName: 'ConfigurationProvider',
|
|
51
64
|
getLocationCredentials,
|
|
@@ -64,17 +77,20 @@ function createStorageBrowser(input) {
|
|
|
64
77
|
* Provides state, configuration and action values that are shared between
|
|
65
78
|
* the primary View components
|
|
66
79
|
*/
|
|
67
|
-
function Provider({ children, ...props }) {
|
|
80
|
+
function Provider({ children, displayText, views, ...props }) {
|
|
68
81
|
return (React__default.createElement(StoreProvider, { ...props },
|
|
69
82
|
React__default.createElement(ConfigurationProvider, null,
|
|
70
|
-
React__default.createElement(
|
|
71
|
-
React__default.createElement(
|
|
83
|
+
React__default.createElement(ActionConfigsProvider, { actionConfigs: actionConfigs },
|
|
84
|
+
React__default.createElement(ActionHandlersProvider, { handlers: handlers },
|
|
85
|
+
React__default.createElement(DisplayTextProvider, { displayText: displayText },
|
|
86
|
+
React__default.createElement(ViewsProvider, { actions: actions, views: views },
|
|
87
|
+
React__default.createElement(ComponentsProvider, { composables: composables, elements: elementsDefault }, children))))))));
|
|
72
88
|
}
|
|
73
89
|
const StorageBrowser = ({ views, displayText }) => (React__default.createElement(ErrorBoundary, null,
|
|
74
|
-
React__default.createElement(Provider, { displayText: displayText },
|
|
75
|
-
React__default.createElement(
|
|
76
|
-
|
|
77
|
-
|
|
90
|
+
React__default.createElement(Provider, { displayText: displayText, views: views },
|
|
91
|
+
React__default.createElement(StorageBrowserDefault, null))));
|
|
92
|
+
StorageBrowser.LocationActionView =
|
|
93
|
+
LocationActionView;
|
|
78
94
|
StorageBrowser.LocationDetailView = LocationDetailView;
|
|
79
95
|
StorageBrowser.LocationsView = LocationsView;
|
|
80
96
|
StorageBrowser.CopyView = CopyView;
|
|
@@ -83,8 +99,7 @@ function createStorageBrowser(input) {
|
|
|
83
99
|
StorageBrowser.UploadView = UploadView;
|
|
84
100
|
StorageBrowser.Provider = Provider;
|
|
85
101
|
StorageBrowser.displayName = 'StorageBrowser';
|
|
86
|
-
|
|
87
|
-
return { StorageBrowser, useView };
|
|
102
|
+
return { StorageBrowser, useAction, useView };
|
|
88
103
|
}
|
|
89
104
|
|
|
90
105
|
export { createStorageBrowser };
|
|
@@ -14,6 +14,12 @@ const DEFAULT_LOCATION_DETAIL_VIEW_DISPLAY_TEXT = {
|
|
|
14
14
|
content: message ?? DEFAULT_ERROR_MESSAGE,
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
|
+
if (!items?.length && hasExhaustedSearch) {
|
|
18
|
+
return {
|
|
19
|
+
type: 'info',
|
|
20
|
+
content: `No results found in the first 10,000 items.`,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
17
23
|
if (!items?.length) {
|
|
18
24
|
return {
|
|
19
25
|
type: 'info',
|