ode-explorer 1.3.2-dev.202401091744 → 1.3.2-dev.202401151654

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.
Files changed (57) hide show
  1. package/dist/ActionBarContainer.js +1 -1
  2. package/dist/AppAction.js +1 -1
  3. package/dist/DeleteModal.js +1 -1
  4. package/dist/DisableModal.js +1 -1
  5. package/dist/EmptyScreenApp.js +1 -1
  6. package/dist/EmptyScreenError.js +1 -1
  7. package/dist/EmptyScreenNoContentInFolder.js +1 -1
  8. package/dist/EmptyScreenSearch.js +1 -1
  9. package/dist/EmptyScreenTrash.js +1 -1
  10. package/dist/FolderModal.js +1 -1
  11. package/dist/FoldersList.js +1 -1
  12. package/dist/Library.js +1 -1
  13. package/dist/MoveModal.js +1 -1
  14. package/dist/OnboardingModal.js +1 -0
  15. package/dist/PublishModal.js +1 -0
  16. package/dist/ResourceModal.js +1 -0
  17. package/dist/ResourcesList.js +1 -1
  18. package/dist/ShareModal.js +1 -0
  19. package/dist/TrashModal.js +1 -1
  20. package/dist/edifice-icons.js +1 -0
  21. package/dist/edifice-react.js +1347 -0
  22. package/dist/index.html +3 -1
  23. package/dist/index.js +4 -223
  24. package/dist/react.js +32 -0
  25. package/dist/version.txt +1 -1
  26. package/lib/ActionBarContainer.js +213 -313
  27. package/lib/AppAction.js +24 -39
  28. package/lib/DeleteModal.js +31 -39
  29. package/lib/DisableModal.js +14 -14
  30. package/lib/EmptyScreenApp.js +27 -43
  31. package/lib/EmptyScreenError.js +9 -10
  32. package/lib/EmptyScreenNoContentInFolder.js +12 -14
  33. package/lib/EmptyScreenSearch.js +11 -13
  34. package/lib/EmptyScreenTrash.js +11 -13
  35. package/lib/FolderModal.js +86 -105
  36. package/lib/FoldersList.js +42 -55
  37. package/lib/Library.js +17 -15
  38. package/lib/MoveModal.js +53 -69
  39. package/lib/OnboardingModal.js +5 -0
  40. package/lib/PublishModal.js +5 -0
  41. package/lib/ResourceModal.js +5 -0
  42. package/lib/ResourcesList.js +190 -202
  43. package/lib/ShareModal.js +5 -0
  44. package/lib/TrashModal.js +14 -14
  45. package/lib/components/OnboardingModal.d.ts +2 -0
  46. package/lib/features/ActionBar/Disable/DisableModal.d.ts +1 -1
  47. package/lib/features/ActionBar/Publish/PublishModal.d.ts +2 -0
  48. package/lib/features/ActionBar/Resource/ResourceModal.d.ts +2 -0
  49. package/lib/features/ActionBar/Share/ShareModal.d.ts +2 -0
  50. package/lib/features/ActionBar/Trash/TrashModal.d.ts +1 -1
  51. package/lib/index.js +2 -2
  52. package/lib/index2.js +1014 -1503
  53. package/lib/services/api/index.d.ts +21 -17
  54. package/lib/store/index.d.ts +5 -5
  55. package/package.json +3 -7
  56. package/dist/style.css +0 -1
  57. package/lib/style.css +0 -410
