@scaleflex/widget-core 0.0.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/CHANGELOG.md +7324 -0
- package/LICENSE +21 -0
- package/README.md +1089 -0
- package/dist/style.css +190 -0
- package/dist/style.min.css +1 -0
- package/lib/Client.js +390 -0
- package/lib/Plugin.js +298 -0
- package/lib/Providers.js +112 -0
- package/lib/SassKeyRenewer.js +332 -0
- package/lib/_common.scss +240 -0
- package/lib/_utils.scss +38 -0
- package/lib/_variables.scss +64 -0
- package/lib/createStore.js +45 -0
- package/lib/defaultLocale.js +66 -0
- package/lib/hooks/index.js +7 -0
- package/lib/hooks/useContextMenu.js +42 -0
- package/lib/hooks/useContextMenuData.js +17 -0
- package/lib/hooks/useCore.js +10 -0
- package/lib/hooks/useModal.js +72 -0
- package/lib/hooks/useModalData.js +7 -0
- package/lib/hooks/usePlugin.js +20 -0
- package/lib/hooks/usePluginsType.js +18 -0
- package/lib/index.js +1918 -0
- package/lib/loggers.js +45 -0
- package/lib/slices/common.slice.js +90 -0
- package/lib/slices/index.js +12 -0
- package/lib/slices/info.slice.js +52 -0
- package/lib/slices/uploads.slice.js +294 -0
- package/lib/slices/user.slice.js +256 -0
- package/lib/style.scss +3 -0
- package/lib/supportsUploadProgress.js +42 -0
- package/lib/utils/calculateTotalEta.js +21 -0
- package/package.json +38 -0
- package/types/index.d.ts +301 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
+
import { combineReducers, configureStore } from '@reduxjs/toolkit';
|
|
8
|
+
import { PLUGINS_IDS } from '@scaleflex/widget-utils/lib/constants';
|
|
9
|
+
import coreReducer from './slices';
|
|
10
|
+
var createRootReducer = function createRootReducer(dynamicReducers) {
|
|
11
|
+
return combineReducers(_objectSpread(_defineProperty({}, PLUGINS_IDS.CORE, coreReducer), dynamicReducers));
|
|
12
|
+
};
|
|
13
|
+
var createStore = function createStore(apiClient) {
|
|
14
|
+
var customMiddlewares = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
15
|
+
var filerobot = arguments.length > 2 ? arguments[2] : undefined;
|
|
16
|
+
var store = configureStore({
|
|
17
|
+
middleware: function middleware(getDefaultMiddleware) {
|
|
18
|
+
return getDefaultMiddleware({
|
|
19
|
+
thunk: {
|
|
20
|
+
extraArgument: {
|
|
21
|
+
apiClient: apiClient,
|
|
22
|
+
filerobot: filerobot
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
// serializableCheck: false // TODO: remove this line after fixing the issue with serializableCheck
|
|
26
|
+
}).concat(customMiddlewares);
|
|
27
|
+
},
|
|
28
|
+
reducer: createRootReducer(),
|
|
29
|
+
devTools: {
|
|
30
|
+
trace: process.env.NODE_ENV === 'development' || process.env.REACT_APP_GITLAB_REVIEW_ENV === 'true',
|
|
31
|
+
traceLimit: 25
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
store.dynamicReducers = {};
|
|
35
|
+
store.injectReducer = function (key, asyncReducer) {
|
|
36
|
+
store.dynamicReducers[key] = asyncReducer;
|
|
37
|
+
store.replaceReducer(createRootReducer(store.dynamicReducers));
|
|
38
|
+
};
|
|
39
|
+
store.removeReducer = function (key) {
|
|
40
|
+
delete store.dynamicReducers[key];
|
|
41
|
+
store.replaceReducer(createRootReducer(store.dynamicReducers));
|
|
42
|
+
};
|
|
43
|
+
return store;
|
|
44
|
+
};
|
|
45
|
+
export default createStore;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
addBulkFilesFailedMessage: {
|
|
3
|
+
0: 'Failed to add %{smart_count} file due to an internal error',
|
|
4
|
+
1: 'Failed to add %{smart_count} files due to internal errors'
|
|
5
|
+
},
|
|
6
|
+
filerobotYouCanOnlyUploadXError: {
|
|
7
|
+
0: 'You can only upload %{smart_count} file',
|
|
8
|
+
1: 'You can only upload %{smart_count} files'
|
|
9
|
+
},
|
|
10
|
+
filerobotYouHaveToAtLeastSelectXError: {
|
|
11
|
+
0: 'You have to select at least %{smart_count} file',
|
|
12
|
+
1: 'You have to select at least %{smart_count} files'
|
|
13
|
+
},
|
|
14
|
+
filerobotExceedsSizeError: 'This file exceeds maximum allowed size of %{size}',
|
|
15
|
+
filerobotFilesExceedsSizeError: 'These files exceed maximum allowed size of %{size}MB',
|
|
16
|
+
filerobotYouCanOnlyUploadFileTypesError: 'You can only upload: %{types}',
|
|
17
|
+
filerobotNoNewAlreadyUploadingError: 'Cannot add new files: already uploading',
|
|
18
|
+
filerobotNoDuplicatesError: 'Cannot add the duplicate file \'%{fileName}\', it already exists',
|
|
19
|
+
filerobotAddedUploadedFilesError: 'Files are already added to the uploads panel, please close it first',
|
|
20
|
+
providerViewCompanionError: 'Connection with Companion failed',
|
|
21
|
+
providerViewCompanionUnauthorizeMessage: 'To unauthorize to your %{provider} account, please go to %{url}',
|
|
22
|
+
filerobotFailedToUploadError: 'Failed to upload %{file}',
|
|
23
|
+
filerobotNoInternetConnectionInfo: 'No Internet connection',
|
|
24
|
+
filerobotConnectedToInternetInfo: 'Connected to the Internet',
|
|
25
|
+
// Strings for remote providers
|
|
26
|
+
foldersViewDragAndDropFilesHereText: 'You can drag & drop files right here',
|
|
27
|
+
foldersViewNoFilesFoundText: 'No files here',
|
|
28
|
+
mutualizedSelectFileNamedLabel: 'Select file %{name}',
|
|
29
|
+
mutualizedUnselectFileNamedLabel: 'Unselect file %{name}',
|
|
30
|
+
mutualizedOpenFolderNamedLabel: 'Open folder %{name}',
|
|
31
|
+
headBarLogOutText: 'Log out',
|
|
32
|
+
explorerTopBarFilterText: 'Filter',
|
|
33
|
+
authViewAuthenticateText: 'Please authenticate with %{pluginName} to select files',
|
|
34
|
+
authViewConnectToButton: 'Connect to %{pluginName}',
|
|
35
|
+
filerobotEmptyFolderAddedMessage: 'No files were added from empty folder',
|
|
36
|
+
filerobotFolderAddedMessage: {
|
|
37
|
+
0: 'Added %{smart_count} file from %{folder}',
|
|
38
|
+
1: 'Added %{smart_count} files from %{folder}'
|
|
39
|
+
},
|
|
40
|
+
explorerServiceUnknownBackendError: 'Unknown error while communicating with server, try again later',
|
|
41
|
+
foldersViewNameLabel: 'Name',
|
|
42
|
+
listViewTableColHeaderSize: 'Assets',
|
|
43
|
+
mutualizedLastModifyLabel: 'Last modify',
|
|
44
|
+
filerobotNoPermissionsInfo: 'No user permissions, ask your admin to add permissions to your account.',
|
|
45
|
+
filerobotInvalidPermissionError: 'Sorry but you are not permitted to do this operation.',
|
|
46
|
+
filerobotFolderUploadingNotAllowedError: 'Your permissions doesn\'t include uploading to this folder (%{folder}).',
|
|
47
|
+
filerobotRestrictedFileError: 'Can not upload %{file_extension} file',
|
|
48
|
+
explorerValidatingCsvFailureError: 'Validating CSV file failed.',
|
|
49
|
+
explorerUpdateViaCsvModalUploadFailedError: 'Upload failed.',
|
|
50
|
+
explorerExceedsCompressionSizeError: 'Downloading of more than %{size} for simultaneous files is not allowed, retry selecting fewer files.',
|
|
51
|
+
explorerDropFilesHint: 'Drop your files here',
|
|
52
|
+
explorerTopBarAsOriginalText: 'As original',
|
|
53
|
+
explorerTopBarAsCsvText: 'List of assets (CSV)',
|
|
54
|
+
explorerCompressionAllowedOnceWarning: 'Please wait till the current compression is finished & try again.',
|
|
55
|
+
contextMenuDownloadOptionsLabel: 'Transformation',
|
|
56
|
+
commonOptionsNoMetadataAvailableTooltip: 'No metadata available',
|
|
57
|
+
informerSeeDetailsButtonLabel: 'See details',
|
|
58
|
+
informerErrorsModalTitle: 'Error details',
|
|
59
|
+
informerErrorsModalCopyButton: 'Copy',
|
|
60
|
+
informerErrorsModalSuccessCopyMsg: 'Errors copied successfully',
|
|
61
|
+
loaderLoadingLabel: 'Loading',
|
|
62
|
+
mutualizedUnknownErrorMessage: 'Unknown error, make sure you have internet connection or try again later',
|
|
63
|
+
explorerServiceEmptySassKeyHeaderError: 'Required request header is missing',
|
|
64
|
+
explorerServiceExpiredSassKeyHeaderError: 'Your permission credential (SASS key) has expired - please relogin to continue',
|
|
65
|
+
explorerResumableUploadFastestServerError: 'A connection could not be established with the upload servers - please contact support@scaleflex.com'
|
|
66
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { default as usePlugin } from './usePlugin';
|
|
2
|
+
export { default as usePluginsType } from './usePluginsType';
|
|
3
|
+
export { default as useModal } from './useModal';
|
|
4
|
+
export { default as useModalData } from './useModalData';
|
|
5
|
+
export { default as useCore } from './useCore';
|
|
6
|
+
export { default as useContextMenu } from './useContextMenu';
|
|
7
|
+
export { default as useContextMenuData } from './useContextMenuData';
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
+
import { useCallback, useContext } from 'react';
|
|
8
|
+
import { ContextMenuDispatcherContext } from '../Providers';
|
|
9
|
+
|
|
10
|
+
// data === {
|
|
11
|
+
// isOpen = true/false, - no need to provide it, it gets handled automatically depending on ur provided props or not.
|
|
12
|
+
// event = {}, foldersUuids = [], filesUuids = [], type = CONTEXTMENU_TYPES.FILE,
|
|
13
|
+
// mode = CONTEXTMENU_MODES.AUTO, options = null // options has priority over mode, if there is options mode will be dismissed otherwise mode is used.
|
|
14
|
+
// items = null/[...] // used in case of other items not file/folder, ex. versioning.,
|
|
15
|
+
// itemsPropName = 'items' // used in case u need to provide the items with a different prop name for the context menu's options to work,
|
|
16
|
+
// --- ex. (itemsPropName: 'folders') then instead of `items: [folder1, folder2]`, it would be folders: `[folder1, folder2]`.
|
|
17
|
+
// fromSidebar = false
|
|
18
|
+
// }
|
|
19
|
+
var useContextMenu = function useContextMenu() {
|
|
20
|
+
var setContextMenuData = useContext(ContextMenuDispatcherContext);
|
|
21
|
+
|
|
22
|
+
// any update (object) provided to the context's data will open the context menu
|
|
23
|
+
// any falsy/undefined value will close the context menu
|
|
24
|
+
var updateContextMenuData = useCallback(function () {
|
|
25
|
+
var update = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
26
|
+
if (update !== null && update !== void 0 && update.event) {
|
|
27
|
+
update.event.preventDefault();
|
|
28
|
+
update.event.stopPropagation();
|
|
29
|
+
update.event.currentTarget.focus(); // requires tabIndex for non-focusable elements.
|
|
30
|
+
}
|
|
31
|
+
return setContextMenuData(function (prev) {
|
|
32
|
+
var updates = typeof update === 'function' ? update(prev) : update;
|
|
33
|
+
return updates && Object.keys(updates).length > 0 ? _objectSpread(_objectSpread({}, updates), {}, {
|
|
34
|
+
isOpen: true
|
|
35
|
+
}) : {
|
|
36
|
+
isOpen: false
|
|
37
|
+
};
|
|
38
|
+
});
|
|
39
|
+
}, [setContextMenuData]);
|
|
40
|
+
return updateContextMenuData;
|
|
41
|
+
};
|
|
42
|
+
export default useContextMenu;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { useContext } from 'react';
|
|
2
|
+
import { ContextMenuDataContext } from '../Providers';
|
|
3
|
+
|
|
4
|
+
// data === {
|
|
5
|
+
// isOpen = true/false, - no need to provide it, it gets handled automatically depending on ur provided props or not.
|
|
6
|
+
// event = {}, foldersUuids = [], filesUuids = [], type = CONTEXTMENU_TYPES.FILE,
|
|
7
|
+
// mode = CONTEXTMENU_MODES.AUTO, options = null // options has priority over mode, if there is options mode will be dismissed otherwise mode is used.
|
|
8
|
+
// items = null/[...] // used in case of other items not file/folder, ex. versioning.,
|
|
9
|
+
// itemsPropName = 'items' // used in case u need to provide the items with a different prop name for the context menu's options to work,
|
|
10
|
+
// --- ex. (itemsPropName: 'folders') then instead of `items: [folder1, folder2]`, it would be folders: `[folder1, folder2]`.
|
|
11
|
+
// fromSidebar = false
|
|
12
|
+
// }
|
|
13
|
+
var useContextMenuData = function useContextMenuData() {
|
|
14
|
+
var contextMenuData = useContext(ContextMenuDataContext);
|
|
15
|
+
return contextMenuData;
|
|
16
|
+
};
|
|
17
|
+
export default useContextMenuData;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { useContext, useMemo } from 'react';
|
|
2
|
+
import { FilerobotPackagesContext } from '../Providers';
|
|
3
|
+
var useCore = function useCore() {
|
|
4
|
+
var _useContext = useContext(FilerobotPackagesContext),
|
|
5
|
+
filerobot = _useContext.filerobot;
|
|
6
|
+
return useMemo(function () {
|
|
7
|
+
return filerobot;
|
|
8
|
+
}, [filerobot]);
|
|
9
|
+
};
|
|
10
|
+
export default useCore;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
+
import { useCallback, useContext } from 'react';
|
|
8
|
+
import { ModalDispatcherContext } from '../Providers';
|
|
9
|
+
|
|
10
|
+
// isHigherLvlModal: if `true`, it will return a function that will return another level of modal's data
|
|
11
|
+
// to be passed to first level/root modal and open moreover higher/another level of modal on top of it.
|
|
12
|
+
// isGlobalHigherLvlModal: if `true` will return a function updated the higher lvl modal data
|
|
13
|
+
var useModal = function useModal() {
|
|
14
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
15
|
+
_ref$isHigherLvlModal = _ref.isHigherLvlModal,
|
|
16
|
+
isHigherLvlModal = _ref$isHigherLvlModal === void 0 ? false : _ref$isHigherLvlModal,
|
|
17
|
+
_ref$isGlobalHigherLv = _ref.isGlobalHigherLvlModal,
|
|
18
|
+
isGlobalHigherLvlModal = _ref$isGlobalHigherLv === void 0 ? false : _ref$isGlobalHigherLv;
|
|
19
|
+
var setModalData = useContext(ModalDispatcherContext);
|
|
20
|
+
|
|
21
|
+
// any update (object) provided to the context's data will open the context menu
|
|
22
|
+
// any falsy/undefined value will close the context menu
|
|
23
|
+
var updateModalData = useCallback(function () {
|
|
24
|
+
var update = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
25
|
+
return setModalData(function (prev) {
|
|
26
|
+
var updates = typeof update === 'function' ? update(prev) : update;
|
|
27
|
+
return updates && Object.keys(updates).length > 0 ? _objectSpread(_objectSpread({}, updates), {}, {
|
|
28
|
+
isOpen: true
|
|
29
|
+
}) : {
|
|
30
|
+
isOpen: false
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
}, []);
|
|
34
|
+
var getHigherLvlModalData = useCallback(function (update) {
|
|
35
|
+
var updates = update;
|
|
36
|
+
if (typeof update === 'function') {
|
|
37
|
+
setModalData(function (firstLevelModalState) {
|
|
38
|
+
updates = update(firstLevelModalState);
|
|
39
|
+
return isGlobalHigherLvlModal ? {
|
|
40
|
+
higherLevelModalData: updates
|
|
41
|
+
} : firstLevelModalState;
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
var hasUpdates = updates && Object.keys(updates).length > 0;
|
|
45
|
+
if (isGlobalHigherLvlModal) {
|
|
46
|
+
setModalData(function (firstLevelModalState) {
|
|
47
|
+
var _updates;
|
|
48
|
+
if ((_updates = updates) !== null && _updates !== void 0 && _updates.higherLevelModalData) {
|
|
49
|
+
updates = _objectSpread(_objectSpread({}, updates), updates.higherLevelModalData);
|
|
50
|
+
delete updates.higherLevelModalData;
|
|
51
|
+
}
|
|
52
|
+
return _objectSpread(_objectSpread({}, firstLevelModalState), {}, {
|
|
53
|
+
higherLevelModalData: hasUpdates ? _objectSpread(_objectSpread({}, updates), {}, {
|
|
54
|
+
isOpen: true
|
|
55
|
+
}) : undefined
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
updates = {
|
|
59
|
+
higherLevelModalData: _objectSpread(_objectSpread({}, updates), {}, {
|
|
60
|
+
isOpen: true
|
|
61
|
+
})
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
return hasUpdates ? _objectSpread(_objectSpread({}, updates), {}, {
|
|
65
|
+
isOpen: true
|
|
66
|
+
}) : {
|
|
67
|
+
isOpen: false
|
|
68
|
+
};
|
|
69
|
+
}, []);
|
|
70
|
+
return isHigherLvlModal || isGlobalHigherLvlModal ? getHigherLvlModalData : updateModalData;
|
|
71
|
+
};
|
|
72
|
+
export default useModal;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useContext, useMemo } from 'react';
|
|
2
|
+
import { FilerobotPackagesContext } from '../Providers';
|
|
3
|
+
var usePlugin = function usePlugin(pluginId) {
|
|
4
|
+
var _useContext = useContext(FilerobotPackagesContext),
|
|
5
|
+
plugins = _useContext.plugins;
|
|
6
|
+
return useMemo(function () {
|
|
7
|
+
var foundPlugin = null;
|
|
8
|
+
Object.keys(plugins).some(function (pluginType) {
|
|
9
|
+
return plugins[pluginType].some(function (plugin) {
|
|
10
|
+
if (plugin.id === pluginId) {
|
|
11
|
+
foundPlugin = plugin;
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
return false;
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
return foundPlugin;
|
|
18
|
+
}, [plugins, pluginId]);
|
|
19
|
+
};
|
|
20
|
+
export default usePlugin;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useContext, useMemo } from 'react';
|
|
2
|
+
import { FilerobotPackagesContext } from '../Providers';
|
|
3
|
+
|
|
4
|
+
// pluginsType => [acquirer, editor, modifier, uploader, progressindicator, orchestrator]
|
|
5
|
+
var usePluginsType = function usePluginsType(pluginsType) {
|
|
6
|
+
var _useContext = useContext(FilerobotPackagesContext),
|
|
7
|
+
plugins = _useContext.plugins;
|
|
8
|
+
return useMemo(function () {
|
|
9
|
+
if (pluginsType) {
|
|
10
|
+
var foundPlugins = plugins[pluginsType] || [];
|
|
11
|
+
return foundPlugins.filter(function (plugin) {
|
|
12
|
+
return !plugin.invisible;
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
return [];
|
|
16
|
+
}, [plugins, pluginsType]);
|
|
17
|
+
};
|
|
18
|
+
export default usePluginsType;
|