@strapi/upload 5.9.0 → 5.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (214) hide show
  1. package/dist/admin/chunks/App-CNK_Kv03.mjs +972 -0
  2. package/dist/admin/chunks/App-CNK_Kv03.mjs.map +1 -0
  3. package/dist/admin/chunks/App-DnxXkEtZ.js +993 -0
  4. package/dist/admin/chunks/App-DnxXkEtZ.js.map +1 -0
  5. package/dist/admin/chunks/ConfigureTheView-BFXInHXz.js +297 -0
  6. package/dist/admin/chunks/ConfigureTheView-BFXInHXz.js.map +1 -0
  7. package/dist/admin/chunks/ConfigureTheView-DTYyp_1T.mjs +276 -0
  8. package/dist/admin/chunks/ConfigureTheView-DTYyp_1T.mjs.map +1 -0
  9. package/dist/admin/chunks/SettingsPage-B_vUS1w1.js +354 -0
  10. package/dist/admin/chunks/SettingsPage-B_vUS1w1.js.map +1 -0
  11. package/dist/admin/chunks/SettingsPage-DA56QDU9.mjs +332 -0
  12. package/dist/admin/chunks/SettingsPage-DA56QDU9.mjs.map +1 -0
  13. package/dist/admin/chunks/ca-Bi4qskZD.mjs +120 -0
  14. package/dist/{_chunks/es-CuWi2pOn.mjs.map → admin/chunks/ca-Bi4qskZD.mjs.map} +1 -1
  15. package/dist/admin/chunks/ca-pCOhKIn8.js +122 -0
  16. package/dist/{_chunks/es-DWFtw_h4.js.map → admin/chunks/ca-pCOhKIn8.js.map} +1 -1
  17. package/dist/admin/chunks/de-BlbX8Dl_.mjs +106 -0
  18. package/dist/{_chunks/pl-Cj8jChOO.mjs.map → admin/chunks/de-BlbX8Dl_.mjs.map} +1 -1
  19. package/dist/admin/chunks/de-DUjKLmOP.js +108 -0
  20. package/dist/{_chunks/de-uGb_Pkq7.js.map → admin/chunks/de-DUjKLmOP.js.map} +1 -1
  21. package/dist/admin/chunks/dk-C2ydE6A7.mjs +102 -0
  22. package/dist/{_chunks/ko-vJl9kPpn.mjs.map → admin/chunks/dk-C2ydE6A7.mjs.map} +1 -1
  23. package/dist/admin/chunks/dk-DSsspA0e.js +104 -0
  24. package/dist/{_chunks/dk-Cd8oFO-O.js.map → admin/chunks/dk-DSsspA0e.js.map} +1 -1
  25. package/dist/admin/chunks/en-Bw_Cb2IV.mjs +143 -0
  26. package/dist/{_chunks/en-oDx2Gnre.mjs.map → admin/chunks/en-Bw_Cb2IV.mjs.map} +1 -1
  27. package/dist/admin/chunks/en-UjETkewz.js +145 -0
  28. package/dist/{_chunks/en-BcOqhiNe.js.map → admin/chunks/en-UjETkewz.js.map} +1 -1
  29. package/dist/admin/chunks/es-CiEgbw0k.mjs +119 -0
  30. package/dist/{_chunks/ca-B2_I-q1t.mjs.map → admin/chunks/es-CiEgbw0k.mjs.map} +1 -1
  31. package/dist/admin/chunks/es-qAL8YcZz.js +121 -0
  32. package/dist/{_chunks/ca-BUpuZx8N.js.map → admin/chunks/es-qAL8YcZz.js.map} +1 -1
  33. package/dist/admin/chunks/fr-BL0Uyj6j.js +145 -0
  34. package/dist/admin/chunks/fr-BL0Uyj6j.js.map +1 -0
  35. package/dist/admin/chunks/fr-CwRt2FJu.mjs +143 -0
  36. package/dist/admin/chunks/fr-CwRt2FJu.mjs.map +1 -0
  37. package/dist/admin/chunks/he-BAmhVpfZ.js +77 -0
  38. package/dist/admin/chunks/he-BAmhVpfZ.js.map +1 -0
  39. package/dist/admin/chunks/he-DdpYNQdt.mjs +75 -0
  40. package/dist/admin/chunks/he-DdpYNQdt.mjs.map +1 -0
  41. package/dist/admin/chunks/index-CDwNb6XT.mjs +7350 -0
  42. package/dist/admin/chunks/index-CDwNb6XT.mjs.map +1 -0
  43. package/dist/admin/chunks/index-Db2l2DRT.js +7407 -0
  44. package/dist/admin/chunks/index-Db2l2DRT.js.map +1 -0
  45. package/dist/admin/chunks/it-Be4kgSNB.mjs +75 -0
  46. package/dist/admin/chunks/it-Be4kgSNB.mjs.map +1 -0
  47. package/dist/admin/chunks/it-_NQZYepl.js +77 -0
  48. package/dist/admin/chunks/it-_NQZYepl.js.map +1 -0
  49. package/dist/admin/chunks/ja-B75QiyXf.js +77 -0
  50. package/dist/admin/chunks/ja-B75QiyXf.js.map +1 -0
  51. package/dist/admin/chunks/ja-U1NhT0bU.mjs +75 -0
  52. package/dist/admin/chunks/ja-U1NhT0bU.mjs.map +1 -0
  53. package/dist/admin/chunks/ko-BOvUcJqv.js +107 -0
  54. package/dist/{_chunks/pl-esgZ7ltN.js.map → admin/chunks/ko-BOvUcJqv.js.map} +1 -1
  55. package/dist/admin/chunks/ko-BciqXefq.mjs +105 -0
  56. package/dist/{_chunks/de-A7mEKx6c.mjs.map → admin/chunks/ko-BciqXefq.mjs.map} +1 -1
  57. package/dist/admin/chunks/ms-B7Zl6Lm9.js +69 -0
  58. package/dist/admin/chunks/ms-B7Zl6Lm9.js.map +1 -0
  59. package/dist/admin/chunks/ms-D-8McNeg.mjs +67 -0
  60. package/dist/admin/chunks/ms-D-8McNeg.mjs.map +1 -0
  61. package/dist/admin/chunks/pl-DdUYocl5.mjs +104 -0
  62. package/dist/{_chunks/dk-BPfkJb9q.mjs.map → admin/chunks/pl-DdUYocl5.mjs.map} +1 -1
  63. package/dist/admin/chunks/pl-cYDYHOEf.js +106 -0
  64. package/dist/{_chunks/ko-Pzj-818C.js.map → admin/chunks/pl-cYDYHOEf.js.map} +1 -1
  65. package/dist/admin/chunks/pt-BR-D1u_azCM.js +77 -0
  66. package/dist/admin/chunks/pt-BR-D1u_azCM.js.map +1 -0
  67. package/dist/admin/chunks/pt-BR-Demjoq41.mjs +75 -0
  68. package/dist/admin/chunks/pt-BR-Demjoq41.mjs.map +1 -0
  69. package/dist/admin/chunks/pt-D8is2LpS.mjs +75 -0
  70. package/dist/admin/chunks/pt-D8is2LpS.mjs.map +1 -0
  71. package/dist/admin/chunks/pt-L2DZeTPL.js +77 -0
  72. package/dist/admin/chunks/pt-L2DZeTPL.js.map +1 -0
  73. package/dist/admin/chunks/ru-CGgHRTey.mjs +75 -0
  74. package/dist/admin/chunks/ru-CGgHRTey.mjs.map +1 -0
  75. package/dist/admin/chunks/ru-Uxbk_WWv.js +77 -0
  76. package/dist/admin/chunks/ru-Uxbk_WWv.js.map +1 -0
  77. package/dist/admin/chunks/sk-BlLP5HAX.js +123 -0
  78. package/dist/admin/chunks/sk-BlLP5HAX.js.map +1 -0
  79. package/dist/admin/chunks/sk-xtSwaPXq.mjs +121 -0
  80. package/dist/admin/chunks/sk-xtSwaPXq.mjs.map +1 -0
  81. package/dist/admin/chunks/th-BOpLVfmg.mjs +75 -0
  82. package/dist/admin/chunks/th-BOpLVfmg.mjs.map +1 -0
  83. package/dist/admin/chunks/th-DNxPLegS.js +77 -0
  84. package/dist/admin/chunks/th-DNxPLegS.js.map +1 -0
  85. package/dist/admin/chunks/tr-BmAPh-f1.mjs +121 -0
  86. package/dist/admin/chunks/tr-BmAPh-f1.mjs.map +1 -0
  87. package/dist/admin/chunks/tr-DWgXG75k.js +123 -0
  88. package/dist/admin/chunks/tr-DWgXG75k.js.map +1 -0
  89. package/dist/admin/chunks/uk-CMvuEdG-.mjs +72 -0
  90. package/dist/admin/chunks/uk-CMvuEdG-.mjs.map +1 -0
  91. package/dist/admin/chunks/uk-D1_rBLhp.js +74 -0
  92. package/dist/admin/chunks/uk-D1_rBLhp.js.map +1 -0
  93. package/dist/admin/chunks/zh-BIl0qgBy.mjs +128 -0
  94. package/dist/admin/chunks/zh-BIl0qgBy.mjs.map +1 -0
  95. package/dist/admin/chunks/zh-Hans-B1GabBRx.mjs +151 -0
  96. package/dist/{_chunks/zh-Hans-Cpmhg8uH.mjs.map → admin/chunks/zh-Hans-B1GabBRx.mjs.map} +1 -1
  97. package/dist/admin/chunks/zh-Hans-B8qxMQIl.js +153 -0
  98. package/dist/{_chunks/zh-Hans-k_xAc6nm.js.map → admin/chunks/zh-Hans-B8qxMQIl.js.map} +1 -1
  99. package/dist/admin/chunks/zh-MemsyMV6.js +130 -0
  100. package/dist/admin/chunks/zh-MemsyMV6.js.map +1 -0
  101. package/dist/admin/index.js +29 -6
  102. package/dist/admin/index.js.map +1 -1
  103. package/dist/admin/index.mjs +24 -8
  104. package/dist/admin/index.mjs.map +1 -1
  105. package/dist/admin/src/hooks/useMediaLibraryPermissions.d.ts +2 -5
  106. package/dist/admin/src/hooks/useRemoveAsset.d.ts +6 -64
  107. package/dist/server/chunks/graphql-BTbIs_EU.js +116 -0
  108. package/dist/server/chunks/graphql-BTbIs_EU.js.map +1 -0
  109. package/dist/server/chunks/graphql-CCPJbCFt.mjs +114 -0
  110. package/dist/server/chunks/graphql-CCPJbCFt.mjs.map +1 -0
  111. package/dist/server/chunks/index-BU4qzb-i.mjs +3161 -0
  112. package/dist/server/chunks/index-BU4qzb-i.mjs.map +1 -0
  113. package/dist/server/chunks/index-BkUy20d9.js +3164 -0
  114. package/dist/server/chunks/index-BkUy20d9.js.map +1 -0
  115. package/dist/server/index.js +19 -2
  116. package/dist/server/index.js.map +1 -1
  117. package/dist/server/index.mjs +14 -4
  118. package/dist/server/index.mjs.map +1 -1
  119. package/dist/server/src/controllers/validation/admin/folder-file.d.ts.map +1 -1
  120. package/dist/shared/contracts/configuration.d.ts +1 -1
  121. package/dist/shared/contracts/settings.d.ts +1 -1
  122. package/package.json +13 -9
  123. package/dist/_chunks/App-BLY6RlTm.mjs +0 -844
  124. package/dist/_chunks/App-BLY6RlTm.mjs.map +0 -1
  125. package/dist/_chunks/App-DNScJAhi.js +0 -864
  126. package/dist/_chunks/App-DNScJAhi.js.map +0 -1
  127. package/dist/_chunks/ConfigureTheView-CJbBTq0t.js +0 -252
  128. package/dist/_chunks/ConfigureTheView-CJbBTq0t.js.map +0 -1
  129. package/dist/_chunks/ConfigureTheView-Dk28Sh2k.mjs +0 -230
  130. package/dist/_chunks/ConfigureTheView-Dk28Sh2k.mjs.map +0 -1
  131. package/dist/_chunks/SettingsPage-CrvbJCia.js +0 -285
  132. package/dist/_chunks/SettingsPage-CrvbJCia.js.map +0 -1
  133. package/dist/_chunks/SettingsPage-DjNyJDaf.mjs +0 -264
  134. package/dist/_chunks/SettingsPage-DjNyJDaf.mjs.map +0 -1
  135. package/dist/_chunks/ca-B2_I-q1t.mjs +0 -121
  136. package/dist/_chunks/ca-BUpuZx8N.js +0 -121
  137. package/dist/_chunks/de-A7mEKx6c.mjs +0 -107
  138. package/dist/_chunks/de-uGb_Pkq7.js +0 -107
  139. package/dist/_chunks/dk-BPfkJb9q.mjs +0 -103
  140. package/dist/_chunks/dk-Cd8oFO-O.js +0 -103
  141. package/dist/_chunks/en-BcOqhiNe.js +0 -144
  142. package/dist/_chunks/en-oDx2Gnre.mjs +0 -144
  143. package/dist/_chunks/es-CuWi2pOn.mjs +0 -120
  144. package/dist/_chunks/es-DWFtw_h4.js +0 -120
  145. package/dist/_chunks/fr-BN6ndmWf.mjs +0 -144
  146. package/dist/_chunks/fr-BN6ndmWf.mjs.map +0 -1
  147. package/dist/_chunks/fr-D2bop66d.js +0 -144
  148. package/dist/_chunks/fr-D2bop66d.js.map +0 -1
  149. package/dist/_chunks/graphql-DMPTPlvx.mjs +0 -71
  150. package/dist/_chunks/graphql-DMPTPlvx.mjs.map +0 -1
  151. package/dist/_chunks/graphql-QF5Y36Qj.js +0 -71
  152. package/dist/_chunks/graphql-QF5Y36Qj.js.map +0 -1
  153. package/dist/_chunks/he-BpxHjaZg.js +0 -76
  154. package/dist/_chunks/he-BpxHjaZg.js.map +0 -1
  155. package/dist/_chunks/he-C9ZOXBB-.mjs +0 -76
  156. package/dist/_chunks/he-C9ZOXBB-.mjs.map +0 -1
  157. package/dist/_chunks/index-BfAVIhAL.js +0 -6144
  158. package/dist/_chunks/index-BfAVIhAL.js.map +0 -1
  159. package/dist/_chunks/index-D57iKFts.js +0 -2721
  160. package/dist/_chunks/index-D57iKFts.js.map +0 -1
  161. package/dist/_chunks/index-DH9hUSe3.mjs +0 -6119
  162. package/dist/_chunks/index-DH9hUSe3.mjs.map +0 -1
  163. package/dist/_chunks/index-sOlgMDiZ.mjs +0 -2711
  164. package/dist/_chunks/index-sOlgMDiZ.mjs.map +0 -1
  165. package/dist/_chunks/it-B7rmoZNx.mjs +0 -76
  166. package/dist/_chunks/it-B7rmoZNx.mjs.map +0 -1
  167. package/dist/_chunks/it-BKCWXl8t.js +0 -76
  168. package/dist/_chunks/it-BKCWXl8t.js.map +0 -1
  169. package/dist/_chunks/ja-DlaJTi_3.mjs +0 -76
  170. package/dist/_chunks/ja-DlaJTi_3.mjs.map +0 -1
  171. package/dist/_chunks/ja-ajHzIJz6.js +0 -76
  172. package/dist/_chunks/ja-ajHzIJz6.js.map +0 -1
  173. package/dist/_chunks/ko-Pzj-818C.js +0 -106
  174. package/dist/_chunks/ko-vJl9kPpn.mjs +0 -106
  175. package/dist/_chunks/ms-CqwG8v8l.mjs +0 -68
  176. package/dist/_chunks/ms-CqwG8v8l.mjs.map +0 -1
  177. package/dist/_chunks/ms-h3gjldBy.js +0 -68
  178. package/dist/_chunks/ms-h3gjldBy.js.map +0 -1
  179. package/dist/_chunks/pl-Cj8jChOO.mjs +0 -105
  180. package/dist/_chunks/pl-esgZ7ltN.js +0 -105
  181. package/dist/_chunks/pt-BR-B4LJHJIp.mjs +0 -76
  182. package/dist/_chunks/pt-BR-B4LJHJIp.mjs.map +0 -1
  183. package/dist/_chunks/pt-BR-Cazr7Z5I.js +0 -76
  184. package/dist/_chunks/pt-BR-Cazr7Z5I.js.map +0 -1
  185. package/dist/_chunks/pt-CNOOM_7x.mjs +0 -76
  186. package/dist/_chunks/pt-CNOOM_7x.mjs.map +0 -1
  187. package/dist/_chunks/pt-cbUnkHM5.js +0 -76
  188. package/dist/_chunks/pt-cbUnkHM5.js.map +0 -1
  189. package/dist/_chunks/ru-DqglvSUC.mjs +0 -76
  190. package/dist/_chunks/ru-DqglvSUC.mjs.map +0 -1
  191. package/dist/_chunks/ru-H6MzFUxp.js +0 -76
  192. package/dist/_chunks/ru-H6MzFUxp.js.map +0 -1
  193. package/dist/_chunks/sk-CZxC4dFY.js +0 -122
  194. package/dist/_chunks/sk-CZxC4dFY.js.map +0 -1
  195. package/dist/_chunks/sk-Dgpb3lnz.mjs +0 -122
  196. package/dist/_chunks/sk-Dgpb3lnz.mjs.map +0 -1
  197. package/dist/_chunks/th-C6unJZ8j.js +0 -76
  198. package/dist/_chunks/th-C6unJZ8j.js.map +0 -1
  199. package/dist/_chunks/th-DRfzuiFf.mjs +0 -76
  200. package/dist/_chunks/th-DRfzuiFf.mjs.map +0 -1
  201. package/dist/_chunks/tr--GzWXE_A.mjs +0 -122
  202. package/dist/_chunks/tr--GzWXE_A.mjs.map +0 -1
  203. package/dist/_chunks/tr-CY6AwX50.js +0 -122
  204. package/dist/_chunks/tr-CY6AwX50.js.map +0 -1
  205. package/dist/_chunks/uk-BniyNsD4.js +0 -73
  206. package/dist/_chunks/uk-BniyNsD4.js.map +0 -1
  207. package/dist/_chunks/uk-DVMT2Piq.mjs +0 -73
  208. package/dist/_chunks/uk-DVMT2Piq.mjs.map +0 -1
  209. package/dist/_chunks/zh-CsZw0IpM.js +0 -129
  210. package/dist/_chunks/zh-CsZw0IpM.js.map +0 -1
  211. package/dist/_chunks/zh-HOnih0is.mjs +0 -129
  212. package/dist/_chunks/zh-HOnih0is.mjs.map +0 -1
  213. package/dist/_chunks/zh-Hans-Cpmhg8uH.mjs +0 -152
  214. package/dist/_chunks/zh-Hans-k_xAc6nm.js +0 -152