package/lib/index2.js CHANGED
@@ -1,235 +1,174 @@
1
- var __defProp = Object.defineProperty;
2
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
- var __publicField = (obj, key, value) => {
4
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
- return value;
6
- };
7
- import { jsx, jsxs, Fragment as Fragment$1 } from "react/jsx-runtime";
8
- import { useState, useRef, useEffect, Suspense, lazy, Fragment } from "react";
9
- import { useScrollToTop, useOdeClient, IconButton, useToast, useUser, LoadingScreen, FormControl, Input, SearchButton, Dropdown, useToggle, TreeView, Button, useXitiTrackPageLoad, isActionAvailable, AppHeader, Breadcrumb, Grid } from "@edifice-ui/react";
10
- import { ArrowLeft, Filter, Delete, Plus } from "@edifice-ui/icons";
11
- import { useTranslation } from "react-i18next";
12
- import { odeServices, FOLDER, APP } from "edifice-ts-client";
13
- import { t } from "i18next";
14
- import { create } from "zustand";
15
- import { useQuery, useInfiniteQuery, useQueryClient, useMutation } from "@tanstack/react-query";
16
- const searchContext = async (searchParams) => {
17
- const search = await odeServices.resource(searchParams.app).searchContext(searchParams);
1
+ var fe = Object.defineProperty;
2
+ var pe = (e, t, s) => t in e ? fe(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
3
+ var $ = (e, t, s) => (pe(e, typeof t != "symbol" ? t + "" : t, s), s);
4
+ import { jsx as c, jsxs as C, Fragment as ae } from "react/jsx-runtime";
5
+ import { useState as ce, useRef as me, useEffect as U, lazy as D, Suspense as v, Fragment as ye } from "react";
6
+ import { useScrollToTop as ge, useOdeClient as B, IconButton as Ie, useToast as q, useUser as we, LoadingScreen as A, FormControl as Se, Input as xe, SearchButton as De, Dropdown as j, useToggle as be, TreeView as Te, Button as Fe, useXitiTrackPageLoad as Ce, isActionAvailable as oe, AppHeader as Ne, Breadcrumb as Re, Grid as ee } from "@edifice-ui/react";
7
+ import { ArrowLeft as Pe, Filter as Ae, Delete as Ee, Plus as Qe } from "@edifice-ui/icons";
8
+ import { useTranslation as _ } from "react-i18next";
9
+ import { odeServices as N, FOLDER as F, APP as se } from "edifice-ts-client";
10
+ import { t as x } from "i18next";
11
+ import { create as ve } from "zustand";
12
+ import { useQuery as qe, useInfiniteQuery as Oe, useQueryClient as O, useMutation as k } from "@tanstack/react-query";
13
+ const ie = async (e) => {
14
+ const t = await N.resource(e.application).searchContext(e);
18
15
  return {
19
- ...search,
20
- folders: search.folders.filter((folder) => !folder.trashed)
16
+ ...t,
17
+ folders: t.folders.filter((s) => !s.trashed)
21
18
  };
22
- };
23
- const createFolder = async ({
24
- searchParams,
25
- name,
26
- parentId
19
+ }, ke = async ({
20
+ searchParams: e,
21
+ name: t,
22
+ parentId: s
27
23
  }) => {
28
- const createFolderParameters = {
29
- name,
30
- parentId,
31
- app: searchParams.app,
32
- type: searchParams.types[0]
24
+ const r = {
25
+ name: t,
26
+ parentId: s,
27
+ application: e.application,
28
+ type: e.types[0]
33
29
  };
34
- return await odeServices.resource(searchParams.app).createFolder(createFolderParameters);
35
- };
36
- const updateFolder = async ({
37
- folderId,
38
- searchParams,
39
- parentId,
40
- name
30
+ return await N.resource(e.application).createFolder(r);
31
+ }, Le = async ({
32
+ folderId: e,
33
+ searchParams: t,
34
+ parentId: s,
35
+ name: r
41
36
  }) => {
42
- const updateFolderParameters = {
43
- folderId,
44
- name,
45
- parentId,
46
- app: searchParams.app,
47
- type: searchParams.types[0]
37
+ const n = {
38
+ folderId: e,
39
+ name: r,
40
+ parentId: s,
41
+ application: t.application,
42
+ type: t.types[0]
48
43
  };
49
- return await odeServices.resource(searchParams.app).updateFolder(updateFolderParameters);
50
- };
51
- const trashAll = async ({
52
- searchParams,
53
- resourceIds,
54
- useAssetIds,
55
- folderIds
44
+ return await N.resource(t.application).updateFolder(n);
45
+ }, Ue = async ({
46
+ searchParams: e,
47
+ resourceIds: t,
48
+ useAssetIds: s,
49
+ folderIds: r
56
50
  }) => {
57
- const trashParameters = {
58
- application: searchParams.app,
59
- resourceType: searchParams.types[0],
60
- resourceIds,
61
- folderIds
51
+ const n = {
52
+ application: e.application,
53
+ resourceType: e.types[0],
54
+ resourceIds: t,
55
+ folderIds: r
62
56
  };
63
- return await odeServices.resource(searchParams.app).trashAll(trashParameters, useAssetIds);
64
- };
65
- const deleteAll = async ({
66
- searchParams,
67
- resourceIds,
68
- useAssetIds,
69
- folderIds
57
+ return await N.resource(e.application).trashAll(n, s);
58
+ }, Be = async ({
59
+ searchParams: e,
60
+ resourceIds: t,
61
+ useAssetIds: s,
62
+ folderIds: r
70
63
  }) => {
71
- const deleteParameters = {
72
- application: searchParams.app,
73
- resourceType: searchParams.types[0],
74
- resourceIds,
75
- folderIds
64
+ const n = {
65
+ application: e.application,
66
+ resourceType: e.types[0],
67
+ resourceIds: t,
68
+ folderIds: r
76
69
  };
77
- return await odeServices.resource(searchParams.app).deleteAll(deleteParameters, useAssetIds);
78
- };
79
- const restoreAll = async ({
80
- searchParams,
81
- resourceIds,
82
- folderIds,
83
- useAssetIds
70
+ return await N.resource(e.application).deleteAll(n, s);
71
+ }, Me = async ({
72
+ searchParams: e,
73
+ resourceIds: t,
74
+ folderIds: s,
75
+ useAssetIds: r
84
76
  }) => {
85
- const trashParameters = {
86
- application: searchParams.app,
87
- resourceType: searchParams.types[0],
88
- resourceIds,
89
- folderIds
77
+ const n = {
78
+ application: e.application,
79
+ resourceType: e.types[0],
80
+ resourceIds: t,
81
+ folderIds: s
90
82
  };
91
- return await odeServices.resource(searchParams.app).restoreAll(trashParameters, useAssetIds);
92
- };
93
- const moveToFolder = async ({
94
- searchParams,
95
- resourceIds,
96
- folderId,
97
- folderIds,
98
- useAssetIds
83
+ return await N.resource(e.application).restoreAll(n, r);
84
+ }, Ke = async ({
85
+ searchParams: e,
86
+ resourceIds: t,
87
+ folderId: s,
88
+ folderIds: r,
89
+ useAssetIds: n
99
90
  }) => {
100
- const moveParameters = {
101
- application: searchParams.app,
102
- folderId,
103
- resourceIds,
104
- folderIds
91
+ const a = {
92
+ application: e.application,
93
+ folderId: s,
94
+ resourceIds: t,
95
+ folderIds: r
105
96
  };
106
- return await odeServices.resource(searchParams.app).moveToFolder(moveParameters, useAssetIds);
107
- };
108
- const shareResource = async ({
109
- app,
110
- resourceId,
111
- rights
112
- }) => {
113
- return await odeServices.share().saveRights(app, resourceId, rights);
114
- };
115
- const updateResource = async ({
116
- app,
117
- params
118
- }) => {
119
- return await odeServices.resource(app).update(params);
120
- };
121
- const sessionHasWorkflowRights = async (actionRights) => {
122
- return await odeServices.rights().sessionHasWorkflowRights(actionRights);
123
- };
124
- const goToResource = ({
125
- searchParams,
126
- assetId
127
- }) => {
128
- return odeServices.resource(searchParams.app).gotoView(assetId);
129
- };
130
- const createResource = ({
131
- searchParams,
132
- params
97
+ return await N.resource(e.application).moveToFolder(a, n);
98
+ }, $e = async ({
99
+ searchParams: e,
100
+ resourceId: t,
101
+ rights: s
102
+ }) => await N.share().saveRights(e.application, t, s), je = async ({
103
+ searchParams: e,
104
+ params: t
105
+ }) => await N.resource(e.application).update(t), _e = async (e) => await N.rights().sessionHasWorkflowRights(e), ze = ({
106
+ searchParams: e,
107
+ assetId: t
133
108
  }) => {
134
- const result = odeServices.resource(searchParams.app).create(params);
135
- return result;
136
- };
137
- const printResource = ({
138
- searchParams,
139
- assetId
109
+ const s = N.resource(e.application).getViewUrl(t);
110
+ window.open(s, "_self");
111
+ }, Ve = ({
112
+ searchParams: e,
113
+ params: t
114
+ }) => N.resource(e.application).create(t), He = ({
115
+ searchParams: e,
116
+ assetId: t
140
117
  }) => {
141
- const result = odeServices.resource(searchParams.app).gotoPrint(assetId);
142
- return result;
118
+ const s = N.resource(e.application).getPrintUrl(t);
119
+ return window.open(s, "_blank");
143
120
  };
144
- function arrayUnique(array) {
145
- return array.filter((item, index) => array.indexOf(item) === index);
121
+ function te(e) {
122
+ return e.filter((t, s) => e.indexOf(t) === s);
146
123
  }
147
- function findNodeById(id, data) {
148
- var _a, _b;
149
- let res;
150
- if ((data == null ? void 0 : data.id) === id) {
151
- return data;
152
- }
153
- if ((_a = data == null ? void 0 : data.children) == null ? void 0 : _a.length) {
154
- (_b = data == null ? void 0 : data.children) == null ? void 0 : _b.every((childNode) => {
155
- res = findNodeById(id, childNode);
156
- return res === void 0;
157
- });
158
- }
159
- return res;
124
+ function V(e, t) {
125
+ var r, n;
126
+ let s;
127
+ return (t == null ? void 0 : t.id) === e ? t : ((r = t == null ? void 0 : t.children) != null && r.length && ((n = t == null ? void 0 : t.children) == null || n.every((a) => (s = V(e, a), s === void 0))), s);
160
128
  }
161
- function getAncestors(folderId, treeData) {
162
- var _a;
163
- const findItem = findNodeById(folderId, treeData);
164
- if ((_a = findItem == null ? void 0 : findItem.folder) == null ? void 0 : _a.ancestors) {
165
- const nodes = (findItem == null ? void 0 : findItem.folder.ancestors) || [];
166
- return [...nodes, folderId];
167
- } else if (folderId === FOLDER.BIN) {
168
- return [FOLDER.BIN];
169
- } else {
170
- return [FOLDER.DEFAULT];
171
- }
129
+ function We(e, t) {
130
+ var r;
131
+ const s = V(e, t);
132
+ return (r = s == null ? void 0 : s.folder) != null && r.ancestors ? [...(s == null ? void 0 : s.folder.ancestors) || [], e] : e === F.BIN ? [F.BIN] : [F.DEFAULT];
172
133
  }
173
- function hasChildren(folderId, data) {
174
- if (data.id === folderId && data.children) {
175
- return data.children.length > 0;
176
- }
177
- if (data.children) {
178
- return data.children.some((child) => hasChildren(data.id, child));
179
- }
180
- return false;
134
+ function le(e, t) {
135
+ return t.id === e && t.children ? t.children.length > 0 : t.children ? t.children.some((s) => le(t.id, s)) : !1;
181
136
  }
182
- function modifyNode(data, callback) {
183
- const root = doModify(data, callback) || data;
184
- return root;
137
+ function H(e, t) {
138
+ return de(e, t) || e;
185
139
  }
186
- function doModify(current, callback, parent) {
187
- var _a;
188
- const result = callback(current, parent);
189
- if ((_a = result == null ? void 0 : result.children) == null ? void 0 : _a.length) {
190
- const children = [];
191
- for (const child of (result == null ? void 0 : result.children) || []) {
192
- const res = doModify(child, callback, result);
193
- if (res) {
194
- children.push(res);
195
- }
140
+ function de(e, t, s) {
141
+ var n;
142
+ const r = t(e, s);
143
+ if ((n = r == null ? void 0 : r.children) != null && n.length) {
144
+ const a = [];
145
+ for (const o of (r == null ? void 0 : r.children) || []) {
146
+ const l = de(o, t, r);
147
+ l && a.push(l);
196
148
  }
197
149
  return {
198
- ...result,
199
- children
150
+ ...r,
151
+ children: a
200
152
  };
201
153
  }
202
- return result;
154
+ return r;
203
155
  }
204
- class TreeNodeFolderWrapper {
205
- constructor(folder) {
206
- __publicField(this, "id");
207
- __publicField(this, "name");
208
- __publicField(this, "childNumber");
209
- __publicField(this, "section", false);
210
- __publicField(this, "children", []);
211
- this.folder = folder;
212
- this.id = folder.id;
213
- this.name = folder.name;
214
- this.childNumber = folder.childNumber;
156
+ class X {
157
+ constructor(t) {
158
+ $(this, "id");
159
+ $(this, "name");
160
+ $(this, "childNumber");
161
+ $(this, "section", !1);
162
+ $(this, "children", []);
163
+ this.folder = t, this.id = t.id, this.name = t.name, this.childNumber = t.childNumber;
215
164
  }
216
165
  }
217
- const wrapTreeNode = (treeNode, folders, parentId) => {
218
- return modifyNode(treeNode, (node) => {
219
- if (node.id === parentId) {
220
- node.children = folders == null ? void 0 : folders.map((e) => new TreeNodeFolderWrapper(e));
221
- }
222
- return node;
223
- });
224
- };
225
- const useStoreContext = create()((set, get) => ({
166
+ const ue = (e, t, s) => H(e, (r) => (r.id === s && (r.children = t == null ? void 0 : t.map((n) => new X(n))), r)), w = ve()((e, t) => ({
226
167
  config: null,
227
168
  searchConfig: {
228
169
  minLength: 1
229
170
  },
230
171
  searchParams: {
231
- app: "",
232
- types: [],
233
172
  filters: {
234
173
  folder: "default",
235
174
  owner: void 0,
@@ -239,17 +178,19 @@ const useStoreContext = create()((set, get) => ({
239
178
  orders: {
240
179
  updatedAt: "desc"
241
180
  },
181
+ application: "",
182
+ types: [],
242
183
  pagination: {
243
184
  startIdx: 0,
244
185
  pageSize: 48,
245
186
  maxIdx: 0
246
187
  },
247
- trashed: false
188
+ trashed: !1
248
189
  },
249
190
  treeData: {
250
- id: FOLDER.DEFAULT,
251
- name: t("explorer.filters.mine"),
252
- section: true,
191
+ id: F.DEFAULT,
192
+ name: x("explorer.filters.mine"),
193
+ section: !0,
253
194
  children: []
254
195
  },
255
196
  selectedNodesIds: ["default"],
@@ -260,1564 +201,1134 @@ const useStoreContext = create()((set, get) => ({
260
201
  selectedResources: [],
261
202
  folderIds: [],
262
203
  resourceIds: [],
263
- resourceIsTrash: false,
264
- resourceActionDisable: false,
204
+ resourceIsTrash: !1,
205
+ resourceActionDisable: !1,
265
206
  status: void 0,
266
207
  updaters: {
267
- setConfig: (config) => set({
268
- config
208
+ setConfig: (s) => e({
209
+ config: s
269
210
  }),
270
- setSearchConfig: (searchConfig) => set((state) => ({
211
+ setSearchConfig: (s) => e((r) => ({
271
212
  searchConfig: {
272
- ...state.searchConfig,
273
- ...searchConfig
213
+ ...r.searchConfig,
214
+ ...s
274
215
  }
275
216
  })),
276
- setTreeData: (treeData) => set(() => ({
277
- treeData
217
+ setTreeData: (s) => e(() => ({
218
+ treeData: s
278
219
  })),
279
- setSearchParams: (searchParams) => {
280
- set((state) => {
220
+ setSearchParams: (s) => {
221
+ e((r) => {
281
222
  const {
282
- searchParams: previousSearchParams
283
- } = state;
284
- if (previousSearchParams.search !== searchParams.search) {
285
- if (searchParams.search) {
286
- return {
287
- ...state,
288
- selectedFolders: [],
289
- selectedNodesIds: [],
290
- selectedResources: [],
291
- currentFolder: void 0,
292
- searchParams: {
293
- ...previousSearchParams,
294
- ...searchParams,
295
- trashed: false,
296
- filters: {
297
- ...previousSearchParams.filters,
298
- folder: void 0
299
- }
300
- }
301
- };
302
- } else {
303
- return {
304
- ...state,
305
- selectedFolders: [],
306
- selectedNodesIds: ["default"],
307
- selectedResources: [],
308
- currentFolder: {
309
- id: "default"
310
- },
311
- searchParams: {
312
- ...previousSearchParams,
313
- ...searchParams,
314
- trashed: false,
315
- filters: {
316
- ...previousSearchParams.filters
317
- }
318
- }
319
- };
223
+ searchParams: n
224
+ } = r;
225
+ return n.search !== s.search ? s.search ? {
226
+ ...r,
227
+ selectedFolders: [],
228
+ selectedNodesIds: [],
229
+ selectedResources: [],
230
+ currentFolder: void 0,
231
+ searchParams: {
232
+ ...n,
233
+ ...s,
234
+ trashed: !1,
235
+ filters: {
236
+ ...n.filters,
237
+ folder: void 0
238
+ }
320
239
  }
321
- } else {
322
- return {
323
- searchParams: {
324
- ...previousSearchParams,
325
- ...searchParams
240
+ } : {
241
+ ...r,
242
+ selectedFolders: [],
243
+ selectedNodesIds: ["default"],
244
+ selectedResources: [],
245
+ currentFolder: {
246
+ id: "default"
247
+ },
248
+ searchParams: {
249
+ ...n,
250
+ ...s,
251
+ trashed: !1,
252
+ filters: {
253
+ ...n.filters
326
254
  }
327
- };
328
- }
255
+ }
256
+ } : {
257
+ searchParams: {
258
+ ...n,
259
+ ...s
260
+ }
261
+ };
329
262
  });
330
263
  },
331
- setSelectedFolders: (selectedFolders) => set(() => ({
332
- selectedFolders
264
+ setSelectedFolders: (s) => e(() => ({
265
+ selectedFolders: s
333
266
  })),
334
- setSelectedResources: (selectedResources) => set(() => ({
335
- selectedResources
267
+ setSelectedResources: (s) => e(() => ({
268
+ selectedResources: s
336
269
  })),
337
- setFolderIds: (folderIds) => set(() => ({
338
- folderIds
270
+ setFolderIds: (s) => e(() => ({
271
+ folderIds: s
339
272
  })),
340
- setResourceIds: (resourceIds) => set(() => ({
341
- resourceIds
273
+ setResourceIds: (s) => e(() => ({
274
+ resourceIds: s
342
275
  })),
343
- setResourceIsTrash: (resourceIsTrash) => set(() => ({
344
- resourceIsTrash
276
+ setResourceIsTrash: (s) => e(() => ({
277
+ resourceIsTrash: s
345
278
  })),
346
- setResourceActionDisable: (resourceActionDisable) => set(() => ({
347
- resourceActionDisable
279
+ setResourceActionDisable: (s) => e(() => ({
280
+ resourceActionDisable: s
348
281
  })),
349
- setCurrentFolder: (currentFolder) => set(() => ({
350
- currentFolder
282
+ setCurrentFolder: (s) => e(() => ({
283
+ currentFolder: s
351
284
  })),
352
- clearSelectedItems: () => set(() => ({
285
+ clearSelectedItems: () => e(() => ({
353
286
  selectedFolders: [],
354
287
  selectedResources: []
355
288
  })),
356
- clearSelectedIds: () => set(() => ({
289
+ clearSelectedIds: () => e(() => ({
357
290
  resourceIds: [],
358
291
  folderIds: []
359
292
  })),
360
- openResource: (resource) => {
293
+ openResource: (s) => {
361
294
  try {
362
295
  const {
363
- searchParams
364
- } = get();
365
- goToResource({
366
- searchParams,
367
- assetId: resource.assetId
296
+ searchParams: r
297
+ } = t();
298
+ ze({
299
+ searchParams: r,
300
+ assetId: s.assetId
368
301
  });
369
- } catch (error) {
370
- console.error("explorer open failed: ", error);
302
+ } catch (r) {
303
+ console.error("explorer open failed: ", r);
371
304
  }
372
305
  },
373
306
  printSelectedResource: () => {
374
307
  try {
375
308
  const {
376
- searchParams,
377
- selectedResources,
378
- resourceIds
379
- } = get();
380
- if (selectedResources.length !== 1) {
309
+ searchParams: s,
310
+ selectedResources: r,
311
+ resourceIds: n
312
+ } = t();
313
+ if (r.length !== 1)
381
314
  throw new Error("Cannot open more than 1 resource");
382
- }
383
- const item = selectedResources.find((resource) => resource.id === resourceIds[0]);
384
- printResource({
385
- searchParams,
386
- assetId: item.assetId
315
+ const a = r.find((o) => o.id === n[0]);
316
+ He({
317
+ searchParams: s,
318
+ assetId: a.assetId
387
319
  });
388
- } catch (error) {
389
- console.error("explorer print failed: ", error);
320
+ } catch (s) {
321
+ console.error("explorer print failed: ", s);
390
322
  }
391
323
  },
392
324
  openFolder: ({
393
- folderId,
394
- folder
325
+ folderId: s,
326
+ folder: r
395
327
  }) => {
396
328
  const {
397
- searchParams,
398
- treeData
399
- } = get();
400
- const previousId = searchParams.filters.folder;
401
- const ancestors = getAncestors(folderId, treeData);
402
- const selectedNodesIds = arrayUnique([...ancestors, folderId]);
403
- if (previousId === folderId)
404
- return;
405
- set((state) => {
406
- return {
407
- ...state,
408
- // reset selection when changing folder
409
- folderIds: [],
410
- resourceIds: [],
411
- selectedNodesIds,
412
- currentFolder: folder || {
413
- id: folderId
329
+ searchParams: n,
330
+ treeData: a
331
+ } = t(), o = n.filters.folder, l = We(s, a), h = te([...l, s]);
332
+ o !== s && e((d) => ({
333
+ ...d,
334
+ // reset selection when changing folder
335
+ folderIds: [],
336
+ resourceIds: [],
337
+ selectedNodesIds: h,
338
+ currentFolder: r || {
339
+ id: s
340
+ },
341
+ searchParams: {
342
+ ...n,
343
+ search: void 0,
344
+ filters: {
345
+ ...n.filters,
346
+ folder: s
414
347
  },
415
- searchParams: {
416
- ...searchParams,
417
- search: void 0,
418
- filters: {
419
- ...searchParams.filters,
420
- folder: folderId
421
- },
422
- trashed: folderId === FOLDER.BIN
423
- }
424
- };
425
- });
348
+ trashed: s === F.BIN
349
+ }
350
+ }));
426
351
  },
427
- foldTreeItem: () => set((state) => ({
428
- ...state,
352
+ foldTreeItem: () => e((s) => ({
353
+ ...s,
429
354
  status: "fold"
430
355
  })),
431
- unfoldTreeItem: async (folderId, queryClient) => {
356
+ unfoldTreeItem: async (s, r) => {
432
357
  const {
433
- treeData,
434
- searchParams
435
- } = get();
436
- set((state) => ({
437
- ...state,
358
+ treeData: n,
359
+ searchParams: a
360
+ } = t();
361
+ if (e((o) => ({
362
+ ...o,
438
363
  status: "unfold"
439
- }));
440
- if (!hasChildren(folderId, treeData)) {
441
- await queryClient.prefetchInfiniteQuery({
364
+ })), !le(s, n)) {
365
+ await r.prefetchInfiniteQuery({
366
+ initialPageParam: 0,
442
367
  queryKey: ["prefetchContext", {
443
- folderId,
444
- trashed: false
368
+ folderId: s,
369
+ trashed: !1
445
370
  }],
446
- queryFn: async () => await searchContext({
447
- ...searchParams,
371
+ queryFn: async () => await ie({
372
+ ...a,
448
373
  filters: {
449
- ...searchParams.filters,
450
- folder: folderId
374
+ ...a.filters,
375
+ folder: s
451
376
  }
452
377
  })
453
378
  });
454
- const data = queryClient.getQueryData(["prefetchContext", {
455
- folderId,
456
- trashed: false
379
+ const o = r.getQueryData(["prefetchContext", {
380
+ folderId: s,
381
+ trashed: !1
457
382
  }]);
458
- set((state) => {
459
- var _a;
383
+ e((l) => {
384
+ var h;
460
385
  return {
461
- ...state,
462
- treeData: wrapTreeNode(treeData, (_a = data == null ? void 0 : data.pages[0]) == null ? void 0 : _a.folders, folderId || FOLDER.DEFAULT)
386
+ ...l,
387
+ treeData: ue(n, (h = o == null ? void 0 : o.pages[0]) == null ? void 0 : h.folders, s || F.DEFAULT)
463
388
  };
464
389
  });
465
390
  }
466
391
  },
467
- selectTreeItem: (folderId) => {
392
+ selectTreeItem: (s) => {
468
393
  const {
469
- treeData
470
- } = get();
471
- const {
472
- openFolder
473
- } = get().updaters;
474
- const folder = findNodeById(folderId, treeData);
475
- const goToTop = useScrollToTop();
476
- goToTop();
477
- set((state) => ({
478
- ...state,
394
+ treeData: r
395
+ } = t(), {
396
+ openFolder: n
397
+ } = t().updaters, a = V(s, r);
398
+ ge()(), e((l) => ({
399
+ ...l,
479
400
  searchParams: {
480
- ...state.searchParams,
401
+ ...l.searchParams,
481
402
  search: void 0
482
403
  },
483
404
  status: "select",
484
405
  selectedResources: []
485
- }));
486
- openFolder({
487
- folder,
488
- folderId
406
+ })), n({
407
+ folder: a,
408
+ folderId: s
489
409
  });
490
410
  },
491
411
  gotoPreviousFolder: () => {
492
412
  const {
493
- selectedNodesIds,
494
- treeData
495
- } = get();
496
- const {
497
- openFolder
498
- } = get().updaters;
499
- const selectedNodesIdsLength = selectedNodesIds.length;
500
- if (selectedNodesIdsLength < 2) {
501
- return void 0;
502
- }
503
- const previousFolder = findNodeById(selectedNodesIds[selectedNodesIdsLength - 2], treeData);
504
- openFolder({
505
- folder: previousFolder,
506
- folderId: (previousFolder == null ? void 0 : previousFolder.id) || FOLDER.DEFAULT
413
+ selectedNodesIds: s,
414
+ treeData: r
415
+ } = t(), {
416
+ openFolder: n
417
+ } = t().updaters, a = s.length;
418
+ if (a < 2)
419
+ return;
420
+ const o = V(s[a - 2], r);
421
+ n({
422
+ folder: o,
423
+ folderId: (o == null ? void 0 : o.id) || F.DEFAULT
507
424
  });
508
425
  },
509
- goToTrash: () => set((state) => ({
510
- ...state,
426
+ goToTrash: () => e((s) => ({
427
+ ...s,
511
428
  selectedNodesIds: [],
512
429
  selectedResources: [],
513
430
  resourceIds: [],
514
431
  folderIds: [],
515
432
  status: "select",
516
433
  searchParams: {
517
- ...state.searchParams,
434
+ ...s.searchParams,
518
435
  search: void 0,
519
436
  filters: {
520
- folder: FOLDER.BIN
437
+ folder: F.BIN
521
438
  },
522
- trashed: true
439
+ trashed: !0
523
440
  },
524
441
  currentFolder: {
525
- id: FOLDER.BIN
442
+ id: F.BIN
526
443
  }
527
444
  }))
528
445
  }
529
- }));
530
- const useSearchParams = () => useStoreContext((state) => state.searchParams);
531
- const useSelectedNodesIds = () => useStoreContext((state) => state.selectedNodesIds);
532
- const useTreeData = () => useStoreContext((state) => state.treeData);
533
- const useSelectedFolders = () => useStoreContext((state) => state.selectedFolders);
534
- const useSelectedResources = () => useStoreContext((state) => state.selectedResources);
535
- const useSearchConfig = () => useStoreContext((state) => state.searchConfig);
536
- const useFolderIds = () => useStoreContext((state) => state.folderIds);
537
- const useResourceIds = () => useStoreContext((state) => state.resourceIds);
538
- const useResourceAssetIds = () => useStoreContext((state) => state.selectedResources.map((r) => r.assetId));
539
- const useResourceWithoutIds = () => useStoreContext((state) => state.selectedResources.filter((r) => r.assetId === r.id));
540
- const useCurrentFolder = () => useStoreContext((state) => state.currentFolder);
541
- const useStoreActions = () => useStoreContext((state) => state.updaters);
542
- const useIsTrash = () => {
543
- const currentFolder = useCurrentFolder();
544
- return (currentFolder == null ? void 0 : currentFolder.id) === FOLDER.BIN;
545
- };
546
- const useResourceIsTrash = () => {
547
- return useStoreContext((state) => state.resourceIsTrash);
548
- };
549
- const useResourceActionDisable = () => {
550
- return useStoreContext((state) => state.resourceActionDisable);
551
- };
552
- const useIsRoot = () => {
553
- const currentFolder = useCurrentFolder();
554
- return (currentFolder == null ? void 0 : currentFolder.id) === "default";
555
- };
556
- const useHasSelectedNodes = () => {
557
- const selectedNodesIds = useSelectedNodesIds();
558
- return selectedNodesIds.length > 1;
559
- };
560
- const useTreeStatus = () => useStoreContext((state) => state.status);
561
- const useSearchForm = () => {
562
- const searchParams = useSearchParams();
563
- const [inputSearch, setInputSearch] = useState("");
564
- const searchConfig = useSearchConfig();
565
- const status = useTreeStatus();
566
- const formRef = useRef(null);
567
- const {
568
- setSearchParams
569
- } = useStoreActions();
570
- const handleInputSearchChange = (event) => {
571
- const newText = event.target.value;
572
- setInputSearch(newText.toString());
573
- };
574
- const handleKeyPress = (event) => {
575
- if (event.key === "Enter" || event.key === "Return") {
576
- event.preventDefault();
577
- setSearchParams({
578
- search: inputSearch ? inputSearch : void 0
579
- });
580
- }
581
- };
582
- const handleSearchSubmit = (e) => {
583
- e.preventDefault();
584
- setSearchParams({
585
- search: inputSearch ? inputSearch : void 0
446
+ })), b = () => w((e) => e.searchParams), re = () => w((e) => e.selectedNodesIds), z = () => w((e) => e.treeData), Bs = () => w((e) => e.selectedFolders), Ms = () => w((e) => e.selectedResources), Xe = () => w((e) => e.searchConfig), G = () => w((e) => e.folderIds), Z = () => w((e) => e.resourceIds), J = () => w((e) => e.selectedResources.map((t) => t.assetId)), Y = () => w((e) => e.selectedResources.filter((t) => t.assetId === t.id)), W = () => w((e) => e.currentFolder), S = () => w((e) => e.updaters), ne = () => {
447
+ const e = W();
448
+ return (e == null ? void 0 : e.id) === F.BIN;
449
+ }, Ge = () => w((e) => e.resourceIsTrash), Ze = () => w((e) => e.resourceActionDisable), Je = () => {
450
+ const e = W();
451
+ return (e == null ? void 0 : e.id) === "default";
452
+ }, Ye = () => re().length > 1, es = () => w((e) => e.status), he = () => {
453
+ const e = b(), [t, s] = ce(""), r = Xe(), n = es(), a = me(null), {
454
+ setSearchParams: o
455
+ } = S(), l = (u) => {
456
+ const f = u.target.value;
457
+ s(f.toString());
458
+ }, h = (u) => {
459
+ (u.key === "Enter" || u.key === "Return") && (u.preventDefault(), o({
460
+ search: t || void 0
461
+ }));
462
+ }, d = (u) => {
463
+ u.preventDefault(), o({
464
+ search: t || void 0
586
465
  });
587
466
  };
588
- useEffect(() => {
589
- const shouldUpdateSearch = inputSearch.length == 0 || inputSearch.length >= searchConfig.minLength;
590
- const searchPartial = shouldUpdateSearch ? {
591
- search: inputSearch ? inputSearch : void 0
467
+ return U(() => {
468
+ const f = t.length == 0 || t.length >= r.minLength ? {
469
+ search: t || void 0
592
470
  } : {};
593
- setSearchParams({
594
- ...searchParams,
595
- ...searchPartial
471
+ o({
472
+ ...e,
473
+ ...f
596
474
  });
597
- }, [inputSearch, searchConfig.minLength]);
598
- useEffect(() => {
599
- if (status === "select")
600
- setInputSearch("");
601
- }, [status]);
602
- useEffect(() => {
603
- setInputSearch(() => {
604
- var _a;
605
- return ((_a = searchParams.search) == null ? void 0 : _a.toString()) ?? "";
475
+ }, [t, r.minLength]), U(() => {
476
+ n === "select" && s("");
477
+ }, [n]), U(() => {
478
+ s(() => {
479
+ var u;
480
+ return ((u = e.search) == null ? void 0 : u.toString()) ?? "";
606
481
  });
607
- }, [searchParams]);
608
- return {
609
- formRef,
610
- inputSearch,
611
- handleInputSearchChange,
612
- handleKeyPress,
613
- handleSearchSubmit
482
+ }, [e]), {
483
+ formRef: a,
484
+ inputSearch: t,
485
+ handleInputSearchChange: l,
486
+ handleKeyPress: h,
487
+ handleSearchSubmit: d
614
488
  };
615
489
  };
616
- function ExplorerBreadcrumb() {
617
- const {
618
- appCode
619
- } = useOdeClient();
490
+ function ss() {
620
491
  const {
621
- gotoPreviousFolder
622
- } = useStoreActions();
623
- const {
624
- t: t2
625
- } = useTranslation();
626
- const {
627
- inputSearch
628
- } = useSearchForm();
629
- const selectedNodesIds = useSelectedNodesIds();
630
- const isTrashFolder = useIsTrash();
631
- const currentFolder = useCurrentFolder();
632
- const trashName = t2("explorer.tree.trash");
633
- const searchName = t2("explorer.tree.search");
634
- const rootName = t2("explorer.filters.mine", {
635
- ns: appCode
636
- });
637
- const previousName = (currentFolder == null ? void 0 : currentFolder.name) || rootName;
638
- return /* @__PURE__ */ jsx("div", { className: "py-16", children: selectedNodesIds.length > 1 && !isTrashFolder ? /* @__PURE__ */ jsxs("div", { className: "d-flex align-items-center gap-8", children: [
639
- /* @__PURE__ */ jsx(IconButton, { icon: /* @__PURE__ */ jsx(ArrowLeft, {}), variant: "ghost", color: "tertiary", "aria-label": t2("back"), className: "ms-n16", onClick: gotoPreviousFolder }),
640
- /* @__PURE__ */ jsx("p", { className: "body py-8 text-truncate", children: /* @__PURE__ */ jsx("strong", { children: previousName }) })
641
- ] }) : /* @__PURE__ */ jsx("h2", { className: "body py-8 fw-bold", children: inputSearch.length !== 0 ? searchName : !isTrashFolder ? rootName : trashName }) });
492
+ appCode: e
493
+ } = B(), {
494
+ gotoPreviousFolder: t
495
+ } = S(), {
496
+ t: s
497
+ } = _(), {
498
+ inputSearch: r
499
+ } = he(), n = re(), a = ne(), o = W(), l = s("explorer.tree.trash"), h = s("explorer.tree.search"), d = s("explorer.filters.mine", {
500
+ ns: e
501
+ }), u = (o == null ? void 0 : o.name) || d;
502
+ return /* @__PURE__ */ c("div", { className: "py-16", children: n.length > 1 && !a ? /* @__PURE__ */ C("div", { className: "d-flex align-items-center gap-8", children: [
503
+ /* @__PURE__ */ c(Ie, { icon: /* @__PURE__ */ c(Pe, {}), variant: "ghost", color: "tertiary", "aria-label": s("back"), className: "ms-n16", onClick: t }),
504
+ /* @__PURE__ */ c("p", { className: "body py-8 text-truncate", children: /* @__PURE__ */ c("strong", { children: u }) })
505
+ ] }) : /* @__PURE__ */ c("h2", { className: "body py-8 fw-bold", children: r.length !== 0 ? h : a ? l : d }) });
642
506
  }
643
- const useDisableModal = () => {
644
- const isActionDisableModalOpen = useResourceActionDisable();
645
- const {
646
- clearSelectedIds,
647
- setResourceActionDisable,
648
- clearSelectedItems
649
- } = useStoreActions();
650
- const onActionDisableCancel = () => {
651
- clearSelectedIds();
652
- clearSelectedItems();
653
- setResourceActionDisable(false);
654
- };
507
+ const ts = () => {
508
+ const e = Ze(), {
509
+ clearSelectedIds: t,
510
+ setResourceActionDisable: s,
511
+ clearSelectedItems: r
512
+ } = S();
655
513
  return {
656
- isActionDisableModalOpen,
657
- onActionDisableCancel
658
- };
659
- };
660
- const useTrashModal = () => {
661
- const isTrashedModalOpen = useResourceIsTrash();
662
- const {
663
- clearSelectedIds,
664
- setResourceIsTrash,
665
- clearSelectedItems
666
- } = useStoreActions();
667
- const onTrashedCancel = () => {
668
- clearSelectedIds();
669
- clearSelectedItems();
670
- setResourceIsTrash(false);
514
+ isActionDisableModalOpen: e,
515
+ onActionDisableCancel: () => {
516
+ t(), r(), s(!1);
517
+ }
671
518
  };
519
+ }, rs = () => {
520
+ const e = Ge(), {
521
+ clearSelectedIds: t,
522
+ setResourceIsTrash: s,
523
+ clearSelectedItems: r
524
+ } = S();
672
525
  return {
673
- isTrashedModalOpen,
674
- onTrashedCancel
526
+ isTrashedModalOpen: e,
527
+ onTrashedCancel: () => {
528
+ t(), r(), s(!1);
529
+ }
675
530
  };
676
531
  };
677
- function addNode(treeData, {
678
- parentId,
679
- newFolder
532
+ function ns(e, {
533
+ parentId: t,
534
+ newFolder: s
680
535
  }) {
681
- return modifyNode(treeData, (node) => {
682
- var _a;
683
- if (node.id === parentId) {
684
- const parentAncestors = [...((_a = node.folder) == null ? void 0 : _a.ancestors) || []];
685
- const ancestors = arrayUnique([...parentAncestors, node.id]);
686
- const newNode = {
687
- ...node,
688
- children: [...node.children || [], new TreeNodeFolderWrapper({
689
- ...newFolder,
690
- ancestors
536
+ return H(e, (r) => {
537
+ var n;
538
+ if (r.id === t) {
539
+ const a = [...((n = r.folder) == null ? void 0 : n.ancestors) || []], o = te([...a, r.id]);
540
+ return {
541
+ ...r,
542
+ children: [...r.children || [], new X({
543
+ ...s,
544
+ ancestors: o
691
545
  })]
692
546
  };
693
- return newNode;
694
- } else {
695
- return node;
696
- }
547
+ } else
548
+ return r;
697
549
  });
698
550
  }
699
- function deleteNode(treeData, {
700
- folders
551
+ function os(e, {
552
+ folders: t
701
553
  }) {
702
- return modifyNode(treeData, (node) => {
703
- if (folders.includes(node.id)) {
704
- return void 0;
705
- } else {
706
- return node;
707
- }
554
+ return H(e, (s) => {
555
+ if (!t.includes(s.id))
556
+ return s;
708
557
  });
709
558
  }
710
- function moveNode(treeData, {
711
- destinationId,
712
- folders
559
+ function as(e, {
560
+ destinationId: t,
561
+ folders: s
713
562
  }) {
714
- return modifyNode(treeData, (node, parent) => {
715
- var _a, _b;
716
- if (destinationId === node.id) {
717
- const parentAncestors = [...((_a = node.folder) == null ? void 0 : _a.ancestors) || []];
718
- const ancestors = arrayUnique([...parentAncestors, node.id]);
719
- const newChildren = [...node.children || []];
720
- const childrenIds = ((_b = node.children) == null ? void 0 : _b.map((child) => child.id)) || [];
721
- for (const folder of folders) {
722
- if (!childrenIds.includes(folder)) {
723
- const item = findNodeById(folder, treeData);
724
- item && newChildren.push({
725
- ...item,
563
+ return H(e, (r, n) => {
564
+ var a, o;
565
+ if (t === r.id) {
566
+ const l = [...((a = r.folder) == null ? void 0 : a.ancestors) || []], h = te([...l, r.id]), d = [...r.children || []], u = ((o = r.children) == null ? void 0 : o.map((i) => i.id)) || [];
567
+ for (const i of s)
568
+ if (!u.includes(i)) {
569
+ const p = V(i, e);
570
+ p && d.push({
571
+ ...p,
726
572
  folder: {
727
- ...item == null ? void 0 : item.folder,
728
- ancestors
573
+ ...p == null ? void 0 : p.folder,
574
+ ancestors: h
729
575
  }
730
576
  });
731
577
  }
732
- }
733
- const newNode = {
734
- ...node,
735
- children: newChildren
578
+ return {
579
+ ...r,
580
+ children: d
736
581
  };
737
- return newNode;
738
- } else if (folders.includes(node.id) && destinationId !== (parent == null ? void 0 : parent.id)) {
739
- return void 0;
740
- } else {
741
- return node;
742
- }
582
+ } else
583
+ return s.includes(r.id) && t !== (n == null ? void 0 : n.id) ? void 0 : r;
743
584
  });
744
585
  }
745
- function updateNode(treeData, {
746
- folderId,
747
- newFolder
586
+ function cs(e, {
587
+ folderId: t,
588
+ newFolder: s
748
589
  }) {
749
- return modifyNode(treeData, (node) => {
750
- if (node.id === folderId) {
751
- return new TreeNodeFolderWrapper(newFolder);
752
- } else {
753
- return node;
754
- }
755
- });
590
+ return H(e, (r) => r.id === t ? new X(s) : r);
756
591
  }
757
- const useActions = () => {
758
- const config = useStoreContext((state) => state.config);
759
- return useQuery({
592
+ const is = () => {
593
+ const e = w((t) => t.config);
594
+ return qe({
760
595
  queryKey: ["actions"],
761
596
  queryFn: async () => {
762
- const actionRights = config.actions.map((action) => action.workflow);
763
- const availableRights = await sessionHasWorkflowRights(actionRights);
764
- return availableRights;
765
- },
766
- select: (data) => {
767
- return config.actions.map((action) => ({
768
- ...action,
769
- available: data[action.workflow]
770
- }));
597
+ const t = e == null ? void 0 : e.actions.map((r) => r.workflow);
598
+ return await _e(t);
771
599
  },
772
- staleTime: Infinity,
773
- enabled: !!config
600
+ select: (t) => e == null ? void 0 : e.actions.map((s) => ({
601
+ ...s,
602
+ available: t[s.workflow]
603
+ })),
604
+ staleTime: 1 / 0,
605
+ enabled: !!e
774
606
  });
775
- };
776
- const useSearchContext = () => {
777
- const config = useStoreContext((state) => state.config);
778
- const searchParams = useSearchParams();
779
- const {
780
- filters,
781
- trashed,
782
- search
783
- } = searchParams;
784
- const queryKey = ["context", {
785
- folderId: filters.folder,
786
- filters,
787
- trashed,
788
- search
607
+ }, ls = () => {
608
+ const e = w((o) => o.config), t = b(), {
609
+ filters: s,
610
+ trashed: r,
611
+ search: n
612
+ } = t, a = ["context", {
613
+ folderId: s.folder,
614
+ filters: s,
615
+ trashed: r,
616
+ search: n
789
617
  }];
790
- return useInfiniteQuery({
791
- queryKey,
618
+ return Oe({
619
+ queryKey: a,
792
620
  queryFn: async ({
793
- pageParam
794
- }) => {
795
- return await searchContext({
796
- ...searchParams,
797
- app: config == null ? void 0 : config.app,
798
- types: config == null ? void 0 : config.types,
799
- pagination: {
800
- ...searchParams.pagination,
801
- startIdx: pageParam
802
- }
803
- });
804
- },
621
+ pageParam: o
622
+ }) => await ie({
623
+ ...t,
624
+ application: e == null ? void 0 : e.app,
625
+ types: e == null ? void 0 : e.types,
626
+ pagination: {
627
+ ...t.pagination,
628
+ startIdx: o
629
+ }
630
+ }),
805
631
  initialPageParam: 0,
806
- enabled: !!config,
807
- retry: false,
808
- getNextPageParam: (lastPage) => {
809
- return lastPage.pagination.startIdx + lastPage.pagination.pageSize;
810
- }
632
+ enabled: !!e,
633
+ retry: !1,
634
+ getNextPageParam: (o) => o.pagination.startIdx + o.pagination.pageSize
811
635
  });
812
- };
813
- const useTrash = () => {
814
- const toast = useToast();
815
- const queryClient = useQueryClient();
816
- const searchParams = useSearchParams();
817
- const treeData = useTreeData();
818
- const folderIds = useFolderIds();
819
- const assetIds = useResourceAssetIds();
820
- const resourceRealIds = useResourceIds();
821
- const useAssetIds = useResourceWithoutIds().length > 0;
822
- const resourceIds = useAssetIds ? assetIds : resourceRealIds;
823
- const {
824
- clearSelectedItems,
825
- clearSelectedIds,
826
- setTreeData,
827
- setSearchParams
828
- } = useStoreActions();
829
- const {
830
- filters,
831
- trashed
832
- } = searchParams;
833
- const queryKey = ["context", {
834
- folderId: filters.folder,
835
- filters,
836
- trashed
636
+ }, Ks = () => {
637
+ const e = q(), t = O(), s = b(), r = z(), n = G(), a = J(), o = Z(), l = Y().length > 0, h = l ? a : o, {
638
+ clearSelectedItems: d,
639
+ clearSelectedIds: u,
640
+ setTreeData: f,
641
+ setSearchParams: i
642
+ } = S(), {
643
+ filters: p,
644
+ trashed: m
645
+ } = s, g = ["context", {
646
+ folderId: p.folder,
647
+ filters: p,
648
+ trashed: m
837
649
  }];
838
- return useMutation({
839
- mutationFn: async () => await trashAll({
840
- searchParams,
841
- folderIds,
842
- resourceIds,
843
- useAssetIds
650
+ return k({
651
+ mutationFn: async () => await Ue({
652
+ searchParams: s,
653
+ folderIds: n,
654
+ resourceIds: h,
655
+ useAssetIds: l
844
656
  }),
845
- onError(error) {
846
- if (typeof error === "string")
847
- toast.error(t(error));
657
+ onError(y) {
658
+ typeof y == "string" && e.error(x(y));
848
659
  },
849
- onSuccess: async (data) => {
850
- await queryClient.cancelQueries({
851
- queryKey
852
- });
853
- const previousData = queryClient.getQueryData(queryKey);
854
- if (previousData) {
855
- toast.success(t("explorer.trash.title"));
856
- return queryClient.setQueryData(queryKey, (prev) => {
857
- var _a;
858
- if (prev) {
859
- const newData = {
860
- ...prev,
861
- pages: prev == null ? void 0 : prev.pages.map((page) => {
862
- var _a2;
660
+ onSuccess: async (y) => {
661
+ if (await t.cancelQueries({
662
+ queryKey: g
663
+ }), t.getQueryData(g))
664
+ return e.success(x("explorer.trash.title")), t.setQueryData(g, (T) => {
665
+ var E;
666
+ if (T) {
667
+ const L = {
668
+ ...T,
669
+ pages: T == null ? void 0 : T.pages.map((R) => {
670
+ var P;
863
671
  return {
864
- ...page,
865
- folders: page.folders.filter((folder) => !folderIds.includes(folder.id)),
672
+ ...R,
673
+ folders: R.folders.filter((Q) => !n.includes(Q.id)),
866
674
  pagination: {
867
- ...page.pagination,
675
+ ...R.pagination,
868
676
  // @ts-ignore
869
- maxIdx: ((_a2 = page == null ? void 0 : page.pagination) == null ? void 0 : _a2.maxIdx) - data.resources.length
677
+ maxIdx: ((P = R == null ? void 0 : R.pagination) == null ? void 0 : P.maxIdx) - y.resources.length
870
678
  },
871
- resources: page.resources.filter((resource) => {
872
- if (useAssetIds) {
873
- return !assetIds.includes(resource.assetId);
874
- } else {
875
- return !resourceIds.includes(resource.id);
876
- }
877
- })
679
+ resources: R.resources.filter((Q) => l ? !a.includes(Q.assetId) : !h.includes(Q.id))
878
680
  };
879
681
  })
880
- };
881
- const update = deleteNode(treeData, {
882
- folders: folderIds
682
+ }, M = os(r, {
683
+ folders: n
883
684
  });
884
- setTreeData(update);
885
- setSearchParams({
886
- ...searchParams,
685
+ return f(M), i({
686
+ ...s,
887
687
  pagination: {
888
- ...searchParams.pagination,
688
+ ...s.pagination,
889
689
  // @ts-ignore
890
- maxIdx: ((_a = searchParams.pagination) == null ? void 0 : _a.maxIdx) - data.resources.length
690
+ maxIdx: ((E = s.pagination) == null ? void 0 : E.maxIdx) - y.resources.length
891
691
  }
892
- });
893
- return newData;
692
+ }), L;
894
693
  }
895
- return void 0;
896
694
  });
897
- }
898
695
  },
899
696
  onSettled: () => {
900
- clearSelectedItems();
901
- clearSelectedIds();
697
+ d(), u();
902
698
  }
903
699
  });
904
- };
905
- const useRestore = () => {
906
- const toast = useToast();
907
- const queryClient = useQueryClient();
908
- const searchParams = useSearchParams();
909
- const folderIds = useFolderIds();
910
- const assetIds = useResourceAssetIds();
911
- const resourceRealIds = useResourceIds();
912
- const useAssetIds = useResourceWithoutIds().length > 0;
913
- const resourceIds = useAssetIds ? assetIds : resourceRealIds;
914
- const {
915
- setFolderIds,
916
- setResourceIds,
917
- setSelectedResources,
918
- setSelectedFolders
919
- } = useStoreActions();
920
- const {
921
- filters,
922
- trashed
923
- } = searchParams;
924
- const queryKey = ["context", {
925
- folderId: filters.folder,
926
- filters,
927
- trashed
700
+ }, $s = () => {
701
+ const e = q(), t = O(), s = b(), r = G(), n = J(), a = Z(), o = Y().length > 0, l = o ? n : a, {
702
+ setFolderIds: h,
703
+ setResourceIds: d,
704
+ setSelectedResources: u,
705
+ setSelectedFolders: f
706
+ } = S(), {
707
+ filters: i,
708
+ trashed: p
709
+ } = s, m = ["context", {
710
+ folderId: i.folder,
711
+ filters: i,
712
+ trashed: p
928
713
  }];
929
- return useMutation({
930
- mutationFn: async () => await restoreAll({
931
- searchParams,
932
- folderIds,
933
- resourceIds,
934
- useAssetIds
714
+ return k({
715
+ mutationFn: async () => await Me({
716
+ searchParams: s,
717
+ folderIds: r,
718
+ resourceIds: l,
719
+ useAssetIds: o
935
720
  }),
936
- onError(error) {
937
- if (typeof error === "string")
938
- toast.error(t(error));
721
+ onError(g) {
722
+ typeof g == "string" && e.error(x(g));
939
723
  },
940
724
  onSuccess: async () => {
941
- await queryClient.cancelQueries({
942
- queryKey
943
- });
944
- const previousData = queryClient.getQueryData(queryKey);
945
- if (previousData) {
946
- toast.success(t("explorer.trash.toast"));
947
- return queryClient.setQueryData(queryKey, (prev) => {
948
- if (prev) {
725
+ if (await t.cancelQueries({
726
+ queryKey: m
727
+ }), t.getQueryData(m))
728
+ return e.success(x("explorer.trash.toast")), t.setQueryData(m, (y) => {
729
+ if (y)
949
730
  return {
950
- ...prev,
951
- pages: prev == null ? void 0 : prev.pages.map((page) => {
952
- return {
953
- ...page,
954
- folders: page.folders.filter((folder) => !folderIds.includes(folder.id)),
955
- resources: page.resources.filter((resource) => {
956
- if (useAssetIds) {
957
- return !assetIds.includes(resource.assetId);
958
- } else {
959
- return !resourceIds.includes(resource.id);
960
- }
961
- })
962
- };
963
- })
731
+ ...y,
732
+ pages: y == null ? void 0 : y.pages.map((I) => ({
733
+ ...I,
734
+ folders: I.folders.filter((T) => !r.includes(T.id)),
735
+ resources: I.resources.filter((T) => o ? !n.includes(T.assetId) : !l.includes(T.id))
736
+ }))
964
737
  };
965
- }
966
- return void 0;
967
738
  });
968
- }
969
739
  },
970
740
  onSettled: () => {
971
- setResourceIds([]);
972
- setSelectedResources([]);
973
- setFolderIds([]);
974
- setSelectedFolders([]);
741
+ d([]), u([]), h([]), f([]);
975
742
  }
976
743
  });
977
- };
978
- const useDelete = () => {
979
- const toast = useToast();
980
- const queryClient = useQueryClient();
981
- const searchParams = useSearchParams();
982
- const folderIds = useFolderIds();
983
- const assetIds = useResourceAssetIds();
984
- const resourceRealIds = useResourceIds();
985
- const useAssetIds = useResourceWithoutIds().length > 0;
986
- const resourceIds = useAssetIds ? assetIds : resourceRealIds;
987
- const {
988
- clearSelectedItems,
989
- clearSelectedIds
990
- } = useStoreActions();
991
- const {
992
- filters,
993
- trashed
994
- } = searchParams;
995
- const queryKey = ["context", {
996
- folderId: filters.folder,
997
- filters,
998
- trashed
744
+ }, js = () => {
745
+ const e = q(), t = O(), s = b(), r = G(), n = J(), a = Z(), o = Y().length > 0, l = o ? n : a, {
746
+ clearSelectedItems: h,
747
+ clearSelectedIds: d
748
+ } = S(), {
749
+ filters: u,
750
+ trashed: f
751
+ } = s, i = ["context", {
752
+ folderId: u.folder,
753
+ filters: u,
754
+ trashed: f
999
755
  }];
1000
- return useMutation({
1001
- mutationFn: async () => await deleteAll({
1002
- searchParams,
1003
- folderIds,
1004
- resourceIds,
1005
- useAssetIds
756
+ return k({
757
+ mutationFn: async () => await Be({
758
+ searchParams: s,
759
+ folderIds: r,
760
+ resourceIds: l,
761
+ useAssetIds: o
1006
762
  }),
1007
- onError(error) {
1008
- if (typeof error === "string")
1009
- toast.error(t(error));
763
+ onError(p) {
764
+ typeof p == "string" && e.error(x(p));
1010
765
  },
1011
766
  onSuccess: async () => {
1012
- await queryClient.cancelQueries({
1013
- queryKey
1014
- });
1015
- const previousData = queryClient.getQueryData(queryKey);
1016
- if (previousData) {
1017
- toast.success(t("explorer.removed.from.trash"));
1018
- return queryClient.setQueryData(queryKey, (prev) => {
1019
- if (prev) {
1020
- const newData = {
1021
- ...prev,
1022
- pages: prev == null ? void 0 : prev.pages.map((page) => {
1023
- return {
1024
- ...page,
1025
- folders: page.folders.filter((folder) => !folderIds.includes(folder.id)),
1026
- resources: page.resources.filter((resource) => {
1027
- if (useAssetIds) {
1028
- return !assetIds.includes(resource.assetId);
1029
- } else {
1030
- return !resourceIds.includes(resource.id);
1031
- }
1032
- })
1033
- };
1034
- })
767
+ if (await t.cancelQueries({
768
+ queryKey: i
769
+ }), t.getQueryData(i))
770
+ return e.success(x("explorer.removed.from.trash")), t.setQueryData(i, (m) => {
771
+ if (m)
772
+ return {
773
+ ...m,
774
+ pages: m == null ? void 0 : m.pages.map((y) => ({
775
+ ...y,
776
+ folders: y.folders.filter((I) => !r.includes(I.id)),
777
+ resources: y.resources.filter((I) => o ? !n.includes(I.assetId) : !l.includes(I.id))
778
+ }))
1035
779
  };
1036
- return newData;
1037
- }
1038
- return void 0;
1039
780
  });
1040
- }
1041
781
  },
1042
782
  onSettled: () => {
1043
- clearSelectedItems();
1044
- clearSelectedIds();
783
+ h(), d();
1045
784
  }
1046
785
  });
1047
- };
1048
- const useMoveItem = () => {
1049
- const toast = useToast();
1050
- const queryClient = useQueryClient();
1051
- const searchParams = useSearchParams();
1052
- const treeData = useTreeData();
1053
- const folderIds = useFolderIds();
1054
- const assetIds = useResourceAssetIds();
1055
- const resourceRealIds = useResourceIds();
1056
- const useAssetIds = useResourceWithoutIds().length > 0;
1057
- const resourceIds = useAssetIds ? assetIds : resourceRealIds;
1058
- const {
1059
- clearSelectedIds,
1060
- clearSelectedItems,
1061
- setTreeData,
1062
- setSearchParams
1063
- } = useStoreActions();
1064
- const {
1065
- filters,
1066
- trashed
1067
- } = searchParams;
1068
- const queryKey = ["context", {
1069
- folderId: filters.folder,
1070
- filters,
1071
- trashed
786
+ }, _s = () => {
787
+ const e = q(), t = O(), s = b(), r = z(), n = G(), a = J(), o = Z(), l = Y().length > 0, h = l ? a : o, {
788
+ clearSelectedIds: d,
789
+ clearSelectedItems: u,
790
+ setTreeData: f,
791
+ setSearchParams: i
792
+ } = S(), {
793
+ filters: p,
794
+ trashed: m
795
+ } = s, g = ["context", {
796
+ folderId: p.folder,
797
+ filters: p,
798
+ trashed: m
1072
799
  }];
1073
- return useMutation({
1074
- mutationFn: async (folderId) => await moveToFolder({
1075
- searchParams,
1076
- folderId,
1077
- folderIds,
1078
- resourceIds,
1079
- useAssetIds
800
+ return k({
801
+ mutationFn: async (y) => await Ke({
802
+ searchParams: s,
803
+ folderId: y,
804
+ folderIds: n,
805
+ resourceIds: h,
806
+ useAssetIds: l
1080
807
  }),
1081
- onError(error) {
1082
- if (typeof error === "string")
1083
- toast.error(t(error));
808
+ onError(y) {
809
+ typeof y == "string" && e.error(x(y));
1084
810
  },
1085
- onSuccess: async (data, variables) => {
1086
- const previousData = queryClient.getQueryData(queryKey);
1087
- if (previousData) {
1088
- return queryClient.setQueryData(queryKey, (prev) => {
1089
- var _a;
1090
- if (prev) {
1091
- const update = moveNode(treeData, {
1092
- destinationId: variables,
1093
- folders: folderIds
1094
- });
1095
- const newData = {
1096
- ...prev,
1097
- pages: prev == null ? void 0 : prev.pages.map((page) => {
1098
- var _a2;
811
+ onSuccess: async (y, I) => {
812
+ if (t.getQueryData(g))
813
+ return t.setQueryData(g, (E) => {
814
+ var L;
815
+ if (E) {
816
+ const M = as(r, {
817
+ destinationId: I,
818
+ folders: n
819
+ }), R = {
820
+ ...E,
821
+ pages: E == null ? void 0 : E.pages.map((P) => {
822
+ var Q;
1099
823
  return {
1100
- ...page,
1101
- folders: page.folders.filter((folder) => !folderIds.includes(folder.id)),
824
+ ...P,
825
+ folders: P.folders.filter((K) => !n.includes(K.id)),
1102
826
  pagination: {
1103
- ...page.pagination,
827
+ ...P.pagination,
1104
828
  // @ts-ignore
1105
- maxIdx: ((_a2 = page.pagination) == null ? void 0 : _a2.maxIdx) - data.resources.length
829
+ maxIdx: ((Q = P.pagination) == null ? void 0 : Q.maxIdx) - y.resources.length
1106
830
  },
1107
- resources: page.resources.filter((resource) => {
1108
- if (useAssetIds) {
1109
- return !assetIds.includes(resource.assetId);
1110
- } else {
1111
- return !resourceIds.includes(resource.id);
1112
- }
1113
- })
831
+ resources: P.resources.filter((K) => l ? !a.includes(K.assetId) : !h.includes(K.id))
1114
832
  };
1115
833
  })
1116
834
  };
1117
- setTreeData(update);
1118
- setSearchParams({
1119
- ...searchParams,
835
+ return f(M), i({
836
+ ...s,
1120
837
  pagination: {
1121
- ...searchParams.pagination,
838
+ ...s.pagination,
1122
839
  // @ts-ignore
1123
- maxIdx: ((_a = searchParams.pagination) == null ? void 0 : _a.maxIdx) - data.resources.length
840
+ maxIdx: ((L = s.pagination) == null ? void 0 : L.maxIdx) - y.resources.length
1124
841
  }
1125
- });
1126
- return newData;
842
+ }), R;
1127
843
  }
1128
- return void 0;
1129
844
  });
1130
- }
1131
845
  },
1132
846
  onSettled: () => {
1133
- clearSelectedItems();
1134
- clearSelectedIds();
847
+ u(), d();
1135
848
  }
1136
849
  });
1137
- };
1138
- const useCreateFolder = () => {
1139
- const toast = useToast();
1140
- const queryClient = useQueryClient();
1141
- const searchParams = useSearchParams();
1142
- const treeData = useTreeData();
1143
- const {
1144
- setTreeData
1145
- } = useStoreActions();
1146
- const {
1147
- filters,
1148
- trashed
1149
- } = searchParams;
1150
- const queryKey = ["context", {
1151
- folderId: filters.folder,
1152
- filters,
1153
- trashed
850
+ }, zs = () => {
851
+ const e = q(), t = O(), s = b(), r = z(), {
852
+ setTreeData: n
853
+ } = S(), {
854
+ filters: a,
855
+ trashed: o
856
+ } = s, l = ["context", {
857
+ folderId: a.folder,
858
+ filters: a,
859
+ trashed: o
1154
860
  }];
1155
- return useMutation({
861
+ return k({
1156
862
  mutationFn: async ({
1157
- name,
1158
- parentId
1159
- }) => await createFolder({
1160
- searchParams,
1161
- name,
1162
- parentId
863
+ name: h,
864
+ parentId: d
865
+ }) => await ke({
866
+ searchParams: s,
867
+ name: h,
868
+ parentId: d
1163
869
  }),
1164
- onError(error) {
1165
- if (typeof error === "string")
1166
- toast.error(t(error));
870
+ onError(h) {
871
+ typeof h == "string" && e.error(x(h));
1167
872
  },
1168
- onSuccess: async (data, variables) => {
1169
- await queryClient.cancelQueries({
1170
- queryKey
873
+ onSuccess: async (h, d) => {
874
+ await t.cancelQueries({
875
+ queryKey: l
1171
876
  });
1172
- const previousData = queryClient.getQueryData(queryKey);
1173
- const newFolder = {
1174
- ...data,
1175
- parentId: variables.parentId,
877
+ const u = t.getQueryData(l), f = {
878
+ ...h,
879
+ parentId: d.parentId,
1176
880
  children: [],
1177
- rights: [`creator:${data == null ? void 0 : data.creator_id}`]
881
+ rights: [`creator:${h == null ? void 0 : h.creator_id}`]
1178
882
  };
1179
- if (previousData) {
1180
- return queryClient.setQueryData(queryKey, (prev) => {
1181
- if (prev) {
1182
- const newData = {
1183
- ...prev,
1184
- pages: prev == null ? void 0 : prev.pages.map((page) => {
1185
- return {
1186
- ...page,
1187
- folders: [...page.folders, newFolder]
1188
- };
1189
- })
1190
- };
1191
- const update = addNode(treeData, {
1192
- parentId: variables.parentId,
1193
- newFolder
883
+ if (u)
884
+ return t.setQueryData(l, (i) => {
885
+ if (i) {
886
+ const p = {
887
+ ...i,
888
+ pages: i == null ? void 0 : i.pages.map((g) => ({
889
+ ...g,
890
+ folders: [...g.folders, f]
891
+ }))
892
+ }, m = ns(r, {
893
+ parentId: d.parentId,
894
+ newFolder: f
1194
895
  });
1195
- setTreeData(update);
1196
- return newData;
896
+ return n(m), p;
1197
897
  }
1198
- return void 0;
1199
898
  });
1200
- }
1201
899
  }
1202
900
  });
1203
- };
1204
- const useUpdatefolder = () => {
1205
- const toast = useToast();
1206
- const queryClient = useQueryClient();
1207
- const searchParams = useSearchParams();
1208
- const treeData = useTreeData();
1209
- const {
1210
- setFolderIds,
1211
- setSelectedFolders,
1212
- setTreeData
1213
- } = useStoreActions();
1214
- const {
1215
- filters,
1216
- trashed
1217
- } = searchParams;
1218
- const queryKey = ["context", {
1219
- folderId: filters.folder,
1220
- filters,
1221
- trashed
901
+ }, Vs = () => {
902
+ const e = q(), t = O(), s = b(), r = z(), {
903
+ setFolderIds: n,
904
+ setSelectedFolders: a,
905
+ setTreeData: o
906
+ } = S(), {
907
+ filters: l,
908
+ trashed: h
909
+ } = s, d = ["context", {
910
+ folderId: l.folder,
911
+ filters: l,
912
+ trashed: h
1222
913
  }];
1223
- return useMutation({
914
+ return k({
1224
915
  mutationFn: async ({
1225
- folderId,
1226
- name,
1227
- parentId
1228
- }) => await updateFolder({
1229
- searchParams,
1230
- folderId,
1231
- parentId,
1232
- name
916
+ folderId: u,
917
+ name: f,
918
+ parentId: i
919
+ }) => await Le({
920
+ searchParams: s,
921
+ folderId: u,
922
+ parentId: i,
923
+ name: f
1233
924
  }),
1234
- onError(error) {
1235
- if (typeof error === "string")
1236
- toast.error(t(error));
925
+ onError(u) {
926
+ typeof u == "string" && e.error(x(u));
1237
927
  },
1238
- onSuccess: async (data, variables) => {
1239
- await queryClient.cancelQueries({
1240
- queryKey
1241
- });
1242
- const previousData = queryClient.getQueryData(queryKey);
1243
- if (previousData) {
1244
- return queryClient.setQueryData(queryKey, (prev) => {
1245
- if (prev) {
1246
- const newData = {
1247
- ...prev,
1248
- pages: prev == null ? void 0 : prev.pages.map((page) => {
1249
- return {
1250
- ...page,
1251
- folders: page.folders.map((folder) => {
1252
- if (folder.id === data.id) {
1253
- return {
1254
- ...data,
1255
- parentId: variables.parentId,
1256
- rights: folder.rights
1257
- };
1258
- } else {
1259
- return folder;
1260
- }
1261
- })
1262
- };
1263
- })
1264
- };
1265
- const update = updateNode(treeData, {
1266
- folderId: variables.folderId,
1267
- newFolder: data
928
+ onSuccess: async (u, f) => {
929
+ if (await t.cancelQueries({
930
+ queryKey: d
931
+ }), t.getQueryData(d))
932
+ return t.setQueryData(d, (p) => {
933
+ if (p) {
934
+ const m = {
935
+ ...p,
936
+ pages: p == null ? void 0 : p.pages.map((y) => ({
937
+ ...y,
938
+ folders: y.folders.map((I) => I.id === u.id ? {
939
+ ...u,
940
+ parentId: f.parentId,
941
+ rights: I.rights
942
+ } : I)
943
+ }))
944
+ }, g = cs(r, {
945
+ folderId: f.folderId,
946
+ newFolder: u
1268
947
  });
1269
- setTreeData(update);
1270
- return newData;
948
+ return o(g), m;
1271
949
  }
1272
- return void 0;
1273
950
  });
1274
- }
1275
951
  },
1276
952
  onSettled: () => {
1277
- setFolderIds([]);
1278
- setSelectedFolders([]);
953
+ n([]), a([]);
1279
954
  }
1280
955
  });
1281
- };
1282
- const useShareResource = () => {
1283
- const toast = useToast();
1284
- const queryClient = useQueryClient();
1285
- const searchParams = useSearchParams();
1286
- const {
1287
- setResourceIds,
1288
- setSelectedResources
1289
- } = useStoreActions();
1290
- const {
1291
- filters,
1292
- trashed,
1293
- app
1294
- } = searchParams;
1295
- const queryKey = ["context", {
1296
- folderId: filters.folder,
1297
- filters,
1298
- trashed
956
+ }, Hs = () => {
957
+ const e = q(), t = O(), s = b(), {
958
+ setResourceIds: r,
959
+ setSelectedResources: n
960
+ } = S(), {
961
+ filters: a,
962
+ trashed: o
963
+ } = s, l = ["context", {
964
+ folderId: a.folder,
965
+ filters: a,
966
+ trashed: o
1299
967
  }];
1300
- return useMutation({
968
+ return k({
1301
969
  mutationFn: async ({
1302
- resourceId,
1303
- rights
1304
- }) => await shareResource({
1305
- app,
1306
- resourceId,
1307
- rights
970
+ resourceId: h,
971
+ rights: d
972
+ }) => await $e({
973
+ searchParams: s,
974
+ resourceId: h,
975
+ rights: d
1308
976
  }),
1309
- onError(error) {
1310
- if (typeof error === "string")
1311
- toast.error(t("explorer.shared.status.error"));
977
+ onError(h) {
978
+ typeof h == "string" && e.error(x("explorer.shared.status.error"));
1312
979
  },
1313
- onSuccess: async (_data, variables) => {
1314
- await queryClient.cancelQueries({
1315
- queryKey
1316
- });
1317
- const previousData = queryClient.getQueryData(queryKey);
1318
- if (previousData) {
1319
- toast.success(t("explorer.shared.status.saved"));
1320
- return queryClient.setQueryData(queryKey, (prev) => {
1321
- if (prev) {
980
+ onSuccess: async (h, d) => {
981
+ if (await t.cancelQueries({
982
+ queryKey: l
983
+ }), t.getQueryData(l))
984
+ return e.success(x("explorer.shared.status.saved")), t.setQueryData(l, (f) => {
985
+ if (f)
1322
986
  return {
1323
- ...prev,
1324
- pages: prev == null ? void 0 : prev.pages.map((page) => {
1325
- return {
1326
- ...page,
1327
- resources: page.resources.map((resource) => {
1328
- if (resource.assetId === (variables == null ? void 0 : variables.resourceId)) {
1329
- let rights = [`creator:${resource.creatorId}`];
1330
- if ((variables == null ? void 0 : variables.rights.length) >= 1) {
1331
- rights = [...rights, ...variables.rights.flatMap((right) => {
1332
- return right.actions.map((action) => {
1333
- return `${right.type}:${right.id}:${action.id}`;
1334
- });
1335
- })];
1336
- }
1337
- return {
1338
- ...resource,
1339
- rights
1340
- };
1341
- } else {
1342
- return resource;
1343
- }
1344
- })
1345
- };
1346
- })
987
+ ...f,
988
+ pages: f == null ? void 0 : f.pages.map((i) => ({
989
+ ...i,
990
+ resources: i.resources.map((p) => {
991
+ if (p.assetId === (d == null ? void 0 : d.resourceId)) {
992
+ let m = [`creator:${p.creatorId}`];
993
+ return (d == null ? void 0 : d.rights.length) >= 1 && (m = [...m, ...d.rights.flatMap((g) => g.actions.map((y) => `${g.type}:${g.id}:${y.id}`))]), {
994
+ ...p,
995
+ rights: m
996
+ };
997
+ } else
998
+ return p;
999
+ })
1000
+ }))
1347
1001
  };
1348
- }
1349
- return void 0;
1350
1002
  });
1351
- }
1352
1003
  },
1353
1004
  onSettled: () => {
1354
- setResourceIds([]);
1355
- setSelectedResources([]);
1005
+ r([]), n([]);
1356
1006
  }
1357
1007
  });
1358
- };
1359
- const useUpdateResource = () => {
1360
- const toast = useToast();
1361
- const queryClient = useQueryClient();
1362
- const searchParams = useSearchParams();
1363
- const {
1364
- filters,
1365
- trashed,
1366
- app
1367
- } = searchParams;
1368
- const queryKey = ["context", {
1369
- folderId: filters.folder,
1370
- filters,
1371
- trashed
1008
+ }, Ws = () => {
1009
+ const e = q(), t = O(), s = b(), {
1010
+ filters: r,
1011
+ trashed: n
1012
+ } = s, a = ["context", {
1013
+ folderId: r.folder,
1014
+ filters: r,
1015
+ trashed: n
1372
1016
  }];
1373
- return useMutation({
1374
- mutationFn: async (params) => await updateResource({
1375
- app,
1376
- params
1017
+ return k({
1018
+ mutationFn: async (o) => await je({
1019
+ searchParams: s,
1020
+ params: o
1377
1021
  }),
1378
- onError(error) {
1379
- if (typeof error === "string")
1380
- toast.error(t(error));
1022
+ onError(o) {
1023
+ typeof o == "string" && e.error(x(o));
1381
1024
  },
1382
- onSuccess: async (_data, variables) => {
1383
- await queryClient.cancelQueries({
1384
- queryKey
1385
- });
1386
- const previousData = queryClient.getQueryData(queryKey);
1387
- if (previousData) {
1388
- return queryClient.setQueryData(queryKey, (prev) => {
1389
- if (prev) {
1025
+ onSuccess: async (o, l) => {
1026
+ if (await t.cancelQueries({
1027
+ queryKey: a
1028
+ }), t.getQueryData(a))
1029
+ return t.setQueryData(a, (d) => {
1030
+ if (d)
1390
1031
  return {
1391
- ...prev,
1392
- pages: prev == null ? void 0 : prev.pages.map((page) => {
1393
- return {
1394
- ...page,
1395
- resources: page.resources.map((resource) => {
1396
- if (resource.assetId === (variables == null ? void 0 : variables.entId)) {
1397
- const {
1398
- name,
1399
- thumbnail,
1400
- public: pub,
1401
- description,
1402
- slug,
1403
- ...others
1404
- } = variables;
1405
- return {
1406
- ...resource,
1407
- ...others,
1408
- // add any custom field
1409
- name,
1410
- thumbnail: typeof thumbnail === "string" ? thumbnail : URL.createObjectURL(thumbnail),
1411
- public: pub,
1412
- description,
1413
- slug
1414
- };
1415
- } else {
1416
- return resource;
1417
- }
1418
- })
1419
- };
1420
- })
1032
+ ...d,
1033
+ pages: d == null ? void 0 : d.pages.map((u) => ({
1034
+ ...u,
1035
+ resources: u.resources.map((f) => {
1036
+ if (f.assetId === (l == null ? void 0 : l.entId)) {
1037
+ const {
1038
+ name: i,
1039
+ thumbnail: p,
1040
+ public: m,
1041
+ description: g,
1042
+ slug: y,
1043
+ ...I
1044
+ } = l;
1045
+ return {
1046
+ ...f,
1047
+ ...I,
1048
+ // add any custom field
1049
+ name: i,
1050
+ thumbnail: typeof p == "string" ? p : URL.createObjectURL(p),
1051
+ public: m,
1052
+ description: g,
1053
+ slug: y
1054
+ };
1055
+ } else
1056
+ return f;
1057
+ })
1058
+ }))
1421
1059
  };
1422
- }
1423
- return void 0;
1424
1060
  });
1425
- }
1426
1061
  }
1427
1062
  });
1428
- };
1429
- const useCreateResource = () => {
1430
- const toast = useToast();
1431
- const queryClient = useQueryClient();
1432
- const searchParams = useSearchParams();
1433
- const {
1434
- user
1435
- } = useUser();
1436
- const {
1437
- appCode: application
1438
- } = useOdeClient();
1439
- const queryKey = ["context", {
1440
- folderId: searchParams.filters.folder,
1441
- filters: searchParams.filters,
1442
- trashed: searchParams.trashed
1063
+ }, Xs = () => {
1064
+ const e = q(), t = O(), s = b(), {
1065
+ user: r
1066
+ } = we(), {
1067
+ appCode: n
1068
+ } = B(), a = ["context", {
1069
+ folderId: s.filters.folder,
1070
+ filters: s.filters,
1071
+ trashed: s.trashed
1443
1072
  }];
1444
- return useMutation({
1445
- mutationFn: async (params) => await createResource({
1446
- searchParams,
1447
- params
1073
+ return k({
1074
+ mutationFn: async (o) => await Ve({
1075
+ searchParams: s,
1076
+ params: o
1448
1077
  }),
1449
- onError(error) {
1450
- if (typeof error === "string")
1451
- toast.error(t(error));
1078
+ onError(o) {
1079
+ typeof o == "string" && e.error(x(o));
1452
1080
  },
1453
- onSuccess: async (data, variables) => {
1454
- var _a, _b, _c;
1455
- await queryClient.cancelQueries({
1456
- queryKey
1081
+ onSuccess: async (o, l) => {
1082
+ var f, i, p;
1083
+ await t.cancelQueries({
1084
+ queryKey: a
1457
1085
  });
1458
- const previousData = queryClient.getQueryData(queryKey);
1459
- const {
1460
- thumbnail
1461
- } = variables;
1462
- const newResource = {
1463
- ...variables,
1464
- thumbnail: thumbnail ? URL.createObjectURL(thumbnail) : "",
1465
- application,
1466
- assetId: data._id || data.entId || "",
1467
- id: data._id || data.entId || "",
1468
- creatorId: user == null ? void 0 : user.userId,
1469
- creatorName: user == null ? void 0 : user.username,
1086
+ const h = t.getQueryData(a), {
1087
+ thumbnail: d
1088
+ } = l, u = {
1089
+ ...l,
1090
+ thumbnail: d ? URL.createObjectURL(d) : "",
1091
+ application: n,
1092
+ assetId: o._id || o.entId || "",
1093
+ id: o._id || o.entId || "",
1094
+ creatorId: r == null ? void 0 : r.userId,
1095
+ creatorName: r == null ? void 0 : r.username,
1470
1096
  createdAt: Date.now(),
1471
- slug: variables.slug || "",
1472
- modifiedAt: ((_a = data.modified) == null ? void 0 : _a.$date) || "",
1473
- modifierId: ((_b = data.author) == null ? void 0 : _b.userId) || "",
1474
- modifierName: ((_c = data.author) == null ? void 0 : _c.username) || "",
1097
+ slug: l.slug || "",
1098
+ modifiedAt: ((f = o.modified) == null ? void 0 : f.$date) || "",
1099
+ modifierId: ((i = o.author) == null ? void 0 : i.userId) || "",
1100
+ modifierName: ((p = o.author) == null ? void 0 : p.username) || "",
1475
1101
  updatedAt: Date.now(),
1476
- trashed: false,
1477
- rights: [`creator:${user == null ? void 0 : user.userId}`]
1102
+ trashed: !1,
1103
+ rights: [`creator:${r == null ? void 0 : r.userId}`]
1478
1104
  };
1479
- if (previousData) {
1480
- return queryClient.setQueryData(queryKey, (prev) => {
1481
- if (prev) {
1105
+ if (h)
1106
+ return t.setQueryData(a, (m) => {
1107
+ if (m)
1482
1108
  return {
1483
- ...prev,
1484
- pages: prev == null ? void 0 : prev.pages.map((page) => {
1485
- return {
1486
- ...page,
1487
- resources: [newResource, ...page.resources]
1488
- };
1489
- })
1109
+ ...m,
1110
+ pages: m == null ? void 0 : m.pages.map((g) => ({
1111
+ ...g,
1112
+ resources: [u, ...g.resources]
1113
+ }))
1490
1114
  };
1491
- }
1492
- return void 0;
1493
1115
  });
1494
- }
1495
1116
  }
1496
1117
  });
1497
- };
1498
- const EmptyScreenApp = /* @__PURE__ */ lazy(async () => await import("./EmptyScreenApp.js"));
1499
- const EmptyScreenSearch = /* @__PURE__ */ lazy(async () => await import("./EmptyScreenSearch.js"));
1500
- const EmptyScreenError = /* @__PURE__ */ lazy(async () => await import("./EmptyScreenError.js"));
1501
- const EmptyScreenNoContentInFolder = /* @__PURE__ */ lazy(async () => await import("./EmptyScreenNoContentInFolder.js"));
1502
- const EmptyScreenTrash = /* @__PURE__ */ lazy(async () => await import("./EmptyScreenTrash.js"));
1503
- const FoldersList = /* @__PURE__ */ lazy(async () => await import("./FoldersList.js"));
1504
- const ResourcesList = /* @__PURE__ */ lazy(async () => await import("./ResourcesList.js"));
1505
- const List = () => {
1506
- const isRoot = useIsRoot();
1507
- const isTrashFolder = useIsTrash();
1508
- const hasSelectedNodes = useHasSelectedNodes();
1509
- const searchParams = useSearchParams();
1510
- const currentFolder = useCurrentFolder();
1511
- const treeData = useTreeData();
1512
- const toast = useToast();
1513
- const {
1514
- appCode
1515
- } = useOdeClient();
1516
- const {
1517
- t: t2
1518
- } = useTranslation();
1519
- const {
1520
- setSearchParams,
1521
- setSearchConfig,
1522
- setTreeData
1523
- } = useStoreActions();
1524
- const {
1525
- data,
1526
- isError,
1527
- error,
1528
- isLoading,
1529
- isFetching,
1530
- fetchNextPage
1531
- } = useSearchContext();
1532
- const hasNoFolders = (data == null ? void 0 : data.pages[0].folders.length) === 0;
1533
- const hasNoResources = (data == null ? void 0 : data.pages[0].resources.length) === 0;
1534
- const hasNoData = hasNoFolders && hasNoResources;
1535
- useEffect(() => {
1536
- var _a, _b, _c;
1537
- if (data) {
1538
- const folders = [...((_a = data == null ? void 0 : data.pages[0]) == null ? void 0 : _a.folders) ?? []];
1539
- if ((_b = data == null ? void 0 : data.pages[0]) == null ? void 0 : _b.searchConfig) {
1540
- setSearchConfig(data.pages[0].searchConfig);
1541
- }
1542
- if (!searchParams.search) {
1543
- if ((currentFolder == null ? void 0 : currentFolder.id) === "default") {
1544
- setTreeData({
1545
- id: FOLDER.DEFAULT,
1546
- section: true,
1547
- children: folders.map((folder) => new TreeNodeFolderWrapper(folder)),
1548
- name: t2("explorer.filters.mine", {
1549
- ns: appCode
1550
- })
1551
- });
1552
- } else {
1553
- setTreeData(wrapTreeNode(treeData, folders, searchParams.filters.folder || FOLDER.DEFAULT));
1554
- }
1555
- }
1556
- setSearchParams({
1557
- ...searchParams,
1558
- pagination: (_c = data == null ? void 0 : data.pages[(data == null ? void 0 : data.pages.length) - 1]) == null ? void 0 : _c.pagination
1118
+ }, ds = /* @__PURE__ */ D(async () => await import("./EmptyScreenApp.js")), us = /* @__PURE__ */ D(async () => await import("./EmptyScreenSearch.js")), hs = /* @__PURE__ */ D(async () => await import("./EmptyScreenError.js")), fs = /* @__PURE__ */ D(async () => await import("./EmptyScreenNoContentInFolder.js")), ps = /* @__PURE__ */ D(async () => await import("./EmptyScreenTrash.js")), ms = /* @__PURE__ */ D(async () => await import("./FoldersList.js")), ys = /* @__PURE__ */ D(async () => await import("./ResourcesList.js")), gs = () => {
1119
+ const e = Je(), t = ne(), s = Ye(), r = b(), n = W(), a = z(), o = q(), {
1120
+ appCode: l
1121
+ } = B(), {
1122
+ t: h
1123
+ } = _(), {
1124
+ setSearchParams: d,
1125
+ setSearchConfig: u,
1126
+ setTreeData: f
1127
+ } = S(), {
1128
+ data: i,
1129
+ isError: p,
1130
+ error: m,
1131
+ isLoading: g,
1132
+ isFetching: y,
1133
+ fetchNextPage: I
1134
+ } = ls(), T = (i == null ? void 0 : i.pages[0].folders.length) === 0, E = (i == null ? void 0 : i.pages[0].resources.length) === 0, L = T && E;
1135
+ return U(() => {
1136
+ var M, R, P;
1137
+ if (i) {
1138
+ const Q = [...((M = i == null ? void 0 : i.pages[0]) == null ? void 0 : M.folders) ?? []];
1139
+ (R = i == null ? void 0 : i.pages[0]) != null && R.searchConfig && u(i.pages[0].searchConfig), r.search || ((n == null ? void 0 : n.id) === "default" ? f({
1140
+ id: F.DEFAULT,
1141
+ section: !0,
1142
+ children: Q.map((K) => new X(K)),
1143
+ name: h("explorer.filters.mine", {
1144
+ ns: l
1145
+ })
1146
+ }) : f(ue(a, Q, r.filters.folder || F.DEFAULT))), d({
1147
+ ...r,
1148
+ pagination: (P = i == null ? void 0 : i.pages[(i == null ? void 0 : i.pages.length) - 1]) == null ? void 0 : P.pagination
1559
1149
  });
1560
1150
  }
1561
- }, [data]);
1562
- useEffect(() => {
1563
- if (error && typeof error === "string") {
1564
- toast.error(t2(error));
1565
- }
1566
- }, [error]);
1567
- if (isLoading)
1568
- return /* @__PURE__ */ jsx(LoadingScreen, {});
1569
- if (isError) {
1570
- return /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(LoadingScreen, {}), children: /* @__PURE__ */ jsx(EmptyScreenError, {}) });
1571
- }
1572
- if (searchParams.search && hasNoData) {
1573
- return /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(LoadingScreen, {}), children: /* @__PURE__ */ jsx(EmptyScreenSearch, {}) });
1574
- }
1575
- if (isRoot && hasNoData) {
1576
- return /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(LoadingScreen, {}), children: /* @__PURE__ */ jsx(EmptyScreenApp, {}) });
1577
- }
1578
- if (hasSelectedNodes && hasNoData && !isTrashFolder) {
1579
- return /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(LoadingScreen, {}), children: /* @__PURE__ */ jsx(EmptyScreenNoContentInFolder, {}) });
1580
- }
1581
- if (isTrashFolder && (data == null ? void 0 : data.pages[0].resources.length) === 0) {
1582
- return /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(LoadingScreen, {}), children: /* @__PURE__ */ jsx(EmptyScreenTrash, {}) });
1583
- }
1584
- return /* @__PURE__ */ jsxs(Suspense, { fallback: /* @__PURE__ */ jsx(LoadingScreen, {}), children: [
1585
- /* @__PURE__ */ jsx(FoldersList, { data, isFetching }),
1586
- /* @__PURE__ */ jsx(ResourcesList, { data, isFetching, fetchNextPage })
1151
+ }, [i]), U(() => {
1152
+ m && typeof m == "string" && o.error(h(m));
1153
+ }, [m]), g ? /* @__PURE__ */ c(A, {}) : p ? /* @__PURE__ */ c(v, { fallback: /* @__PURE__ */ c(A, {}), children: /* @__PURE__ */ c(hs, {}) }) : r.search && L ? /* @__PURE__ */ c(v, { fallback: /* @__PURE__ */ c(A, {}), children: /* @__PURE__ */ c(us, {}) }) : e && L ? /* @__PURE__ */ c(v, { fallback: /* @__PURE__ */ c(A, {}), children: /* @__PURE__ */ c(ds, {}) }) : s && L && !t ? /* @__PURE__ */ c(v, { fallback: /* @__PURE__ */ c(A, {}), children: /* @__PURE__ */ c(fs, {}) }) : t && (i == null ? void 0 : i.pages[0].resources.length) === 0 ? /* @__PURE__ */ c(v, { fallback: /* @__PURE__ */ c(A, {}), children: /* @__PURE__ */ c(ps, {}) }) : /* @__PURE__ */ C(v, { fallback: /* @__PURE__ */ c(A, {}), children: [
1154
+ /* @__PURE__ */ c(ms, { data: i, isFetching: y }),
1155
+ /* @__PURE__ */ c(ys, { data: i, isFetching: y, fetchNextPage: I })
1587
1156
  ] });
1588
- };
1589
- const useSelectedFilters = () => {
1590
- const {
1591
- appCode,
1592
- currentApp
1593
- } = useOdeClient();
1157
+ }, Is = () => {
1594
1158
  const {
1595
- t: t2
1596
- } = useTranslation();
1597
- const [selectedFilters, setSelectedFilters] = useState("");
1598
- const handleOnSelectFilter = (value) => {
1599
- if (value === "0") {
1600
- setSelectedFilters("");
1159
+ appCode: e,
1160
+ currentApp: t
1161
+ } = B(), {
1162
+ t: s
1163
+ } = _(), [r, n] = ce(""), a = (u) => {
1164
+ if (u === "0") {
1165
+ n("");
1601
1166
  return;
1602
1167
  }
1603
- setSelectedFilters(value);
1604
- };
1605
- const currentFolder = useCurrentFolder();
1606
- const searchParams = useSearchParams();
1607
- const {
1608
- setSearchParams
1609
- } = useStoreActions();
1610
- useEffect(() => {
1611
- const isOwnerSelected = () => {
1612
- return selectedFilters.includes("1") ? true : void 0;
1613
- };
1614
- const isSharedSelected = () => {
1615
- return selectedFilters.includes("2") ? true : void 0;
1616
- };
1617
- const isPublicSelected = () => {
1618
- return selectedFilters.includes("7") ? true : void 0;
1619
- };
1620
- setSearchParams({
1621
- ...searchParams,
1168
+ n(u);
1169
+ }, o = W(), l = b(), {
1170
+ setSearchParams: h
1171
+ } = S();
1172
+ U(() => {
1173
+ const u = () => r.includes("1") ? !0 : void 0, f = () => r.includes("2") ? !0 : void 0, i = () => r.includes("7") ? !0 : void 0;
1174
+ h({
1175
+ ...l,
1622
1176
  filters: {
1623
- owner: isOwnerSelected(),
1624
- public: isPublicSelected(),
1625
- shared: isSharedSelected(),
1626
- folder: currentFolder ? currentFolder.id : "default"
1177
+ owner: u(),
1178
+ public: i(),
1179
+ shared: f(),
1180
+ folder: o ? o.id : "default"
1627
1181
  }
1628
1182
  });
1629
- }, [currentFolder, setSearchParams, selectedFilters]);
1630
- const options = [{
1631
- label: t2("explorer.filter.all", {
1632
- ns: appCode
1183
+ }, [o, h, r]);
1184
+ const d = [{
1185
+ label: s("explorer.filter.all", {
1186
+ ns: e
1633
1187
  }),
1634
1188
  value: "0"
1635
1189
  }, {
1636
- label: t2("explorer.filter.owner", {
1637
- ns: appCode
1190
+ label: s("explorer.filter.owner", {
1191
+ ns: e
1638
1192
  }),
1639
1193
  value: "1"
1640
1194
  }, {
1641
- label: t2("explorer.filter.shared", {
1642
- ns: appCode
1195
+ label: s("explorer.filter.shared", {
1196
+ ns: e
1643
1197
  }),
1644
1198
  value: "2"
1645
- }, ...(currentApp == null ? void 0 : currentApp.displayName) == APP.EXERCIZER ? [{
1199
+ }, ...(t == null ? void 0 : t.displayName) == se.EXERCIZER ? [{
1646
1200
  label: "Exercices interactifs",
1647
1201
  value: "3"
1648
- }] : [], ...(currentApp == null ? void 0 : currentApp.displayName) == APP.EXERCIZER ? [{
1202
+ }] : [], ...(t == null ? void 0 : t.displayName) == se.EXERCIZER ? [{
1649
1203
  label: "Exercices à rendre",
1650
1204
  value: "4"
1651
- }] : [], ...(currentApp == null ? void 0 : currentApp.displayName) == "pages" ? [{
1205
+ }] : [], ...(t == null ? void 0 : t.displayName) == "pages" ? [{
1652
1206
  label: "Projets publics",
1653
1207
  value: "5"
1654
- }] : [], ...(currentApp == null ? void 0 : currentApp.displayName) == "pages" ? [{
1208
+ }] : [], ...(t == null ? void 0 : t.displayName) == "pages" ? [{
1655
1209
  label: "Projets internes",
1656
1210
  value: "6"
1657
- }] : [], ...(currentApp == null ? void 0 : currentApp.displayName) == APP.BLOG ? [{
1658
- label: t2("explorer.filter.public", {
1659
- ns: appCode
1211
+ }] : [], ...(t == null ? void 0 : t.displayName) == se.BLOG ? [{
1212
+ label: s("explorer.filter.public", {
1213
+ ns: e
1660
1214
  }),
1661
1215
  value: "7"
1662
1216
  }] : []];
1663
1217
  return {
1664
- selectedFilters,
1665
- options,
1666
- handleOnSelectFilter
1218
+ selectedFilters: r,
1219
+ options: d,
1220
+ handleOnSelectFilter: a
1667
1221
  };
1668
- };
1669
- const SearchForm = () => {
1670
- const {
1671
- appCode
1672
- } = useOdeClient();
1222
+ }, ws = () => {
1673
1223
  const {
1674
- t: t2
1675
- } = useTranslation();
1676
- const {
1677
- selectedFilters,
1678
- options,
1679
- handleOnSelectFilter
1680
- } = useSelectedFilters();
1681
- const {
1682
- formRef,
1683
- inputSearch,
1684
- handleInputSearchChange,
1685
- handleKeyPress,
1686
- handleSearchSubmit
1687
- } = useSearchForm();
1688
- const count = selectedFilters.length > 0 ? selectedFilters.length : void 0;
1689
- return /* @__PURE__ */ jsxs("form", { noValidate: true, className: "bg-light p-16 ps-24 ms-n16 ms-lg-n24 me-n16 position-relative z-3 d-flex gap-8", ref: formRef, children: [
1690
- /* @__PURE__ */ jsxs(FormControl, { id: "search", className: "input-group", children: [
1691
- /* @__PURE__ */ jsx(Input, { type: "search", placeholder: t2("explorer.label.search", {
1692
- ns: appCode
1693
- }), size: "lg", noValidationIcon: true, value: inputSearch, onChange: handleInputSearchChange, onKeyDown: handleKeyPress }),
1694
- /* @__PURE__ */ jsx(SearchButton, { type: "submit", "aria-label": t2("explorer.label.search", {
1695
- ns: appCode
1696
- }), onClick: handleSearchSubmit })
1224
+ appCode: e
1225
+ } = B(), {
1226
+ t
1227
+ } = _(), {
1228
+ selectedFilters: s,
1229
+ options: r,
1230
+ handleOnSelectFilter: n
1231
+ } = Is(), {
1232
+ formRef: a,
1233
+ inputSearch: o,
1234
+ handleInputSearchChange: l,
1235
+ handleKeyPress: h,
1236
+ handleSearchSubmit: d
1237
+ } = he(), u = s.length > 0 ? s.length : void 0;
1238
+ return /* @__PURE__ */ C("form", { noValidate: !0, className: "bg-light p-16 ps-24 ms-n16 ms-lg-n24 me-n16 position-relative z-3 d-flex gap-8", ref: a, children: [
1239
+ /* @__PURE__ */ C(Se, { id: "search", className: "input-group", children: [
1240
+ /* @__PURE__ */ c(xe, { type: "search", placeholder: t("explorer.label.search", {
1241
+ ns: e
1242
+ }), size: "lg", noValidationIcon: !0, value: o, onChange: l, onKeyDown: h }),
1243
+ /* @__PURE__ */ c(De, { type: "submit", "aria-label": t("explorer.label.search", {
1244
+ ns: e
1245
+ }), onClick: d })
1697
1246
  ] }),
1698
- /* @__PURE__ */ jsxs(Dropdown, { placement: "bottom-end", children: [
1699
- /* @__PURE__ */ jsx(Dropdown.Trigger, { label: t2("explorer.filters"), icon: /* @__PURE__ */ jsx(Filter, { width: 20 }), variant: "ghost", badgeContent: count }),
1700
- /* @__PURE__ */ jsx(Dropdown.Menu, { children: options.map((option) => {
1701
- if (option.value === "0") {
1702
- return /* @__PURE__ */ jsxs(Fragment, { children: [
1703
- /* @__PURE__ */ jsx(Dropdown.RadioItem, { value: option.value, model: selectedFilters, onChange: () => handleOnSelectFilter(option.value), children: option.label }),
1704
- /* @__PURE__ */ jsx(Dropdown.Separator, {})
1705
- ] }, "0");
1706
- }
1707
- return /* @__PURE__ */ jsx(Dropdown.RadioItem, { value: option.value, model: selectedFilters, onChange: () => handleOnSelectFilter(option.value), children: option.label }, option.value);
1708
- }) })
1247
+ /* @__PURE__ */ C(j, { placement: "bottom-end", children: [
1248
+ /* @__PURE__ */ c(j.Trigger, { label: t("explorer.filters"), icon: /* @__PURE__ */ c(Ae, { width: 20 }), variant: "ghost", badgeContent: u }),
1249
+ /* @__PURE__ */ c(j.Menu, { children: r.map((f) => f.value === "0" ? /* @__PURE__ */ C(ye, { children: [
1250
+ /* @__PURE__ */ c(j.RadioItem, { value: f.value, model: s, onChange: () => n(f.value), children: f.label }),
1251
+ /* @__PURE__ */ c(j.Separator, {})
1252
+ ] }, "0") : /* @__PURE__ */ c(j.RadioItem, { value: f.value, model: s, onChange: () => n(f.value), children: f.label }, f.value)) })
1709
1253
  ] })
1710
1254
  ] });
1711
- };
1712
- const TrashButton = ({
1713
- id,
1714
- selected,
1715
- onSelect
1255
+ }, Ss = ({
1256
+ id: e,
1257
+ selected: t,
1258
+ onSelect: s
1716
1259
  }) => {
1717
1260
  const {
1718
- t: t2
1719
- } = useTranslation();
1720
- return /* @__PURE__ */ jsx("div", { className: "treeview", children: /* @__PURE__ */ jsx("ul", { role: "tree", className: "m-0 p-0", children: /* @__PURE__ */ jsx("li", { id, role: "treeitem", "aria-selected": selected, children: /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx("div", { className: "action-container", children: /* @__PURE__ */ jsx("div", { onClick: onSelect, role: "button", tabIndex: 0, children: /* @__PURE__ */ jsxs("div", { className: "d-flex align-items-center gap-8 py-8 ps-24", children: [
1721
- /* @__PURE__ */ jsx(Delete, { width: "20", height: "20" }),
1722
- /* @__PURE__ */ jsx("span", { children: t2("explorer.tree.trash") })
1261
+ t: r
1262
+ } = _();
1263
+ return /* @__PURE__ */ c("div", { className: "treeview", children: /* @__PURE__ */ c("ul", { role: "tree", className: "m-0 p-0", children: /* @__PURE__ */ c("li", { id: e, role: "treeitem", "aria-selected": t, children: /* @__PURE__ */ c("div", { children: /* @__PURE__ */ c("div", { className: "action-container", children: /* @__PURE__ */ c("div", { onClick: s, role: "button", tabIndex: 0, children: /* @__PURE__ */ C("div", { className: "d-flex align-items-center gap-8 py-8 ps-24", children: [
1264
+ /* @__PURE__ */ c(Ee, { width: "20", height: "20" }),
1265
+ /* @__PURE__ */ c("span", { children: r("explorer.tree.trash") })
1723
1266
  ] }) }) }) }) }) }) });
1724
- };
1725
- const CreateFolderModal = /* @__PURE__ */ lazy(async () => await import("./FolderModal.js"));
1726
- const TreeViewContainer = () => {
1727
- const queryclient = useQueryClient();
1728
- const [isModalOpen, toggle] = useToggle();
1729
- const treeData = useTreeData();
1730
- const isTrashFolder = useIsTrash();
1731
- const selectedNodesIds = useSelectedNodesIds();
1732
- const {
1733
- appCode
1734
- } = useOdeClient();
1735
- const {
1736
- t: t2
1737
- } = useTranslation(["common", appCode]);
1738
- const {
1739
- goToTrash,
1740
- selectTreeItem,
1741
- unfoldTreeItem,
1742
- foldTreeItem,
1743
- clearSelectedItems,
1744
- clearSelectedIds
1745
- } = useStoreActions();
1746
- const handleTreeItemUnfold = async (folderId) => {
1747
- await unfoldTreeItem(folderId, queryclient);
1748
- };
1749
- const handleOnFolderCreate = () => {
1750
- clearSelectedItems();
1751
- clearSelectedIds();
1752
- toggle();
1267
+ }, xs = /* @__PURE__ */ D(async () => await import("./FolderModal.js")), Ds = () => {
1268
+ const e = O(), [t, s] = be(), r = z(), n = ne(), a = re(), {
1269
+ appCode: o
1270
+ } = B(), {
1271
+ t: l
1272
+ } = _(["common", o]), {
1273
+ goToTrash: h,
1274
+ selectTreeItem: d,
1275
+ unfoldTreeItem: u,
1276
+ foldTreeItem: f,
1277
+ clearSelectedItems: i,
1278
+ clearSelectedIds: p
1279
+ } = S(), m = async (y) => {
1280
+ await u(y, e);
1281
+ }, g = () => {
1282
+ i(), p(), s();
1753
1283
  };
1754
- return /* @__PURE__ */ jsxs(Fragment$1, { children: [
1755
- /* @__PURE__ */ jsx(TreeView, { data: treeData, selectedNodesIds, onTreeItemSelect: selectTreeItem, onTreeItemFold: foldTreeItem, onTreeItemUnfold: handleTreeItemUnfold }),
1756
- /* @__PURE__ */ jsx(TrashButton, { id: FOLDER.BIN, selected: isTrashFolder, onSelect: goToTrash }),
1757
- /* @__PURE__ */ jsx("div", { className: "d-grid my-16", children: /* @__PURE__ */ jsx(Button, { disabled: isTrashFolder, type: "button", color: "primary", variant: "outline", leftIcon: /* @__PURE__ */ jsx(Plus, {}), onClick: handleOnFolderCreate, children: t2("explorer.folder.new") }) }),
1758
- /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(LoadingScreen, {}), children: isModalOpen && /* @__PURE__ */ jsx(CreateFolderModal, { edit: false, isOpen: isModalOpen, onSuccess: toggle, onCancel: toggle }) })
1284
+ return /* @__PURE__ */ C(ae, { children: [
1285
+ /* @__PURE__ */ c(Te, { data: r, selectedNodesIds: a, onTreeItemSelect: d, onTreeItemFold: f, onTreeItemUnfold: m }),
1286
+ /* @__PURE__ */ c(Ss, { id: F.BIN, selected: n, onSelect: h }),
1287
+ /* @__PURE__ */ c("div", { className: "d-grid my-16", children: /* @__PURE__ */ c(Fe, { disabled: n, type: "button", color: "primary", variant: "outline", leftIcon: /* @__PURE__ */ c(Qe, {}), onClick: g, children: l("explorer.folder.new") }) }),
1288
+ /* @__PURE__ */ c(v, { fallback: /* @__PURE__ */ c(A, {}), children: t && /* @__PURE__ */ c(xs, { edit: !1, isOpen: t, onSuccess: s, onCancel: s }) })
1759
1289
  ] });
1760
- };
1761
- const style = "";
1762
- const OnboardingModal = /* @__PURE__ */ lazy(async () => {
1763
- const module = await import("@edifice-ui/react");
1764
- return {
1765
- default: module.OnboardingModal
1766
- };
1767
- });
1768
- const AppAction = /* @__PURE__ */ lazy(async () => await import("./AppAction.js"));
1769
- const Library = /* @__PURE__ */ lazy(async () => await import("./Library.js"));
1770
- const ActionBar = /* @__PURE__ */ lazy(async () => await import("./ActionBarContainer.js"));
1771
- const ActionResourceDisableModal = /* @__PURE__ */ lazy(async () => await import("./DisableModal.js"));
1772
- const TrashedResourceModal = /* @__PURE__ */ lazy(async () => await import("./TrashModal.js"));
1773
- const Explorer = ({
1774
- config
1290
+ }, bs = /* @__PURE__ */ D(async () => await import("./AppAction.js")), Ts = /* @__PURE__ */ D(async () => await import("./Library.js")), Fs = /* @__PURE__ */ D(async () => await import("./ActionBarContainer.js")), Cs = /* @__PURE__ */ D(async () => await import("./DisableModal.js")), Ns = /* @__PURE__ */ D(async () => await import("./TrashModal.js")), Rs = /* @__PURE__ */ D(async () => await import("./OnboardingModal.js")), Gs = ({
1291
+ config: e
1775
1292
  }) => {
1776
- const searchParams = useSearchParams();
1777
- const {
1778
- setConfig,
1779
- setSearchParams
1780
- } = useStoreActions();
1781
- useEffect(() => {
1782
- setConfig(config || {});
1783
- setSearchParams({
1784
- ...searchParams,
1785
- app: config.app,
1786
- types: config.types
1293
+ const t = b(), {
1294
+ setConfig: s,
1295
+ setSearchParams: r
1296
+ } = S();
1297
+ U(() => {
1298
+ s(e || {}), r({
1299
+ ...t,
1300
+ application: e.app,
1301
+ types: e.types
1787
1302
  });
1788
- }, [config]);
1789
- const {
1790
- currentApp
1791
- } = useOdeClient();
1792
- const {
1793
- data: actions
1794
- } = useActions();
1795
- const {
1796
- isTrashedModalOpen,
1797
- onTrashedCancel
1798
- } = useTrashModal();
1303
+ }, [e]);
1799
1304
  const {
1800
- isActionDisableModalOpen,
1801
- onActionDisableCancel
1802
- } = useDisableModal();
1803
- useXitiTrackPageLoad();
1804
- const canPublish = isActionAvailable("publish", actions);
1805
- const canCreate = isActionAvailable("create", actions);
1806
- return config && /* @__PURE__ */ jsxs(Fragment$1, { children: [
1807
- /* @__PURE__ */ jsx(AppHeader, { render: () => canCreate ? /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(LoadingScreen, {}), children: /* @__PURE__ */ jsx(AppAction, {}) }) : null, children: /* @__PURE__ */ jsx(Breadcrumb, { app: currentApp }) }),
1808
- /* @__PURE__ */ jsxs(Grid, { className: "flex-grow-1", children: [
1809
- /* @__PURE__ */ jsx(Grid.Col, { sm: "3", lg: "2", xl: "3", className: "border-end pt-16 pe-16 d-none d-lg-block", as: "aside", children: /* @__PURE__ */ jsxs(Suspense, { fallback: /* @__PURE__ */ jsx(LoadingScreen, {}), children: [
1810
- /* @__PURE__ */ jsx(TreeViewContainer, {}),
1811
- canPublish && /* @__PURE__ */ jsx(Library, {})
1305
+ currentApp: n
1306
+ } = B(), {
1307
+ data: a
1308
+ } = is(), {
1309
+ isTrashedModalOpen: o,
1310
+ onTrashedCancel: l
1311
+ } = rs(), {
1312
+ isActionDisableModalOpen: h,
1313
+ onActionDisableCancel: d
1314
+ } = ts();
1315
+ Ce();
1316
+ const u = oe("publish", a), f = oe("create", a);
1317
+ return e && /* @__PURE__ */ C(ae, { children: [
1318
+ /* @__PURE__ */ c(Ne, { render: () => f ? /* @__PURE__ */ c(v, { fallback: /* @__PURE__ */ c(A, {}), children: /* @__PURE__ */ c(bs, {}) }) : null, children: /* @__PURE__ */ c(Re, { app: n }) }),
1319
+ /* @__PURE__ */ C(ee, { className: "flex-grow-1", children: [
1320
+ /* @__PURE__ */ c(ee.Col, { sm: "3", lg: "2", xl: "3", className: "border-end pt-16 pe-16 d-none d-lg-block", as: "aside", children: /* @__PURE__ */ C(v, { fallback: /* @__PURE__ */ c(A, {}), children: [
1321
+ /* @__PURE__ */ c(Ds, {}),
1322
+ u && /* @__PURE__ */ c(Ts, {})
1812
1323
  ] }) }),
1813
- /* @__PURE__ */ jsxs(Grid.Col, { sm: "4", md: "8", lg: "6", xl: "9", children: [
1814
- /* @__PURE__ */ jsx(SearchForm, {}),
1815
- /* @__PURE__ */ jsx(ExplorerBreadcrumb, {}),
1816
- /* @__PURE__ */ jsx(List, {})
1324
+ /* @__PURE__ */ C(ee.Col, { sm: "4", md: "8", lg: "6", xl: "9", children: [
1325
+ /* @__PURE__ */ c(ws, {}),
1326
+ /* @__PURE__ */ c(ss, {}),
1327
+ /* @__PURE__ */ c(gs, {})
1817
1328
  ] }),
1818
- /* @__PURE__ */ jsxs(Suspense, { fallback: /* @__PURE__ */ jsx(LoadingScreen, {}), children: [
1819
- /* @__PURE__ */ jsx(ActionBar, {}),
1820
- /* @__PURE__ */ jsx(OnboardingModal, { id: "showOnboardingTrash", items: [{
1329
+ /* @__PURE__ */ C(v, { fallback: /* @__PURE__ */ c(A, {}), children: [
1330
+ /* @__PURE__ */ c(Fs, {}),
1331
+ /* @__PURE__ */ c(Rs, { id: "showOnboardingTrash", items: [{
1821
1332
  src: "onboarding/illu-trash-menu.svg",
1822
1333
  alt: "explorer.modal.onboarding.trash.screen1.alt",
1823
1334
  text: "explorer.modal.onboarding.trash.screen1.title"
@@ -1835,33 +1346,33 @@ const Explorer = ({
1835
1346
  nextText: "explorer.modal.onboarding.trash.next",
1836
1347
  closeText: "explorer.modal.onboarding.trash.close"
1837
1348
  } }),
1838
- isTrashedModalOpen && /* @__PURE__ */ jsx(TrashedResourceModal, { isOpen: isTrashedModalOpen, onCancel: onTrashedCancel }),
1839
- isActionDisableModalOpen && /* @__PURE__ */ jsx(ActionResourceDisableModal, { isOpen: isActionDisableModalOpen, onCancel: onActionDisableCancel })
1349
+ o && /* @__PURE__ */ c(Ns, { isOpen: o, onCancel: l }),
1350
+ h && /* @__PURE__ */ c(Cs, { isOpen: h, onCancel: d })
1840
1351
  ] })
1841
1352
  ] })
1842
1353
  ] });
1843
1354
  };
1844
1355
  export {
1845
- Explorer as E,
1846
- useActions as a,
1847
- useCurrentFolder as b,
1848
- useCreateResource as c,
1849
- useIsTrash as d,
1850
- useStoreContext as e,
1851
- useResourceIds as f,
1852
- useSelectedResources as g,
1853
- useSelectedFolders as h,
1854
- useFolderIds as i,
1855
- useRestore as j,
1856
- useResourceIsTrash as k,
1857
- useShareResource as l,
1858
- useUpdateResource as m,
1859
- useSearchParams as n,
1860
- useCreateFolder as o,
1861
- useUpdatefolder as p,
1862
- useDelete as q,
1863
- useTrash as r,
1864
- useMoveItem as s,
1865
- useTreeData as t,
1866
- useStoreActions as u
1356
+ Gs as E,
1357
+ is as a,
1358
+ W as b,
1359
+ Xs as c,
1360
+ ne as d,
1361
+ w as e,
1362
+ Z as f,
1363
+ Ms as g,
1364
+ Bs as h,
1365
+ G as i,
1366
+ $s as j,
1367
+ Ge as k,
1368
+ Hs as l,
1369
+ Ws as m,
1370
+ b as n,
1371
+ zs as o,
1372
+ Vs as p,
1373
+ js as q,
1374
+ Ks as r,
1375
+ _s as s,
1376
+ z as t,
1377
+ S as u
1867
1378
  };