@scaleflex/widget-explorer 4.5.0 → 4.5.4
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 +35 -0
- package/README.md +21 -3
- package/dist/style.css +2 -0
- package/dist/style.min.css +1 -1
- package/lib/components/ActionBar/DownloadWithExportButton.js +32 -4
- package/lib/components/AssetsList/ListView/AssetsSection/AssetsSectionTableRow.js +1 -1
- package/lib/components/Breadcrumbs/index.js +114 -6
- package/lib/components/CollectionsView/CollectionFolderIcon.js +35 -0
- package/lib/components/CollectionsView/CollectionVirtualFoldersTree/CollectionTreeSkeletion.js +26 -0
- package/lib/components/CollectionsView/CollectionVirtualFoldersTree/CollectionVirtualFoldersTree.styled.js +52 -0
- package/lib/components/CollectionsView/CollectionVirtualFoldersTree/CollectionVirtualFoldersTree.utils.js +24 -0
- package/lib/components/CollectionsView/CollectionVirtualFoldersTree/Folder.js +88 -0
- package/lib/components/CollectionsView/CollectionVirtualFoldersTree/Tree.js +50 -0
- package/lib/components/CollectionsView/CollectionVirtualFoldersTree/index.js +75 -0
- package/lib/components/CollectionsView/CollectionsSkeleton.js +30 -0
- package/lib/components/CollectionsView/CollectionsTree/ActiveCollectionContent.js +61 -0
- package/lib/components/CollectionsView/CollectionsTree/CollectionTreeItem.js +44 -0
- package/lib/components/CollectionsView/CollectionsTree/CollectionsContent.js +130 -0
- package/lib/components/CollectionsView/CollectionsTree/CollectionsTree.styled.js +84 -0
- package/lib/components/CollectionsView/CollectionsTree/index.js +47 -0
- package/lib/components/CollectionsView/CollectionsView.styled.js +38 -0
- package/lib/components/CollectionsView/VirtualFoldersGrid.js +67 -0
- package/lib/components/CollectionsView/index.js +188 -0
- package/lib/components/Details/Details.constants.js +1 -0
- package/lib/components/EmptyViewPlaceholder/EmptyViewPlaceholder.styled.js +1 -1
- package/lib/components/FileItem/FileInfo/index.js +8 -2
- package/lib/components/FileWindowPanel/FileTabs/VariationsTab/VariationsTabNavigator.js +1 -7
- package/lib/components/FileWindowPanel/FileTabs/VariationsTab/index.js +4 -1
- package/lib/components/FileWindowPanel/Header/index.js +9 -0
- package/lib/components/Filters/hooks/useFilters.js +3 -2
- package/lib/components/HeaderBar/index.js +6 -2
- package/lib/components/LabelsView/LabelsTree/LabelsTree.styled.js +86 -0
- package/lib/components/LabelsView/LabelsTree/LabelsTreeSkeleton.js +21 -0
- package/lib/components/LabelsView/LabelsTree/index.js +128 -0
- package/lib/components/LabelsView/LabelsView.styled.js +10 -0
- package/lib/components/LabelsView/index.js +139 -0
- package/lib/components/Modals/DownloadConsent/DownloadConsent.hooks.js +11 -0
- package/lib/components/Modals/TransformedDownload/TransformedDownload.hooks.js +9 -0
- package/lib/components/Views/Views.constants.js +30 -4
- package/lib/components/Views/index.js +11 -4
- package/lib/components/common/FileMetadataFieldValue/GeneralMetadataFieldValue.js +1 -1
- package/lib/components/common/Sort/Sort.constants.js +28 -1
- package/lib/defaultLocale.js +36 -1
- package/lib/slices/collections.slice.js +714 -0
- package/lib/slices/common.slice.js +15 -52
- package/lib/slices/files.slice.js +6 -3
- package/lib/slices/index.js +5 -1
- package/lib/slices/labels.slice.js +652 -0
- package/lib/slices/views.slice.js +12 -0
- package/lib/utils/prepareSearchUrl.js +10 -0
- package/package.json +8 -8
|
@@ -0,0 +1,714 @@
|
|
|
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
|
+
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
8
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
9
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
10
|
+
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
11
|
+
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
12
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
13
|
+
import { createSelector, createSlice, isAnyOf } from '@reduxjs/toolkit';
|
|
14
|
+
import { PLUGINS_IDS, VIEW_IDS, FMAW_URL_QUERY_PARAMS } from '@scaleflex/widget-utils/lib/constants';
|
|
15
|
+
import createThunk from '@scaleflex/widget-utils/lib/createThunk';
|
|
16
|
+
import escapeRegExp from '@scaleflex/widget-utils/lib/escapeRegExp';
|
|
17
|
+
import getActionErrorState from '@scaleflex/widget-utils/lib/getActionErrorState';
|
|
18
|
+
import { filesRemoved, selectFilesOffset } from './files.slice';
|
|
19
|
+
import { changeView, changeViewFetchFilesCachedQueries, resetSearchAndFiltersMode, searchOrListViewFiles, selectIsCollectionsView } from './views.slice';
|
|
20
|
+
import { filterFolders } from '../components/CollectionsView/CollectionVirtualFoldersTree/CollectionVirtualFoldersTree.utils';
|
|
21
|
+
import { COLLECTIONS_SORT_OPTIONS, SORT_ORDER } from '../components/common/Sort/Sort.constants';
|
|
22
|
+
import { currentFolderUpdated } from './folders.slice';
|
|
23
|
+
import { exactAndExtendedFilesRemoved } from './search.slice';
|
|
24
|
+
var slicePropName = 'collections';
|
|
25
|
+
var sliceName = "".concat(PLUGINS_IDS.EXPLORER, "/").concat(slicePropName);
|
|
26
|
+
var initialState = {
|
|
27
|
+
uuids: [],
|
|
28
|
+
entities: {},
|
|
29
|
+
activeUuid: null,
|
|
30
|
+
searchTerm: '',
|
|
31
|
+
selectedUuids: [],
|
|
32
|
+
sortOrder: SORT_ORDER.ASC,
|
|
33
|
+
sortedBy: null,
|
|
34
|
+
loading: true,
|
|
35
|
+
isSending: false,
|
|
36
|
+
isIntermediateVirtualFolder: false,
|
|
37
|
+
activeVirtualFolder: null,
|
|
38
|
+
isActiveVirtualFolderLoading: false,
|
|
39
|
+
showTree: true,
|
|
40
|
+
activeVirtualFolders: {},
|
|
41
|
+
activeVirtualFoldersPaths: [],
|
|
42
|
+
error: null
|
|
43
|
+
};
|
|
44
|
+
export var DEFAULT_COLLECTION_SORT = {
|
|
45
|
+
BY: COLLECTIONS_SORT_OPTIONS[0].value,
|
|
46
|
+
ORDER: SORT_ORDER.ASC
|
|
47
|
+
};
|
|
48
|
+
var compareCollectionsToSort = function compareCollectionsToSort(_ref) {
|
|
49
|
+
var _x$sortBy, _y$sortBy;
|
|
50
|
+
var sortOrder = _ref.sortOrder,
|
|
51
|
+
sortBy = _ref.sortBy,
|
|
52
|
+
aCollection = _ref.aCollection,
|
|
53
|
+
bCollection = _ref.bCollection;
|
|
54
|
+
var x = sortOrder === SORT_ORDER.ASC ? aCollection : bCollection;
|
|
55
|
+
var y = sortOrder === SORT_ORDER.ASC ? bCollection : aCollection;
|
|
56
|
+
var xValue = (_x$sortBy = x === null || x === void 0 ? void 0 : x[sortBy]) !== null && _x$sortBy !== void 0 ? _x$sortBy : '';
|
|
57
|
+
var yValue = (_y$sortBy = y === null || y === void 0 ? void 0 : y[sortBy]) !== null && _y$sortBy !== void 0 ? _y$sortBy : '';
|
|
58
|
+
if (!Number.isNaN(+xValue) && !Number.isNaN(+yValue)) return +xValue - +yValue;
|
|
59
|
+
if (!isNaN(new Date(xValue)) && !isNaN(new Date(yValue))) return yValue.toString().localeCompare(xValue);
|
|
60
|
+
return xValue.toString().localeCompare(yValue);
|
|
61
|
+
};
|
|
62
|
+
export var sortCollections = createThunk(function (_ref2, thunkApi) {
|
|
63
|
+
var sortBy = _ref2.sortBy,
|
|
64
|
+
sortOrder = _ref2.sortOrder;
|
|
65
|
+
// Creating new array as sorting is done in the same array reference.
|
|
66
|
+
var state = thunkApi.getState();
|
|
67
|
+
var collections = selectCollections(state);
|
|
68
|
+
var sortedCollectionUuids = _toConsumableArray(selectCollectionsUuids(state));
|
|
69
|
+
if (sortBy) {
|
|
70
|
+
sortedCollectionUuids.sort(function (aUuid, bUuid) {
|
|
71
|
+
var aCollection = collections[aUuid];
|
|
72
|
+
var bCollection = collections[bUuid];
|
|
73
|
+
return compareCollectionsToSort({
|
|
74
|
+
sortBy: sortBy,
|
|
75
|
+
sortOrder: sortOrder,
|
|
76
|
+
aCollection: aCollection,
|
|
77
|
+
bCollection: bCollection
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
thunkApi.dispatch(collectionsSortingUpdated({
|
|
81
|
+
uuids: sortedCollectionUuids
|
|
82
|
+
}));
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
var getSortedCollections = function getSortedCollections(collectionsBeforeNormalization, sortBy, sortOrder) {
|
|
86
|
+
return _toConsumableArray(collectionsBeforeNormalization).sort(function (aCollection, bCollection) {
|
|
87
|
+
return compareCollectionsToSort({
|
|
88
|
+
sortBy: sortBy,
|
|
89
|
+
sortOrder: sortOrder,
|
|
90
|
+
aCollection: aCollection,
|
|
91
|
+
bCollection: bCollection
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
export var activateFirstCollection = createThunk(function (_, thunkApi) {
|
|
96
|
+
var _collections$;
|
|
97
|
+
var collections = selectCollectionsArray(thunkApi.getState());
|
|
98
|
+
return thunkApi.dispatch(activateCollection({
|
|
99
|
+
uuid: (_collections$ = collections[0]) === null || _collections$ === void 0 ? void 0 : _collections$.uuid
|
|
100
|
+
}));
|
|
101
|
+
});
|
|
102
|
+
export var activateCollection = createThunk(function () {
|
|
103
|
+
var _extra$filerobot$getP;
|
|
104
|
+
var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
105
|
+
collectionUuid = _ref3.uuid,
|
|
106
|
+
refreshActiveCollection = _ref3.refreshActiveCollection;
|
|
107
|
+
var thunkApi = arguments.length > 1 ? arguments[1] : undefined;
|
|
108
|
+
var dispatch = thunkApi.dispatch,
|
|
109
|
+
getState = thunkApi.getState,
|
|
110
|
+
extra = thunkApi.extra;
|
|
111
|
+
var state = getState();
|
|
112
|
+
var currentActiveCollectionUuid = selectActiveCollectionUuid(state);
|
|
113
|
+
if (!collectionUuid || currentActiveCollectionUuid === collectionUuid && !refreshActiveCollection) return;
|
|
114
|
+
var isCollectionsViewNotActivated = !selectIsCollectionsView(state);
|
|
115
|
+
var requestToReturn;
|
|
116
|
+
if (isCollectionsViewNotActivated) {
|
|
117
|
+
requestToReturn = dispatch(activateCollectionsView({
|
|
118
|
+
itemToOpen: collectionUuid
|
|
119
|
+
}));
|
|
120
|
+
} else {
|
|
121
|
+
requestToReturn = dispatch(fetchCollectionVirtualFolders({
|
|
122
|
+
collectionUuid: collectionUuid
|
|
123
|
+
}));
|
|
124
|
+
}
|
|
125
|
+
dispatch(collectionActivated(collectionUuid));
|
|
126
|
+
(_extra$filerobot$getP = extra.filerobot.getPlugin(PLUGINS_IDS.EXPLORER)) === null || _extra$filerobot$getP === void 0 ? void 0 : _extra$filerobot$getP.updateViewQueryInUrl({
|
|
127
|
+
viewItem: collectionUuid
|
|
128
|
+
});
|
|
129
|
+
return requestToReturn;
|
|
130
|
+
});
|
|
131
|
+
export var activateCollectionsView = createThunk(async function () {
|
|
132
|
+
var _ref4 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
133
|
+
collectionUuidToActivate = _ref4.itemToOpen,
|
|
134
|
+
collectionFolderF64ToOpen = _ref4.subItemToOpen,
|
|
135
|
+
_ref4$skipViewDispatc = _ref4.skipViewDispatch,
|
|
136
|
+
skipViewDispatch = _ref4$skipViewDispatc === void 0 ? false : _ref4$skipViewDispatc,
|
|
137
|
+
_ref4$skipFetch = _ref4.skipFetch,
|
|
138
|
+
skipFetch = _ref4$skipFetch === void 0 ? false : _ref4$skipFetch,
|
|
139
|
+
_ref4$keepFiltersAndS = _ref4.keepFiltersAndSearch,
|
|
140
|
+
keepFiltersAndSearch = _ref4$keepFiltersAndS === void 0 ? false : _ref4$keepFiltersAndS,
|
|
141
|
+
_ref4$fromUrl = _ref4.fromUrl,
|
|
142
|
+
fromUrl = _ref4$fromUrl === void 0 ? false : _ref4$fromUrl;
|
|
143
|
+
var thunkApi = arguments.length > 1 ? arguments[1] : undefined;
|
|
144
|
+
var dispatch = thunkApi.dispatch,
|
|
145
|
+
getState = thunkApi.getState,
|
|
146
|
+
extra = thunkApi.extra;
|
|
147
|
+
var _extra$filerobot = extra.filerobot,
|
|
148
|
+
info = _extra$filerobot.info,
|
|
149
|
+
i18n = _extra$filerobot.i18n;
|
|
150
|
+
if (!skipViewDispatch) dispatch(changeView({
|
|
151
|
+
view: VIEW_IDS.COLLECTIONS,
|
|
152
|
+
keepFiltersAndSearch: keepFiltersAndSearch,
|
|
153
|
+
fromUrl: fromUrl
|
|
154
|
+
}));
|
|
155
|
+
dispatch(collectionsStateReset());
|
|
156
|
+
dispatch(currentFolderUpdated({}));
|
|
157
|
+
dispatch(filesRemoved());
|
|
158
|
+
dispatch(exactAndExtendedFilesRemoved([]));
|
|
159
|
+
var collections = skipFetch ? selectCollectionsArray(getState()) : await dispatch(fetchCollections()).throwRejection();
|
|
160
|
+
var firstCollection = (collections || [])[0] || {};
|
|
161
|
+
var collectionUuid = collectionUuidToActivate || firstCollection.uuid;
|
|
162
|
+
if (!collectionUuid) return;
|
|
163
|
+
if (collectionUuidToActivate && !selectCollectionByUuid(getState(), collectionUuidToActivate)) {
|
|
164
|
+
info(i18n('collectionsDefaultCollectionError'), 'error', 3000);
|
|
165
|
+
thunkApi.dispatch(collectionsStateUpdated({
|
|
166
|
+
error: {
|
|
167
|
+
message: i18n('collectionsDefaultCollectionError'),
|
|
168
|
+
details: i18n('collectionsDefaultCollectionErrorDescription')
|
|
169
|
+
}
|
|
170
|
+
}));
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
var requestToReturn = dispatch(activateCollection({
|
|
174
|
+
uuid: collectionUuid
|
|
175
|
+
}));
|
|
176
|
+
if (collectionFolderF64ToOpen) {
|
|
177
|
+
// We are waiting the activateCollection to finish to make sure we are fetching the files of the opened virtual folder
|
|
178
|
+
// cause we need to have the opened/passed virtual folder data from the API that's why we are waiting.
|
|
179
|
+
await requestToReturn;
|
|
180
|
+
requestToReturn = dispatch(fetchCollectionsFiles({
|
|
181
|
+
collectionUuid: collectionUuid,
|
|
182
|
+
folder: {
|
|
183
|
+
filters: collectionFolderF64ToOpen
|
|
184
|
+
},
|
|
185
|
+
offset: 0
|
|
186
|
+
}));
|
|
187
|
+
}
|
|
188
|
+
return requestToReturn;
|
|
189
|
+
});
|
|
190
|
+
export var toggleCollectionsTree = createThunk(function (showTree, thunkApi) {
|
|
191
|
+
var newValue = showTree !== null && showTree !== void 0 ? showTree : !selectIsCollectionTreeOpened(thunkApi.getState());
|
|
192
|
+
thunkApi.dispatch(collectionsStateUpdated({
|
|
193
|
+
showTree: newValue
|
|
194
|
+
}));
|
|
195
|
+
thunkApi.extra.filerobot.emit('collections-tree-trigger', newValue);
|
|
196
|
+
return newValue;
|
|
197
|
+
});
|
|
198
|
+
export var fetchCollections = createThunk(async function () {
|
|
199
|
+
var _ref5 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
200
|
+
avoidCollectionsUpdate = _ref5.avoidCollectionsUpdate;
|
|
201
|
+
var thunkApi = arguments.length > 1 ? arguments[1] : undefined;
|
|
202
|
+
var sortBy = DEFAULT_COLLECTION_SORT.BY,
|
|
203
|
+
sortOrder = DEFAULT_COLLECTION_SORT.ORDER;
|
|
204
|
+
var _await$thunkApi$extra = await thunkApi.extra.apiClient.get('collections', {
|
|
205
|
+
id: 'listCollections',
|
|
206
|
+
abortSignal: thunkApi.signal
|
|
207
|
+
}),
|
|
208
|
+
collections = _await$thunkApi$extra.collections;
|
|
209
|
+
var sortedCollections = collections ? getSortedCollections(collections, sortBy, sortOrder) : [];
|
|
210
|
+
if (!avoidCollectionsUpdate) {
|
|
211
|
+
thunkApi.dispatch(collectionsReplaced(sortedCollections));
|
|
212
|
+
}
|
|
213
|
+
return sortedCollections;
|
|
214
|
+
}, {
|
|
215
|
+
actionType: "".concat(sliceName, "/fetchCollections")
|
|
216
|
+
});
|
|
217
|
+
export var fetchCollectionVirtualFolders = createThunk(async function () {
|
|
218
|
+
var _filerobot$getPlugin;
|
|
219
|
+
var _ref6 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
220
|
+
avoidCollectionVirtualUpdate = _ref6.avoidCollectionVirtualUpdate,
|
|
221
|
+
collectionUuid = _ref6.collectionUuid;
|
|
222
|
+
var thunkApi = arguments.length > 1 ? arguments[1] : undefined;
|
|
223
|
+
var dispatch = thunkApi.dispatch,
|
|
224
|
+
_thunkApi$extra = thunkApi.extra,
|
|
225
|
+
apiClient = _thunkApi$extra.apiClient,
|
|
226
|
+
filerobot = _thunkApi$extra.filerobot,
|
|
227
|
+
getState = thunkApi.getState;
|
|
228
|
+
var state = getState();
|
|
229
|
+
var activeCollectionUuid = collectionUuid || selectActiveCollectionUuid(state);
|
|
230
|
+
dispatch(resetSearchAndFiltersMode());
|
|
231
|
+
dispatch(collectionActivated(activeCollectionUuid));
|
|
232
|
+
(_filerobot$getPlugin = filerobot.getPlugin(PLUGINS_IDS.EXPLORER)) === null || _filerobot$getPlugin === void 0 ? void 0 : _filerobot$getPlugin.updateViewQueryInUrl({
|
|
233
|
+
viewItem: activeCollectionUuid
|
|
234
|
+
});
|
|
235
|
+
var _await$apiClient$get = await apiClient.get("collections/".concat(activeCollectionUuid, "/folders"), {
|
|
236
|
+
id: 'listCollectionVirtualFolders',
|
|
237
|
+
abortSignal: thunkApi.signal
|
|
238
|
+
}),
|
|
239
|
+
_await$apiClient$get$ = _await$apiClient$get.folders,
|
|
240
|
+
folders = _await$apiClient$get$ === void 0 ? [] : _await$apiClient$get$;
|
|
241
|
+
|
|
242
|
+
// TODO: (Remove this if fixed on BE)... Issue from backend, that error is being returned as a 200 response and inside folders object, solving it here till backend fix it.
|
|
243
|
+
if (folders.status === 'error') {
|
|
244
|
+
filerobot.info(folders.msg, 'error');
|
|
245
|
+
return thunkApi.rejectWithValue(folders.msg);
|
|
246
|
+
}
|
|
247
|
+
if (!avoidCollectionVirtualUpdate) {
|
|
248
|
+
thunkApi.dispatch(collectionVirtualFoldersReplaced(folders));
|
|
249
|
+
}
|
|
250
|
+
return folders;
|
|
251
|
+
}, {
|
|
252
|
+
actionType: "".concat(sliceName, "/fetchCollectionVirtualFolders")
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
// export const createCollection = createThunk(
|
|
256
|
+
// async ({ collection = {} }, thunkApi) => {
|
|
257
|
+
// const { signal, dispatch, extra: { apiClient } } = thunkApi
|
|
258
|
+
|
|
259
|
+
// /** (Dima: I suppose it's same as for labels)
|
|
260
|
+
// * !TODO: Once we have the whole new label object returned in the backend request's response, we should return the addedLabel const...
|
|
261
|
+
// * then add a case for it in extraReducer to append that label to labels entities for enabling auto updating with no additional requests
|
|
262
|
+
// */
|
|
263
|
+
// const { collection: addedCollection = {} } = await apiClient.post('collections', { data: collection, abortSignal: signal })
|
|
264
|
+
|
|
265
|
+
// dispatch(collectionModalOpened({ show: false, collectionToEdit: null }))
|
|
266
|
+
|
|
267
|
+
// return addedCollection
|
|
268
|
+
// },
|
|
269
|
+
// { actionType: `${sliceName}/createCollection` }
|
|
270
|
+
// )
|
|
271
|
+
|
|
272
|
+
// export const updateCollectionByUuid = createThunk(
|
|
273
|
+
// async ({ collection } = {}, thunkApi) => {
|
|
274
|
+
// const { signal, dispatch, extra: { apiClient } } = thunkApi
|
|
275
|
+
// const { uuid: collectionUuid } = collection
|
|
276
|
+
|
|
277
|
+
// const { collection: updatedCollection } = await apiClient.put(
|
|
278
|
+
// `collections/${collectionUuid}`,
|
|
279
|
+
// { data: collection, abortSignal: signal }
|
|
280
|
+
// )
|
|
281
|
+
|
|
282
|
+
// dispatch(collectionModalOpened({ show: false, collectionToEdit: null }))
|
|
283
|
+
|
|
284
|
+
// return updatedCollection
|
|
285
|
+
// },
|
|
286
|
+
// { actionType: `${sliceName}/updateCollectionByUuid` }
|
|
287
|
+
// )
|
|
288
|
+
|
|
289
|
+
export var deleteCollections = createThunk(async function () {
|
|
290
|
+
var collectionsUuids = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
291
|
+
var thunkApi = arguments.length > 1 ? arguments[1] : undefined;
|
|
292
|
+
var signal = thunkApi.signal,
|
|
293
|
+
apiClient = thunkApi.extra.apiClient;
|
|
294
|
+
collectionsUuids.length === 1 ? await apiClient["delete"]("collections/".concat(collectionsUuids[0]), {
|
|
295
|
+
abortSignal: signal
|
|
296
|
+
}) : await apiClient["delete"]('collections', {
|
|
297
|
+
data: {
|
|
298
|
+
collections_uuids: collectionsUuids
|
|
299
|
+
},
|
|
300
|
+
abortSignal: signal
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
// Deactivate collection if it was deleted + remove all previously active collection files + remove URL query param
|
|
304
|
+
var activeCollectionUuid = selectActiveCollectionUuid(thunkApi.getState());
|
|
305
|
+
if (activeCollectionUuid && collectionsUuids.includes(activeCollectionUuid)) {
|
|
306
|
+
var _thunkApi$extra$filer;
|
|
307
|
+
thunkApi.dispatch(filesRemoved());
|
|
308
|
+
thunkApi.dispatch(exactAndExtendedFilesRemoved([]));
|
|
309
|
+
thunkApi.dispatch(collectionActivated(null));
|
|
310
|
+
(_thunkApi$extra$filer = thunkApi.extra.filerobot.getPlugin(PLUGINS_IDS.EXPLORER)) === null || _thunkApi$extra$filer === void 0 ? void 0 : _thunkApi$extra$filer.deleteUrlQueryParams([FMAW_URL_QUERY_PARAMS.VIEW_ITEM, FMAW_URL_QUERY_PARAMS.VIEW_SUB_ITEM]);
|
|
311
|
+
changeViewFetchFilesCachedQueries(null);
|
|
312
|
+
}
|
|
313
|
+
thunkApi.extra.filerobot.emit('objects-removed', collectionsUuids, 'collections');
|
|
314
|
+
return collectionsUuids;
|
|
315
|
+
}, {
|
|
316
|
+
actionType: "".concat(sliceName, "/deleteCollections")
|
|
317
|
+
});
|
|
318
|
+
export var fetchCollectionsFiles = createThunk(async function () {
|
|
319
|
+
var _extra$filerobot$getP2;
|
|
320
|
+
var _ref7 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
321
|
+
folder = _ref7.folder,
|
|
322
|
+
offset = _ref7.offset,
|
|
323
|
+
_ref7$collectionUuid = _ref7.collectionUuid,
|
|
324
|
+
collectionUuid = _ref7$collectionUuid === void 0 ? null : _ref7$collectionUuid,
|
|
325
|
+
sortBy = _ref7.sortBy,
|
|
326
|
+
sortOrder = _ref7.sortOrder;
|
|
327
|
+
var thunkApi = arguments.length > 1 ? arguments[1] : undefined;
|
|
328
|
+
var dispatch = thunkApi.dispatch,
|
|
329
|
+
getState = thunkApi.getState,
|
|
330
|
+
extra = thunkApi.extra;
|
|
331
|
+
var state = getState();
|
|
332
|
+
var currentActiveVirtualFolder = selectCollectionsActiveVirtualFolder(state);
|
|
333
|
+
var virtualFolder = folder || currentActiveVirtualFolder || {};
|
|
334
|
+
var filters = virtualFolder.filters;
|
|
335
|
+
var uuid = collectionUuid || selectActiveCollection(state).uuid;
|
|
336
|
+
var usedOffset = offset !== null && offset !== void 0 ? offset : selectFilesOffset(state);
|
|
337
|
+
if (!(currentActiveVirtualFolder !== null && currentActiveVirtualFolder !== void 0 && currentActiveVirtualFolder.path) || (currentActiveVirtualFolder === null || currentActiveVirtualFolder === void 0 ? void 0 : currentActiveVirtualFolder.path) !== (virtualFolder === null || virtualFolder === void 0 ? void 0 : virtualFolder.path)) {
|
|
338
|
+
dispatch(activeCollectionsVirtualFolderUpdated(virtualFolder));
|
|
339
|
+
}
|
|
340
|
+
if (!filters) return;
|
|
341
|
+
(_extra$filerobot$getP2 = extra.filerobot.getPlugin(PLUGINS_IDS.EXPLORER)) === null || _extra$filerobot$getP2 === void 0 ? void 0 : _extra$filerobot$getP2.updateViewQueryInUrl({
|
|
342
|
+
viewItem: uuid,
|
|
343
|
+
viewSubItem: filters
|
|
344
|
+
});
|
|
345
|
+
var result = await dispatch(searchOrListViewFiles({
|
|
346
|
+
cachedViewQueries: {
|
|
347
|
+
collection_uuid: uuid,
|
|
348
|
+
f64: filters,
|
|
349
|
+
recursive: true
|
|
350
|
+
},
|
|
351
|
+
offset: usedOffset,
|
|
352
|
+
replaceOldFiles: usedOffset === 0,
|
|
353
|
+
skipPendingDispatch: usedOffset > 0,
|
|
354
|
+
sorting: sortBy && sortOrder && [sortBy, sortOrder],
|
|
355
|
+
withStats: false
|
|
356
|
+
}));
|
|
357
|
+
return result;
|
|
358
|
+
}, {
|
|
359
|
+
actionType: "".concat(sliceName, "/fetchCollectionsFiles")
|
|
360
|
+
});
|
|
361
|
+
var collectionsSlice = createSlice({
|
|
362
|
+
name: sliceName,
|
|
363
|
+
initialState: initialState,
|
|
364
|
+
reducers: {
|
|
365
|
+
collectionsAdded: function collectionsAdded(state, action) {
|
|
366
|
+
var newCollections = _objectSpread({}, state.entities);
|
|
367
|
+
var newUuids = _toConsumableArray(state.uuids);
|
|
368
|
+
action.payload.forEach(function (collection) {
|
|
369
|
+
newCollections[collection.uuid] = collection;
|
|
370
|
+
newUuids.push(collection.uuid);
|
|
371
|
+
});
|
|
372
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
373
|
+
entities: newCollections,
|
|
374
|
+
uuids: newUuids
|
|
375
|
+
});
|
|
376
|
+
},
|
|
377
|
+
collectionAdded: function collectionAdded(state, action) {
|
|
378
|
+
var newCollections = _objectSpread({}, state.entities);
|
|
379
|
+
var newUuids = _toConsumableArray(state.uuids);
|
|
380
|
+
var collection = action.payload;
|
|
381
|
+
newCollections[collection.uuid] = collection;
|
|
382
|
+
newUuids.push(collection.uuid);
|
|
383
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
384
|
+
entities: newCollections,
|
|
385
|
+
uuids: newUuids
|
|
386
|
+
});
|
|
387
|
+
},
|
|
388
|
+
collectionUpdated: function collectionUpdated(state, action) {
|
|
389
|
+
var newCollections = _objectSpread({}, state.entities);
|
|
390
|
+
newCollections[action.payload.uuid] = _objectSpread(_objectSpread({}, newCollections[action.payload.uuid]), action.payload);
|
|
391
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
392
|
+
entities: newCollections
|
|
393
|
+
});
|
|
394
|
+
},
|
|
395
|
+
collectionsRemoved: function collectionsRemoved(state, action) {
|
|
396
|
+
var collectionsUuids = action.payload;
|
|
397
|
+
var newCollections = _objectSpread({}, state.entities);
|
|
398
|
+
var newUuids = _toConsumableArray(state.uuids);
|
|
399
|
+
collectionsUuids.forEach(function (collectionUuid) {
|
|
400
|
+
var deletedCollectionIndex = newUuids.indexOf(collectionUuid);
|
|
401
|
+
delete newCollections[collectionUuid];
|
|
402
|
+
newUuids.splice(deletedCollectionIndex, 1);
|
|
403
|
+
});
|
|
404
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
405
|
+
entities: newCollections,
|
|
406
|
+
uuids: newUuids
|
|
407
|
+
});
|
|
408
|
+
},
|
|
409
|
+
collectionsReplaced: function collectionsReplaced(state, action) {
|
|
410
|
+
var newCollections = {};
|
|
411
|
+
var collectionsUuids = [];
|
|
412
|
+
action.payload.forEach(function (collection) {
|
|
413
|
+
newCollections[collection.uuid] = collection;
|
|
414
|
+
collectionsUuids.push(collection.uuid);
|
|
415
|
+
});
|
|
416
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
417
|
+
entities: newCollections,
|
|
418
|
+
uuids: collectionsUuids,
|
|
419
|
+
activeVirtualFolder: initialState.activeVirtualFolder,
|
|
420
|
+
activeUuid: initialState.activeUuid,
|
|
421
|
+
isIntermediateVirtualFolder: initialState.isIntermediateVirtualFolder,
|
|
422
|
+
activeVirtualFolders: initialState.activeVirtualFolders,
|
|
423
|
+
activeVirtualFoldersPaths: initialState.activeVirtualFoldersPaths
|
|
424
|
+
});
|
|
425
|
+
},
|
|
426
|
+
collectionVirtualFoldersReplaced: function collectionVirtualFoldersReplaced(state, action) {
|
|
427
|
+
if (!Array.isArray(action.payload)) {
|
|
428
|
+
return state;
|
|
429
|
+
}
|
|
430
|
+
var activeVirtualFolders = {};
|
|
431
|
+
var activeVirtualFoldersPaths = [];
|
|
432
|
+
action.payload.forEach(function (folder) {
|
|
433
|
+
activeVirtualFolders[folder.path] = folder;
|
|
434
|
+
activeVirtualFoldersPaths.push(folder.path);
|
|
435
|
+
});
|
|
436
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
437
|
+
activeVirtualFolders: activeVirtualFolders,
|
|
438
|
+
activeVirtualFoldersPaths: activeVirtualFoldersPaths,
|
|
439
|
+
isIntermediateVirtualFolder: true
|
|
440
|
+
});
|
|
441
|
+
},
|
|
442
|
+
collectionsSearchTermUpdated: function collectionsSearchTermUpdated(state, action) {
|
|
443
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
444
|
+
searchTerm: action.payload
|
|
445
|
+
});
|
|
446
|
+
},
|
|
447
|
+
collectionsSortingUpdated: function collectionsSortingUpdated(state, action) {
|
|
448
|
+
var _action$payload = action.payload,
|
|
449
|
+
_action$payload$sortB = _action$payload.sortBy,
|
|
450
|
+
sortBy = _action$payload$sortB === void 0 ? state.sortedBy : _action$payload$sortB,
|
|
451
|
+
_action$payload$order = _action$payload.order,
|
|
452
|
+
order = _action$payload$order === void 0 ? state.sortOrder : _action$payload$order,
|
|
453
|
+
uuids = _action$payload.uuids;
|
|
454
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
455
|
+
sortedBy: sortBy,
|
|
456
|
+
sortOrder: order
|
|
457
|
+
}, uuids && {
|
|
458
|
+
uuids: uuids
|
|
459
|
+
});
|
|
460
|
+
},
|
|
461
|
+
collectionActivated: function collectionActivated(state, action) {
|
|
462
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
463
|
+
activeUuid: action.payload,
|
|
464
|
+
activeVirtualFolder: null
|
|
465
|
+
// noMoreActiveCollectionsFiles: false // TODO: Do we need it? This state doesn't used.
|
|
466
|
+
});
|
|
467
|
+
},
|
|
468
|
+
collectionsSelected: function collectionsSelected(state, action) {
|
|
469
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
470
|
+
selectedUuids: action.payload
|
|
471
|
+
});
|
|
472
|
+
},
|
|
473
|
+
collectionsDeselected: function collectionsDeselected(state) {
|
|
474
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
475
|
+
selectedUuids: initialState.selectedUuids
|
|
476
|
+
});
|
|
477
|
+
},
|
|
478
|
+
activeCollectionsVirtualFolderUpdated: function activeCollectionsVirtualFolderUpdated(state, action) {
|
|
479
|
+
var _action$payload2, _action$payload3, _Object$values;
|
|
480
|
+
var virtualFolder = !((_action$payload2 = action.payload) !== null && _action$payload2 !== void 0 && _action$payload2.path) && (_action$payload3 = action.payload) !== null && _action$payload3 !== void 0 && _action$payload3.filters ? (_Object$values = Object.values(state.activeVirtualFolders || {})) === null || _Object$values === void 0 ? void 0 : _Object$values.find(function () {
|
|
481
|
+
var _ref8 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
482
|
+
filters = _ref8.filters;
|
|
483
|
+
return action.payload.filters === filters;
|
|
484
|
+
}) : action.payload;
|
|
485
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
486
|
+
activeVirtualFolder: virtualFolder,
|
|
487
|
+
sortedBy: initialState.sortedBy,
|
|
488
|
+
sortOrder: initialState.sortOrder
|
|
489
|
+
});
|
|
490
|
+
},
|
|
491
|
+
allCollectionsSelected: function allCollectionsSelected(state) {
|
|
492
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
493
|
+
selectedUuids: state.uuids
|
|
494
|
+
});
|
|
495
|
+
},
|
|
496
|
+
collectionsStateUpdated: function collectionsStateUpdated(state, action) {
|
|
497
|
+
return _objectSpread(_objectSpread({}, state), action.payload);
|
|
498
|
+
},
|
|
499
|
+
collectionsStateReset: function collectionsStateReset(state) {
|
|
500
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
501
|
+
activeUuid: null,
|
|
502
|
+
searchTerm: '',
|
|
503
|
+
selectedUuids: [],
|
|
504
|
+
sortOrder: SORT_ORDER.ASC,
|
|
505
|
+
sortedBy: null,
|
|
506
|
+
// loading: true,
|
|
507
|
+
isSending: false,
|
|
508
|
+
isIntermediateVirtualFolder: false,
|
|
509
|
+
activeVirtualFolder: null,
|
|
510
|
+
isActiveVirtualFolderLoading: false,
|
|
511
|
+
showTree: true,
|
|
512
|
+
activeVirtualFolders: {},
|
|
513
|
+
activeVirtualFoldersPaths: [],
|
|
514
|
+
error: null
|
|
515
|
+
});
|
|
516
|
+
}
|
|
517
|
+
},
|
|
518
|
+
extraReducers: function extraReducers(builder) {
|
|
519
|
+
builder
|
|
520
|
+
// .addCase(createCollection.fulfilled, (state, action) => (
|
|
521
|
+
// collectionsSlice.caseReducers.collectionAdded(state, action)
|
|
522
|
+
// ))
|
|
523
|
+
.addCase(deleteCollections.fulfilled, function (state, action) {
|
|
524
|
+
return collectionsSlice.caseReducers.collectionsRemoved(state, action);
|
|
525
|
+
})
|
|
526
|
+
// .addCase(updateCollectionByUuid.fulfilled, (state, action) => (
|
|
527
|
+
// collectionsSlice.caseReducers.collectionUpdated(state, action)
|
|
528
|
+
// ))
|
|
529
|
+
// .addCase(collectionModalOpened.type, (state) => (
|
|
530
|
+
// collectionsSlice.caseReducers.collectionsDeselected(state)
|
|
531
|
+
// ))
|
|
532
|
+
.addCase(fetchCollectionVirtualFolders.pending, function (state) {
|
|
533
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
534
|
+
isActiveVirtualFolderLoading: true,
|
|
535
|
+
error: null,
|
|
536
|
+
isIntermediateVirtualFolder: true
|
|
537
|
+
});
|
|
538
|
+
}).addCase(fetchCollectionVirtualFolders.fulfilled, function (state) {
|
|
539
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
540
|
+
isActiveVirtualFolderLoading: false,
|
|
541
|
+
isIntermediateVirtualFolder: true
|
|
542
|
+
});
|
|
543
|
+
}).addCase(fetchCollectionVirtualFolders.rejected, function (state, action) {
|
|
544
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
545
|
+
isActiveVirtualFolderLoading: initialState.isActiveVirtualFolderLoading,
|
|
546
|
+
activeUuid: initialState.activeUuid,
|
|
547
|
+
isIntermediateVirtualFolder: initialState.isIntermediateVirtualFolder,
|
|
548
|
+
error: getActionErrorState(state, action, true)
|
|
549
|
+
});
|
|
550
|
+
}).addCase(fetchCollections.pending, function (state, action) {
|
|
551
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
552
|
+
loading: true,
|
|
553
|
+
error: null
|
|
554
|
+
});
|
|
555
|
+
}).addCase(fetchCollections.rejected, function (state, action) {
|
|
556
|
+
return getActionErrorState(state, action);
|
|
557
|
+
}).addCase(fetchCollections.fulfilled, function (state, action) {
|
|
558
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
559
|
+
loading: false,
|
|
560
|
+
error: null
|
|
561
|
+
});
|
|
562
|
+
}).addMatcher(isAnyOf(activeCollectionsVirtualFolderUpdated, collectionActivated), function (state) {
|
|
563
|
+
var _activeCollection$dat;
|
|
564
|
+
var entities = state.entities,
|
|
565
|
+
activeUuid = state.activeUuid,
|
|
566
|
+
activeVirtualFolder = state.activeVirtualFolder;
|
|
567
|
+
var activeCollection = entities[activeUuid];
|
|
568
|
+
if (!activeCollection) return;
|
|
569
|
+
var isIntermediateVirtualFolder = (((_activeCollection$dat = activeCollection.data) === null || _activeCollection$dat === void 0 ? void 0 : _activeCollection$dat.groupby) || []).length && !(activeVirtualFolder !== null && activeVirtualFolder !== void 0 && activeVirtualFolder.filters);
|
|
570
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
571
|
+
isIntermediateVirtualFolder: isIntermediateVirtualFolder
|
|
572
|
+
});
|
|
573
|
+
}).addMatcher(function (_ref9) {
|
|
574
|
+
var type = _ref9.type;
|
|
575
|
+
return type.startsWith(sliceName) && type.endsWith('/rejected');
|
|
576
|
+
}, function (state, action) {
|
|
577
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
578
|
+
loading: false,
|
|
579
|
+
isActiveVirtualFolderLoading: false,
|
|
580
|
+
error: getActionErrorState(state, action, true)
|
|
581
|
+
});
|
|
582
|
+
});
|
|
583
|
+
}
|
|
584
|
+
});
|
|
585
|
+
var _collectionsSlice$act = collectionsSlice.actions,
|
|
586
|
+
collectionsAdded = _collectionsSlice$act.collectionsAdded,
|
|
587
|
+
collectionAdded = _collectionsSlice$act.collectionAdded,
|
|
588
|
+
collectionUpdated = _collectionsSlice$act.collectionUpdated,
|
|
589
|
+
collectionsRemoved = _collectionsSlice$act.collectionsRemoved,
|
|
590
|
+
collectionsReplaced = _collectionsSlice$act.collectionsReplaced,
|
|
591
|
+
collectionVirtualFoldersReplaced = _collectionsSlice$act.collectionVirtualFoldersReplaced,
|
|
592
|
+
collectionsSearchTermUpdated = _collectionsSlice$act.collectionsSearchTermUpdated,
|
|
593
|
+
collectionsSortingUpdated = _collectionsSlice$act.collectionsSortingUpdated,
|
|
594
|
+
collectionActivated = _collectionsSlice$act.collectionActivated,
|
|
595
|
+
collectionsSelected = _collectionsSlice$act.collectionsSelected,
|
|
596
|
+
activeCollectionsVirtualFolderUpdated = _collectionsSlice$act.activeCollectionsVirtualFolderUpdated,
|
|
597
|
+
collectionsDeselected = _collectionsSlice$act.collectionsDeselected,
|
|
598
|
+
singleCollectionUpdated = _collectionsSlice$act.singleCollectionUpdated,
|
|
599
|
+
allCollectionsSelected = _collectionsSlice$act.allCollectionsSelected,
|
|
600
|
+
collectionsStateUpdated = _collectionsSlice$act.collectionsStateUpdated,
|
|
601
|
+
collectionsStateReset = _collectionsSlice$act.collectionsStateReset;
|
|
602
|
+
export { collectionsAdded, collectionAdded, collectionUpdated, collectionsRemoved, collectionsReplaced, collectionVirtualFoldersReplaced, collectionsSearchTermUpdated, collectionsSortingUpdated, collectionActivated, collectionsSelected, activeCollectionsVirtualFolderUpdated, collectionsDeselected, singleCollectionUpdated, allCollectionsSelected, collectionsStateUpdated, collectionsStateReset };
|
|
603
|
+
export var selectCollectionsState = function selectCollectionsState(state) {
|
|
604
|
+
var _state$PLUGINS_IDS$EX;
|
|
605
|
+
return ((_state$PLUGINS_IDS$EX = state[PLUGINS_IDS.EXPLORER]) === null || _state$PLUGINS_IDS$EX === void 0 ? void 0 : _state$PLUGINS_IDS$EX[slicePropName]) || initialState;
|
|
606
|
+
};
|
|
607
|
+
export var selectCollections = function selectCollections(state) {
|
|
608
|
+
return selectCollectionsState(state).entities;
|
|
609
|
+
};
|
|
610
|
+
export var selectCollectionsUuids = function selectCollectionsUuids(state) {
|
|
611
|
+
return selectCollectionsState(state).uuids;
|
|
612
|
+
};
|
|
613
|
+
export var selectCollectionsArray = function selectCollectionsArray(state) {
|
|
614
|
+
return Object.values(selectCollections(state));
|
|
615
|
+
};
|
|
616
|
+
export var selectCollectionByUuid = function selectCollectionByUuid(state, uuid) {
|
|
617
|
+
return selectCollections(state)[uuid];
|
|
618
|
+
};
|
|
619
|
+
export var selectActiveCollectionUuid = function selectActiveCollectionUuid(state) {
|
|
620
|
+
return selectCollectionsState(state).activeUuid;
|
|
621
|
+
};
|
|
622
|
+
export var selectActiveCollection = function selectActiveCollection(state) {
|
|
623
|
+
return selectCollectionByUuid(state, selectActiveCollectionUuid(state));
|
|
624
|
+
};
|
|
625
|
+
export var selectIsCollectionsLoading = function selectIsCollectionsLoading(state) {
|
|
626
|
+
return selectIsCollectionsView(state) && selectCollectionsState(state).loading;
|
|
627
|
+
};
|
|
628
|
+
export var selectCollectionsSearchTerm = function selectCollectionsSearchTerm(state) {
|
|
629
|
+
return selectCollectionsState(state).searchTerm;
|
|
630
|
+
};
|
|
631
|
+
export var selectSelectedCollectionsUuids = function selectSelectedCollectionsUuids(state) {
|
|
632
|
+
return selectCollectionsState(state).selectedUuids;
|
|
633
|
+
};
|
|
634
|
+
export var selectIsCollectionsActivated = function selectIsCollectionsActivated(state) {
|
|
635
|
+
return !!selectActiveCollectionUuid(state);
|
|
636
|
+
};
|
|
637
|
+
export var selectCollectionsActiveVirtualFolder = function selectCollectionsActiveVirtualFolder(state) {
|
|
638
|
+
return selectCollectionsState(state).activeVirtualFolder;
|
|
639
|
+
};
|
|
640
|
+
export var selectCollectionsActiveVirtualFolderChildren = function selectCollectionsActiveVirtualFolderChildren(state) {
|
|
641
|
+
var _selectCollectionsAct;
|
|
642
|
+
return (_selectCollectionsAct = selectCollectionsActiveVirtualFolder(state)) === null || _selectCollectionsAct === void 0 ? void 0 : _selectCollectionsAct.children;
|
|
643
|
+
};
|
|
644
|
+
export var selectIsCollectionTreeOpened = function selectIsCollectionTreeOpened(state) {
|
|
645
|
+
return selectCollectionsState(state).showTree;
|
|
646
|
+
};
|
|
647
|
+
export var selectIsIntermediateVirtualFolder = function selectIsIntermediateVirtualFolder(state) {
|
|
648
|
+
return selectCollectionsState(state).isIntermediateVirtualFolder;
|
|
649
|
+
};
|
|
650
|
+
export var selectIsActiveVirtualFolderLoading = function selectIsActiveVirtualFolderLoading(state) {
|
|
651
|
+
return selectCollectionsState(state).isActiveVirtualFolderLoading;
|
|
652
|
+
};
|
|
653
|
+
export var selectCollectionsActiveVirtualFolders = function selectCollectionsActiveVirtualFolders(state) {
|
|
654
|
+
return selectCollectionsState(state).activeVirtualFolders;
|
|
655
|
+
};
|
|
656
|
+
export var selectCollectionsActiveVirtualFoldersArray = function selectCollectionsActiveVirtualFoldersArray(state) {
|
|
657
|
+
return Object.values(selectCollectionsActiveVirtualFolders(state));
|
|
658
|
+
};
|
|
659
|
+
export var selectCollectionsActiveVirtualFolderByUuid = function selectCollectionsActiveVirtualFolderByUuid(state, uuid) {
|
|
660
|
+
return selectCollectionsActiveVirtualFolders(state)[uuid];
|
|
661
|
+
};
|
|
662
|
+
export var selectActiveCollectionsVirtualFoldersPaths = function selectActiveCollectionsVirtualFoldersPaths(state) {
|
|
663
|
+
return selectCollectionsState(state).activeVirtualFoldersPaths;
|
|
664
|
+
};
|
|
665
|
+
export var selectCollectionsSortBy = function selectCollectionsSortBy(state) {
|
|
666
|
+
return selectCollectionsState(state).sortedBy;
|
|
667
|
+
};
|
|
668
|
+
export var selectCollectionsSortOrder = function selectCollectionsSortOrder(state) {
|
|
669
|
+
return selectCollectionsState(state).sortOrder;
|
|
670
|
+
};
|
|
671
|
+
export var selectCollectionsError = function selectCollectionsError(state) {
|
|
672
|
+
return selectCollectionsState(state).error;
|
|
673
|
+
};
|
|
674
|
+
export var selectSelectedCollections = createSelector([selectCollections, selectSelectedCollectionsUuids], function (collections, selectedUuids) {
|
|
675
|
+
return selectedUuids.map(function (uuid) {
|
|
676
|
+
return collections[uuid];
|
|
677
|
+
});
|
|
678
|
+
});
|
|
679
|
+
export var selectIsAllCollectionsSelected = createSelector([selectSelectedCollectionsUuids, selectCollectionsUuids], function (selectedUuids, collectionsUuids) {
|
|
680
|
+
return selectedUuids.length > 0 && selectedUuids.length === collectionsUuids.length;
|
|
681
|
+
});
|
|
682
|
+
export var selectCollectionsUuidsBySearchTerm = createSelector([selectCollections, selectCollectionsUuids, function (_state, searchTerm) {
|
|
683
|
+
return searchTerm;
|
|
684
|
+
}], function (collections, collectionsUuids, searchTerm) {
|
|
685
|
+
return !searchTerm ? _toConsumableArray(collectionsUuids) : _toConsumableArray(collectionsUuids).filter(function (collectionUuid) {
|
|
686
|
+
var _collections$collecti = collections[collectionUuid].title,
|
|
687
|
+
title = _collections$collecti === void 0 ? '' : _collections$collecti;
|
|
688
|
+
return new RegExp(escapeRegExp(searchTerm), 'i').test(title);
|
|
689
|
+
});
|
|
690
|
+
});
|
|
691
|
+
export var selectCollectionsFilteredVirtualFolders = createSelector([selectCollectionsActiveVirtualFoldersArray, function (_state, searchTerm) {
|
|
692
|
+
return searchTerm;
|
|
693
|
+
}], function (virtualFolders, searchTerm) {
|
|
694
|
+
return !searchTerm ? virtualFolders : filterFolders(virtualFolders, searchTerm);
|
|
695
|
+
});
|
|
696
|
+
var sortFolders = function sortFolders() {
|
|
697
|
+
var folders = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
698
|
+
var sortBy = arguments.length > 1 ? arguments[1] : undefined;
|
|
699
|
+
var sortOrder = arguments.length > 2 ? arguments[2] : undefined;
|
|
700
|
+
if (sortBy) {
|
|
701
|
+
return _toConsumableArray(folders).sort(function (aFolder, bFolder) {
|
|
702
|
+
var _x$sortBy2, _y$sortBy2;
|
|
703
|
+
var x = sortOrder === SORT_ORDER.ASC ? aFolder : bFolder;
|
|
704
|
+
var y = sortOrder === SORT_ORDER.ASC ? bFolder : aFolder;
|
|
705
|
+
var xValue = (_x$sortBy2 = x === null || x === void 0 ? void 0 : x[sortBy]) !== null && _x$sortBy2 !== void 0 ? _x$sortBy2 : '';
|
|
706
|
+
var yValue = (_y$sortBy2 = y === null || y === void 0 ? void 0 : y[sortBy]) !== null && _y$sortBy2 !== void 0 ? _y$sortBy2 : '';
|
|
707
|
+
return xValue.toString().localeCompare(yValue);
|
|
708
|
+
});
|
|
709
|
+
}
|
|
710
|
+
return folders;
|
|
711
|
+
};
|
|
712
|
+
export var selectSortedCollectionsActiveVirtualFoldersArray = createSelector([selectCollectionsActiveVirtualFoldersArray, selectCollectionsSortBy, selectCollectionsSortOrder], sortFolders);
|
|
713
|
+
export var selectCollectionsActiveVirtualFolderSortedChildren = createSelector([selectCollectionsActiveVirtualFolderChildren, selectCollectionsSortBy, selectCollectionsSortOrder], sortFolders);
|
|
714
|
+
export default collectionsSlice.reducer;
|