@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,652 @@
|
|
|
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 _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
3
|
+
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."); }
|
|
4
|
+
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; } }
|
|
5
|
+
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
6
|
+
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
7
|
+
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; }
|
|
8
|
+
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; }
|
|
9
|
+
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; }
|
|
10
|
+
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; }
|
|
11
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
12
|
+
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); }
|
|
13
|
+
import { createSelector, createSlice } from '@reduxjs/toolkit';
|
|
14
|
+
import createThunk from '@scaleflex/widget-utils/lib/createThunk';
|
|
15
|
+
import { VIEW_IDS, PLUGINS_IDS, FMAW_URL_QUERY_PARAMS } from '@scaleflex/widget-utils/lib/constants';
|
|
16
|
+
import escapeRegExp from '@scaleflex/widget-utils/lib/escapeRegExp';
|
|
17
|
+
import getActionErrorState from '@scaleflex/widget-utils/lib/getActionErrorState';
|
|
18
|
+
import { filesRemoved, searchFilesService } from './files.slice';
|
|
19
|
+
import { downloadOneFile, downloadItems } from '../thunks/downloads.thunks';
|
|
20
|
+
import { selectIsLabelsView, changeView, searchOrListViewFiles, changeViewFetchFilesCachedQueries } from './views.slice';
|
|
21
|
+
import { SORT_ORDER, SORT_BY } from '../components/common/Sort/Sort.constants';
|
|
22
|
+
import { selectionsCleared } from './selections.slice';
|
|
23
|
+
import { currentFolderUpdated } from './folders.slice';
|
|
24
|
+
import { applyBulkFilesPropertiesChanges, updateBulkFilesLabels } from './metadata.slice';
|
|
25
|
+
import { fileWindowUpdated } from './panels.slice';
|
|
26
|
+
import { exactAndExtendedFilesRemoved } from './search.slice';
|
|
27
|
+
|
|
28
|
+
// TODO: We are hardcoding file slice name as it causes initialization error
|
|
29
|
+
var filesSliceName = 'Explorer/files';
|
|
30
|
+
var slicePropName = 'labels';
|
|
31
|
+
var sliceName = "".concat(PLUGINS_IDS.EXPLORER, "/").concat(slicePropName);
|
|
32
|
+
var ATTACH_LABELS_TO_FILES_LIMIT = 250;
|
|
33
|
+
var BULK_EDIT_LABELS_TYPES = {
|
|
34
|
+
ADD: 'labels.add',
|
|
35
|
+
DELETE: 'labels.del'
|
|
36
|
+
};
|
|
37
|
+
var initialState = {
|
|
38
|
+
uuids: [],
|
|
39
|
+
entities: {},
|
|
40
|
+
activeLabelUuid: null,
|
|
41
|
+
searchTerm: '',
|
|
42
|
+
selectedUuids: [],
|
|
43
|
+
sortOrder: SORT_ORDER.ASC,
|
|
44
|
+
sortedBy: SORT_BY.NAME,
|
|
45
|
+
loading: true,
|
|
46
|
+
showTree: true,
|
|
47
|
+
error: null
|
|
48
|
+
};
|
|
49
|
+
var checkIfReachedTheLimit = function checkIfReachedTheLimit(filesUuids) {
|
|
50
|
+
return filesUuids.length >= ATTACH_LABELS_TO_FILES_LIMIT;
|
|
51
|
+
};
|
|
52
|
+
var prepareBulkAttachedLabels = function prepareBulkAttachedLabels(type, labelsSids) {
|
|
53
|
+
return labelsSids.map(function (labelSid) {
|
|
54
|
+
return {
|
|
55
|
+
type: type,
|
|
56
|
+
value: labelSid
|
|
57
|
+
};
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
// Used only in enabling/opening/activating labels view, and possible to open a specific label after loading the view through its param.
|
|
62
|
+
export var activateLabelsView = createThunk(async function () {
|
|
63
|
+
var _labels, _selectSortedLabelsUu;
|
|
64
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
65
|
+
_ref$itemToOpen = _ref.itemToOpen,
|
|
66
|
+
labelUuidOrSidToActivate = _ref$itemToOpen === void 0 ? null : _ref$itemToOpen,
|
|
67
|
+
_ref$skipViewDispatch = _ref.skipViewDispatch,
|
|
68
|
+
skipViewDispatch = _ref$skipViewDispatch === void 0 ? false : _ref$skipViewDispatch,
|
|
69
|
+
_ref$skipFetch = _ref.skipFetch,
|
|
70
|
+
skipFetch = _ref$skipFetch === void 0 ? false : _ref$skipFetch,
|
|
71
|
+
_ref$keepFiltersAndSe = _ref.keepFiltersAndSearch,
|
|
72
|
+
keepFiltersAndSearch = _ref$keepFiltersAndSe === void 0 ? false : _ref$keepFiltersAndSe,
|
|
73
|
+
_ref$fromUrl = _ref.fromUrl,
|
|
74
|
+
fromUrl = _ref$fromUrl === void 0 ? false : _ref$fromUrl;
|
|
75
|
+
var thunkApi = arguments.length > 1 ? arguments[1] : undefined;
|
|
76
|
+
var dispatch = thunkApi.dispatch,
|
|
77
|
+
getState = thunkApi.getState,
|
|
78
|
+
signal = thunkApi.signal,
|
|
79
|
+
extra = thunkApi.extra;
|
|
80
|
+
var _extra$filerobot = extra.filerobot,
|
|
81
|
+
i18n = _extra$filerobot.i18n,
|
|
82
|
+
info = _extra$filerobot.info;
|
|
83
|
+
if (!skipViewDispatch) dispatch(changeView({
|
|
84
|
+
view: VIEW_IDS.LABELS,
|
|
85
|
+
keepFiltersAndSearch: keepFiltersAndSearch,
|
|
86
|
+
fromUrl: fromUrl
|
|
87
|
+
}));
|
|
88
|
+
dispatch(currentFolderUpdated({}));
|
|
89
|
+
dispatch(filesRemoved());
|
|
90
|
+
dispatch(exactAndExtendedFilesRemoved([]));
|
|
91
|
+
var labels;
|
|
92
|
+
if (!skipFetch) {
|
|
93
|
+
labels = await dispatch(fetchLabels({
|
|
94
|
+
abortSignal: signal
|
|
95
|
+
})).throwRejection();
|
|
96
|
+
}
|
|
97
|
+
var state = getState();
|
|
98
|
+
var foundLabel = labelUuidOrSidToActivate && (selectLabelByUuid(state, labelUuidOrSidToActivate) || ((_labels = labels) === null || _labels === void 0 ? void 0 : _labels.length) > 0 && labels.find(function () {
|
|
99
|
+
var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
100
|
+
sid = _ref2.sid;
|
|
101
|
+
return sid === labelUuidOrSidToActivate;
|
|
102
|
+
}));
|
|
103
|
+
if (labelUuidOrSidToActivate && !foundLabel) {
|
|
104
|
+
info(i18n('labelsDefaultLabelError'), 'error', 3000);
|
|
105
|
+
dispatch(labelsStateUpdated({
|
|
106
|
+
error: {
|
|
107
|
+
message: i18n('labelsDefaultLabelError'),
|
|
108
|
+
details: i18n('labelsDefaultLabelErrorDescription')
|
|
109
|
+
}
|
|
110
|
+
}));
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
var labelUuid = (foundLabel === null || foundLabel === void 0 ? void 0 : foundLabel.uuid) || ((_selectSortedLabelsUu = selectSortedLabelsUuids(state)) === null || _selectSortedLabelsUu === void 0 ? void 0 : _selectSortedLabelsUu[0]);
|
|
114
|
+
return labelUuid ? dispatch(activateLabel({
|
|
115
|
+
uuid: labelUuid,
|
|
116
|
+
fromUrl: fromUrl
|
|
117
|
+
})) : null;
|
|
118
|
+
});
|
|
119
|
+
export var toggleLabelsTree = createThunk(function (showTree, thunkApi) {
|
|
120
|
+
var newValue = showTree !== null && showTree !== void 0 ? showTree : !selectIsLabelsTreeOpened(thunkApi.getState());
|
|
121
|
+
thunkApi.dispatch(labelsStateUpdated({
|
|
122
|
+
showTree: newValue
|
|
123
|
+
}));
|
|
124
|
+
thunkApi.extra.filerobot.emit('labels-tree-trigger', newValue);
|
|
125
|
+
return newValue;
|
|
126
|
+
});
|
|
127
|
+
export var fetchLabelFiles = createThunk(async function () {
|
|
128
|
+
var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
129
|
+
labelSid = _ref3.labelSid,
|
|
130
|
+
offset = _ref3.offset,
|
|
131
|
+
_ref3$replaceOldFiles = _ref3.replaceOldFiles,
|
|
132
|
+
replaceOldFiles = _ref3$replaceOldFiles === void 0 ? false : _ref3$replaceOldFiles,
|
|
133
|
+
sortBy = _ref3.sortBy,
|
|
134
|
+
sortOrder = _ref3.sortOrder,
|
|
135
|
+
_ref3$skipPending = _ref3.skipPending,
|
|
136
|
+
skipPending = _ref3$skipPending === void 0 ? true : _ref3$skipPending,
|
|
137
|
+
_ref3$abortSignal = _ref3.abortSignal,
|
|
138
|
+
abortSignal = _ref3$abortSignal === void 0 ? null : _ref3$abortSignal;
|
|
139
|
+
var thunkApi = arguments.length > 1 ? arguments[1] : undefined;
|
|
140
|
+
var state = thunkApi.getState();
|
|
141
|
+
var sid = labelSid || selectActiveLabelSid(state);
|
|
142
|
+
var result = await thunkApi.dispatch(searchOrListViewFiles({
|
|
143
|
+
cachedViewQueries: {
|
|
144
|
+
labels: sid.replace('#', ''),
|
|
145
|
+
recursive: true
|
|
146
|
+
},
|
|
147
|
+
offset: offset,
|
|
148
|
+
sorting: sortBy && sortOrder && [sortBy, sortOrder],
|
|
149
|
+
skipPendingDispatch: skipPending,
|
|
150
|
+
replaceOldFiles: replaceOldFiles,
|
|
151
|
+
abortSignal: abortSignal,
|
|
152
|
+
withStats: false
|
|
153
|
+
}));
|
|
154
|
+
return result;
|
|
155
|
+
}, {
|
|
156
|
+
actionType: "".concat(sliceName, "/fetchLabelFiles")
|
|
157
|
+
});
|
|
158
|
+
export var activateFirstLabel = createThunk(function (_, thunkApi) {
|
|
159
|
+
var _labels$;
|
|
160
|
+
var labels = selectLabelsArray(thunkApi.getState());
|
|
161
|
+
return thunkApi.dispatch(activateLabel({
|
|
162
|
+
uuid: (_labels$ = labels[0]) === null || _labels$ === void 0 ? void 0 : _labels$.uuid
|
|
163
|
+
}));
|
|
164
|
+
});
|
|
165
|
+
export var activateLabel = createThunk(function (_ref4, thunkApi) {
|
|
166
|
+
var labelUuid = _ref4.uuid,
|
|
167
|
+
labelSid = _ref4.sid,
|
|
168
|
+
_ref4$abortSignal = _ref4.abortSignal,
|
|
169
|
+
abortSignal = _ref4$abortSignal === void 0 ? null : _ref4$abortSignal,
|
|
170
|
+
fromUrl = _ref4.fromUrl;
|
|
171
|
+
var state = thunkApi.getState();
|
|
172
|
+
if (!labelUuid) {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
if (!fromUrl) {
|
|
176
|
+
// Close file details panel when activate label, unless it's from url then don't close it as we might open file window from url in labels view
|
|
177
|
+
thunkApi.dispatch(fileWindowUpdated(null));
|
|
178
|
+
}
|
|
179
|
+
var isLabelsViewNotActivated = !selectIsLabelsView(state);
|
|
180
|
+
if (isLabelsViewNotActivated) {
|
|
181
|
+
thunkApi.dispatch(activateLabelsView({
|
|
182
|
+
itemToOpen: labelUuid
|
|
183
|
+
}));
|
|
184
|
+
} else {
|
|
185
|
+
var _thunkApi$extra$filer;
|
|
186
|
+
var _ref5 = labelSid ? {
|
|
187
|
+
sid: labelSid
|
|
188
|
+
} : selectLabelByUuid(state, labelUuid) || {},
|
|
189
|
+
_ref5$sid = _ref5.sid,
|
|
190
|
+
sid = _ref5$sid === void 0 ? '' : _ref5$sid;
|
|
191
|
+
if (!sid) {
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
thunkApi.dispatch(labelActivated({
|
|
195
|
+
labelUuid: labelUuid,
|
|
196
|
+
selectedUuids: []
|
|
197
|
+
}));
|
|
198
|
+
// We are not awaiting for the request to finish, as we don't want to wait for it to finish to activate the label
|
|
199
|
+
(_thunkApi$extra$filer = thunkApi.extra.filerobot.getPlugin(PLUGINS_IDS.EXPLORER)) === null || _thunkApi$extra$filer === void 0 ? void 0 : _thunkApi$extra$filer.updateViewQueryInUrl({
|
|
200
|
+
viewItem: sid
|
|
201
|
+
});
|
|
202
|
+
return thunkApi.dispatch(fetchLabelFiles({
|
|
203
|
+
labelSid: sid,
|
|
204
|
+
offset: 0,
|
|
205
|
+
skipPending: false,
|
|
206
|
+
abortSignal: abortSignal
|
|
207
|
+
}));
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
export var downloadLabelAssets = createThunk(async function (labelUuid, thunkApi) {
|
|
211
|
+
var _selectLabelByUuid;
|
|
212
|
+
var labelSid = (_selectLabelByUuid = selectLabelByUuid(thunkApi.getState(), labelUuid)) === null || _selectLabelByUuid === void 0 ? void 0 : _selectLabelByUuid.sid;
|
|
213
|
+
var _await$searchFilesSer = await searchFilesService({
|
|
214
|
+
filters: {
|
|
215
|
+
labels: [labelSid]
|
|
216
|
+
},
|
|
217
|
+
recursive: true
|
|
218
|
+
}, thunkApi),
|
|
219
|
+
_await$searchFilesSer2 = _await$searchFilesSer.files,
|
|
220
|
+
files = _await$searchFilesSer2 === void 0 ? [] : _await$searchFilesSer2;
|
|
221
|
+
return thunkApi.dispatch(files.length === 1 ? downloadOneFile({
|
|
222
|
+
file: files[0]
|
|
223
|
+
}) : downloadItems({
|
|
224
|
+
items: files
|
|
225
|
+
}));
|
|
226
|
+
});
|
|
227
|
+
export var fetchLabels = createThunk(async function () {
|
|
228
|
+
var _ref6 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
229
|
+
avoidLabelsUpdate = _ref6.avoidLabelsUpdate;
|
|
230
|
+
var thunkApi = arguments.length > 1 ? arguments[1] : undefined;
|
|
231
|
+
if (avoidLabelsUpdate) {
|
|
232
|
+
thunkApi.skipDispatch();
|
|
233
|
+
}
|
|
234
|
+
var _await$thunkApi$extra = await thunkApi.extra.apiClient.get('labels', {
|
|
235
|
+
id: 'listLabels',
|
|
236
|
+
abortSignal: thunkApi.signal
|
|
237
|
+
}),
|
|
238
|
+
labels = _await$thunkApi$extra.labels;
|
|
239
|
+
return labels || [];
|
|
240
|
+
}, {
|
|
241
|
+
actionType: "".concat(sliceName, "/fetchLabels")
|
|
242
|
+
});
|
|
243
|
+
export var createLabel = createThunk(async function (_ref7, thunkApi) {
|
|
244
|
+
var _ref7$label = _ref7.label,
|
|
245
|
+
label = _ref7$label === void 0 ? {} : _ref7$label,
|
|
246
|
+
_ref7$selectionUuids = _ref7.selectionUuids,
|
|
247
|
+
selectionUuids = _ref7$selectionUuids === void 0 ? [] : _ref7$selectionUuids;
|
|
248
|
+
/**
|
|
249
|
+
* !TODO: Once we have the whole new label object returned in the backend request's response, we should return the addedLabel const...
|
|
250
|
+
* then add a case for it in extraReducer to append that label to labels entities for enabling auto updating with no additional requests
|
|
251
|
+
* (FRA-2623)
|
|
252
|
+
*/
|
|
253
|
+
var _await$thunkApi$extra2 = await thunkApi.extra.apiClient.post('labels', {
|
|
254
|
+
data: {
|
|
255
|
+
label: label
|
|
256
|
+
},
|
|
257
|
+
abortSignal: thunkApi.signal
|
|
258
|
+
}),
|
|
259
|
+
_await$thunkApi$extra3 = _await$thunkApi$extra2.label,
|
|
260
|
+
addedLabel = _await$thunkApi$extra3 === void 0 ? {} : _await$thunkApi$extra3;
|
|
261
|
+
var updatedLabels = await thunkApi.dispatch(fetchLabels({
|
|
262
|
+
avoidLabelsUpdate: true
|
|
263
|
+
}));
|
|
264
|
+
var newLabelUuid = addedLabel.uuid;
|
|
265
|
+
var newActiveLabel = (updatedLabels || []).find(function (label) {
|
|
266
|
+
return label.uuid === newLabelUuid;
|
|
267
|
+
}) || addedLabel;
|
|
268
|
+
|
|
269
|
+
// If we have files selection we need to add new label to those files and redirect to active label view
|
|
270
|
+
if (selectionUuids.length > 0 && newActiveLabel) {
|
|
271
|
+
await thunkApi.dispatch(attachFilesLabels({
|
|
272
|
+
filesUuids: selectionUuids,
|
|
273
|
+
labelsSids: [newActiveLabel.sid]
|
|
274
|
+
}));
|
|
275
|
+
}
|
|
276
|
+
return [newActiveLabel];
|
|
277
|
+
}, {
|
|
278
|
+
actionType: "".concat(sliceName, "/createLabel")
|
|
279
|
+
});
|
|
280
|
+
export var updateLabelByUuid = createThunk(async function () {
|
|
281
|
+
var label = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
282
|
+
var thunkApi = arguments.length > 1 ? arguments[1] : undefined;
|
|
283
|
+
var labelUuid = label.uuid;
|
|
284
|
+
/**
|
|
285
|
+
* !TODO: Once we have the whole label object returned in the backend request's response,
|
|
286
|
+
* then we shold un-comment the updatedLabel const & remove dispatched fetchLabels
|
|
287
|
+
* (FRA-2623)
|
|
288
|
+
*/
|
|
289
|
+
// const { label: updatedLabel } = await thunkApi.extra.apiClient.put(
|
|
290
|
+
await thunkApi.extra.apiClient.put("labels/".concat(labelUuid), {
|
|
291
|
+
data: {
|
|
292
|
+
label: label
|
|
293
|
+
},
|
|
294
|
+
abortSignal: thunkApi.signal
|
|
295
|
+
});
|
|
296
|
+
var labels = await thunkApi.dispatch(fetchLabels({
|
|
297
|
+
avoidLabelsUpdate: true
|
|
298
|
+
}));
|
|
299
|
+
var updatedLabel = (labels || []).find(function (label) {
|
|
300
|
+
return label.uuid === labelUuid;
|
|
301
|
+
});
|
|
302
|
+
return updatedLabel;
|
|
303
|
+
}, {
|
|
304
|
+
actionType: "".concat(sliceName, "/updateLabelByUuid")
|
|
305
|
+
});
|
|
306
|
+
export var deleteLabels = createThunk(async function () {
|
|
307
|
+
var labelsUuids = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
308
|
+
var thunkApi = arguments.length > 1 ? arguments[1] : undefined;
|
|
309
|
+
var dispatch = thunkApi.dispatch,
|
|
310
|
+
extra = thunkApi.extra,
|
|
311
|
+
getState = thunkApi.getState;
|
|
312
|
+
var response = await thunkApi.extra.apiClient["delete"]('labels', {
|
|
313
|
+
data: {
|
|
314
|
+
labels: labelsUuids
|
|
315
|
+
},
|
|
316
|
+
abortSignal: thunkApi.signal
|
|
317
|
+
});
|
|
318
|
+
var _thunkApi$extra$filer2 = thunkApi.extra.filerobot.getPlugin(PLUGINS_IDS.EXPLORER),
|
|
319
|
+
deleteUrlQueryParams = _thunkApi$extra$filer2.deleteUrlQueryParams;
|
|
320
|
+
var state = getState();
|
|
321
|
+
var labelsSids = labelsUuids.map(function (labelUuid) {
|
|
322
|
+
var _selectLabelByUuid2;
|
|
323
|
+
return (_selectLabelByUuid2 = selectLabelByUuid(state, labelUuid)) === null || _selectLabelByUuid2 === void 0 ? void 0 : _selectLabelByUuid2.sid;
|
|
324
|
+
});
|
|
325
|
+
dispatch(labelsRemoved(labelsUuids));
|
|
326
|
+
|
|
327
|
+
// Deactivate label if it was deleted + remove all previously active label files + remove URL query param
|
|
328
|
+
var activeLabelUuid = selectActiveLabelUuid(getState());
|
|
329
|
+
if (activeLabelUuid && labelsUuids.includes(activeLabelUuid)) {
|
|
330
|
+
dispatch(filesRemoved());
|
|
331
|
+
dispatch(exactAndExtendedFilesRemoved([]));
|
|
332
|
+
dispatch(labelActivated({
|
|
333
|
+
labelUuid: null,
|
|
334
|
+
selectedUuids: []
|
|
335
|
+
}));
|
|
336
|
+
deleteUrlQueryParams([FMAW_URL_QUERY_PARAMS.VIEW_ITEM, FMAW_URL_QUERY_PARAMS.VIEW_SUB_ITEM]);
|
|
337
|
+
changeViewFetchFilesCachedQueries(null);
|
|
338
|
+
}
|
|
339
|
+
extra.filerobot.emit('objects-removed', labelsSids, 'labels');
|
|
340
|
+
return response;
|
|
341
|
+
});
|
|
342
|
+
export var applyBulkAttachedLabels = createThunk(async function (_ref8, thunkApi) {
|
|
343
|
+
var type = _ref8.type,
|
|
344
|
+
filesUuids = _ref8.filesUuids,
|
|
345
|
+
labelsSids = _ref8.labelsSids;
|
|
346
|
+
var dispatch = thunkApi.dispatch;
|
|
347
|
+
var changes = prepareBulkAttachedLabels(type, labelsSids);
|
|
348
|
+
var bulkEditPayload = {
|
|
349
|
+
filesUuids: filesUuids
|
|
350
|
+
};
|
|
351
|
+
if (type === BULK_EDIT_LABELS_TYPES.ADD) {
|
|
352
|
+
bulkEditPayload.addedLabels = labelsSids;
|
|
353
|
+
} else {
|
|
354
|
+
bulkEditPayload.removedLabels = labelsSids;
|
|
355
|
+
}
|
|
356
|
+
await dispatch(applyBulkFilesPropertiesChanges({
|
|
357
|
+
filesUuids: filesUuids,
|
|
358
|
+
changes: changes
|
|
359
|
+
}));
|
|
360
|
+
dispatch(updateBulkFilesLabels({
|
|
361
|
+
filesUuids: filesUuids,
|
|
362
|
+
addedLabels: labelsSids
|
|
363
|
+
}));
|
|
364
|
+
});
|
|
365
|
+
export var attachFilesLabels = createThunk(async function (_ref9, thunkApi) {
|
|
366
|
+
var _ref9$filesUuids = _ref9.filesUuids,
|
|
367
|
+
filesUuids = _ref9$filesUuids === void 0 ? [] : _ref9$filesUuids,
|
|
368
|
+
_ref9$labelsSids = _ref9.labelsSids,
|
|
369
|
+
labelsSids = _ref9$labelsSids === void 0 ? [] : _ref9$labelsSids;
|
|
370
|
+
if (checkIfReachedTheLimit(filesUuids)) {
|
|
371
|
+
thunkApi.dispatch(applyBulkAttachedLabels({
|
|
372
|
+
type: BULK_EDIT_LABELS_TYPES.ADD,
|
|
373
|
+
filesUuids: filesUuids,
|
|
374
|
+
labelsSids: labelsSids
|
|
375
|
+
}));
|
|
376
|
+
thunkApi.dispatch(selectionsCleared());
|
|
377
|
+
return;
|
|
378
|
+
}
|
|
379
|
+
var isOneFileOnly = filesUuids.length === 1;
|
|
380
|
+
// attach labels in files request (first case for single file and second for multiple files)
|
|
381
|
+
var response = await thunkApi.extra.apiClient.post(isOneFileOnly ? "files/".concat(filesUuids[0], "/labels") : 'files/labels',
|
|
382
|
+
// else case => Attaching N labels to M files
|
|
383
|
+
{
|
|
384
|
+
data: _objectSpread({
|
|
385
|
+
labels: labelsSids
|
|
386
|
+
}, !isOneFileOnly && {
|
|
387
|
+
files_uuids: filesUuids
|
|
388
|
+
})
|
|
389
|
+
});
|
|
390
|
+
return response.files || [response.file];
|
|
391
|
+
}, {
|
|
392
|
+
actionType: "".concat(filesSliceName, "/updateFilesByAttachLabels")
|
|
393
|
+
});
|
|
394
|
+
export var detachFilesLabels = createThunk(async function (_ref10, thunkApi) {
|
|
395
|
+
var _ref10$filesUuids = _ref10.filesUuids,
|
|
396
|
+
filesUuids = _ref10$filesUuids === void 0 ? [] : _ref10$filesUuids,
|
|
397
|
+
_ref10$labelsSids = _ref10.labelsSids,
|
|
398
|
+
labelsSids = _ref10$labelsSids === void 0 ? [] : _ref10$labelsSids,
|
|
399
|
+
toggleContextMenu = _ref10.toggleContextMenu;
|
|
400
|
+
if (checkIfReachedTheLimit(filesUuids)) {
|
|
401
|
+
thunkApi.dispatch(applyBulkAttachedLabels({
|
|
402
|
+
type: BULK_EDIT_LABELS_TYPES.DELETE,
|
|
403
|
+
filesUuids: filesUuids,
|
|
404
|
+
labelsSids: labelsSids
|
|
405
|
+
}));
|
|
406
|
+
thunkApi.dispatch(selectionsCleared());
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
409
|
+
var isOneFileOnly = filesUuids.length === 1;
|
|
410
|
+
var response = await thunkApi.extra.apiClient["delete"](isOneFileOnly ? "files/".concat(filesUuids[0], "/labels") : 'files/labels',
|
|
411
|
+
// else case => // Detaching N labels from M files
|
|
412
|
+
{
|
|
413
|
+
data: _objectSpread({
|
|
414
|
+
labels: labelsSids
|
|
415
|
+
}, !isOneFileOnly && {
|
|
416
|
+
files_uuids: filesUuids
|
|
417
|
+
})
|
|
418
|
+
});
|
|
419
|
+
if (typeof toggleContextMenu === 'function') {
|
|
420
|
+
toggleContextMenu();
|
|
421
|
+
}
|
|
422
|
+
thunkApi.dispatch(selectionsCleared());
|
|
423
|
+
return {
|
|
424
|
+
removeFiles: true,
|
|
425
|
+
filesUuids: response.files ? response.files.map(function (_ref11) {
|
|
426
|
+
var uuid = _ref11.uuid;
|
|
427
|
+
return uuid;
|
|
428
|
+
}) : [response.file.uuid]
|
|
429
|
+
};
|
|
430
|
+
}, {
|
|
431
|
+
actionType: "".concat(filesSliceName, "/updateFilesByDeAttachLabels")
|
|
432
|
+
});
|
|
433
|
+
var labelsSlice = createSlice({
|
|
434
|
+
name: sliceName,
|
|
435
|
+
initialState: initialState,
|
|
436
|
+
reducers: {
|
|
437
|
+
labelsAdded: function labelsAdded(state, action) {
|
|
438
|
+
var newLabels = _objectSpread({}, state.entities);
|
|
439
|
+
var newLabelsUuids = _toConsumableArray(state.uuids);
|
|
440
|
+
action.payload.forEach(function (label) {
|
|
441
|
+
newLabels[label.uuid] = label;
|
|
442
|
+
newLabelsUuids.push(label.uuid);
|
|
443
|
+
});
|
|
444
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
445
|
+
uuids: _toConsumableArray(new Set(newLabelsUuids)),
|
|
446
|
+
entities: newLabels,
|
|
447
|
+
loading: false,
|
|
448
|
+
error: null
|
|
449
|
+
});
|
|
450
|
+
},
|
|
451
|
+
labelUpdated: function labelUpdated(state, action) {
|
|
452
|
+
var newLabels = _objectSpread({}, state.entities);
|
|
453
|
+
newLabels[action.payload.uuid] = _objectSpread(_objectSpread({}, newLabels[action.payload.uuid]), action.payload);
|
|
454
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
455
|
+
entities: newLabels
|
|
456
|
+
});
|
|
457
|
+
},
|
|
458
|
+
labelsRemoved: function labelsRemoved(state, action) {
|
|
459
|
+
var labelsUuids = action.payload;
|
|
460
|
+
var newLabels = _objectSpread({}, state.entities);
|
|
461
|
+
var newLabelsUuids = _toConsumableArray(state.uuids);
|
|
462
|
+
labelsUuids.forEach(function (labelUuid) {
|
|
463
|
+
newLabelsUuids.splice(newLabelsUuids.indexOf(labelUuid), 1);
|
|
464
|
+
delete newLabels[labelUuid];
|
|
465
|
+
});
|
|
466
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
467
|
+
uuids: newLabelsUuids,
|
|
468
|
+
entities: newLabels
|
|
469
|
+
});
|
|
470
|
+
},
|
|
471
|
+
labelsSearchTermUpdated: function labelsSearchTermUpdated(state, action) {
|
|
472
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
473
|
+
searchTerm: action.payload
|
|
474
|
+
});
|
|
475
|
+
},
|
|
476
|
+
labelsSortingUpdated: function labelsSortingUpdated(state, action) {
|
|
477
|
+
var _action$payload = action.payload,
|
|
478
|
+
_action$payload$sortB = _action$payload.sortBy,
|
|
479
|
+
sortBy = _action$payload$sortB === void 0 ? state.sortedBy : _action$payload$sortB,
|
|
480
|
+
_action$payload$order = _action$payload.order,
|
|
481
|
+
order = _action$payload$order === void 0 ? state.sortOrder : _action$payload$order;
|
|
482
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
483
|
+
sortedBy: sortBy,
|
|
484
|
+
sortOrder: order
|
|
485
|
+
});
|
|
486
|
+
},
|
|
487
|
+
labelActivated: function labelActivated(state, action) {
|
|
488
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
489
|
+
activeLabelUuid: action.payload.labelUuid,
|
|
490
|
+
selectedUuids: action.payload.selectedUuids || []
|
|
491
|
+
});
|
|
492
|
+
},
|
|
493
|
+
labelsSelectionToggled: function labelsSelectionToggled(state, action) {
|
|
494
|
+
if (action.payload.uuids) {
|
|
495
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
496
|
+
selectedUuids: action.payload.uuids
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
var selectedLabels = _toConsumableArray(state.selectedUuids);
|
|
500
|
+
var selectedLabelUuid = action.payload.uuid;
|
|
501
|
+
var labelIndex = selectedLabels.indexOf(selectedLabelUuid);
|
|
502
|
+
var newSelections;
|
|
503
|
+
if (labelIndex > -1) {
|
|
504
|
+
selectedLabels.splice(labelIndex, 1);
|
|
505
|
+
newSelections = _toConsumableArray(selectedLabels);
|
|
506
|
+
} else {
|
|
507
|
+
newSelections = [].concat(_toConsumableArray(selectedLabels), [selectedLabelUuid]);
|
|
508
|
+
}
|
|
509
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
510
|
+
selectedUuids: newSelections
|
|
511
|
+
});
|
|
512
|
+
},
|
|
513
|
+
labelsStateUpdated: function labelsStateUpdated(state, action) {
|
|
514
|
+
return _objectSpread(_objectSpread({}, state), action.payload);
|
|
515
|
+
}
|
|
516
|
+
},
|
|
517
|
+
extraReducers: function extraReducers(builder) {
|
|
518
|
+
builder.addCase(updateLabelByUuid.fulfilled, function (state, action) {
|
|
519
|
+
return labelsSlice.caseReducers.labelUpdated(state, action);
|
|
520
|
+
}).addCase(createLabel.fulfilled, function (state, action) {
|
|
521
|
+
return labelsSlice.caseReducers.labelsAdded(state, action);
|
|
522
|
+
}).addCase(fetchLabels.pending, function (state) {
|
|
523
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
524
|
+
loading: true
|
|
525
|
+
});
|
|
526
|
+
}).addCase(fetchLabels.fulfilled, function (state, action) {
|
|
527
|
+
return labelsSlice.caseReducers.labelsAdded(state, action);
|
|
528
|
+
}).addCase(fetchLabels.rejected, function (state, action) {
|
|
529
|
+
return getActionErrorState(state, action);
|
|
530
|
+
}).addCase(fetchLabelFiles.pending, function (state, action) {
|
|
531
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
532
|
+
error: null
|
|
533
|
+
});
|
|
534
|
+
});
|
|
535
|
+
}
|
|
536
|
+
});
|
|
537
|
+
var _labelsSlice$actions = labelsSlice.actions,
|
|
538
|
+
labelsViewActivated = _labelsSlice$actions.labelsViewActivated,
|
|
539
|
+
labelsAdded = _labelsSlice$actions.labelsAdded,
|
|
540
|
+
labelUpdated = _labelsSlice$actions.labelUpdated,
|
|
541
|
+
labelsRemoved = _labelsSlice$actions.labelsRemoved,
|
|
542
|
+
labelsSearchTermUpdated = _labelsSlice$actions.labelsSearchTermUpdated,
|
|
543
|
+
labelsSortingUpdated = _labelsSlice$actions.labelsSortingUpdated,
|
|
544
|
+
labelActivated = _labelsSlice$actions.labelActivated,
|
|
545
|
+
labelsSelectionToggled = _labelsSlice$actions.labelsSelectionToggled,
|
|
546
|
+
labelsStateUpdated = _labelsSlice$actions.labelsStateUpdated;
|
|
547
|
+
export { labelsViewActivated, labelsAdded, labelUpdated, labelsRemoved, labelsSearchTermUpdated, labelsSortingUpdated, labelActivated, labelsSelectionToggled, labelsStateUpdated };
|
|
548
|
+
export var selectLabelsState = function selectLabelsState(state) {
|
|
549
|
+
var _state$PLUGINS_IDS$EX;
|
|
550
|
+
return ((_state$PLUGINS_IDS$EX = state[PLUGINS_IDS.EXPLORER]) === null || _state$PLUGINS_IDS$EX === void 0 ? void 0 : _state$PLUGINS_IDS$EX[slicePropName]) || initialState;
|
|
551
|
+
};
|
|
552
|
+
export var selectLabels = function selectLabels(state) {
|
|
553
|
+
return selectLabelsState(state).entities;
|
|
554
|
+
};
|
|
555
|
+
export var selectLabelsUuids = function selectLabelsUuids(state) {
|
|
556
|
+
return selectLabelsState(state).uuids;
|
|
557
|
+
};
|
|
558
|
+
export var selectLabelsArray = createSelector(selectLabels, function (labels) {
|
|
559
|
+
return Object.values(labels);
|
|
560
|
+
});
|
|
561
|
+
export var selectLabelByUuid = function selectLabelByUuid(state, uuid) {
|
|
562
|
+
return selectLabels(state)[uuid];
|
|
563
|
+
};
|
|
564
|
+
export var selectActiveLabelUuid = function selectActiveLabelUuid(state) {
|
|
565
|
+
return selectLabelsState(state).activeLabelUuid;
|
|
566
|
+
};
|
|
567
|
+
export var selectActiveLabel = function selectActiveLabel(state) {
|
|
568
|
+
return selectLabelByUuid(state, selectActiveLabelUuid(state));
|
|
569
|
+
};
|
|
570
|
+
export var selectActiveLabelSid = function selectActiveLabelSid(state) {
|
|
571
|
+
var _selectActiveLabel;
|
|
572
|
+
return (_selectActiveLabel = selectActiveLabel(state)) === null || _selectActiveLabel === void 0 ? void 0 : _selectActiveLabel.sid;
|
|
573
|
+
};
|
|
574
|
+
export var selectLabelsSearchTerm = function selectLabelsSearchTerm(state) {
|
|
575
|
+
return selectLabelsState(state).searchTerm;
|
|
576
|
+
};
|
|
577
|
+
export var selectIsLabelsLoading = function selectIsLabelsLoading(state) {
|
|
578
|
+
return selectIsLabelsView(state) && selectLabelsState(state).loading;
|
|
579
|
+
};
|
|
580
|
+
export var selectLabelsSorting = function selectLabelsSorting(state) {
|
|
581
|
+
return selectLabelsState(state).sorting;
|
|
582
|
+
};
|
|
583
|
+
export var selectLabelsSortBy = function selectLabelsSortBy(state) {
|
|
584
|
+
return selectLabelsState(state).sortedBy;
|
|
585
|
+
};
|
|
586
|
+
export var selectLabelsSortOrder = function selectLabelsSortOrder(state) {
|
|
587
|
+
return selectLabelsState(state).sortOrder;
|
|
588
|
+
};
|
|
589
|
+
export var selectLabelsSelectedUuids = function selectLabelsSelectedUuids(state) {
|
|
590
|
+
return selectLabelsState(state).selectedUuids;
|
|
591
|
+
};
|
|
592
|
+
export var selectIsLabelsTreeOpened = function selectIsLabelsTreeOpened(state) {
|
|
593
|
+
return selectLabelsState(state).showTree;
|
|
594
|
+
};
|
|
595
|
+
export var selectLabelsError = function selectLabelsError(state) {
|
|
596
|
+
return selectLabelsState(state).error;
|
|
597
|
+
};
|
|
598
|
+
export var selectLabelsSelected = createSelector([selectLabels, selectLabelsSelectedUuids], function (labels, selectedUuids) {
|
|
599
|
+
return selectedUuids.map(function (uuid) {
|
|
600
|
+
return labels[uuid];
|
|
601
|
+
});
|
|
602
|
+
});
|
|
603
|
+
export var selectIsLabelSelected = function selectIsLabelSelected(state, uuid) {
|
|
604
|
+
return selectLabelsSelectedUuids(state).includes(uuid);
|
|
605
|
+
};
|
|
606
|
+
export var selectFileLabels = createSelector([selectLabelsArray, function (_state, fileLabels) {
|
|
607
|
+
return Array.isArray(fileLabels) ? fileLabels : [];
|
|
608
|
+
}], function (labels, fileLabels) {
|
|
609
|
+
return fileLabels.map(function (fileLabel) {
|
|
610
|
+
return labels.find(function (label) {
|
|
611
|
+
return fileLabel === label.sid;
|
|
612
|
+
});
|
|
613
|
+
});
|
|
614
|
+
});
|
|
615
|
+
var sortLabels = function sortLabels() {
|
|
616
|
+
var labels = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
617
|
+
var currentLabelsUuids = arguments.length > 1 ? arguments[1] : undefined;
|
|
618
|
+
var sortBy = arguments.length > 2 ? arguments[2] : undefined;
|
|
619
|
+
var sortOrder = arguments.length > 3 ? arguments[3] : undefined;
|
|
620
|
+
if (sortBy) {
|
|
621
|
+
var isAscOrder = sortOrder === SORT_ORDER.ASC;
|
|
622
|
+
return _toConsumableArray(currentLabelsUuids).sort(function (aUuid, bUuid) {
|
|
623
|
+
var _x$sortBy, _y$sortBy;
|
|
624
|
+
var aLabel = labels[aUuid];
|
|
625
|
+
var bLabel = labels[bUuid];
|
|
626
|
+
var x = isAscOrder ? aLabel : bLabel;
|
|
627
|
+
var y = isAscOrder ? bLabel : aLabel;
|
|
628
|
+
var xValue = (_x$sortBy = x === null || x === void 0 ? void 0 : x[sortBy]) !== null && _x$sortBy !== void 0 ? _x$sortBy : '';
|
|
629
|
+
var yValue = (_y$sortBy = y === null || y === void 0 ? void 0 : y[sortBy]) !== null && _y$sortBy !== void 0 ? _y$sortBy : '';
|
|
630
|
+
if (!Number.isNaN(+xValue) && !Number.isNaN(+yValue)) return +xValue - +yValue;
|
|
631
|
+
if (!isNaN(new Date(xValue)) && !isNaN(new Date(yValue))) return yValue.toString().localeCompare(xValue);
|
|
632
|
+
return xValue.toString().localeCompare(yValue);
|
|
633
|
+
});
|
|
634
|
+
}
|
|
635
|
+
return currentLabelsUuids;
|
|
636
|
+
};
|
|
637
|
+
export var selectSortedLabelsUuids = createSelector([selectLabels, selectLabelsUuids, selectLabelsSortBy, selectLabelsSortOrder], sortLabels);
|
|
638
|
+
export var selectLabelsBySearchTerm = createSelector([selectLabelsArray, function (_state, labelsSearchTerm) {
|
|
639
|
+
return labelsSearchTerm;
|
|
640
|
+
}], function (labels, labelsSearchTerm) {
|
|
641
|
+
var filteredLabels = labelsSearchTerm ? labels.filter(function (label) {
|
|
642
|
+
return new RegExp(escapeRegExp(labelsSearchTerm), 'i').test(label.name);
|
|
643
|
+
}) : labels;
|
|
644
|
+
return filteredLabels;
|
|
645
|
+
});
|
|
646
|
+
export var selectSortedLabelsUuidsBySearchTerm = createSelector([selectLabelsBySearchTerm, selectLabels, selectLabelsSortBy, selectLabelsSortOrder], function (filteredLabels, labels, sortBy, sortOrder) {
|
|
647
|
+
return sortLabels(labels, filteredLabels.map(function (_ref12) {
|
|
648
|
+
var uuid = _ref12.uuid;
|
|
649
|
+
return uuid;
|
|
650
|
+
}), sortBy, sortOrder);
|
|
651
|
+
});
|
|
652
|
+
export default labelsSlice.reducer;
|
|
@@ -309,6 +309,12 @@ export var selectIsAssetsViewAvailable = function selectIsAssetsViewAvailable(st
|
|
|
309
309
|
export var selectIsFoldersViewAvailable = function selectIsFoldersViewAvailable(state) {
|
|
310
310
|
return checkViewAvailability(state, VIEW_IDS.FOLDERS);
|
|
311
311
|
};
|
|
312
|
+
export var selectIsLabelsViewAvailable = function selectIsLabelsViewAvailable(state) {
|
|
313
|
+
return checkViewAvailability(state, VIEW_IDS.LABELS);
|
|
314
|
+
};
|
|
315
|
+
export var selectIsCollectionsViewAvailable = function selectIsCollectionsViewAvailable(state) {
|
|
316
|
+
return checkViewAvailability(state, VIEW_IDS.COLLECTIONS);
|
|
317
|
+
};
|
|
312
318
|
export var selectIsSearchMode = function selectIsSearchMode(state) {
|
|
313
319
|
return Boolean(selectSearchQuery(state));
|
|
314
320
|
};
|
|
@@ -321,6 +327,12 @@ export var selectIsAssetsView = function selectIsAssetsView(state) {
|
|
|
321
327
|
export var selectIsFoldersView = function selectIsFoldersView(state) {
|
|
322
328
|
return checkViewActivation(state, VIEW_IDS.FOLDERS);
|
|
323
329
|
};
|
|
330
|
+
export var selectIsLabelsView = function selectIsLabelsView(state) {
|
|
331
|
+
return checkViewActivation(state, VIEW_IDS.LABELS);
|
|
332
|
+
};
|
|
333
|
+
export var selectIsCollectionsView = function selectIsCollectionsView(state) {
|
|
334
|
+
return checkViewActivation(state, VIEW_IDS.COLLECTIONS);
|
|
335
|
+
};
|
|
324
336
|
export var selectViewLayout = function selectViewLayout(state) {
|
|
325
337
|
return selectViewsState(state).layout;
|
|
326
338
|
};
|