@@ -0,0 +1,972 @@
1
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
+ import * as React from 'react';
3
+ import { ConfirmDialog, useNotification, useFetchClient, useTracking, useQueryParams, Layouts, Page, SearchInput, Pagination } from '@strapi/admin/strapi-admin';
4
+ import { useIntl } from 'react-intl';
5
+ import { useLocation, NavLink, useNavigate, Link as Link$1, Routes, Route } from 'react-router-dom';
6
+ import { g as getTrad, a as getFolderURL, u as useFolderCard, b as useBulkRemove, p as pluginId, c as useFolderStructure, S as SelectTree, n as normalizeAPIError, E as EmptyAssets, F as FilterPopover, d as displayedFilters, e as FilterList, B as Breadcrumbs, f as useMediaLibraryPermissions, h as usePersistentState, i as useAssets, j as useFolders, k as containsAssetFilter, l as useFolder, m as useSelectionState, o as SortPicker, v as viewOptions, T as TableList, q as FolderGridList, r as FolderCard, s as FolderCardBody, t as FolderCardBodyAction, A as AssetGridList, U as UploadAssetDialog, w as EditFolderDialog, x as EditAssetDialog, y as localStorageKeys, z as useConfig } from './index-CDwNb6XT.mjs';
7
+ import 'byte-size';
8
+ import 'date-fns';
9
+ import { stringify } from 'qs';
10
+ import { Box, Checkbox, Dialog, Button, Modal, Flex, Loader, Grid, Field, Typography, Popover, Link, IconButton, VisuallyHidden, Divider } from '@strapi/design-system';
11
+ import { Trash, Folder, Plus, Filter, ArrowLeft, Cog, List, GridFour, Pencil } from '@strapi/icons';
12
+ import { styled } from 'styled-components';
13
+ import { Formik, Form } from 'formik';
14
+ import isEmpty from 'lodash/isEmpty';
15
+ import { useQueryClient, useMutation } from 'react-query';
16
+ import { EmptyPermissions } from '@strapi/icons/symbols';
17
+ import 'yup';
18
+ import 'lodash/isEqual';
19
+ import 'react-select';
20
+ import 'cropperjs';
21
+ import '@mux/mux-player-react';
22
+ import 'cropperjs/dist/cropper.css';
23
+ import 'react-dnd';
24
+ import 'date-fns/parseISO';
25
+
26
+ const getBreadcrumbDataML = (folder, { pathname, query })=>{
27
+ const data = [
28
+ {
29
+ id: null,
30
+ label: {
31
+ id: getTrad('plugin.name'),
32
+ defaultMessage: 'Media Library'
33
+ },
34
+ href: folder ? getFolderURL(pathname, query || {}) : undefined
35
+ }
36
+ ];
37
+ if (folder?.parent && typeof folder?.parent !== 'number' && folder?.parent?.parent) {
38
+ data.push([]);
39
+ }
40
+ if (folder?.parent && typeof folder.parent !== 'number') {
41
+ data.push({
42
+ id: folder.parent.id,
43
+ label: folder.parent.name,
44
+ href: getFolderURL(pathname, query || {}, {
45
+ folder: folder.parent.id?.toString(),
46
+ folderPath: folder.parent.path
47
+ })
48
+ });
49
+ }
50
+ if (folder) {
51
+ data.push({
52
+ id: folder.id,
53
+ label: folder.name
54
+ });
55
+ }
56
+ return data;
57
+ };
58
+
59
+ const FolderCardCheckbox = (props)=>{
60
+ const { id } = useFolderCard();
61
+ return /*#__PURE__*/ jsx(Box, {
62
+ position: "relative",
63
+ zIndex: 2,
64
+ children: /*#__PURE__*/ jsx(Checkbox, {
65
+ "aria-labelledby": `${id}-title`,
66
+ ...props
67
+ })
68
+ });
69
+ };
70
+
71
+ const BulkDeleteButton = ({ selected, onSuccess })=>{
72
+ const { formatMessage } = useIntl();
73
+ const { remove } = useBulkRemove();
74
+ const handleConfirmRemove = async ()=>{
75
+ await remove(selected);
76
+ onSuccess();
77
+ };
78
+ return /*#__PURE__*/ jsxs(Dialog.Root, {
79
+ children: [
80
+ /*#__PURE__*/ jsx(Dialog.Trigger, {
81
+ children: /*#__PURE__*/ jsx(Button, {
82
+ variant: "danger-light",
83
+ size: "S",
84
+ startIcon: /*#__PURE__*/ jsx(Trash, {}),
85
+ children: formatMessage({
86
+ id: 'global.delete',
87
+ defaultMessage: 'Delete'
88
+ })
89
+ })
90
+ }),
91
+ /*#__PURE__*/ jsx(ConfirmDialog, {
92
+ onConfirm: handleConfirmRemove
93
+ })
94
+ ]
95
+ });
96
+ };
97
+
98
+ const useBulkMove = ()=>{
99
+ const { formatMessage } = useIntl();
100
+ const { toggleNotification } = useNotification();
101
+ const queryClient = useQueryClient();
102
+ const { post } = useFetchClient();
103
+ const bulkMoveQuery = ({ destinationFolderId, filesAndFolders })=>{
104
+ const payload = filesAndFolders.reduce((acc, selected)=>{
105
+ const { id, type } = selected;
106
+ const key = type === 'asset' ? 'fileIds' : 'folderIds';
107
+ if (!acc[key]) {
108
+ acc[key] = [];
109
+ }
110
+ acc[key].push(id);
111
+ return acc;
112
+ }, {});
113
+ return post('/upload/actions/bulk-move', {
114
+ ...payload,
115
+ destinationFolderId
116
+ });
117
+ };
118
+ const mutation = useMutation(bulkMoveQuery, {
119
+ onSuccess (res) {
120
+ const { data: { data } } = res;
121
+ if (data?.files?.length > 0) {
122
+ queryClient.refetchQueries([
123
+ pluginId,
124
+ 'assets'
125
+ ], {
126
+ active: true
127
+ });
128
+ queryClient.refetchQueries([
129
+ pluginId,
130
+ 'asset-count'
131
+ ], {
132
+ active: true
133
+ });
134
+ }
135
+ // folders need to be re-fetched in any case, because assets might have been
136
+ // moved into a sub-folder and therefore the count needs to be updated
137
+ queryClient.refetchQueries([
138
+ pluginId,
139
+ 'folders'
140
+ ], {
141
+ active: true
142
+ });
143
+ toggleNotification({
144
+ type: 'success',
145
+ message: formatMessage({
146
+ id: getTrad('modal.move.success-label'),
147
+ defaultMessage: 'Elements have been moved successfully.'
148
+ })
149
+ });
150
+ }
151
+ });
152
+ const move = (destinationFolderId, filesAndFolders)=>mutation.mutateAsync({
153
+ destinationFolderId,
154
+ filesAndFolders
155
+ });
156
+ return {
157
+ ...mutation,
158
+ move
159
+ };
160
+ };
161
+
162
+ const BulkMoveDialog = ({ onClose, selected = [], currentFolder })=>{
163
+ const { formatMessage } = useIntl();
164
+ const { data: folderStructure, isLoading } = useFolderStructure();
165
+ const { move } = useBulkMove();
166
+ if (!folderStructure) {
167
+ return null;
168
+ }
169
+ const handleSubmit = async (values, { setErrors })=>{
170
+ try {
171
+ if (typeof values.destination !== 'string') {
172
+ const destinationValue = values.destination.value;
173
+ await move(destinationValue, selected);
174
+ onClose();
175
+ }
176
+ } catch (error) {
177
+ const normalizedError = normalizeAPIError(error);
178
+ if (normalizedError && 'errors' in normalizedError) {
179
+ const formikErrors = normalizedError.errors?.reduce((acc, error)=>{
180
+ acc[error.values?.path?.length || 'destination'] = error.defaultMessage;
181
+ return acc;
182
+ }, {});
183
+ if (!isEmpty(formikErrors)) {
184
+ setErrors(formikErrors);
185
+ }
186
+ }
187
+ }
188
+ };
189
+ if (isLoading) {
190
+ return /*#__PURE__*/ jsx(Modal.Content, {
191
+ children: /*#__PURE__*/ jsx(Modal.Body, {
192
+ children: /*#__PURE__*/ jsx(Flex, {
193
+ justifyContent: "center",
194
+ paddingTop: 4,
195
+ paddingBottom: 4,
196
+ children: /*#__PURE__*/ jsx(Loader, {
197
+ children: formatMessage({
198
+ id: getTrad('content.isLoading'),
199
+ defaultMessage: 'Content is loading.'
200
+ })
201
+ })
202
+ })
203
+ })
204
+ });
205
+ }
206
+ const initialFormData = {
207
+ destination: {
208
+ value: currentFolder?.id || '',
209
+ label: currentFolder?.name || folderStructure[0].label
210
+ }
211
+ };
212
+ return /*#__PURE__*/ jsx(Modal.Content, {
213
+ children: /*#__PURE__*/ jsx(Formik, {
214
+ validateOnChange: false,
215
+ onSubmit: handleSubmit,
216
+ initialValues: initialFormData,
217
+ children: ({ values, errors, setFieldValue })=>/*#__PURE__*/ jsxs(Form, {
218
+ noValidate: true,
219
+ children: [
220
+ /*#__PURE__*/ jsx(Modal.Header, {
221
+ children: /*#__PURE__*/ jsx(Modal.Title, {
222
+ children: formatMessage({
223
+ id: getTrad('modal.folder.move.title'),
224
+ defaultMessage: 'Move elements to'
225
+ })
226
+ })
227
+ }),
228
+ /*#__PURE__*/ jsx(Modal.Body, {
229
+ children: /*#__PURE__*/ jsx(Grid.Root, {
230
+ gap: 4,
231
+ children: /*#__PURE__*/ jsx(Grid.Item, {
232
+ xs: 12,
233
+ col: 12,
234
+ direction: "column",
235
+ alignItems: "stretch",
236
+ children: /*#__PURE__*/ jsxs(Field.Root, {
237
+ id: "folder-destination",
238
+ children: [
239
+ /*#__PURE__*/ jsx(Field.Label, {
240
+ children: formatMessage({
241
+ id: getTrad('form.input.label.folder-location'),
242
+ defaultMessage: 'Location'
243
+ })
244
+ }),
245
+ /*#__PURE__*/ jsx(SelectTree, {
246
+ options: folderStructure,
247
+ onChange: (value)=>{
248
+ setFieldValue('destination', value);
249
+ },
250
+ defaultValue: typeof values.destination !== 'string' ? values.destination : undefined,
251
+ name: "destination",
252
+ menuPortalTarget: document.querySelector('body'),
253
+ inputId: "folder-destination",
254
+ error: errors?.destination,
255
+ ariaErrorMessage: "destination-error"
256
+ }),
257
+ errors.destination && /*#__PURE__*/ jsx(Typography, {
258
+ variant: "pi",
259
+ tag: "p",
260
+ textColor: "danger600",
261
+ children: errors.destination
262
+ })
263
+ ]
264
+ })
265
+ })
266
+ })
267
+ }),
268
+ /*#__PURE__*/ jsxs(Modal.Footer, {
269
+ children: [
270
+ /*#__PURE__*/ jsx(Modal.Close, {
271
+ children: /*#__PURE__*/ jsx(Button, {
272
+ variant: "tertiary",
273
+ name: "cancel",
274
+ children: formatMessage({
275
+ id: 'cancel',
276
+ defaultMessage: 'Cancel'
277
+ })
278
+ })
279
+ }),
280
+ /*#__PURE__*/ jsx(Button, {
281
+ type: "submit",
282
+ loading: isLoading,
283
+ children: formatMessage({
284
+ id: 'modal.folder.move.submit',
285
+ defaultMessage: 'Move'
286
+ })
287
+ })
288
+ ]
289
+ })
290
+ ]
291
+ })
292
+ })
293
+ });
294
+ };
295
+
296
+ const BulkMoveButton = ({ selected = [], onSuccess, currentFolder })=>{
297
+ const { formatMessage } = useIntl();
298
+ const [showConfirmDialog, setShowConfirmDialog] = React.useState(false);
299
+ const handleConfirmMove = ()=>{
300
+ setShowConfirmDialog(false);
301
+ onSuccess();
302
+ };
303
+ return /*#__PURE__*/ jsxs(Modal.Root, {
304
+ open: showConfirmDialog,
305
+ onOpenChange: setShowConfirmDialog,
306
+ children: [
307
+ /*#__PURE__*/ jsx(Modal.Trigger, {
308
+ children: /*#__PURE__*/ jsx(Button, {
309
+ variant: "secondary",
310
+ size: "S",
311
+ startIcon: /*#__PURE__*/ jsx(Folder, {}),
312
+ children: formatMessage({
313
+ id: 'global.move',
314
+ defaultMessage: 'Move'
315
+ })
316
+ })
317
+ }),
318
+ /*#__PURE__*/ jsx(BulkMoveDialog, {
319
+ currentFolder: currentFolder,
320
+ onClose: handleConfirmMove,
321
+ selected: selected
322
+ })
323
+ ]
324
+ });
325
+ };
326
+
327
+ const BulkActions = ({ selected = [], onSuccess, currentFolder })=>{
328
+ const { formatMessage } = useIntl();
329
+ const numberAssets = selected?.reduce(function(_this, val) {
330
+ return val?.type === 'folder' && 'files' in val && val?.files && 'count' in val.files ? _this + val?.files?.count : _this + 1;
331
+ }, 0);
332
+ return /*#__PURE__*/ jsxs(Flex, {
333
+ gap: 2,
334
+ paddingBottom: 5,
335
+ children: [
336
+ /*#__PURE__*/ jsx(Typography, {
337
+ variant: "epsilon",
338
+ textColor: "neutral600",
339
+ children: formatMessage({
340
+ id: getTrad('list.assets.selected'),
341
+ defaultMessage: '{numberFolders, plural, one {1 folder} other {# folders}} - {numberAssets, plural, one {1 asset} other {# assets}} selected'
342
+ }, {
343
+ numberFolders: selected?.filter(({ type })=>type === 'folder').length,
344
+ numberAssets
345
+ })
346
+ }),
347
+ /*#__PURE__*/ jsx(BulkDeleteButton, {
348
+ selected: selected,
349
+ onSuccess: onSuccess
350
+ }),
351
+ /*#__PURE__*/ jsx(BulkMoveButton, {
352
+ currentFolder: currentFolder,
353
+ selected: selected,
354
+ onSuccess: onSuccess
355
+ })
356
+ ]
357
+ });
358
+ };
359
+
360
+ const getContentIntlMessage = ({ isFiltering, canCreate, canRead })=>{
361
+ if (isFiltering) {
362
+ return {
363
+ id: 'list.assets-empty.title-withSearch',
364
+ defaultMessage: 'There are no elements with the applied filters'
365
+ };
366
+ }
367
+ if (canRead) {
368
+ if (canCreate) {
369
+ return {
370
+ id: 'list.assets.empty-upload',
371
+ defaultMessage: 'Upload your first assets...'
372
+ };
373
+ }
374
+ return {
375
+ id: 'list.assets.empty',
376
+ defaultMessage: 'Media Library is empty'
377
+ };
378
+ }
379
+ return {
380
+ id: 'header.actions.no-permissions',
381
+ defaultMessage: 'No permissions to view'
382
+ };
383
+ };
384
+ const EmptyOrNoPermissions = ({ canCreate, isFiltering, canRead, onActionClick })=>{
385
+ const { formatMessage } = useIntl();
386
+ const content = getContentIntlMessage({
387
+ isFiltering,
388
+ canCreate,
389
+ canRead
390
+ });
391
+ return /*#__PURE__*/ jsx(EmptyAssets, {
392
+ icon: !canRead ? EmptyPermissions : undefined,
393
+ action: canCreate && !isFiltering && /*#__PURE__*/ jsx(Button, {
394
+ variant: "secondary",
395
+ startIcon: /*#__PURE__*/ jsx(Plus, {}),
396
+ onClick: onActionClick,
397
+ children: formatMessage({
398
+ id: getTrad('header.actions.add-assets'),
399
+ defaultMessage: 'Add new assets'
400
+ })
401
+ }),
402
+ content: formatMessage({
403
+ ...content,
404
+ id: getTrad(content.id)
405
+ })
406
+ });
407
+ };
408
+
409
+ const Filters = ()=>{
410
+ const [open, setOpen] = React.useState(false);
411
+ const { formatMessage } = useIntl();
412
+ const { trackUsage } = useTracking();
413
+ const [{ query }, setQuery] = useQueryParams();
414
+ const filters = query?.filters?.$and || [];
415
+ const handleRemoveFilter = (nextFilters)=>{
416
+ setQuery({
417
+ filters: {
418
+ $and: nextFilters
419
+ },
420
+ page: 1
421
+ });
422
+ };
423
+ const handleSubmit = (filters)=>{
424
+ trackUsage('didFilterMediaLibraryElements', {
425
+ location: 'content-manager',
426
+ filter: Object.keys(filters[filters.length - 1])[0]
427
+ });
428
+ setQuery({
429
+ filters: {
430
+ $and: filters
431
+ },
432
+ page: 1
433
+ });
434
+ };
435
+ return /*#__PURE__*/ jsxs(Popover.Root, {
436
+ open: open,
437
+ onOpenChange: setOpen,
438
+ children: [
439
+ /*#__PURE__*/ jsx(Popover.Trigger, {
440
+ children: /*#__PURE__*/ jsx(Button, {
441
+ variant: "tertiary",
442
+ startIcon: /*#__PURE__*/ jsx(Filter, {}),
443
+ size: "S",
444
+ children: formatMessage({
445
+ id: 'app.utils.filters',
446
+ defaultMessage: 'Filters'
447
+ })
448
+ })
449
+ }),
450
+ /*#__PURE__*/ jsx(FilterPopover, {
451
+ displayedFilters: displayedFilters,
452
+ filters: filters,
453
+ onSubmit: handleSubmit,
454
+ onToggle: setOpen
455
+ }),
456
+ /*#__PURE__*/ jsx(FilterList, {
457
+ appliedFilters: filters,
458
+ filtersSchema: displayedFilters,
459
+ onRemoveFilter: handleRemoveFilter
460
+ })
461
+ ]
462
+ });
463
+ };
464
+
465
+ const Header = ({ breadcrumbs = null, canCreate, folder = null, onToggleEditFolderDialog, onToggleUploadAssetDialog })=>{
466
+ const { formatMessage } = useIntl();
467
+ const { pathname } = useLocation();
468
+ const [{ query }] = useQueryParams();
469
+ const backQuery = {
470
+ ...query,
471
+ folder: folder?.parent && typeof folder.parent !== 'number' && folder.parent.id ? folder.parent.id : undefined,
472
+ folderPath: folder?.parent && typeof folder.parent !== 'number' && folder.parent.path ? folder.parent.path : undefined
473
+ };
474
+ return /*#__PURE__*/ jsx(Layouts.Header, {
475
+ title: formatMessage({
476
+ id: getTrad('plugin.name'),
477
+ defaultMessage: `Media Library`
478
+ }),
479
+ subtitle: breadcrumbs && typeof breadcrumbs !== 'boolean' && folder && /*#__PURE__*/ jsx(Breadcrumbs, {
480
+ label: formatMessage({
481
+ id: getTrad('header.breadcrumbs.nav.label'),
482
+ defaultMessage: 'Folders navigation'
483
+ }),
484
+ breadcrumbs: breadcrumbs,
485
+ currentFolderId: folder?.id
486
+ }),
487
+ navigationAction: folder && /*#__PURE__*/ jsx(Link, {
488
+ tag: NavLink,
489
+ startIcon: /*#__PURE__*/ jsx(ArrowLeft, {}),
490
+ to: `${pathname}?${stringify(backQuery, {
491
+ encode: false
492
+ })}`,
493
+ children: formatMessage({
494
+ id: getTrad('header.actions.folder-level-up'),
495
+ defaultMessage: 'Back'
496
+ })
497
+ }),
498
+ primaryAction: canCreate && /*#__PURE__*/ jsxs(Flex, {
499
+ gap: 2,
500
+ children: [
501
+ /*#__PURE__*/ jsx(Button, {
502
+ startIcon: /*#__PURE__*/ jsx(Plus, {}),
503
+ variant: "secondary",
504
+ onClick: onToggleEditFolderDialog,
505
+ children: formatMessage({
506
+ id: getTrad('header.actions.add-folder'),
507
+ defaultMessage: 'Add new folder'
508
+ })
509
+ }),
510
+ /*#__PURE__*/ jsx(Button, {
511
+ startIcon: /*#__PURE__*/ jsx(Plus, {}),
512
+ onClick: onToggleUploadAssetDialog,
513
+ children: formatMessage({
514
+ id: getTrad('header.actions.add-assets'),
515
+ defaultMessage: 'Add new assets'
516
+ })
517
+ })
518
+ ]
519
+ })
520
+ });
521
+ };
522
+
523
+ // TODO: find a better naming convention for the file that was an index file before
524
+ const BoxWithHeight = styled(Box)`
525
+ height: 3.2rem;
526
+ display: flex;
527
+ align-items: center;
528
+ `;
529
+ const TypographyMaxWidth = styled(Typography)`
530
+ max-width: 100%;
531
+ `;
532
+ const ActionContainer = styled(Box)`
533
+ svg {
534
+ path {
535
+ fill: ${({ theme })=>theme.colors.neutral500};
536
+ }
537
+ }
538
+ `;
539
+ const MediaLibrary = ()=>{
540
+ const navigate = useNavigate();
541
+ const { canRead, canCreate, canUpdate, canCopyLink, canDownload, canConfigureView, isLoading: permissionsLoading } = useMediaLibraryPermissions();
542
+ const currentFolderToEditRef = React.useRef();
543
+ const { formatMessage } = useIntl();
544
+ const { pathname } = useLocation();
545
+ const { trackUsage } = useTracking();
546
+ const [{ query }, setQuery] = useQueryParams();
547
+ const isFiltering = Boolean(query._q || query.filters);
548
+ const [view, setView] = usePersistentState(localStorageKeys.view, viewOptions.GRID);
549
+ const isGridView = view === viewOptions.GRID;
550
+ const { data: assetsData, isLoading: assetsLoading, error: assetsError } = useAssets({
551
+ skipWhen: !canRead,
552
+ query
553
+ });
554
+ const { data: foldersData, isLoading: foldersLoading, error: foldersError } = useFolders({
555
+ enabled: canRead && assetsData?.pagination?.page === 1 && !containsAssetFilter(query),
556
+ query
557
+ });
558
+ const { data: currentFolder, isLoading: isCurrentFolderLoading, error: currentFolderError } = useFolder(query?.folder, {
559
+ enabled: canRead && !!query?.folder
560
+ });
561
+ // Folder was not found: redirect to the media library root
562
+ if (currentFolderError?.name === 'NotFoundError') {
563
+ navigate(pathname);
564
+ }
565
+ const folders = foldersData?.map((folder)=>({
566
+ ...folder,
567
+ type: 'folder',
568
+ folderURL: getFolderURL(pathname, query, {
569
+ folder: folder.id.toString(),
570
+ folderPath: folder.path
571
+ }),
572
+ isSelectable: canUpdate
573
+ })) ?? [];
574
+ const folderCount = folders?.length || 0;
575
+ const assets = assetsData?.results?.map((asset)=>({
576
+ ...asset,
577
+ type: 'asset',
578
+ isSelectable: canUpdate
579
+ })) || [];
580
+ const assetCount = assets?.length ?? 0;
581
+ const totalAssetCount = assetsData?.pagination?.total;
582
+ const isLoading = isCurrentFolderLoading || foldersLoading || permissionsLoading || assetsLoading;
583
+ const [showUploadAssetDialog, setShowUploadAssetDialog] = React.useState(false);
584
+ const [showEditFolderDialog, setShowEditFolderDialog] = React.useState(false);
585
+ const [assetToEdit, setAssetToEdit] = React.useState(undefined);
586
+ const [folderToEdit, setFolderToEdit] = React.useState(undefined);
587
+ const [selected, { selectOne, selectAll }] = useSelectionState([
588
+ 'type',
589
+ 'id'
590
+ ], []);
591
+ const indeterminateBulkSelect = selected?.length > 0 && selected?.length !== assetCount + folderCount;
592
+ const toggleUploadAssetDialog = ()=>setShowUploadAssetDialog((prev)=>!prev);
593
+ const toggleEditFolderDialog = ({ created = false } = {})=>{
594
+ // folders are only displayed on the first page, therefore
595
+ // we have to navigate the user to that page, in case a folder
596
+ // was created successfully in order for them to see it
597
+ if (created && query?.page !== '1') {
598
+ setQuery({
599
+ ...query,
600
+ page: 1
601
+ });
602
+ }
603
+ setShowEditFolderDialog((prev)=>!prev);
604
+ };
605
+ const handleBulkSelect = (checked, elements)=>{
606
+ if (checked) {
607
+ trackUsage('didSelectAllMediaLibraryElements');
608
+ }
609
+ selectAll(elements);
610
+ };
611
+ const handleChangeSort = (value)=>{
612
+ trackUsage('didSortMediaLibraryElements', {
613
+ location: 'upload',
614
+ sort: value
615
+ });
616
+ setQuery({
617
+ sort: value
618
+ });
619
+ };
620
+ const handleEditFolder = (folder)=>{
621
+ setFolderToEdit(folder);
622
+ setShowEditFolderDialog(true);
623
+ };
624
+ const handleEditFolderClose = (payload)=>{
625
+ setFolderToEdit(null);
626
+ toggleEditFolderDialog(payload);
627
+ if (currentFolderToEditRef.current) {
628
+ currentFolderToEditRef.current.focus();
629
+ }
630
+ };
631
+ const handleAssetDeleted = (numberOfAssets)=>{
632
+ if (numberOfAssets === assetCount && assetsData?.pagination?.page === assetsData?.pagination?.pageCount && assetsData?.pagination?.page && assetsData.pagination.page > 1) {
633
+ setQuery({
634
+ ...query,
635
+ page: assetsData.pagination.page - 1
636
+ });
637
+ }
638
+ };
639
+ const handleBulkActionSuccess = ()=>{
640
+ selectAll();
641
+ handleAssetDeleted(selected.length);
642
+ };
643
+ if (isLoading) {
644
+ return /*#__PURE__*/ jsx(Page.Loading, {});
645
+ }
646
+ if (assetsError || foldersError) {
647
+ return /*#__PURE__*/ jsx(Page.Error, {});
648
+ }
649
+ return /*#__PURE__*/ jsxs(Layouts.Root, {
650
+ children: [
651
+ /*#__PURE__*/ jsxs(Page.Main, {
652
+ children: [
653
+ /*#__PURE__*/ jsx(Header, {
654
+ breadcrumbs: !isCurrentFolderLoading ? getBreadcrumbDataML(currentFolder, {
655
+ pathname,
656
+ query
657
+ }) : null,
658
+ canCreate: canCreate,
659
+ onToggleEditFolderDialog: toggleEditFolderDialog,
660
+ onToggleUploadAssetDialog: toggleUploadAssetDialog,
661
+ folder: currentFolder
662
+ }),
663
+ /*#__PURE__*/ jsx(Layouts.Action, {
664
+ startActions: /*#__PURE__*/ jsxs(Fragment, {
665
+ children: [
666
+ canUpdate && isGridView && (assetCount > 0 || folderCount > 0) && /*#__PURE__*/ jsx(BoxWithHeight, {
667
+ paddingLeft: 2,
668
+ paddingRight: 2,
669
+ background: "neutral0",
670
+ hasRadius: true,
671
+ borderColor: "neutral200",
672
+ children: /*#__PURE__*/ jsx(Checkbox, {
673
+ "aria-label": formatMessage({
674
+ id: getTrad('bulk.select.label'),
675
+ defaultMessage: 'Select all folders & assets'
676
+ }),
677
+ checked: indeterminateBulkSelect ? 'indeterminate' : (assetCount > 0 || folderCount > 0) && selected.length === assetCount + folderCount,
678
+ onCheckedChange: (e)=>handleBulkSelect(e, [
679
+ ...assets,
680
+ ...folders
681
+ ])
682
+ })
683
+ }),
684
+ canRead && isGridView && /*#__PURE__*/ jsx(SortPicker, {
685
+ value: query?.sort,
686
+ onChangeSort: handleChangeSort
687
+ }),
688
+ canRead && /*#__PURE__*/ jsx(Filters, {})
689
+ ]
690
+ }),
691
+ endActions: /*#__PURE__*/ jsxs(Fragment, {
692
+ children: [
693
+ canConfigureView ? /*#__PURE__*/ jsx(ActionContainer, {
694
+ paddingTop: 1,
695
+ paddingBottom: 1,
696
+ children: /*#__PURE__*/ jsx(IconButton, {
697
+ tag: Link$1,
698
+ to: {
699
+ pathname: `${pathname}/configuration`,
700
+ search: stringify(query, {
701
+ encode: false
702
+ })
703
+ },
704
+ label: formatMessage({
705
+ id: 'app.links.configure-view',
706
+ defaultMessage: 'Configure the view'
707
+ }),
708
+ children: /*#__PURE__*/ jsx(Cog, {})
709
+ })
710
+ }) : null,
711
+ /*#__PURE__*/ jsx(ActionContainer, {
712
+ paddingTop: 1,
713
+ paddingBottom: 1,
714
+ children: /*#__PURE__*/ jsx(IconButton, {
715
+ label: isGridView ? formatMessage({
716
+ id: getTrad('view-switch.list'),
717
+ defaultMessage: 'List View'
718
+ }) : formatMessage({
719
+ id: getTrad('view-switch.grid'),
720
+ defaultMessage: 'Grid View'
721
+ }),
722
+ onClick: ()=>setView(isGridView ? viewOptions.LIST : viewOptions.GRID),
723
+ children: isGridView ? /*#__PURE__*/ jsx(List, {}) : /*#__PURE__*/ jsx(GridFour, {})
724
+ })
725
+ }),
726
+ /*#__PURE__*/ jsx(SearchInput, {
727
+ label: formatMessage({
728
+ id: getTrad('search.label'),
729
+ defaultMessage: 'Search for an asset'
730
+ }),
731
+ trackedEvent: "didSearchMediaLibraryElements",
732
+ trackedEventDetails: {
733
+ location: 'upload'
734
+ }
735
+ })
736
+ ]
737
+ })
738
+ }),
739
+ /*#__PURE__*/ jsxs(Layouts.Content, {
740
+ children: [
741
+ selected.length > 0 && /*#__PURE__*/ jsx(BulkActions, {
742
+ currentFolder: currentFolder,
743
+ selected: selected,
744
+ onSuccess: handleBulkActionSuccess
745
+ }),
746
+ folderCount === 0 && assetCount === 0 && /*#__PURE__*/ jsx(EmptyOrNoPermissions, {
747
+ canCreate: canCreate,
748
+ canRead: canRead,
749
+ isFiltering: isFiltering,
750
+ onActionClick: toggleUploadAssetDialog
751
+ }),
752
+ canRead && !isGridView && (assetCount > 0 || folderCount > 0) && /*#__PURE__*/ jsx(TableList, {
753
+ assetCount: assetCount,
754
+ folderCount: folderCount,
755
+ indeterminate: indeterminateBulkSelect,
756
+ onChangeSort: handleChangeSort,
757
+ onChangeFolder: (folderID, folderPath)=>navigate(getFolderURL(pathname, query, {
758
+ folder: folderID.toString(),
759
+ folderPath
760
+ })),
761
+ onEditAsset: setAssetToEdit,
762
+ onEditFolder: handleEditFolder,
763
+ onSelectOne: selectOne,
764
+ onSelectAll: handleBulkSelect,
765
+ rows: [
766
+ ...folders,
767
+ ...assets
768
+ ],
769
+ selected: selected,
770
+ shouldDisableBulkSelect: !canUpdate,
771
+ sortQuery: query?.sort ?? ''
772
+ }),
773
+ canRead && isGridView && /*#__PURE__*/ jsxs(Fragment, {
774
+ children: [
775
+ folderCount > 0 && /*#__PURE__*/ jsx(FolderGridList, {
776
+ title: (isFiltering && assetCount > 0 || !isFiltering) && formatMessage({
777
+ id: getTrad('list.folders.title'),
778
+ defaultMessage: 'Folders ({count})'
779
+ }, {
780
+ count: folderCount
781
+ }) || '',
782
+ children: folders.map((folder)=>{
783
+ const selectedFolders = selected.filter(({ type })=>type === 'folder');
784
+ const isSelected = !!selectedFolders.find((currentFolder)=>currentFolder.id === folder.id);
785
+ const url = getFolderURL(pathname, query, {
786
+ folder: folder?.id.toString(),
787
+ folderPath: folder?.path
788
+ });
789
+ return /*#__PURE__*/ jsx(Grid.Item, {
790
+ col: 3,
791
+ direction: "column",
792
+ alignItems: "stretch",
793
+ children: /*#__PURE__*/ jsx(FolderCard, {
794
+ ref: folderToEdit && folder.id === folderToEdit.id ? currentFolderToEditRef : undefined,
795
+ ariaLabel: folder.name,
796
+ id: `folder-${folder.id}`,
797
+ to: url,
798
+ startAction: folder.isSelectable ? /*#__PURE__*/ jsx(FolderCardCheckbox, {
799
+ "data-testid": `folder-checkbox-${folder.id}`,
800
+ checked: isSelected,
801
+ onCheckedChange: ()=>selectOne(folder)
802
+ }) : null,
803
+ cardActions: /*#__PURE__*/ jsx(IconButton, {
804
+ label: formatMessage({
805
+ id: getTrad('list.folder.edit'),
806
+ defaultMessage: 'Edit folder'
807
+ }),
808
+ onClick: ()=>handleEditFolder(folder),
809
+ children: /*#__PURE__*/ jsx(Pencil, {})
810
+ }),
811
+ children: /*#__PURE__*/ jsx(FolderCardBody, {
812
+ children: /*#__PURE__*/ jsx(FolderCardBodyAction, {
813
+ to: url,
814
+ children: /*#__PURE__*/ jsxs(Flex, {
815
+ tag: "h2",
816
+ direction: "column",
817
+ alignItems: "start",
818
+ maxWidth: "100%",
819
+ children: [
820
+ /*#__PURE__*/ jsxs(TypographyMaxWidth, {
821
+ fontWeight: "semiBold",
822
+ textColor: "neutral800",
823
+ ellipsis: true,
824
+ children: [
825
+ folder.name,
826
+ /*#__PURE__*/ jsx(VisuallyHidden, {
827
+ children: ":"
828
+ })
829
+ ]
830
+ }),
831
+ /*#__PURE__*/ jsx(TypographyMaxWidth, {
832
+ tag: "span",
833
+ textColor: "neutral600",
834
+ variant: "pi",
835
+ ellipsis: true,
836
+ children: formatMessage({
837
+ id: getTrad('list.folder.subtitle'),
838
+ defaultMessage: '{folderCount, plural, =0 {# folder} one {# folder} other {# folders}}, {filesCount, plural, =0 {# asset} one {# asset} other {# assets}}'
839
+ }, {
840
+ folderCount: folder.children?.count,
841
+ filesCount: folder.files?.count
842
+ })
843
+ })
844
+ ]
845
+ })
846
+ })
847
+ })
848
+ })
849
+ }, `folder-${folder.id}`);
850
+ })
851
+ }),
852
+ assetCount > 0 && folderCount > 0 && /*#__PURE__*/ jsx(Box, {
853
+ paddingTop: 6,
854
+ paddingBottom: 4,
855
+ children: /*#__PURE__*/ jsx(Divider, {})
856
+ }),
857
+ assetCount > 0 && /*#__PURE__*/ jsx(AssetGridList, {
858
+ assets: assets,
859
+ onEditAsset: setAssetToEdit,
860
+ onSelectAsset: selectOne,
861
+ selectedAssets: selected.filter(({ type })=>type === 'asset'),
862
+ title: (!isFiltering || isFiltering && folderCount > 0) && assetsData?.pagination?.page === 1 && formatMessage({
863
+ id: getTrad('list.assets.title'),
864
+ defaultMessage: 'Assets ({count})'
865
+ }, {
866
+ count: totalAssetCount
867
+ }) || ''
868
+ })
869
+ ]
870
+ }),
871
+ /*#__PURE__*/ jsxs(Pagination.Root, {
872
+ ...assetsData?.pagination,
873
+ children: [
874
+ /*#__PURE__*/ jsx(Pagination.PageSize, {}),
875
+ /*#__PURE__*/ jsx(Pagination.Links, {})
876
+ ]
877
+ })
878
+ ]
879
+ })
880
+ ]
881
+ }),
882
+ showUploadAssetDialog && /*#__PURE__*/ jsx(UploadAssetDialog, {
883
+ open: showUploadAssetDialog,
884
+ onClose: toggleUploadAssetDialog,
885
+ trackedLocation: "upload",
886
+ folderId: query?.folder
887
+ }),
888
+ showEditFolderDialog && /*#__PURE__*/ jsx(EditFolderDialog, {
889
+ open: showEditFolderDialog,
890
+ onClose: ()=>handleEditFolderClose(),
891
+ folder: folderToEdit,
892
+ parentFolderId: query?.folder,
893
+ location: "upload"
894
+ }),
895
+ assetToEdit && /*#__PURE__*/ jsx(EditAssetDialog, {
896
+ onClose: (editedAsset)=>{
897
+ // The asset has been deleted
898
+ if (editedAsset === null) {
899
+ handleAssetDeleted(1);
900
+ }
901
+ setAssetToEdit(undefined);
902
+ },
903
+ open: !!assetToEdit,
904
+ asset: assetToEdit,
905
+ canUpdate: canUpdate,
906
+ canCopyLink: canCopyLink,
907
+ canDownload: canDownload,
908
+ trackedLocation: "upload"
909
+ })
910
+ ]
911
+ });
912
+ };
913
+
914
+ // TODO: find a better naming convention for the file that was an index file before
915
+ const ConfigureTheView = /*#__PURE__*/ React.lazy(async ()=>import('./ConfigureTheView-DTYyp_1T.mjs').then((mod)=>({
916
+ default: mod.ConfigureTheView
917
+ })));
918
+ const Upload = ()=>{
919
+ const { config: { isLoading, isError, data: config } } = useConfig();
920
+ const [{ rawQuery }, setQuery] = useQueryParams();
921
+ const { formatMessage } = useIntl();
922
+ const title = formatMessage({
923
+ id: getTrad('plugin.name'),
924
+ defaultMessage: 'Media Library'
925
+ });
926
+ React.useEffect(()=>{
927
+ if (isLoading || isError || rawQuery) {
928
+ return;
929
+ }
930
+ setQuery({
931
+ sort: config.sort,
932
+ page: 1,
933
+ pageSize: config.pageSize
934
+ });
935
+ }, [
936
+ isLoading,
937
+ isError,
938
+ config,
939
+ rawQuery,
940
+ setQuery
941
+ ]);
942
+ if (isLoading) {
943
+ return /*#__PURE__*/ jsx(Page.Loading, {});
944
+ }
945
+ return /*#__PURE__*/ jsxs(Page.Main, {
946
+ children: [
947
+ /*#__PURE__*/ jsx(Page.Title, {
948
+ children: title
949
+ }),
950
+ rawQuery ? /*#__PURE__*/ jsx(React.Suspense, {
951
+ fallback: /*#__PURE__*/ jsx(Page.Loading, {}),
952
+ children: /*#__PURE__*/ jsxs(Routes, {
953
+ children: [
954
+ /*#__PURE__*/ jsx(Route, {
955
+ index: true,
956
+ element: /*#__PURE__*/ jsx(MediaLibrary, {})
957
+ }),
958
+ /*#__PURE__*/ jsx(Route, {
959
+ path: "configuration",
960
+ element: /*#__PURE__*/ jsx(ConfigureTheView, {
961
+ config: config
962
+ })
963
+ })
964
+ ]
965
+ })
966
+ }) : null
967
+ ]
968
+ });
969
+ };
970
+
971
+ export { Upload };
972
+ //# sourceMappingURL=App-CNK_Kv03.mjs.map