@strapi/content-manager 0.0.0-experimental.cb311d9fcfbd8e441f790aea232f0a39bdd90e16 → 0.0.0-experimental.cb74730ce5154c26404d4dccca14976a22319002

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 (210) hide show
  1. package/dist/_chunks/CardDragPreview-C0QyJgRA.js.map +1 -1
  2. package/dist/_chunks/CardDragPreview-DOxamsuj.mjs.map +1 -1
  3. package/dist/_chunks/{ComponentConfigurationPage-D0dyDTwq.mjs → ComponentConfigurationPage-BgCLcjXO.mjs} +4 -4
  4. package/dist/_chunks/{ComponentConfigurationPage-D0dyDTwq.mjs.map → ComponentConfigurationPage-BgCLcjXO.mjs.map} +1 -1
  5. package/dist/_chunks/{ComponentConfigurationPage-DL1MHO8i.js → ComponentConfigurationPage-DywpTZeV.js} +5 -6
  6. package/dist/_chunks/{ComponentConfigurationPage-DL1MHO8i.js.map → ComponentConfigurationPage-DywpTZeV.js.map} +1 -1
  7. package/dist/_chunks/{ComponentIcon-BXdiCGQp.js → ComponentIcon-CRbtQEUV.js} +2 -3
  8. package/dist/_chunks/{ComponentIcon-BXdiCGQp.js.map → ComponentIcon-CRbtQEUV.js.map} +1 -1
  9. package/dist/_chunks/ComponentIcon-u4bIXTFY.mjs.map +1 -1
  10. package/dist/_chunks/{EditConfigurationPage-13b7S5Cq.mjs → EditConfigurationPage-BNjOAHNS.mjs} +4 -4
  11. package/dist/_chunks/{EditConfigurationPage-13b7S5Cq.mjs.map → EditConfigurationPage-BNjOAHNS.mjs.map} +1 -1
  12. package/dist/_chunks/{EditConfigurationPage-CMaOf-A-.js → EditConfigurationPage-CxRlP5if.js} +5 -6
  13. package/dist/_chunks/{EditConfigurationPage-CMaOf-A-.js.map → EditConfigurationPage-CxRlP5if.js.map} +1 -1
  14. package/dist/_chunks/{EditViewPage-BSVmMpRd.js → EditViewPage-BRewdTqE.js} +63 -13
  15. package/dist/_chunks/EditViewPage-BRewdTqE.js.map +1 -0
  16. package/dist/_chunks/{EditViewPage-C3tIZ8F5.mjs → EditViewPage-CD_hqc1J.mjs} +63 -12
  17. package/dist/_chunks/EditViewPage-CD_hqc1J.mjs.map +1 -0
  18. package/dist/_chunks/{Field-BvuT8cGL.mjs → Field-BPkQ-3Ku.mjs} +230 -158
  19. package/dist/_chunks/Field-BPkQ-3Ku.mjs.map +1 -0
  20. package/dist/_chunks/{Field-DUCVth4C.js → Field-DwvmENVf.js} +233 -162
  21. package/dist/_chunks/Field-DwvmENVf.js.map +1 -0
  22. package/dist/_chunks/FieldTypeIcon-CMlNO8PE.mjs.map +1 -1
  23. package/dist/_chunks/FieldTypeIcon-Dnwq_IRF.js.map +1 -1
  24. package/dist/_chunks/{Form-Cpl4W1ak.js → Form-C_Gwv8P_.js} +39 -21
  25. package/dist/_chunks/Form-C_Gwv8P_.js.map +1 -0
  26. package/dist/_chunks/{Form-BZmDNVr9.mjs → Form-Czi0cf_2.mjs} +37 -18
  27. package/dist/_chunks/Form-Czi0cf_2.mjs.map +1 -0
  28. package/dist/_chunks/{History-D4U2YISB.js → History-C1TKAig-.js} +42 -100
  29. package/dist/_chunks/History-C1TKAig-.js.map +1 -0
  30. package/dist/_chunks/{History-Cq_Hrzuu.mjs → History-CIQHyi4T.mjs} +43 -100
  31. package/dist/_chunks/History-CIQHyi4T.mjs.map +1 -0
  32. package/dist/_chunks/{ListConfigurationPage-Bny6CdWe.js → ListConfigurationPage-D-NGRLYu.js} +19 -9
  33. package/dist/_chunks/ListConfigurationPage-D-NGRLYu.js.map +1 -0
  34. package/dist/_chunks/{ListConfigurationPage-W-KQHmBv.mjs → ListConfigurationPage-DcZsfyEL.mjs} +19 -8
  35. package/dist/_chunks/ListConfigurationPage-DcZsfyEL.mjs.map +1 -0
  36. package/dist/_chunks/{ListViewPage-HBBnJa8K.mjs → ListViewPage-C10McTK1.mjs} +99 -72
  37. package/dist/_chunks/ListViewPage-C10McTK1.mjs.map +1 -0
  38. package/dist/_chunks/{ListViewPage-O8F1pBJo.js → ListViewPage-xv5IQoZp.js} +103 -77
  39. package/dist/_chunks/ListViewPage-xv5IQoZp.js.map +1 -0
  40. package/dist/_chunks/{NoContentTypePage-B-gIhHWM.mjs → NoContentTypePage-CPc0Cd3S.mjs} +2 -2
  41. package/dist/_chunks/{NoContentTypePage-B-gIhHWM.mjs.map → NoContentTypePage-CPc0Cd3S.mjs.map} +1 -1
  42. package/dist/_chunks/{NoContentTypePage-CQWChGPw.js → NoContentTypePage-Dzw5Yj5u.js} +2 -2
  43. package/dist/_chunks/{NoContentTypePage-CQWChGPw.js.map → NoContentTypePage-Dzw5Yj5u.js.map} +1 -1
  44. package/dist/_chunks/{NoPermissionsPage-CY46zxnM.js → NoPermissionsPage-DAe5CDCC.js} +2 -2
  45. package/dist/_chunks/{NoPermissionsPage-CY46zxnM.js.map → NoPermissionsPage-DAe5CDCC.js.map} +1 -1
  46. package/dist/_chunks/{NoPermissionsPage-XhOPl8wx.mjs → NoPermissionsPage-wfPBh2_0.mjs} +2 -2
  47. package/dist/_chunks/{NoPermissionsPage-XhOPl8wx.mjs.map → NoPermissionsPage-wfPBh2_0.mjs.map} +1 -1
  48. package/dist/_chunks/Preview-B7LyGT_b.js +290 -0
  49. package/dist/_chunks/Preview-B7LyGT_b.js.map +1 -0
  50. package/dist/_chunks/Preview-BVFFm7uB.mjs +272 -0
  51. package/dist/_chunks/Preview-BVFFm7uB.mjs.map +1 -0
  52. package/dist/_chunks/{Relations-C4gGfZRv.js → Relations-BmYR1AjY.js} +76 -43
  53. package/dist/_chunks/Relations-BmYR1AjY.js.map +1 -0
  54. package/dist/_chunks/{Relations-vFZ6Wasg.mjs → Relations-JPhWxk-s.mjs} +76 -42
  55. package/dist/_chunks/Relations-JPhWxk-s.mjs.map +1 -0
  56. package/dist/_chunks/{en-uOUIxfcQ.js → en-BK8Xyl5I.js} +28 -15
  57. package/dist/_chunks/{en-uOUIxfcQ.js.map → en-BK8Xyl5I.js.map} +1 -1
  58. package/dist/_chunks/{en-BrCTWlZv.mjs → en-Dtk_ot79.mjs} +28 -15
  59. package/dist/_chunks/{en-BrCTWlZv.mjs.map → en-Dtk_ot79.mjs.map} +1 -1
  60. package/dist/_chunks/{es-EUonQTon.js → es-9K52xZIr.js} +2 -2
  61. package/dist/_chunks/{ja-CcFe8diO.js.map → es-9K52xZIr.js.map} +1 -1
  62. package/dist/_chunks/{es-CeXiYflN.mjs → es-D34tqjMw.mjs} +2 -2
  63. package/dist/_chunks/{es-CeXiYflN.mjs.map → es-D34tqjMw.mjs.map} +1 -1
  64. package/dist/_chunks/{fr-CD9VFbPM.mjs → fr--pg5jUbt.mjs} +13 -3
  65. package/dist/_chunks/{fr-CD9VFbPM.mjs.map → fr--pg5jUbt.mjs.map} +1 -1
  66. package/dist/_chunks/{fr-B7kGGg3E.js → fr-B2Kyv8Z9.js} +13 -3
  67. package/dist/_chunks/{fr-B7kGGg3E.js.map → fr-B2Kyv8Z9.js.map} +1 -1
  68. package/dist/_chunks/hooks-BAaaKPS_.js.map +1 -1
  69. package/dist/_chunks/{index-5EMXLEM_.js → index-C2Q_PLWj.js} +1199 -927
  70. package/dist/_chunks/index-C2Q_PLWj.js.map +1 -0
  71. package/dist/_chunks/{index-Dpxg3ctD.mjs → index-DLIkNVnQ.mjs} +1217 -945
  72. package/dist/_chunks/index-DLIkNVnQ.mjs.map +1 -0
  73. package/dist/_chunks/{ja-CcFe8diO.js → ja-7sfIbjxE.js} +2 -2
  74. package/dist/_chunks/{es-EUonQTon.js.map → ja-7sfIbjxE.js.map} +1 -1
  75. package/dist/_chunks/{ja-CtsUxOvk.mjs → ja-BHqhDq4V.mjs} +2 -2
  76. package/dist/_chunks/{ja-CtsUxOvk.mjs.map → ja-BHqhDq4V.mjs.map} +1 -1
  77. package/dist/_chunks/{layout-P3eKO1Qy.js → layout-7AsWJzZJ.js} +10 -10
  78. package/dist/_chunks/layout-7AsWJzZJ.js.map +1 -0
  79. package/dist/_chunks/{layout-C0INpKap.mjs → layout-qE8qkNH_.mjs} +9 -8
  80. package/dist/_chunks/layout-qE8qkNH_.mjs.map +1 -0
  81. package/dist/_chunks/{objects-gigeqt7s.js → objects-BcXOv6_9.js} +2 -4
  82. package/dist/_chunks/{objects-gigeqt7s.js.map → objects-BcXOv6_9.js.map} +1 -1
  83. package/dist/_chunks/{objects-mKMAmfec.mjs → objects-D6yBsdmx.mjs} +2 -4
  84. package/dist/_chunks/{objects-mKMAmfec.mjs.map → objects-D6yBsdmx.mjs.map} +1 -1
  85. package/dist/_chunks/{relations-FBRRBWeO.mjs → relations-BjHH_1Am.mjs} +6 -7
  86. package/dist/_chunks/relations-BjHH_1Am.mjs.map +1 -0
  87. package/dist/_chunks/{relations-B1y0K6LE.js → relations-EifVzf_2.js} +6 -7
  88. package/dist/_chunks/relations-EifVzf_2.js.map +1 -0
  89. package/dist/_chunks/{usePrev-B9w_-eYc.js → useDebounce-CtcjDB3L.js} +14 -1
  90. package/dist/_chunks/useDebounce-CtcjDB3L.js.map +1 -0
  91. package/dist/_chunks/useDebounce-DmuSJIF3.mjs +29 -0
  92. package/dist/_chunks/useDebounce-DmuSJIF3.mjs.map +1 -0
  93. package/dist/_chunks/{useDragAndDrop-J0TUUbR6.js → useDragAndDrop-BMtgCYzL.js} +5 -9
  94. package/dist/_chunks/{useDragAndDrop-J0TUUbR6.js.map → useDragAndDrop-BMtgCYzL.js.map} +1 -1
  95. package/dist/_chunks/{useDragAndDrop-DdHgKsqq.mjs → useDragAndDrop-DJ6jqvZN.mjs} +4 -7
  96. package/dist/_chunks/{useDragAndDrop-DdHgKsqq.mjs.map → useDragAndDrop-DJ6jqvZN.mjs.map} +1 -1
  97. package/dist/admin/index.js +2 -1
  98. package/dist/admin/index.js.map +1 -1
  99. package/dist/admin/index.mjs +5 -4
  100. package/dist/admin/src/exports.d.ts +1 -1
  101. package/dist/admin/src/history/services/historyVersion.d.ts +1 -1
  102. package/dist/admin/src/hooks/useDocument.d.ts +32 -1
  103. package/dist/admin/src/pages/EditView/EditViewPage.d.ts +9 -1
  104. package/dist/admin/src/pages/EditView/components/DocumentStatus.d.ts +2 -2
  105. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/EditorLayout.d.ts +2 -2
  106. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygFooter.d.ts +2 -2
  107. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygStyles.d.ts +4 -48
  108. package/dist/admin/src/pages/EditView/components/Header.d.ts +11 -11
  109. package/dist/admin/src/preview/components/PreviewContent.d.ts +2 -0
  110. package/dist/admin/src/preview/components/PreviewHeader.d.ts +2 -0
  111. package/dist/admin/src/preview/components/PreviewSidePanel.d.ts +3 -0
  112. package/dist/admin/src/preview/constants.d.ts +1 -0
  113. package/dist/admin/src/preview/index.d.ts +4 -0
  114. package/dist/admin/src/preview/pages/Preview.d.ts +11 -0
  115. package/dist/admin/src/preview/routes.d.ts +3 -0
  116. package/dist/admin/src/preview/services/preview.d.ts +3 -0
  117. package/dist/admin/src/router.d.ts +1 -1
  118. package/dist/admin/src/services/api.d.ts +1 -1
  119. package/dist/admin/src/services/components.d.ts +2 -2
  120. package/dist/admin/src/services/contentTypes.d.ts +3 -3
  121. package/dist/admin/src/services/documents.d.ts +19 -20
  122. package/dist/admin/src/services/init.d.ts +1 -1
  123. package/dist/admin/src/services/relations.d.ts +2 -2
  124. package/dist/admin/src/services/uid.d.ts +3 -3
  125. package/dist/admin/src/utils/validation.d.ts +4 -1
  126. package/dist/server/index.js +486 -219
  127. package/dist/server/index.js.map +1 -1
  128. package/dist/server/index.mjs +486 -218
  129. package/dist/server/index.mjs.map +1 -1
  130. package/dist/server/src/bootstrap.d.ts.map +1 -1
  131. package/dist/server/src/controllers/collection-types.d.ts.map +1 -1
  132. package/dist/server/src/controllers/index.d.ts.map +1 -1
  133. package/dist/server/src/controllers/relations.d.ts.map +1 -1
  134. package/dist/server/src/controllers/utils/metadata.d.ts +15 -1
  135. package/dist/server/src/controllers/utils/metadata.d.ts.map +1 -1
  136. package/dist/server/src/history/services/history.d.ts.map +1 -1
  137. package/dist/server/src/history/services/lifecycles.d.ts.map +1 -1
  138. package/dist/server/src/history/services/utils.d.ts +3 -3
  139. package/dist/server/src/history/services/utils.d.ts.map +1 -1
  140. package/dist/server/src/index.d.ts +4 -4
  141. package/dist/server/src/policies/hasPermissions.d.ts.map +1 -1
  142. package/dist/server/src/preview/constants.d.ts +2 -0
  143. package/dist/server/src/preview/constants.d.ts.map +1 -0
  144. package/dist/server/src/preview/controllers/index.d.ts +2 -0
  145. package/dist/server/src/preview/controllers/index.d.ts.map +1 -0
  146. package/dist/server/src/preview/controllers/preview.d.ts +13 -0
  147. package/dist/server/src/preview/controllers/preview.d.ts.map +1 -0
  148. package/dist/server/src/preview/controllers/validation/preview.d.ts +6 -0
  149. package/dist/server/src/preview/controllers/validation/preview.d.ts.map +1 -0
  150. package/dist/server/src/preview/index.d.ts +4 -0
  151. package/dist/server/src/preview/index.d.ts.map +1 -0
  152. package/dist/server/src/preview/routes/index.d.ts +8 -0
  153. package/dist/server/src/preview/routes/index.d.ts.map +1 -0
  154. package/dist/server/src/preview/routes/preview.d.ts +4 -0
  155. package/dist/server/src/preview/routes/preview.d.ts.map +1 -0
  156. package/dist/server/src/preview/services/index.d.ts +16 -0
  157. package/dist/server/src/preview/services/index.d.ts.map +1 -0
  158. package/dist/server/src/preview/services/preview-config.d.ts +32 -0
  159. package/dist/server/src/preview/services/preview-config.d.ts.map +1 -0
  160. package/dist/server/src/preview/services/preview.d.ts +12 -0
  161. package/dist/server/src/preview/services/preview.d.ts.map +1 -0
  162. package/dist/server/src/preview/utils.d.ts +19 -0
  163. package/dist/server/src/preview/utils.d.ts.map +1 -0
  164. package/dist/server/src/register.d.ts.map +1 -1
  165. package/dist/server/src/routes/index.d.ts.map +1 -1
  166. package/dist/server/src/services/document-manager.d.ts.map +1 -1
  167. package/dist/server/src/services/document-metadata.d.ts +8 -8
  168. package/dist/server/src/services/document-metadata.d.ts.map +1 -1
  169. package/dist/server/src/services/index.d.ts +4 -4
  170. package/dist/server/src/services/index.d.ts.map +1 -1
  171. package/dist/server/src/services/permission-checker.d.ts.map +1 -1
  172. package/dist/server/src/services/utils/configuration/index.d.ts +2 -2
  173. package/dist/server/src/services/utils/configuration/layouts.d.ts +2 -2
  174. package/dist/server/src/utils/index.d.ts +2 -0
  175. package/dist/server/src/utils/index.d.ts.map +1 -1
  176. package/dist/shared/contracts/collection-types.d.ts +3 -1
  177. package/dist/shared/contracts/collection-types.d.ts.map +1 -1
  178. package/dist/shared/contracts/index.d.ts +1 -0
  179. package/dist/shared/contracts/index.d.ts.map +1 -1
  180. package/dist/shared/contracts/preview.d.ts +27 -0
  181. package/dist/shared/contracts/preview.d.ts.map +1 -0
  182. package/dist/shared/index.js +4 -0
  183. package/dist/shared/index.js.map +1 -1
  184. package/dist/shared/index.mjs +4 -0
  185. package/dist/shared/index.mjs.map +1 -1
  186. package/package.json +15 -15
  187. package/dist/_chunks/EditViewPage-BSVmMpRd.js.map +0 -1
  188. package/dist/_chunks/EditViewPage-C3tIZ8F5.mjs.map +0 -1
  189. package/dist/_chunks/Field-BvuT8cGL.mjs.map +0 -1
  190. package/dist/_chunks/Field-DUCVth4C.js.map +0 -1
  191. package/dist/_chunks/Form-BZmDNVr9.mjs.map +0 -1
  192. package/dist/_chunks/Form-Cpl4W1ak.js.map +0 -1
  193. package/dist/_chunks/History-Cq_Hrzuu.mjs.map +0 -1
  194. package/dist/_chunks/History-D4U2YISB.js.map +0 -1
  195. package/dist/_chunks/ListConfigurationPage-Bny6CdWe.js.map +0 -1
  196. package/dist/_chunks/ListConfigurationPage-W-KQHmBv.mjs.map +0 -1
  197. package/dist/_chunks/ListViewPage-HBBnJa8K.mjs.map +0 -1
  198. package/dist/_chunks/ListViewPage-O8F1pBJo.js.map +0 -1
  199. package/dist/_chunks/Relations-C4gGfZRv.js.map +0 -1
  200. package/dist/_chunks/Relations-vFZ6Wasg.mjs.map +0 -1
  201. package/dist/_chunks/index-5EMXLEM_.js.map +0 -1
  202. package/dist/_chunks/index-Dpxg3ctD.mjs.map +0 -1
  203. package/dist/_chunks/layout-C0INpKap.mjs.map +0 -1
  204. package/dist/_chunks/layout-P3eKO1Qy.js.map +0 -1
  205. package/dist/_chunks/relations-B1y0K6LE.js.map +0 -1
  206. package/dist/_chunks/relations-FBRRBWeO.mjs.map +0 -1
  207. package/dist/_chunks/usePrev-B9w_-eYc.js.map +0 -1
  208. package/dist/_chunks/usePrev-DH6iah0A.mjs +0 -16
  209. package/dist/_chunks/usePrev-DH6iah0A.mjs.map +0 -1
  210. package/strapi-server.js +0 -3
@@ -4,18 +4,18 @@ const jsxRuntime = require("react/jsx-runtime");
4
4
  const strapiAdmin = require("@strapi/admin/strapi-admin");
5
5
  const React = require("react");
6
6
  const designSystem = require("@strapi/design-system");
7
+ const mapValues = require("lodash/fp/mapValues");
7
8
  const reactIntl = require("react-intl");
8
9
  const reactRouterDom = require("react-router-dom");
9
10
  const styledComponents = require("styled-components");
10
11
  const yup = require("yup");
12
+ const qs = require("qs");
11
13
  const pipe = require("lodash/fp/pipe");
12
14
  const dateFns = require("date-fns");
13
- const qs = require("qs");
14
15
  const toolkit = require("@reduxjs/toolkit");
15
16
  const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
16
17
  function _interopNamespace(e) {
17
- if (e && e.__esModule)
18
- return e;
18
+ if (e && e.__esModule) return e;
19
19
  const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
20
20
  if (e) {
21
21
  for (const k in e) {
@@ -32,15 +32,23 @@ function _interopNamespace(e) {
32
32
  return Object.freeze(n);
33
33
  }
34
34
  const React__namespace = /* @__PURE__ */ _interopNamespace(React);
35
+ const mapValues__default = /* @__PURE__ */ _interopDefault(mapValues);
35
36
  const yup__namespace = /* @__PURE__ */ _interopNamespace(yup);
36
37
  const pipe__default = /* @__PURE__ */ _interopDefault(pipe);
37
- const __variableDynamicImportRuntimeHelper = (glob, path) => {
38
+ const __variableDynamicImportRuntimeHelper = (glob, path, segs) => {
38
39
  const v = glob[path];
39
40
  if (v) {
40
41
  return typeof v === "function" ? v() : Promise.resolve(v);
41
42
  }
42
43
  return new Promise((_, reject) => {
43
- (typeof queueMicrotask === "function" ? queueMicrotask : setTimeout)(reject.bind(null, new Error("Unknown variable dynamic import: " + path)));
44
+ (typeof queueMicrotask === "function" ? queueMicrotask : setTimeout)(
45
+ reject.bind(
46
+ null,
47
+ new Error(
48
+ "Unknown variable dynamic import: " + path + (path.split("/").length !== segs ? ". Note that variables only represent file names one level deep." : "")
49
+ )
50
+ )
51
+ );
44
52
  });
45
53
  };
46
54
  const PLUGIN_ID = "content-manager";
@@ -121,6 +129,7 @@ const DocumentRBAC = ({ children, permissions }) => {
121
129
  if (!slug) {
122
130
  throw new Error("Cannot find the slug param in the URL");
123
131
  }
132
+ const [{ rawQuery }] = strapiAdmin.useQueryParams();
124
133
  const userPermissions = strapiAdmin.useAuth("DocumentRBAC", (state) => state.permissions);
125
134
  const contentTypePermissions = React__namespace.useMemo(() => {
126
135
  const contentTypePermissions2 = userPermissions.filter(
@@ -131,7 +140,14 @@ const DocumentRBAC = ({ children, permissions }) => {
131
140
  return { ...acc, [action]: [permission] };
132
141
  }, {});
133
142
  }, [slug, userPermissions]);
134
- const { isLoading, allowedActions } = strapiAdmin.useRBAC(contentTypePermissions, permissions ?? void 0);
143
+ const { isLoading, allowedActions } = strapiAdmin.useRBAC(
144
+ contentTypePermissions,
145
+ permissions ?? void 0,
146
+ // TODO: useRBAC context should be typed and built differently
147
+ // We are passing raw query as context to the hook so that it can
148
+ // rely on the locale provided from DocumentRBAC for its permission calculations.
149
+ rawQuery
150
+ );
135
151
  const canCreateFields = !isLoading && allowedActions.canCreate ? extractAndDedupeFields(contentTypePermissions.create) : [];
136
152
  const canReadFields = !isLoading && allowedActions.canRead ? extractAndDedupeFields(contentTypePermissions.read) : [];
137
153
  const canUpdateFields = !isLoading && allowedActions.canUpdate ? extractAndDedupeFields(contentTypePermissions.update) : [];
@@ -179,7 +195,8 @@ const contentManagerApi = strapiAdmin.adminApi.enhanceEndpoints({
179
195
  "Document",
180
196
  "InitialData",
181
197
  "HistoryVersion",
182
- "Relations"
198
+ "Relations",
199
+ "UidAvailability"
183
200
  ]
184
201
  });
185
202
  const documentApi = contentManagerApi.injectEndpoints({
@@ -209,7 +226,10 @@ const documentApi = contentManagerApi.injectEndpoints({
209
226
  params
210
227
  }
211
228
  }),
212
- invalidatesTags: (_result, _error, { model }) => [{ type: "Document", id: `${model}_LIST` }]
229
+ invalidatesTags: (_result, _error, { model }) => [
230
+ { type: "Document", id: `${model}_LIST` },
231
+ { type: "UidAvailability", id: model }
232
+ ]
213
233
  }),
214
234
  /**
215
235
  * Creates a new collection-type document. This should ONLY be used for collection-types.
@@ -226,7 +246,8 @@ const documentApi = contentManagerApi.injectEndpoints({
226
246
  }),
227
247
  invalidatesTags: (result, _error, { model }) => [
228
248
  { type: "Document", id: `${model}_LIST` },
229
- "Relations"
249
+ "Relations",
250
+ { type: "UidAvailability", id: model }
230
251
  ]
231
252
  }),
232
253
  deleteDocument: builder.mutation({
@@ -267,7 +288,8 @@ const documentApi = contentManagerApi.injectEndpoints({
267
288
  id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
268
289
  },
269
290
  { type: "Document", id: `${model}_LIST` },
270
- "Relations"
291
+ "Relations",
292
+ { type: "UidAvailability", id: model }
271
293
  ];
272
294
  }
273
295
  }),
@@ -280,7 +302,7 @@ const documentApi = contentManagerApi.injectEndpoints({
280
302
  url: `/content-manager/collection-types/${model}`,
281
303
  method: "GET",
282
304
  config: {
283
- params
305
+ params: qs.stringify(params, { encode: true })
284
306
  }
285
307
  }),
286
308
  providesTags: (result, _error, arg) => {
@@ -392,7 +414,8 @@ const documentApi = contentManagerApi.injectEndpoints({
392
414
  type: "Document",
393
415
  id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
394
416
  },
395
- "Relations"
417
+ "Relations",
418
+ { type: "UidAvailability", id: model }
396
419
  ];
397
420
  },
398
421
  async onQueryStarted({ data, ...patch }, { dispatch, queryFulfilled }) {
@@ -458,8 +481,7 @@ const {
458
481
  useUnpublishManyDocumentsMutation
459
482
  } = documentApi;
460
483
  const buildValidParams = (query) => {
461
- if (!query)
462
- return query;
484
+ if (!query) return query;
463
485
  const { plugins: _, ...validQueryParams } = {
464
486
  ...query,
465
487
  ...Object.values(query?.plugins ?? {}).reduce(
@@ -467,28 +489,44 @@ const buildValidParams = (query) => {
467
489
  {}
468
490
  )
469
491
  };
470
- if ("_q" in validQueryParams) {
471
- validQueryParams._q = encodeURIComponent(validQueryParams._q);
472
- }
473
492
  return validQueryParams;
474
493
  };
475
494
  const isBaseQueryError = (error) => {
476
495
  return error.name !== void 0;
477
496
  };
478
- const createYupSchema = (attributes = {}, components = {}) => {
497
+ const arrayValidator = (attribute, options) => ({
498
+ message: strapiAdmin.translatedErrors.required,
499
+ test(value) {
500
+ if (options.status === "draft") {
501
+ return true;
502
+ }
503
+ if (!attribute.required) {
504
+ return true;
505
+ }
506
+ if (!value) {
507
+ return false;
508
+ }
509
+ if (Array.isArray(value) && value.length === 0) {
510
+ return false;
511
+ }
512
+ return true;
513
+ }
514
+ });
515
+ const createYupSchema = (attributes = {}, components = {}, options = { status: null }) => {
479
516
  const createModelSchema = (attributes2) => yup__namespace.object().shape(
480
517
  Object.entries(attributes2).reduce((acc, [name, attribute]) => {
481
518
  if (DOCUMENT_META_FIELDS.includes(name)) {
482
519
  return acc;
483
520
  }
484
521
  const validations = [
522
+ addNullableValidation,
485
523
  addRequiredValidation,
486
524
  addMinLengthValidation,
487
525
  addMaxLengthValidation,
488
526
  addMinValidation,
489
527
  addMaxValidation,
490
528
  addRegexValidation
491
- ].map((fn) => fn(attribute));
529
+ ].map((fn) => fn(attribute, options));
492
530
  const transformSchema = pipe__default.default(...validations);
493
531
  switch (attribute.type) {
494
532
  case "component": {
@@ -498,12 +536,12 @@ const createYupSchema = (attributes = {}, components = {}) => {
498
536
  ...acc,
499
537
  [name]: transformSchema(
500
538
  yup__namespace.array().of(createModelSchema(attributes3).nullable(false))
501
- )
539
+ ).test(arrayValidator(attribute, options))
502
540
  };
503
541
  } else {
504
542
  return {
505
543
  ...acc,
506
- [name]: transformSchema(createModelSchema(attributes3))
544
+ [name]: transformSchema(createModelSchema(attributes3).nullable())
507
545
  };
508
546
  }
509
547
  }
@@ -525,7 +563,7 @@ const createYupSchema = (attributes = {}, components = {}) => {
525
563
  }
526
564
  )
527
565
  )
528
- )
566
+ ).test(arrayValidator(attribute, options))
529
567
  };
530
568
  case "relation":
531
569
  return {
@@ -537,7 +575,7 @@ const createYupSchema = (attributes = {}, components = {}) => {
537
575
  } else if (Array.isArray(value)) {
538
576
  return yup__namespace.array().of(
539
577
  yup__namespace.object().shape({
540
- id: yup__namespace.string().required()
578
+ id: yup__namespace.number().required()
541
579
  })
542
580
  );
543
581
  } else if (typeof value === "object") {
@@ -615,13 +653,7 @@ const createAttributeSchema = (attribute) => {
615
653
  return yup__namespace.mixed();
616
654
  }
617
655
  };
618
- const addRequiredValidation = (attribute) => (schema) => {
619
- if ((attribute.type === "component" && attribute.repeatable || attribute.type === "dynamiczone") && attribute.required && "min" in schema) {
620
- return schema.min(1, strapiAdmin.translatedErrors.required);
621
- }
622
- if (attribute.required && attribute.type !== "relation") {
623
- return schema.required(strapiAdmin.translatedErrors.required);
624
- }
656
+ const nullableSchema = (schema) => {
625
657
  return schema?.nullable ? schema.nullable() : (
626
658
  // In some cases '.nullable' will not be available on the schema.
627
659
  // e.g. when the schema has been built using yup.lazy (e.g. for relations).
@@ -629,7 +661,22 @@ const addRequiredValidation = (attribute) => (schema) => {
629
661
  schema
630
662
  );
631
663
  };
632
- const addMinLengthValidation = (attribute) => (schema) => {
664
+ const addNullableValidation = () => (schema) => {
665
+ return nullableSchema(schema);
666
+ };
667
+ const addRequiredValidation = (attribute, options) => (schema) => {
668
+ if (options.status === "draft" || !attribute.required) {
669
+ return schema;
670
+ }
671
+ if (attribute.required && "required" in schema) {
672
+ return schema.required(strapiAdmin.translatedErrors.required);
673
+ }
674
+ return schema;
675
+ };
676
+ const addMinLengthValidation = (attribute, options) => (schema) => {
677
+ if (options.status === "draft") {
678
+ return schema;
679
+ }
633
680
  if ("minLength" in attribute && attribute.minLength && Number.isInteger(attribute.minLength) && "min" in schema) {
634
681
  return schema.min(attribute.minLength, {
635
682
  ...strapiAdmin.translatedErrors.minLength,
@@ -651,32 +698,13 @@ const addMaxLengthValidation = (attribute) => (schema) => {
651
698
  }
652
699
  return schema;
653
700
  };
654
- const addMinValidation = (attribute) => (schema) => {
655
- if ("min" in attribute) {
701
+ const addMinValidation = (attribute, options) => (schema) => {
702
+ if (options.status === "draft") {
703
+ return schema;
704
+ }
705
+ if ("min" in attribute && "min" in schema) {
656
706
  const min = toInteger(attribute.min);
657
- if (attribute.type === "component" && attribute.repeatable || attribute.type === "dynamiczone") {
658
- if (!attribute.required && "test" in schema && min) {
659
- return schema.test(
660
- "custom-min",
661
- {
662
- ...strapiAdmin.translatedErrors.min,
663
- values: {
664
- min: attribute.min
665
- }
666
- },
667
- (value) => {
668
- if (!value) {
669
- return true;
670
- }
671
- if (Array.isArray(value) && value.length === 0) {
672
- return true;
673
- }
674
- return value.length >= min;
675
- }
676
- );
677
- }
678
- }
679
- if ("min" in schema && min) {
707
+ if (min) {
680
708
  return schema.min(min, {
681
709
  ...strapiAdmin.translatedErrors.min,
682
710
  values: {
@@ -794,19 +822,115 @@ const extractContentTypeComponents = (attributes = {}, allComponents = {}) => {
794
822
  }, {});
795
823
  return componentsByKey;
796
824
  };
797
- const useDocument = (args, opts) => {
825
+ const HOOKS = {
826
+ /**
827
+ * Hook that allows to mutate the displayed headers of the list view table
828
+ * @constant
829
+ * @type {string}
830
+ */
831
+ INJECT_COLUMN_IN_TABLE: "Admin/CM/pages/ListView/inject-column-in-table",
832
+ /**
833
+ * Hook that allows to mutate the CM's collection types links pre-set filters
834
+ * @constant
835
+ * @type {string}
836
+ */
837
+ MUTATE_COLLECTION_TYPES_LINKS: "Admin/CM/pages/App/mutate-collection-types-links",
838
+ /**
839
+ * Hook that allows to mutate the CM's edit view layout
840
+ * @constant
841
+ * @type {string}
842
+ */
843
+ MUTATE_EDIT_VIEW_LAYOUT: "Admin/CM/pages/EditView/mutate-edit-view-layout",
844
+ /**
845
+ * Hook that allows to mutate the CM's single types links pre-set filters
846
+ * @constant
847
+ * @type {string}
848
+ */
849
+ MUTATE_SINGLE_TYPES_LINKS: "Admin/CM/pages/App/mutate-single-types-links"
850
+ };
851
+ const contentTypesApi = contentManagerApi.injectEndpoints({
852
+ endpoints: (builder) => ({
853
+ getContentTypeConfiguration: builder.query({
854
+ query: (uid) => ({
855
+ url: `/content-manager/content-types/${uid}/configuration`,
856
+ method: "GET"
857
+ }),
858
+ transformResponse: (response) => response.data,
859
+ providesTags: (_result, _error, uid) => [
860
+ { type: "ContentTypesConfiguration", id: uid },
861
+ { type: "ContentTypeSettings", id: "LIST" }
862
+ ]
863
+ }),
864
+ getAllContentTypeSettings: builder.query({
865
+ query: () => "/content-manager/content-types-settings",
866
+ transformResponse: (response) => response.data,
867
+ providesTags: [{ type: "ContentTypeSettings", id: "LIST" }]
868
+ }),
869
+ updateContentTypeConfiguration: builder.mutation({
870
+ query: ({ uid, ...body }) => ({
871
+ url: `/content-manager/content-types/${uid}/configuration`,
872
+ method: "PUT",
873
+ data: body
874
+ }),
875
+ transformResponse: (response) => response.data,
876
+ invalidatesTags: (_result, _error, { uid }) => [
877
+ { type: "ContentTypesConfiguration", id: uid },
878
+ { type: "ContentTypeSettings", id: "LIST" },
879
+ // Is this necessary?
880
+ { type: "InitialData" }
881
+ ]
882
+ })
883
+ })
884
+ });
885
+ const {
886
+ useGetContentTypeConfigurationQuery,
887
+ useGetAllContentTypeSettingsQuery,
888
+ useUpdateContentTypeConfigurationMutation
889
+ } = contentTypesApi;
890
+ const checkIfAttributeIsDisplayable = (attribute) => {
891
+ const { type } = attribute;
892
+ if (type === "relation") {
893
+ return !attribute.relation.toLowerCase().includes("morph");
894
+ }
895
+ return !["json", "dynamiczone", "richtext", "password", "blocks"].includes(type) && !!type;
896
+ };
897
+ const getMainField = (attribute, mainFieldName, { schemas, components }) => {
898
+ if (!mainFieldName) {
899
+ return void 0;
900
+ }
901
+ const mainFieldType = attribute.type === "component" ? components[attribute.component].attributes[mainFieldName].type : (
902
+ // @ts-expect-error – `targetModel` does exist on the attribute for a relation.
903
+ schemas.find((schema) => schema.uid === attribute.targetModel)?.attributes[mainFieldName].type
904
+ );
905
+ return {
906
+ name: mainFieldName,
907
+ type: mainFieldType ?? "string"
908
+ };
909
+ };
910
+ const DEFAULT_SETTINGS = {
911
+ bulkable: false,
912
+ filterable: false,
913
+ searchable: false,
914
+ pagination: false,
915
+ defaultSortBy: "",
916
+ defaultSortOrder: "asc",
917
+ mainField: "id",
918
+ pageSize: 10
919
+ };
920
+ const useDocumentLayout = (model) => {
921
+ const { schema, components } = useDocument({ model, collectionType: "" }, { skip: true });
922
+ const [{ query }] = strapiAdmin.useQueryParams();
923
+ const runHookWaterfall = strapiAdmin.useStrapiApp("useDocumentLayout", (state) => state.runHookWaterfall);
798
924
  const { toggleNotification } = strapiAdmin.useNotification();
799
925
  const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
926
+ const { isLoading: isLoadingSchemas, schemas } = useContentTypeSchema();
800
927
  const {
801
- currentData: data,
802
- isLoading: isLoadingDocument,
803
- isFetching: isFetchingDocument,
804
- error
805
- } = useGetDocumentQuery(args, {
806
- ...opts,
807
- skip: !args.documentId && args.collectionType !== SINGLE_TYPES || opts?.skip
808
- });
809
- const { components, schema, isLoading: isLoadingSchema } = useContentTypeSchema(args.model);
928
+ data,
929
+ isLoading: isLoadingConfigs,
930
+ error,
931
+ isFetching: isFetchingConfigs
932
+ } = useGetContentTypeConfigurationQuery(model);
933
+ const isLoading = isLoadingSchemas || isFetchingConfigs || isLoadingConfigs;
810
934
  React__namespace.useEffect(() => {
811
935
  if (error) {
812
936
  toggleNotification({
@@ -814,397 +938,654 @@ const useDocument = (args, opts) => {
814
938
  message: formatAPIError(error)
815
939
  });
816
940
  }
817
- }, [toggleNotification, error, formatAPIError, args.collectionType]);
818
- const validationSchema = React__namespace.useMemo(() => {
819
- if (!schema) {
820
- return null;
821
- }
822
- return createYupSchema(schema.attributes, components);
823
- }, [schema, components]);
824
- const validate = React__namespace.useCallback(
825
- (document) => {
826
- if (!validationSchema) {
827
- throw new Error(
828
- "There is no validation schema generated, this is likely due to the schema not being loaded yet."
829
- );
830
- }
831
- try {
832
- validationSchema.validateSync(document, { abortEarly: false, strict: true });
833
- return null;
834
- } catch (error2) {
835
- if (error2 instanceof yup.ValidationError) {
836
- return strapiAdmin.getYupValidationErrors(error2);
837
- }
838
- throw error2;
839
- }
941
+ }, [error, formatAPIError, toggleNotification]);
942
+ const editLayout = React__namespace.useMemo(
943
+ () => data && !isLoading ? formatEditLayout(data, { schemas, schema, components }) : {
944
+ layout: [],
945
+ components: {},
946
+ metadatas: {},
947
+ options: {},
948
+ settings: DEFAULT_SETTINGS
840
949
  },
841
- [validationSchema]
950
+ [data, isLoading, schemas, schema, components]
951
+ );
952
+ const listLayout = React__namespace.useMemo(() => {
953
+ return data && !isLoading ? formatListLayout(data, { schemas, schema, components }) : {
954
+ layout: [],
955
+ metadatas: {},
956
+ options: {},
957
+ settings: DEFAULT_SETTINGS
958
+ };
959
+ }, [data, isLoading, schemas, schema, components]);
960
+ const { layout: edit } = React__namespace.useMemo(
961
+ () => runHookWaterfall(HOOKS.MUTATE_EDIT_VIEW_LAYOUT, {
962
+ layout: editLayout,
963
+ query
964
+ }),
965
+ [editLayout, query, runHookWaterfall]
842
966
  );
843
- const isLoading = isLoadingDocument || isFetchingDocument || isLoadingSchema;
844
967
  return {
845
- components,
846
- document: data?.data,
847
- meta: data?.meta,
968
+ error,
848
969
  isLoading,
849
- schema,
850
- validate
851
- };
852
- };
853
- const useDoc = () => {
854
- const { id, slug, collectionType, origin } = reactRouterDom.useParams();
855
- const [{ query }] = strapiAdmin.useQueryParams();
856
- const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
857
- if (!collectionType) {
858
- throw new Error("Could not find collectionType in url params");
859
- }
860
- if (!slug) {
861
- throw new Error("Could not find model in url params");
862
- }
863
- return {
864
- collectionType,
865
- model: slug,
866
- id: origin || id === "create" ? void 0 : id,
867
- ...useDocument(
868
- { documentId: origin || id, model: slug, collectionType, params },
869
- {
870
- skip: id === "create" || !origin && !id && collectionType !== SINGLE_TYPES
871
- }
872
- )
970
+ edit,
971
+ list: listLayout
873
972
  };
874
973
  };
875
- const prefixPluginTranslations = (trad, pluginId) => {
876
- if (!pluginId) {
877
- throw new TypeError("pluginId can't be empty");
878
- }
879
- return Object.keys(trad).reduce((acc, current) => {
880
- acc[`${pluginId}.${current}`] = trad[current];
881
- return acc;
882
- }, {});
883
- };
884
- const getTranslation = (id) => `content-manager.${id}`;
885
- const DEFAULT_UNEXPECTED_ERROR_MSG = {
886
- id: "notification.error",
887
- defaultMessage: "An error occurred, please try again"
974
+ const useDocLayout = () => {
975
+ const { model } = useDoc();
976
+ return useDocumentLayout(model);
888
977
  };
889
- const useDocumentActions = () => {
890
- const { toggleNotification } = strapiAdmin.useNotification();
891
- const { formatMessage } = reactIntl.useIntl();
892
- const { trackUsage } = strapiAdmin.useTracking();
893
- const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
894
- const [deleteDocument] = useDeleteDocumentMutation();
895
- const _delete = React__namespace.useCallback(
896
- async ({ collectionType, model, documentId, params }, trackerProperty) => {
897
- try {
898
- trackUsage("willDeleteEntry", trackerProperty);
899
- const res = await deleteDocument({
900
- collectionType,
901
- model,
902
- documentId,
903
- params
904
- });
905
- if ("error" in res) {
906
- toggleNotification({
907
- type: "danger",
908
- message: formatAPIError(res.error)
909
- });
910
- return { error: res.error };
911
- }
912
- toggleNotification({
913
- type: "success",
914
- message: formatMessage({
915
- id: getTranslation("success.record.delete"),
916
- defaultMessage: "Deleted document"
917
- })
918
- });
919
- trackUsage("didDeleteEntry", trackerProperty);
920
- return res.data;
921
- } catch (err) {
922
- toggleNotification({
923
- type: "danger",
924
- message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
925
- });
926
- trackUsage("didNotDeleteEntry", { error: err, ...trackerProperty });
927
- throw err;
978
+ const formatEditLayout = (data, {
979
+ schemas,
980
+ schema,
981
+ components
982
+ }) => {
983
+ let currentPanelIndex = 0;
984
+ const panelledEditAttributes = convertEditLayoutToFieldLayouts(
985
+ data.contentType.layouts.edit,
986
+ schema?.attributes,
987
+ data.contentType.metadatas,
988
+ { configurations: data.components, schemas: components },
989
+ schemas
990
+ ).reduce((panels, row) => {
991
+ if (row.some((field) => field.type === "dynamiczone")) {
992
+ panels.push([row]);
993
+ currentPanelIndex += 2;
994
+ } else {
995
+ if (!panels[currentPanelIndex]) {
996
+ panels.push([row]);
997
+ } else {
998
+ panels[currentPanelIndex].push(row);
928
999
  }
929
- },
930
- [trackUsage, deleteDocument, toggleNotification, formatMessage, formatAPIError]
931
- );
932
- const [deleteManyDocuments] = useDeleteManyDocumentsMutation();
933
- const deleteMany = React__namespace.useCallback(
934
- async ({ model, documentIds, params }) => {
935
- try {
936
- trackUsage("willBulkDeleteEntries");
937
- const res = await deleteManyDocuments({
938
- model,
939
- documentIds,
940
- params
941
- });
942
- if ("error" in res) {
943
- toggleNotification({
944
- type: "danger",
945
- message: formatAPIError(res.error)
946
- });
947
- return { error: res.error };
1000
+ }
1001
+ return panels;
1002
+ }, []);
1003
+ const componentEditAttributes = Object.entries(data.components).reduce(
1004
+ (acc, [uid, configuration]) => {
1005
+ acc[uid] = {
1006
+ layout: convertEditLayoutToFieldLayouts(
1007
+ configuration.layouts.edit,
1008
+ components[uid].attributes,
1009
+ configuration.metadatas,
1010
+ { configurations: data.components, schemas: components }
1011
+ ),
1012
+ settings: {
1013
+ ...configuration.settings,
1014
+ icon: components[uid].info.icon,
1015
+ displayName: components[uid].info.displayName
948
1016
  }
949
- toggleNotification({
950
- type: "success",
951
- title: formatMessage({
952
- id: getTranslation("success.records.delete"),
953
- defaultMessage: "Successfully deleted."
954
- }),
955
- message: ""
956
- });
957
- trackUsage("didBulkDeleteEntries");
958
- return res.data;
959
- } catch (err) {
960
- toggleNotification({
961
- type: "danger",
962
- message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
963
- });
964
- trackUsage("didNotBulkDeleteEntries");
965
- throw err;
966
- }
1017
+ };
1018
+ return acc;
967
1019
  },
968
- [trackUsage, deleteManyDocuments, toggleNotification, formatMessage, formatAPIError]
1020
+ {}
969
1021
  );
970
- const [discardDocument] = useDiscardDocumentMutation();
971
- const discard = React__namespace.useCallback(
972
- async ({ collectionType, model, documentId, params }) => {
973
- try {
974
- const res = await discardDocument({
975
- collectionType,
976
- model,
977
- documentId,
978
- params
979
- });
980
- if ("error" in res) {
981
- toggleNotification({
982
- type: "danger",
983
- message: formatAPIError(res.error)
984
- });
985
- return { error: res.error };
986
- }
987
- toggleNotification({
988
- type: "success",
989
- message: formatMessage({
990
- id: "content-manager.success.record.discard",
991
- defaultMessage: "Changes discarded"
992
- })
993
- });
994
- return res.data;
995
- } catch (err) {
996
- toggleNotification({
997
- type: "danger",
998
- message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
999
- });
1000
- throw err;
1001
- }
1022
+ const editMetadatas = Object.entries(data.contentType.metadatas).reduce(
1023
+ (acc, [attribute, metadata]) => {
1024
+ return {
1025
+ ...acc,
1026
+ [attribute]: metadata.edit
1027
+ };
1002
1028
  },
1003
- [discardDocument, formatAPIError, formatMessage, toggleNotification]
1029
+ {}
1004
1030
  );
1005
- const [publishDocument] = usePublishDocumentMutation();
1006
- const publish = React__namespace.useCallback(
1007
- async ({ collectionType, model, documentId, params }, data) => {
1008
- try {
1009
- trackUsage("willPublishEntry");
1010
- const res = await publishDocument({
1011
- collectionType,
1012
- model,
1013
- documentId,
1014
- data,
1015
- params
1016
- });
1017
- if ("error" in res) {
1018
- toggleNotification({ type: "danger", message: formatAPIError(res.error) });
1019
- return { error: res.error };
1020
- }
1021
- trackUsage("didPublishEntry");
1022
- toggleNotification({
1023
- type: "success",
1024
- message: formatMessage({
1025
- id: getTranslation("success.record.publish"),
1026
- defaultMessage: "Published document"
1027
- })
1028
- });
1029
- return res.data;
1030
- } catch (err) {
1031
- toggleNotification({
1032
- type: "danger",
1033
- message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
1034
- });
1035
- throw err;
1036
- }
1031
+ return {
1032
+ layout: panelledEditAttributes,
1033
+ components: componentEditAttributes,
1034
+ metadatas: editMetadatas,
1035
+ settings: {
1036
+ ...data.contentType.settings,
1037
+ displayName: schema?.info.displayName
1037
1038
  },
1038
- [trackUsage, publishDocument, toggleNotification, formatMessage, formatAPIError]
1039
- );
1040
- const [publishManyDocuments] = usePublishManyDocumentsMutation();
1041
- const publishMany = React__namespace.useCallback(
1042
- async ({ model, documentIds, params }) => {
1043
- try {
1044
- const res = await publishManyDocuments({
1045
- model,
1046
- documentIds,
1047
- params
1048
- });
1049
- if ("error" in res) {
1050
- toggleNotification({ type: "danger", message: formatAPIError(res.error) });
1051
- return { error: res.error };
1052
- }
1053
- toggleNotification({
1054
- type: "success",
1055
- message: formatMessage({
1056
- id: getTranslation("success.record.publish"),
1057
- defaultMessage: "Published document"
1058
- })
1059
- });
1060
- return res.data;
1061
- } catch (err) {
1062
- toggleNotification({
1063
- type: "danger",
1064
- message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
1065
- });
1066
- throw err;
1039
+ options: {
1040
+ ...schema?.options,
1041
+ ...schema?.pluginOptions,
1042
+ ...data.contentType.options
1043
+ }
1044
+ };
1045
+ };
1046
+ const convertEditLayoutToFieldLayouts = (rows, attributes = {}, metadatas, components, schemas = []) => {
1047
+ return rows.map(
1048
+ (row) => row.map((field) => {
1049
+ const attribute = attributes[field.name];
1050
+ if (!attribute) {
1051
+ return null;
1067
1052
  }
1068
- },
1069
- [
1070
- // trackUsage,
1071
- publishManyDocuments,
1072
- toggleNotification,
1073
- formatMessage,
1074
- formatAPIError
1075
- ]
1053
+ const { edit: metadata } = metadatas[field.name];
1054
+ const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
1055
+ return {
1056
+ attribute,
1057
+ disabled: !metadata.editable,
1058
+ hint: metadata.description,
1059
+ label: metadata.label ?? "",
1060
+ name: field.name,
1061
+ // @ts-expect-error – mainField does exist on the metadata for a relation.
1062
+ mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
1063
+ schemas,
1064
+ components: components?.schemas ?? {}
1065
+ }),
1066
+ placeholder: metadata.placeholder ?? "",
1067
+ required: attribute.required ?? false,
1068
+ size: field.size,
1069
+ unique: "unique" in attribute ? attribute.unique : false,
1070
+ visible: metadata.visible ?? true,
1071
+ type: attribute.type
1072
+ };
1073
+ }).filter((field) => field !== null)
1076
1074
  );
1077
- const [updateDocument] = useUpdateDocumentMutation();
1078
- const update = React__namespace.useCallback(
1079
- async ({ collectionType, model, documentId, params }, data, trackerProperty) => {
1075
+ };
1076
+ const formatListLayout = (data, {
1077
+ schemas,
1078
+ schema,
1079
+ components
1080
+ }) => {
1081
+ const listMetadatas = Object.entries(data.contentType.metadatas).reduce(
1082
+ (acc, [attribute, metadata]) => {
1083
+ return {
1084
+ ...acc,
1085
+ [attribute]: metadata.list
1086
+ };
1087
+ },
1088
+ {}
1089
+ );
1090
+ const listAttributes = convertListLayoutToFieldLayouts(
1091
+ data.contentType.layouts.list,
1092
+ schema?.attributes,
1093
+ listMetadatas,
1094
+ { configurations: data.components, schemas: components },
1095
+ schemas
1096
+ );
1097
+ return {
1098
+ layout: listAttributes,
1099
+ settings: { ...data.contentType.settings, displayName: schema?.info.displayName },
1100
+ metadatas: listMetadatas,
1101
+ options: {
1102
+ ...schema?.options,
1103
+ ...schema?.pluginOptions,
1104
+ ...data.contentType.options
1105
+ }
1106
+ };
1107
+ };
1108
+ const convertListLayoutToFieldLayouts = (columns, attributes = {}, metadatas, components, schemas = []) => {
1109
+ return columns.map((name) => {
1110
+ const attribute = attributes[name];
1111
+ if (!attribute) {
1112
+ return null;
1113
+ }
1114
+ const metadata = metadatas[name];
1115
+ const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
1116
+ return {
1117
+ attribute,
1118
+ label: metadata.label ?? "",
1119
+ mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
1120
+ schemas,
1121
+ components: components?.schemas ?? {}
1122
+ }),
1123
+ name,
1124
+ searchable: metadata.searchable ?? true,
1125
+ sortable: metadata.sortable ?? true
1126
+ };
1127
+ }).filter((field) => field !== null);
1128
+ };
1129
+ const useDocument = (args, opts) => {
1130
+ const { toggleNotification } = strapiAdmin.useNotification();
1131
+ const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
1132
+ const {
1133
+ currentData: data,
1134
+ isLoading: isLoadingDocument,
1135
+ isFetching: isFetchingDocument,
1136
+ error
1137
+ } = useGetDocumentQuery(args, {
1138
+ ...opts,
1139
+ skip: !args.documentId && args.collectionType !== SINGLE_TYPES || opts?.skip
1140
+ });
1141
+ const {
1142
+ components,
1143
+ schema,
1144
+ schemas,
1145
+ isLoading: isLoadingSchema
1146
+ } = useContentTypeSchema(args.model);
1147
+ React__namespace.useEffect(() => {
1148
+ if (error) {
1149
+ toggleNotification({
1150
+ type: "danger",
1151
+ message: formatAPIError(error)
1152
+ });
1153
+ }
1154
+ }, [toggleNotification, error, formatAPIError, args.collectionType]);
1155
+ const validationSchema = React__namespace.useMemo(() => {
1156
+ if (!schema) {
1157
+ return null;
1158
+ }
1159
+ return createYupSchema(schema.attributes, components);
1160
+ }, [schema, components]);
1161
+ const validate = React__namespace.useCallback(
1162
+ (document) => {
1163
+ if (!validationSchema) {
1164
+ throw new Error(
1165
+ "There is no validation schema generated, this is likely due to the schema not being loaded yet."
1166
+ );
1167
+ }
1080
1168
  try {
1081
- trackUsage("willEditEntry", trackerProperty);
1082
- const res = await updateDocument({
1083
- collectionType,
1084
- model,
1085
- documentId,
1086
- data,
1087
- params
1088
- });
1089
- if ("error" in res) {
1090
- toggleNotification({ type: "danger", message: formatAPIError(res.error) });
1091
- trackUsage("didNotEditEntry", { error: res.error, ...trackerProperty });
1092
- return { error: res.error };
1169
+ validationSchema.validateSync(document, { abortEarly: false, strict: true });
1170
+ return null;
1171
+ } catch (error2) {
1172
+ if (error2 instanceof yup.ValidationError) {
1173
+ return strapiAdmin.getYupValidationErrors(error2);
1093
1174
  }
1094
- trackUsage("didEditEntry", trackerProperty);
1095
- toggleNotification({
1096
- type: "success",
1097
- message: formatMessage({
1098
- id: getTranslation("success.record.save"),
1099
- defaultMessage: "Saved document"
1100
- })
1101
- });
1102
- return res.data;
1103
- } catch (err) {
1104
- trackUsage("didNotEditEntry", { error: err, ...trackerProperty });
1105
- toggleNotification({
1106
- type: "danger",
1107
- message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
1108
- });
1109
- throw err;
1175
+ throw error2;
1110
1176
  }
1111
1177
  },
1112
- [trackUsage, updateDocument, toggleNotification, formatMessage, formatAPIError]
1178
+ [validationSchema]
1113
1179
  );
1114
- const [unpublishDocument] = useUnpublishDocumentMutation();
1115
- const unpublish = React__namespace.useCallback(
1116
- async ({ collectionType, model, documentId, params }, discardDraft = false) => {
1180
+ const isLoading = isLoadingDocument || isFetchingDocument || isLoadingSchema;
1181
+ const hasError = !!error;
1182
+ return {
1183
+ components,
1184
+ document: data?.data,
1185
+ meta: data?.meta,
1186
+ isLoading,
1187
+ hasError,
1188
+ schema,
1189
+ schemas,
1190
+ validate
1191
+ };
1192
+ };
1193
+ const useDoc = () => {
1194
+ const { id, slug, collectionType, origin } = reactRouterDom.useParams();
1195
+ const [{ query }] = strapiAdmin.useQueryParams();
1196
+ const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
1197
+ if (!collectionType) {
1198
+ throw new Error("Could not find collectionType in url params");
1199
+ }
1200
+ if (!slug) {
1201
+ throw new Error("Could not find model in url params");
1202
+ }
1203
+ const document = useDocument(
1204
+ { documentId: origin || id, model: slug, collectionType, params },
1205
+ {
1206
+ skip: id === "create" || !origin && !id && collectionType !== SINGLE_TYPES
1207
+ }
1208
+ );
1209
+ const returnId = origin || id === "create" ? void 0 : id;
1210
+ return {
1211
+ collectionType,
1212
+ model: slug,
1213
+ id: returnId,
1214
+ ...document
1215
+ };
1216
+ };
1217
+ const useContentManagerContext = () => {
1218
+ const {
1219
+ collectionType,
1220
+ model,
1221
+ id,
1222
+ components,
1223
+ isLoading: isLoadingDoc,
1224
+ schema,
1225
+ schemas
1226
+ } = useDoc();
1227
+ const layout = useDocumentLayout(model);
1228
+ const form = strapiAdmin.useForm("useContentManagerContext", (state) => state);
1229
+ const isSingleType = collectionType === SINGLE_TYPES;
1230
+ const slug = model;
1231
+ const isCreatingEntry = id === "create";
1232
+ useContentTypeSchema();
1233
+ const isLoading = isLoadingDoc || layout.isLoading;
1234
+ const error = layout.error;
1235
+ return {
1236
+ error,
1237
+ isLoading,
1238
+ // Base metadata
1239
+ model,
1240
+ collectionType,
1241
+ id,
1242
+ slug,
1243
+ isCreatingEntry,
1244
+ isSingleType,
1245
+ hasDraftAndPublish: schema?.options?.draftAndPublish ?? false,
1246
+ // All schema infos
1247
+ components,
1248
+ contentType: schema,
1249
+ contentTypes: schemas,
1250
+ // Form state
1251
+ form,
1252
+ // layout infos
1253
+ layout
1254
+ };
1255
+ };
1256
+ const prefixPluginTranslations = (trad, pluginId) => {
1257
+ return Object.keys(trad).reduce((acc, current) => {
1258
+ acc[`${pluginId}.${current}`] = trad[current];
1259
+ return acc;
1260
+ }, {});
1261
+ };
1262
+ const getTranslation = (id) => `content-manager.${id}`;
1263
+ const DEFAULT_UNEXPECTED_ERROR_MSG = {
1264
+ id: "notification.error",
1265
+ defaultMessage: "An error occurred, please try again"
1266
+ };
1267
+ const useDocumentActions = () => {
1268
+ const { toggleNotification } = strapiAdmin.useNotification();
1269
+ const { formatMessage } = reactIntl.useIntl();
1270
+ const { trackUsage } = strapiAdmin.useTracking();
1271
+ const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
1272
+ const navigate = reactRouterDom.useNavigate();
1273
+ const setCurrentStep = strapiAdmin.useGuidedTour("useDocumentActions", (state) => state.setCurrentStep);
1274
+ const [deleteDocument] = useDeleteDocumentMutation();
1275
+ const _delete = React__namespace.useCallback(
1276
+ async ({ collectionType, model, documentId, params }, trackerProperty) => {
1117
1277
  try {
1118
- trackUsage("willUnpublishEntry");
1119
- const res = await unpublishDocument({
1278
+ trackUsage("willDeleteEntry", trackerProperty);
1279
+ const res = await deleteDocument({
1120
1280
  collectionType,
1121
1281
  model,
1122
1282
  documentId,
1123
- params,
1124
- data: {
1125
- discardDraft
1126
- }
1283
+ params
1127
1284
  });
1128
1285
  if ("error" in res) {
1129
- toggleNotification({ type: "danger", message: formatAPIError(res.error) });
1286
+ toggleNotification({
1287
+ type: "danger",
1288
+ message: formatAPIError(res.error)
1289
+ });
1130
1290
  return { error: res.error };
1131
1291
  }
1132
- trackUsage("didUnpublishEntry");
1133
1292
  toggleNotification({
1134
1293
  type: "success",
1135
1294
  message: formatMessage({
1136
- id: getTranslation("success.record.unpublish"),
1137
- defaultMessage: "Unpublished document"
1295
+ id: getTranslation("success.record.delete"),
1296
+ defaultMessage: "Deleted document"
1138
1297
  })
1139
1298
  });
1299
+ trackUsage("didDeleteEntry", trackerProperty);
1140
1300
  return res.data;
1141
1301
  } catch (err) {
1142
1302
  toggleNotification({
1143
1303
  type: "danger",
1144
1304
  message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
1145
1305
  });
1306
+ trackUsage("didNotDeleteEntry", { error: err, ...trackerProperty });
1146
1307
  throw err;
1147
1308
  }
1148
1309
  },
1149
- [trackUsage, unpublishDocument, toggleNotification, formatMessage, formatAPIError]
1310
+ [trackUsage, deleteDocument, toggleNotification, formatMessage, formatAPIError]
1150
1311
  );
1151
- const [unpublishManyDocuments] = useUnpublishManyDocumentsMutation();
1152
- const unpublishMany = React__namespace.useCallback(
1312
+ const [deleteManyDocuments] = useDeleteManyDocumentsMutation();
1313
+ const deleteMany = React__namespace.useCallback(
1153
1314
  async ({ model, documentIds, params }) => {
1154
1315
  try {
1155
- trackUsage("willBulkUnpublishEntries");
1156
- const res = await unpublishManyDocuments({
1316
+ trackUsage("willBulkDeleteEntries");
1317
+ const res = await deleteManyDocuments({
1157
1318
  model,
1158
1319
  documentIds,
1159
1320
  params
1160
1321
  });
1161
1322
  if ("error" in res) {
1162
- toggleNotification({ type: "danger", message: formatAPIError(res.error) });
1323
+ toggleNotification({
1324
+ type: "danger",
1325
+ message: formatAPIError(res.error)
1326
+ });
1163
1327
  return { error: res.error };
1164
1328
  }
1165
- trackUsage("didBulkUnpublishEntries");
1166
1329
  toggleNotification({
1167
1330
  type: "success",
1168
1331
  title: formatMessage({
1169
- id: getTranslation("success.records.unpublish"),
1170
- defaultMessage: "Successfully unpublished."
1332
+ id: getTranslation("success.records.delete"),
1333
+ defaultMessage: "Successfully deleted."
1171
1334
  }),
1172
1335
  message: ""
1173
1336
  });
1337
+ trackUsage("didBulkDeleteEntries");
1174
1338
  return res.data;
1175
1339
  } catch (err) {
1176
1340
  toggleNotification({
1177
1341
  type: "danger",
1178
1342
  message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
1179
1343
  });
1180
- trackUsage("didNotBulkUnpublishEntries");
1344
+ trackUsage("didNotBulkDeleteEntries");
1181
1345
  throw err;
1182
1346
  }
1183
1347
  },
1184
- [trackUsage, unpublishManyDocuments, toggleNotification, formatMessage, formatAPIError]
1348
+ [trackUsage, deleteManyDocuments, toggleNotification, formatMessage, formatAPIError]
1185
1349
  );
1186
- const [createDocument] = useCreateDocumentMutation();
1187
- const create = React__namespace.useCallback(
1188
- async ({ model, params }, data, trackerProperty) => {
1350
+ const [discardDocument] = useDiscardDocumentMutation();
1351
+ const discard = React__namespace.useCallback(
1352
+ async ({ collectionType, model, documentId, params }) => {
1189
1353
  try {
1190
- const res = await createDocument({
1354
+ const res = await discardDocument({
1355
+ collectionType,
1191
1356
  model,
1192
- data,
1357
+ documentId,
1193
1358
  params
1194
1359
  });
1195
1360
  if ("error" in res) {
1196
- toggleNotification({ type: "danger", message: formatAPIError(res.error) });
1197
- trackUsage("didNotCreateEntry", { error: res.error, ...trackerProperty });
1361
+ toggleNotification({
1362
+ type: "danger",
1363
+ message: formatAPIError(res.error)
1364
+ });
1198
1365
  return { error: res.error };
1199
1366
  }
1200
- trackUsage("didCreateEntry", trackerProperty);
1201
1367
  toggleNotification({
1202
1368
  type: "success",
1203
1369
  message: formatMessage({
1204
- id: getTranslation("success.record.save"),
1370
+ id: "content-manager.success.record.discard",
1371
+ defaultMessage: "Changes discarded"
1372
+ })
1373
+ });
1374
+ return res.data;
1375
+ } catch (err) {
1376
+ toggleNotification({
1377
+ type: "danger",
1378
+ message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
1379
+ });
1380
+ throw err;
1381
+ }
1382
+ },
1383
+ [discardDocument, formatAPIError, formatMessage, toggleNotification]
1384
+ );
1385
+ const [publishDocument] = usePublishDocumentMutation();
1386
+ const publish = React__namespace.useCallback(
1387
+ async ({ collectionType, model, documentId, params }, data) => {
1388
+ try {
1389
+ trackUsage("willPublishEntry");
1390
+ const res = await publishDocument({
1391
+ collectionType,
1392
+ model,
1393
+ documentId,
1394
+ data,
1395
+ params
1396
+ });
1397
+ if ("error" in res) {
1398
+ toggleNotification({ type: "danger", message: formatAPIError(res.error) });
1399
+ return { error: res.error };
1400
+ }
1401
+ trackUsage("didPublishEntry");
1402
+ toggleNotification({
1403
+ type: "success",
1404
+ message: formatMessage({
1405
+ id: getTranslation("success.record.publish"),
1406
+ defaultMessage: "Published document"
1407
+ })
1408
+ });
1409
+ return res.data;
1410
+ } catch (err) {
1411
+ toggleNotification({
1412
+ type: "danger",
1413
+ message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
1414
+ });
1415
+ throw err;
1416
+ }
1417
+ },
1418
+ [trackUsage, publishDocument, toggleNotification, formatMessage, formatAPIError]
1419
+ );
1420
+ const [publishManyDocuments] = usePublishManyDocumentsMutation();
1421
+ const publishMany = React__namespace.useCallback(
1422
+ async ({ model, documentIds, params }) => {
1423
+ try {
1424
+ const res = await publishManyDocuments({
1425
+ model,
1426
+ documentIds,
1427
+ params
1428
+ });
1429
+ if ("error" in res) {
1430
+ toggleNotification({ type: "danger", message: formatAPIError(res.error) });
1431
+ return { error: res.error };
1432
+ }
1433
+ toggleNotification({
1434
+ type: "success",
1435
+ message: formatMessage({
1436
+ id: getTranslation("success.record.publish"),
1437
+ defaultMessage: "Published document"
1438
+ })
1439
+ });
1440
+ return res.data;
1441
+ } catch (err) {
1442
+ toggleNotification({
1443
+ type: "danger",
1444
+ message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
1445
+ });
1446
+ throw err;
1447
+ }
1448
+ },
1449
+ [
1450
+ // trackUsage,
1451
+ publishManyDocuments,
1452
+ toggleNotification,
1453
+ formatMessage,
1454
+ formatAPIError
1455
+ ]
1456
+ );
1457
+ const [updateDocument] = useUpdateDocumentMutation();
1458
+ const update = React__namespace.useCallback(
1459
+ async ({ collectionType, model, documentId, params }, data, trackerProperty) => {
1460
+ try {
1461
+ trackUsage("willEditEntry", trackerProperty);
1462
+ const res = await updateDocument({
1463
+ collectionType,
1464
+ model,
1465
+ documentId,
1466
+ data,
1467
+ params
1468
+ });
1469
+ if ("error" in res) {
1470
+ toggleNotification({ type: "danger", message: formatAPIError(res.error) });
1471
+ trackUsage("didNotEditEntry", { error: res.error, ...trackerProperty });
1472
+ return { error: res.error };
1473
+ }
1474
+ trackUsage("didEditEntry", trackerProperty);
1475
+ toggleNotification({
1476
+ type: "success",
1477
+ message: formatMessage({
1478
+ id: getTranslation("success.record.save"),
1479
+ defaultMessage: "Saved document"
1480
+ })
1481
+ });
1482
+ return res.data;
1483
+ } catch (err) {
1484
+ trackUsage("didNotEditEntry", { error: err, ...trackerProperty });
1485
+ toggleNotification({
1486
+ type: "danger",
1487
+ message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
1488
+ });
1489
+ throw err;
1490
+ }
1491
+ },
1492
+ [trackUsage, updateDocument, toggleNotification, formatMessage, formatAPIError]
1493
+ );
1494
+ const [unpublishDocument] = useUnpublishDocumentMutation();
1495
+ const unpublish = React__namespace.useCallback(
1496
+ async ({ collectionType, model, documentId, params }, discardDraft = false) => {
1497
+ try {
1498
+ trackUsage("willUnpublishEntry");
1499
+ const res = await unpublishDocument({
1500
+ collectionType,
1501
+ model,
1502
+ documentId,
1503
+ params,
1504
+ data: {
1505
+ discardDraft
1506
+ }
1507
+ });
1508
+ if ("error" in res) {
1509
+ toggleNotification({ type: "danger", message: formatAPIError(res.error) });
1510
+ return { error: res.error };
1511
+ }
1512
+ trackUsage("didUnpublishEntry");
1513
+ toggleNotification({
1514
+ type: "success",
1515
+ message: formatMessage({
1516
+ id: getTranslation("success.record.unpublish"),
1517
+ defaultMessage: "Unpublished document"
1518
+ })
1519
+ });
1520
+ return res.data;
1521
+ } catch (err) {
1522
+ toggleNotification({
1523
+ type: "danger",
1524
+ message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
1525
+ });
1526
+ throw err;
1527
+ }
1528
+ },
1529
+ [trackUsage, unpublishDocument, toggleNotification, formatMessage, formatAPIError]
1530
+ );
1531
+ const [unpublishManyDocuments] = useUnpublishManyDocumentsMutation();
1532
+ const unpublishMany = React__namespace.useCallback(
1533
+ async ({ model, documentIds, params }) => {
1534
+ try {
1535
+ trackUsage("willBulkUnpublishEntries");
1536
+ const res = await unpublishManyDocuments({
1537
+ model,
1538
+ documentIds,
1539
+ params
1540
+ });
1541
+ if ("error" in res) {
1542
+ toggleNotification({ type: "danger", message: formatAPIError(res.error) });
1543
+ return { error: res.error };
1544
+ }
1545
+ trackUsage("didBulkUnpublishEntries");
1546
+ toggleNotification({
1547
+ type: "success",
1548
+ title: formatMessage({
1549
+ id: getTranslation("success.records.unpublish"),
1550
+ defaultMessage: "Successfully unpublished."
1551
+ }),
1552
+ message: ""
1553
+ });
1554
+ return res.data;
1555
+ } catch (err) {
1556
+ toggleNotification({
1557
+ type: "danger",
1558
+ message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
1559
+ });
1560
+ trackUsage("didNotBulkUnpublishEntries");
1561
+ throw err;
1562
+ }
1563
+ },
1564
+ [trackUsage, unpublishManyDocuments, toggleNotification, formatMessage, formatAPIError]
1565
+ );
1566
+ const [createDocument] = useCreateDocumentMutation();
1567
+ const create = React__namespace.useCallback(
1568
+ async ({ model, params }, data, trackerProperty) => {
1569
+ try {
1570
+ const res = await createDocument({
1571
+ model,
1572
+ data,
1573
+ params
1574
+ });
1575
+ if ("error" in res) {
1576
+ toggleNotification({ type: "danger", message: formatAPIError(res.error) });
1577
+ trackUsage("didNotCreateEntry", { error: res.error, ...trackerProperty });
1578
+ return { error: res.error };
1579
+ }
1580
+ trackUsage("didCreateEntry", trackerProperty);
1581
+ toggleNotification({
1582
+ type: "success",
1583
+ message: formatMessage({
1584
+ id: getTranslation("success.record.save"),
1205
1585
  defaultMessage: "Saved document"
1206
1586
  })
1207
1587
  });
1588
+ setCurrentStep("contentManager.success");
1208
1589
  return res.data;
1209
1590
  } catch (err) {
1210
1591
  toggleNotification({
@@ -1244,7 +1625,7 @@ const useDocumentActions = () => {
1244
1625
  throw err;
1245
1626
  }
1246
1627
  },
1247
- [autoCloneDocument, formatAPIError, formatMessage, toggleNotification]
1628
+ [autoCloneDocument, formatMessage, toggleNotification]
1248
1629
  );
1249
1630
  const [cloneDocument] = useCloneDocumentMutation();
1250
1631
  const clone = React__namespace.useCallback(
@@ -1270,6 +1651,7 @@ const useDocumentActions = () => {
1270
1651
  defaultMessage: "Cloned document"
1271
1652
  })
1272
1653
  });
1654
+ navigate(`../../${res.data.data.documentId}`, { relative: "path" });
1273
1655
  return res.data;
1274
1656
  } catch (err) {
1275
1657
  toggleNotification({
@@ -1280,7 +1662,7 @@ const useDocumentActions = () => {
1280
1662
  throw err;
1281
1663
  }
1282
1664
  },
1283
- [cloneDocument, trackUsage, toggleNotification, formatMessage, formatAPIError]
1665
+ [cloneDocument, trackUsage, toggleNotification, formatMessage, formatAPIError, navigate]
1284
1666
  );
1285
1667
  const [getDoc] = useLazyGetDocumentQuery();
1286
1668
  const getDocument = React__namespace.useCallback(
@@ -1305,10 +1687,10 @@ const useDocumentActions = () => {
1305
1687
  update
1306
1688
  };
1307
1689
  };
1308
- const ProtectedHistoryPage = React.lazy(
1309
- () => Promise.resolve().then(() => require("./History-D4U2YISB.js")).then((mod) => ({ default: mod.ProtectedHistoryPage }))
1690
+ const ProtectedHistoryPage = React__namespace.lazy(
1691
+ () => Promise.resolve().then(() => require("./History-C1TKAig-.js")).then((mod) => ({ default: mod.ProtectedHistoryPage }))
1310
1692
  );
1311
- const routes$1 = [
1693
+ const routes$2 = [
1312
1694
  {
1313
1695
  path: ":collectionType/:slug/:id/history",
1314
1696
  Component: ProtectedHistoryPage
@@ -1318,32 +1700,45 @@ const routes$1 = [
1318
1700
  Component: ProtectedHistoryPage
1319
1701
  }
1320
1702
  ];
1703
+ const ProtectedPreviewPage = React__namespace.lazy(
1704
+ () => Promise.resolve().then(() => require("./Preview-B7LyGT_b.js")).then((mod) => ({ default: mod.ProtectedPreviewPage }))
1705
+ );
1706
+ const routes$1 = [
1707
+ {
1708
+ path: ":collectionType/:slug/:id/preview",
1709
+ Component: ProtectedPreviewPage
1710
+ },
1711
+ {
1712
+ path: ":collectionType/:slug/preview",
1713
+ Component: ProtectedPreviewPage
1714
+ }
1715
+ ];
1321
1716
  const ProtectedEditViewPage = React.lazy(
1322
- () => Promise.resolve().then(() => require("./EditViewPage-BSVmMpRd.js")).then((mod) => ({ default: mod.ProtectedEditViewPage }))
1717
+ () => Promise.resolve().then(() => require("./EditViewPage-BRewdTqE.js")).then((mod) => ({ default: mod.ProtectedEditViewPage }))
1323
1718
  );
1324
1719
  const ProtectedListViewPage = React.lazy(
1325
- () => Promise.resolve().then(() => require("./ListViewPage-O8F1pBJo.js")).then((mod) => ({ default: mod.ProtectedListViewPage }))
1720
+ () => Promise.resolve().then(() => require("./ListViewPage-xv5IQoZp.js")).then((mod) => ({ default: mod.ProtectedListViewPage }))
1326
1721
  );
1327
1722
  const ProtectedListConfiguration = React.lazy(
1328
- () => Promise.resolve().then(() => require("./ListConfigurationPage-Bny6CdWe.js")).then((mod) => ({
1723
+ () => Promise.resolve().then(() => require("./ListConfigurationPage-D-NGRLYu.js")).then((mod) => ({
1329
1724
  default: mod.ProtectedListConfiguration
1330
1725
  }))
1331
1726
  );
1332
1727
  const ProtectedEditConfigurationPage = React.lazy(
1333
- () => Promise.resolve().then(() => require("./EditConfigurationPage-CMaOf-A-.js")).then((mod) => ({
1728
+ () => Promise.resolve().then(() => require("./EditConfigurationPage-CxRlP5if.js")).then((mod) => ({
1334
1729
  default: mod.ProtectedEditConfigurationPage
1335
1730
  }))
1336
1731
  );
1337
1732
  const ProtectedComponentConfigurationPage = React.lazy(
1338
- () => Promise.resolve().then(() => require("./ComponentConfigurationPage-DL1MHO8i.js")).then((mod) => ({
1733
+ () => Promise.resolve().then(() => require("./ComponentConfigurationPage-DywpTZeV.js")).then((mod) => ({
1339
1734
  default: mod.ProtectedComponentConfigurationPage
1340
1735
  }))
1341
1736
  );
1342
1737
  const NoPermissions = React.lazy(
1343
- () => Promise.resolve().then(() => require("./NoPermissionsPage-CY46zxnM.js")).then((mod) => ({ default: mod.NoPermissions }))
1738
+ () => Promise.resolve().then(() => require("./NoPermissionsPage-DAe5CDCC.js")).then((mod) => ({ default: mod.NoPermissions }))
1344
1739
  );
1345
1740
  const NoContentType = React.lazy(
1346
- () => Promise.resolve().then(() => require("./NoContentTypePage-CQWChGPw.js")).then((mod) => ({ default: mod.NoContentType }))
1741
+ () => Promise.resolve().then(() => require("./NoContentTypePage-Dzw5Yj5u.js")).then((mod) => ({ default: mod.NoContentType }))
1347
1742
  );
1348
1743
  const CollectionTypePages = () => {
1349
1744
  const { collectionType } = reactRouterDom.useParams();
@@ -1355,7 +1750,7 @@ const CollectionTypePages = () => {
1355
1750
  const CLONE_RELATIVE_PATH = ":collectionType/:slug/clone/:origin";
1356
1751
  const CLONE_PATH = `/content-manager/${CLONE_RELATIVE_PATH}`;
1357
1752
  const LIST_RELATIVE_PATH = ":collectionType/:slug";
1358
- const LIST_PATH = `/content-manager/${LIST_RELATIVE_PATH}`;
1753
+ const LIST_PATH = `/content-manager/collection-types/:slug`;
1359
1754
  const routes = [
1360
1755
  {
1361
1756
  path: LIST_RELATIVE_PATH,
@@ -1389,6 +1784,7 @@ const routes = [
1389
1784
  path: "no-content-types",
1390
1785
  Component: NoContentType
1391
1786
  },
1787
+ ...routes$2,
1392
1788
  ...routes$1
1393
1789
  ];
1394
1790
  const DocumentActions = ({ actions: actions2 }) => {
@@ -1463,6 +1859,8 @@ const DocumentActionButton = (action) => {
1463
1859
  onClick: handleClick(action),
1464
1860
  justifyContent: "center",
1465
1861
  variant: action.variant || "default",
1862
+ paddingTop: "7px",
1863
+ paddingBottom: "7px",
1466
1864
  children: action.label
1467
1865
  }
1468
1866
  ),
@@ -1485,6 +1883,11 @@ const DocumentActionButton = (action) => {
1485
1883
  ) : null
1486
1884
  ] });
1487
1885
  };
1886
+ const MenuItem = styledComponents.styled(designSystem.Menu.Item)`
1887
+ &:hover {
1888
+ background: ${({ theme, isVariantDanger, isDisabled }) => isVariantDanger && !isDisabled ? theme.colors.danger100 : "neutral"};
1889
+ }
1890
+ `;
1488
1891
  const DocumentActionsMenu = ({
1489
1892
  actions: actions2,
1490
1893
  children,
@@ -1540,44 +1943,35 @@ const DocumentActionsMenu = ({
1540
1943
  ]
1541
1944
  }
1542
1945
  ),
1543
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.Content, { top: "4px", maxHeight: void 0, popoverPlacement: "bottom-end", children: [
1946
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.Content, { maxHeight: void 0, popoverPlacement: "bottom-end", children: [
1544
1947
  actions2.map((action) => {
1545
1948
  return /* @__PURE__ */ jsxRuntime.jsx(
1546
- designSystem.Menu.Item,
1949
+ MenuItem,
1547
1950
  {
1548
1951
  disabled: action.disabled,
1549
1952
  onSelect: handleClick(action),
1550
1953
  display: "block",
1551
- children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", gap: 4, children: [
1552
- /* @__PURE__ */ jsxRuntime.jsxs(
1553
- designSystem.Flex,
1554
- {
1555
- color: !action.disabled ? convertActionVariantToColor(action.variant) : "inherit",
1556
- gap: 2,
1557
- tag: "span",
1558
- children: [
1559
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: action.icon }),
1560
- action.label
1561
- ]
1562
- }
1563
- ),
1564
- action.id.startsWith("HistoryAction") && /* @__PURE__ */ jsxRuntime.jsx(
1565
- designSystem.Flex,
1566
- {
1567
- alignItems: "center",
1568
- background: "alternative100",
1569
- borderStyle: "solid",
1570
- borderColor: "alternative200",
1571
- borderWidth: "1px",
1572
- height: 5,
1573
- paddingLeft: 2,
1574
- paddingRight: 2,
1575
- hasRadius: true,
1576
- color: "alternative600",
1577
- children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", fontWeight: "bold", lineHeight: 1, children: formatMessage({ id: "global.new", defaultMessage: "New" }) })
1578
- }
1579
- )
1580
- ] })
1954
+ isVariantDanger: action.variant === "danger",
1955
+ isDisabled: action.disabled,
1956
+ children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "space-between", gap: 4, children: /* @__PURE__ */ jsxRuntime.jsxs(
1957
+ designSystem.Flex,
1958
+ {
1959
+ color: !action.disabled ? convertActionVariantToColor(action.variant) : "inherit",
1960
+ gap: 2,
1961
+ tag: "span",
1962
+ children: [
1963
+ /* @__PURE__ */ jsxRuntime.jsx(
1964
+ designSystem.Flex,
1965
+ {
1966
+ tag: "span",
1967
+ color: !action.disabled ? convertActionVariantToIconColor(action.variant) : "inherit",
1968
+ children: action.icon
1969
+ }
1970
+ ),
1971
+ action.label
1972
+ ]
1973
+ }
1974
+ ) })
1581
1975
  },
1582
1976
  action.id
1583
1977
  );
@@ -1619,6 +2013,18 @@ const convertActionVariantToColor = (variant = "secondary") => {
1619
2013
  return "primary600";
1620
2014
  }
1621
2015
  };
2016
+ const convertActionVariantToIconColor = (variant = "secondary") => {
2017
+ switch (variant) {
2018
+ case "danger":
2019
+ return "danger600";
2020
+ case "secondary":
2021
+ return "neutral500";
2022
+ case "success":
2023
+ return "success600";
2024
+ default:
2025
+ return "primary600";
2026
+ }
2027
+ };
1622
2028
  const DocumentActionConfirmDialog = ({
1623
2029
  onClose,
1624
2030
  onCancel,
@@ -1645,11 +2051,11 @@ const DocumentActionConfirmDialog = ({
1645
2051
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Header, { children: title }),
1646
2052
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Body, { children: content }),
1647
2053
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Footer, { children: [
1648
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Cancel, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", children: formatMessage({
2054
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Cancel, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", fullWidth: true, children: formatMessage({
1649
2055
  id: "app.components.Button.cancel",
1650
2056
  defaultMessage: "Cancel"
1651
2057
  }) }) }),
1652
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: handleConfirm, variant, children: formatMessage({
2058
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: handleConfirm, variant, fullWidth: true, children: formatMessage({
1653
2059
  id: "app.components.Button.confirm",
1654
2060
  defaultMessage: "Confirm"
1655
2061
  }) })
@@ -1676,6 +2082,18 @@ const DocumentActionModal = ({
1676
2082
  typeof Footer === "function" ? /* @__PURE__ */ jsxRuntime.jsx(Footer, { onClose: handleClose }) : Footer
1677
2083
  ] }) });
1678
2084
  };
2085
+ const transformData = (data) => {
2086
+ if (Array.isArray(data)) {
2087
+ return data.map(transformData);
2088
+ }
2089
+ if (typeof data === "object" && data !== null) {
2090
+ if ("apiData" in data) {
2091
+ return data.apiData;
2092
+ }
2093
+ return mapValues__default.default(transformData)(data);
2094
+ }
2095
+ return data;
2096
+ };
1679
2097
  const PublishAction$1 = ({
1680
2098
  activeTab,
1681
2099
  documentId,
@@ -1688,12 +2106,11 @@ const PublishAction$1 = ({
1688
2106
  const navigate = reactRouterDom.useNavigate();
1689
2107
  const { toggleNotification } = strapiAdmin.useNotification();
1690
2108
  const { _unstableFormatValidationErrors: formatValidationErrors } = strapiAdmin.useAPIErrorHandler();
2109
+ const isListView = reactRouterDom.useMatch(LIST_PATH) !== null;
1691
2110
  const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
2111
+ const { id } = reactRouterDom.useParams();
1692
2112
  const { formatMessage } = reactIntl.useIntl();
1693
- const { canPublish, canCreate, canUpdate } = useDocumentRBAC(
1694
- "PublishAction",
1695
- ({ canPublish: canPublish2, canCreate: canCreate2, canUpdate: canUpdate2 }) => ({ canPublish: canPublish2, canCreate: canCreate2, canUpdate: canUpdate2 })
1696
- );
2113
+ const canPublish = useDocumentRBAC("PublishAction", ({ canPublish: canPublish2 }) => canPublish2);
1697
2114
  const { publish } = useDocumentActions();
1698
2115
  const [
1699
2116
  countDraftRelations,
@@ -1745,32 +2162,35 @@ const PublishAction$1 = ({
1745
2162
  }
1746
2163
  }, [documentId, modified, formValues, setLocalCountOfDraftRelations]);
1747
2164
  React__namespace.useEffect(() => {
1748
- if (documentId) {
1749
- const fetchDraftRelationsCount = async () => {
1750
- const { data, error } = await countDraftRelations({
1751
- collectionType,
1752
- model,
1753
- documentId,
1754
- params
1755
- });
1756
- if (error) {
1757
- throw error;
1758
- }
1759
- if (data) {
1760
- setServerCountOfDraftRelations(data.data);
1761
- }
1762
- };
1763
- fetchDraftRelationsCount();
2165
+ if (!document || !document.documentId || isListView) {
2166
+ return;
1764
2167
  }
1765
- }, [documentId, countDraftRelations, collectionType, model, params]);
1766
- const isDocumentPublished = (document?.[PUBLISHED_AT_ATTRIBUTE_NAME] || meta?.availableStatus.some((doc) => doc[PUBLISHED_AT_ATTRIBUTE_NAME] !== null)) && document?.status !== "modified";
2168
+ const fetchDraftRelationsCount = async () => {
2169
+ const { data, error } = await countDraftRelations({
2170
+ collectionType,
2171
+ model,
2172
+ documentId,
2173
+ params
2174
+ });
2175
+ if (error) {
2176
+ throw error;
2177
+ }
2178
+ if (data) {
2179
+ setServerCountOfDraftRelations(data.data);
2180
+ }
2181
+ };
2182
+ fetchDraftRelationsCount();
2183
+ }, [isListView, document, documentId, countDraftRelations, collectionType, model, params]);
2184
+ const isDocumentPublished = (document?.[PUBLISHED_AT_ATTRIBUTE_NAME] || meta?.availableStatus.some((doc) => doc[PUBLISHED_AT_ATTRIBUTE_NAME] !== null)) && document?.status !== "modified";
1767
2185
  if (!schema?.options?.draftAndPublish) {
1768
2186
  return null;
1769
2187
  }
1770
2188
  const performPublish = async () => {
1771
2189
  setSubmitting(true);
1772
2190
  try {
1773
- const { errors } = await validate();
2191
+ const { errors } = await validate(true, {
2192
+ status: "published"
2193
+ });
1774
2194
  if (errors) {
1775
2195
  toggleNotification({
1776
2196
  type: "danger",
@@ -1788,13 +2208,15 @@ const PublishAction$1 = ({
1788
2208
  documentId,
1789
2209
  params
1790
2210
  },
1791
- formValues
2211
+ transformData(formValues)
1792
2212
  );
1793
2213
  if ("data" in res && collectionType !== SINGLE_TYPES) {
1794
- navigate({
1795
- pathname: `../${collectionType}/${model}/${res.data.documentId}`,
1796
- search: rawQuery
1797
- });
2214
+ if (id === "create") {
2215
+ navigate({
2216
+ pathname: `../${collectionType}/${model}/${res.data.documentId}`,
2217
+ search: rawQuery
2218
+ });
2219
+ }
1798
2220
  } else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
1799
2221
  setErrors(formatValidationErrors(res.error));
1800
2222
  }
@@ -1803,7 +2225,8 @@ const PublishAction$1 = ({
1803
2225
  }
1804
2226
  };
1805
2227
  const totalDraftRelations = localCountOfDraftRelations + serverCountOfDraftRelations;
1806
- const hasDraftRelations = totalDraftRelations > 0;
2228
+ const enableDraftRelationsCount = false;
2229
+ const hasDraftRelations = enableDraftRelationsCount;
1807
2230
  return {
1808
2231
  /**
1809
2232
  * Disabled when:
@@ -1820,9 +2243,6 @@ const PublishAction$1 = ({
1820
2243
  defaultMessage: "Publish"
1821
2244
  }),
1822
2245
  onClick: async () => {
1823
- if (hasDraftRelations) {
1824
- return;
1825
- }
1826
2246
  await performPublish();
1827
2247
  },
1828
2248
  dialog: hasDraftRelations ? {
@@ -1861,10 +2281,6 @@ const UpdateAction = ({
1861
2281
  const cloneMatch = reactRouterDom.useMatch(CLONE_PATH);
1862
2282
  const isCloning = cloneMatch !== null;
1863
2283
  const { formatMessage } = reactIntl.useIntl();
1864
- useDocumentRBAC("UpdateAction", ({ canCreate: canCreate2, canUpdate: canUpdate2 }) => ({
1865
- canCreate: canCreate2,
1866
- canUpdate: canUpdate2
1867
- }));
1868
2284
  const { create, update, clone } = useDocumentActions();
1869
2285
  const [{ query, rawQuery }] = strapiAdmin.useQueryParams();
1870
2286
  const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
@@ -1884,13 +2300,15 @@ const UpdateAction = ({
1884
2300
  */
1885
2301
  disabled: isSubmitting || !modified && !isCloning || activeTab === "published",
1886
2302
  label: formatMessage({
1887
- id: "content-manager.containers.Edit.save",
2303
+ id: "global.save",
1888
2304
  defaultMessage: "Save"
1889
2305
  }),
1890
2306
  onClick: async () => {
1891
2307
  setSubmitting(true);
1892
2308
  try {
1893
- const { errors } = await validate();
2309
+ const { errors } = await validate(true, {
2310
+ status: "draft"
2311
+ });
1894
2312
  if (errors) {
1895
2313
  toggleNotification({
1896
2314
  type: "danger",
@@ -1908,7 +2326,7 @@ const UpdateAction = ({
1908
2326
  documentId: cloneMatch.params.origin,
1909
2327
  params
1910
2328
  },
1911
- document
2329
+ transformData(document)
1912
2330
  );
1913
2331
  if ("data" in res) {
1914
2332
  navigate(
@@ -1929,7 +2347,7 @@ const UpdateAction = ({
1929
2347
  documentId,
1930
2348
  params
1931
2349
  },
1932
- document
2350
+ transformData(document)
1933
2351
  );
1934
2352
  if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
1935
2353
  setErrors(formatValidationErrors(res.error));
@@ -1942,7 +2360,7 @@ const UpdateAction = ({
1942
2360
  model,
1943
2361
  params
1944
2362
  },
1945
- document
2363
+ transformData(document)
1946
2364
  );
1947
2365
  if ("data" in res && collectionType !== SINGLE_TYPES) {
1948
2366
  navigate(
@@ -1995,7 +2413,7 @@ const UnpublishAction$1 = ({
1995
2413
  id: "app.utils.unpublish",
1996
2414
  defaultMessage: "Unpublish"
1997
2415
  }),
1998
- icon: /* @__PURE__ */ jsxRuntime.jsx(StyledCrossCircle, {}),
2416
+ icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Cross, {}),
1999
2417
  onClick: async () => {
2000
2418
  if (!documentId && collectionType !== SINGLE_TYPES || isDocumentModified) {
2001
2419
  if (!documentId) {
@@ -2107,7 +2525,7 @@ const DiscardAction = ({
2107
2525
  id: "content-manager.actions.discard.label",
2108
2526
  defaultMessage: "Discard changes"
2109
2527
  }),
2110
- icon: /* @__PURE__ */ jsxRuntime.jsx(StyledCrossCircle, {}),
2528
+ icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Cross, {}),
2111
2529
  position: ["panel", "table-row"],
2112
2530
  variant: "danger",
2113
2531
  dialog: {
@@ -2135,11 +2553,6 @@ const DiscardAction = ({
2135
2553
  };
2136
2554
  };
2137
2555
  DiscardAction.type = "discard";
2138
- const StyledCrossCircle = styledComponents.styled(Icons.CrossCircle)`
2139
- path {
2140
- fill: currentColor;
2141
- }
2142
- `;
2143
2556
  const DEFAULT_ACTIONS = [PublishAction$1, UpdateAction, UnpublishAction$1, DiscardAction];
2144
2557
  const intervals = ["years", "months", "days", "hours", "minutes", "seconds"];
2145
2558
  const RelativeTime = React__namespace.forwardRef(
@@ -2152,7 +2565,7 @@ const RelativeTime = React__namespace.forwardRef(
2152
2565
  });
2153
2566
  const unit = intervals.find((intervalUnit) => {
2154
2567
  return interval[intervalUnit] > 0 && Object.keys(interval).includes(intervalUnit);
2155
- });
2568
+ }) ?? "seconds";
2156
2569
  const relativeTime = dateFns.isPast(timestamp) ? -interval[unit] : interval[unit];
2157
2570
  const customInterval = customIntervals.find(
2158
2571
  (custom) => interval[custom.unit] < custom.threshold
@@ -2186,19 +2599,29 @@ const getDisplayName = ({
2186
2599
  return email ?? "";
2187
2600
  };
2188
2601
  const capitalise = (str) => str.charAt(0).toUpperCase() + str.slice(1);
2189
- const DocumentStatus = ({ status = "draft", ...restProps }) => {
2190
- const statusVariant = status === "draft" ? "primary" : status === "published" ? "success" : "alternative";
2191
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Status, { ...restProps, showBullet: false, size: "S", variant: statusVariant, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "span", variant: "omega", fontWeight: "bold", children: capitalise(status) }) });
2602
+ const DocumentStatus = ({ status = "draft", size = "S", ...restProps }) => {
2603
+ const statusVariant = status === "draft" ? "secondary" : status === "published" ? "success" : "alternative";
2604
+ const { formatMessage } = reactIntl.useIntl();
2605
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Status, { ...restProps, size, variant: statusVariant, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "span", variant: "omega", fontWeight: "bold", children: formatMessage({
2606
+ id: `content-manager.containers.List.${status}`,
2607
+ defaultMessage: capitalise(status)
2608
+ }) }) });
2192
2609
  };
2193
2610
  const Header = ({ isCreating, status, title: documentTitle = "Untitled" }) => {
2194
2611
  const { formatMessage } = reactIntl.useIntl();
2195
2612
  const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
2613
+ const params = reactRouterDom.useParams();
2196
2614
  const title = isCreating ? formatMessage({
2197
2615
  id: "content-manager.containers.edit.title.new",
2198
2616
  defaultMessage: "Create an entry"
2199
2617
  }) : documentTitle;
2200
2618
  return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", paddingTop: 6, paddingBottom: 4, gap: 2, children: [
2201
- /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.BackButton, {}),
2619
+ /* @__PURE__ */ jsxRuntime.jsx(
2620
+ strapiAdmin.BackButton,
2621
+ {
2622
+ fallback: params.collectionType === SINGLE_TYPES ? void 0 : `../${COLLECTION_TYPES}/${params.slug}`
2623
+ }
2624
+ ),
2202
2625
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { width: "100%", justifyContent: "space-between", gap: "80px", alignItems: "flex-start", children: [
2203
2626
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "alpha", tag: "h1", children: title }),
2204
2627
  /* @__PURE__ */ jsxRuntime.jsx(HeaderToolbar, {})
@@ -2286,12 +2709,12 @@ const Information = ({ activeTab }) => {
2286
2709
  isDisplayed: !!publishDocument?.[PUBLISHED_AT_ATTRIBUTE_NAME],
2287
2710
  label: formatMessage({
2288
2711
  id: "content-manager.containers.edit.information.last-published.label",
2289
- defaultMessage: "Last published"
2712
+ defaultMessage: "Published"
2290
2713
  }),
2291
2714
  value: formatMessage(
2292
2715
  {
2293
2716
  id: "content-manager.containers.edit.information.last-published.value",
2294
- defaultMessage: `Published {time}{isAnonymous, select, true {} other { by {author}}}`
2717
+ defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
2295
2718
  },
2296
2719
  {
2297
2720
  time: /* @__PURE__ */ jsxRuntime.jsx(RelativeTime, { timestamp: new Date(publishDocument?.[PUBLISHED_AT_ATTRIBUTE_NAME]) }),
@@ -2304,12 +2727,12 @@ const Information = ({ activeTab }) => {
2304
2727
  isDisplayed: !!createAndUpdateDocument?.[UPDATED_AT_ATTRIBUTE_NAME],
2305
2728
  label: formatMessage({
2306
2729
  id: "content-manager.containers.edit.information.last-draft.label",
2307
- defaultMessage: "Last draft"
2730
+ defaultMessage: "Updated"
2308
2731
  }),
2309
2732
  value: formatMessage(
2310
2733
  {
2311
2734
  id: "content-manager.containers.edit.information.last-draft.value",
2312
- defaultMessage: `Modified {time}{isAnonymous, select, true {} other { by {author}}}`
2735
+ defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
2313
2736
  },
2314
2737
  {
2315
2738
  time: /* @__PURE__ */ jsxRuntime.jsx(
@@ -2327,12 +2750,12 @@ const Information = ({ activeTab }) => {
2327
2750
  isDisplayed: !!createAndUpdateDocument?.[CREATED_AT_ATTRIBUTE_NAME],
2328
2751
  label: formatMessage({
2329
2752
  id: "content-manager.containers.edit.information.document.label",
2330
- defaultMessage: "Document"
2753
+ defaultMessage: "Created"
2331
2754
  }),
2332
2755
  value: formatMessage(
2333
2756
  {
2334
2757
  id: "content-manager.containers.edit.information.document.value",
2335
- defaultMessage: `Created {time}{isAnonymous, select, true {} other { by {author}}}`
2758
+ defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
2336
2759
  },
2337
2760
  {
2338
2761
  time: /* @__PURE__ */ jsxRuntime.jsx(
@@ -2370,25 +2793,77 @@ const Information = ({ activeTab }) => {
2370
2793
  );
2371
2794
  };
2372
2795
  const HeaderActions = ({ actions: actions2 }) => {
2373
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { children: actions2.map((action) => {
2374
- if ("options" in action) {
2796
+ const [dialogId, setDialogId] = React__namespace.useState(null);
2797
+ const handleClick = (action) => async (e) => {
2798
+ if (!("options" in action)) {
2799
+ const { onClick = () => false, dialog, id } = action;
2800
+ const muteDialog = await onClick(e);
2801
+ if (dialog && !muteDialog) {
2802
+ e.preventDefault();
2803
+ setDialogId(id);
2804
+ }
2805
+ }
2806
+ };
2807
+ const handleClose = () => {
2808
+ setDialogId(null);
2809
+ };
2810
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { gap: 1, children: actions2.map((action) => {
2811
+ if (action.options) {
2375
2812
  return /* @__PURE__ */ jsxRuntime.jsx(
2376
2813
  designSystem.SingleSelect,
2377
2814
  {
2378
2815
  size: "S",
2379
- disabled: action.disabled,
2380
- "aria-label": action.label,
2381
2816
  onChange: action.onSelect,
2382
- value: action.value,
2817
+ "aria-label": action.label,
2818
+ ...action,
2383
2819
  children: action.options.map(({ label, ...option }) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { ...option, children: label }, option.value))
2384
2820
  },
2385
2821
  action.id
2386
2822
  );
2387
2823
  } else {
2388
- return null;
2824
+ if (action.type === "icon") {
2825
+ return /* @__PURE__ */ jsxRuntime.jsxs(React__namespace.Fragment, { children: [
2826
+ /* @__PURE__ */ jsxRuntime.jsx(
2827
+ designSystem.IconButton,
2828
+ {
2829
+ disabled: action.disabled,
2830
+ label: action.label,
2831
+ size: "S",
2832
+ onClick: handleClick(action),
2833
+ children: action.icon
2834
+ }
2835
+ ),
2836
+ action.dialog ? /* @__PURE__ */ jsxRuntime.jsx(
2837
+ HeaderActionDialog,
2838
+ {
2839
+ ...action.dialog,
2840
+ isOpen: dialogId === action.id,
2841
+ onClose: handleClose
2842
+ }
2843
+ ) : null
2844
+ ] }, action.id);
2845
+ }
2389
2846
  }
2390
2847
  }) });
2391
2848
  };
2849
+ const HeaderActionDialog = ({
2850
+ onClose,
2851
+ onCancel,
2852
+ title,
2853
+ content: Content,
2854
+ isOpen
2855
+ }) => {
2856
+ const handleClose = async () => {
2857
+ if (onCancel) {
2858
+ await onCancel();
2859
+ }
2860
+ onClose();
2861
+ };
2862
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Root, { open: isOpen, onOpenChange: handleClose, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Content, { children: [
2863
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Header, { children: title }),
2864
+ typeof Content === "function" ? /* @__PURE__ */ jsxRuntime.jsx(Content, { onClose: handleClose }) : Content
2865
+ ] }) });
2866
+ };
2392
2867
  const ConfigureTheViewAction = ({ collectionType, model }) => {
2393
2868
  const navigate = reactRouterDom.useNavigate();
2394
2869
  const { formatMessage } = reactIntl.useIntl();
@@ -2429,12 +2904,16 @@ const DeleteAction$1 = ({ documentId, model, collectionType, document }) => {
2429
2904
  const { delete: deleteAction } = useDocumentActions();
2430
2905
  const { toggleNotification } = strapiAdmin.useNotification();
2431
2906
  const setSubmitting = strapiAdmin.useForm("DeleteAction", (state) => state.setSubmitting);
2907
+ const isLocalized = document?.locale != null;
2432
2908
  return {
2433
2909
  disabled: !canDelete || !document,
2434
- label: formatMessage({
2435
- id: "content-manager.actions.delete.label",
2436
- defaultMessage: "Delete document"
2437
- }),
2910
+ label: formatMessage(
2911
+ {
2912
+ id: "content-manager.actions.delete.label",
2913
+ defaultMessage: "Delete entry{isLocalized, select, true { (all locales)} other {}}"
2914
+ },
2915
+ { isLocalized }
2916
+ ),
2438
2917
  icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Trash, {}),
2439
2918
  dialog: {
2440
2919
  type: "dialog",
@@ -2474,419 +2953,117 @@ const DeleteAction$1 = ({ documentId, model, collectionType, document }) => {
2474
2953
  params: {
2475
2954
  locale: "*"
2476
2955
  }
2477
- });
2478
- if (!("error" in res)) {
2479
- navigate({ pathname: `../${collectionType}/${model}` }, { replace: true });
2480
- }
2481
- } finally {
2482
- if (!listViewPathMatch) {
2483
- setSubmitting(false);
2484
- }
2485
- }
2486
- }
2487
- },
2488
- variant: "danger",
2489
- position: ["header", "table-row"]
2490
- };
2491
- };
2492
- DeleteAction$1.type = "delete";
2493
- const DEFAULT_HEADER_ACTIONS = [EditTheModelAction, ConfigureTheViewAction, DeleteAction$1];
2494
- const Panels = () => {
2495
- const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
2496
- const [
2497
- {
2498
- query: { status }
2499
- }
2500
- ] = strapiAdmin.useQueryParams({
2501
- status: "draft"
2502
- });
2503
- const { model, id, document, meta, collectionType } = useDoc();
2504
- const plugins = strapiAdmin.useStrapiApp("Panels", (state) => state.plugins);
2505
- const props = {
2506
- activeTab: status,
2507
- model,
2508
- documentId: id,
2509
- document: isCloning ? void 0 : document,
2510
- meta: isCloning ? void 0 : meta,
2511
- collectionType
2512
- };
2513
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: /* @__PURE__ */ jsxRuntime.jsx(
2514
- strapiAdmin.DescriptionComponentRenderer,
2515
- {
2516
- props,
2517
- descriptions: plugins["content-manager"].apis.getEditViewSidePanels(),
2518
- children: (panels) => panels.map(({ content, id: id2, ...description }) => /* @__PURE__ */ jsxRuntime.jsx(Panel, { ...description, children: content }, id2))
2519
- }
2520
- ) });
2521
- };
2522
- const ActionsPanel = () => {
2523
- const { formatMessage } = reactIntl.useIntl();
2524
- return {
2525
- title: formatMessage({
2526
- id: "content-manager.containers.edit.panels.default.title",
2527
- defaultMessage: "Document"
2528
- }),
2529
- content: /* @__PURE__ */ jsxRuntime.jsx(ActionsPanelContent, {})
2530
- };
2531
- };
2532
- ActionsPanel.type = "actions";
2533
- const ActionsPanelContent = () => {
2534
- const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
2535
- const [
2536
- {
2537
- query: { status = "draft" }
2538
- }
2539
- ] = strapiAdmin.useQueryParams();
2540
- const { model, id, document, meta, collectionType } = useDoc();
2541
- const plugins = strapiAdmin.useStrapiApp("ActionsPanel", (state) => state.plugins);
2542
- const props = {
2543
- activeTab: status,
2544
- model,
2545
- documentId: id,
2546
- document: isCloning ? void 0 : document,
2547
- meta: isCloning ? void 0 : meta,
2548
- collectionType
2549
- };
2550
- return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 2, width: "100%", children: [
2551
- /* @__PURE__ */ jsxRuntime.jsx(
2552
- strapiAdmin.DescriptionComponentRenderer,
2553
- {
2554
- props,
2555
- descriptions: plugins["content-manager"].apis.getDocumentActions(),
2556
- children: (actions2) => /* @__PURE__ */ jsxRuntime.jsx(DocumentActions, { actions: actions2 })
2557
- }
2558
- ),
2559
- /* @__PURE__ */ jsxRuntime.jsx(InjectionZone, { area: "editView.right-links", slug: model })
2560
- ] });
2561
- };
2562
- const Panel = React__namespace.forwardRef(({ children, title }, ref) => {
2563
- return /* @__PURE__ */ jsxRuntime.jsxs(
2564
- designSystem.Flex,
2565
- {
2566
- ref,
2567
- tag: "aside",
2568
- "aria-labelledby": "additional-information",
2569
- background: "neutral0",
2570
- borderColor: "neutral150",
2571
- hasRadius: true,
2572
- paddingBottom: 4,
2573
- paddingLeft: 4,
2574
- paddingRight: 4,
2575
- paddingTop: 4,
2576
- shadow: "tableShadow",
2577
- gap: 3,
2578
- direction: "column",
2579
- justifyContent: "stretch",
2580
- alignItems: "flex-start",
2581
- children: [
2582
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "h2", variant: "sigma", textTransform: "uppercase", children: title }),
2583
- children
2584
- ]
2585
- }
2586
- );
2587
- });
2588
- const HOOKS = {
2589
- /**
2590
- * Hook that allows to mutate the displayed headers of the list view table
2591
- * @constant
2592
- * @type {string}
2593
- */
2594
- INJECT_COLUMN_IN_TABLE: "Admin/CM/pages/ListView/inject-column-in-table",
2595
- /**
2596
- * Hook that allows to mutate the CM's collection types links pre-set filters
2597
- * @constant
2598
- * @type {string}
2599
- */
2600
- MUTATE_COLLECTION_TYPES_LINKS: "Admin/CM/pages/App/mutate-collection-types-links",
2601
- /**
2602
- * Hook that allows to mutate the CM's edit view layout
2603
- * @constant
2604
- * @type {string}
2605
- */
2606
- MUTATE_EDIT_VIEW_LAYOUT: "Admin/CM/pages/EditView/mutate-edit-view-layout",
2607
- /**
2608
- * Hook that allows to mutate the CM's single types links pre-set filters
2609
- * @constant
2610
- * @type {string}
2611
- */
2612
- MUTATE_SINGLE_TYPES_LINKS: "Admin/CM/pages/App/mutate-single-types-links"
2613
- };
2614
- const contentTypesApi = contentManagerApi.injectEndpoints({
2615
- endpoints: (builder) => ({
2616
- getContentTypeConfiguration: builder.query({
2617
- query: (uid) => ({
2618
- url: `/content-manager/content-types/${uid}/configuration`,
2619
- method: "GET"
2620
- }),
2621
- transformResponse: (response) => response.data,
2622
- providesTags: (_result, _error, uid) => [
2623
- { type: "ContentTypesConfiguration", id: uid },
2624
- { type: "ContentTypeSettings", id: "LIST" }
2625
- ]
2626
- }),
2627
- getAllContentTypeSettings: builder.query({
2628
- query: () => "/content-manager/content-types-settings",
2629
- transformResponse: (response) => response.data,
2630
- providesTags: [{ type: "ContentTypeSettings", id: "LIST" }]
2631
- }),
2632
- updateContentTypeConfiguration: builder.mutation({
2633
- query: ({ uid, ...body }) => ({
2634
- url: `/content-manager/content-types/${uid}/configuration`,
2635
- method: "PUT",
2636
- data: body
2637
- }),
2638
- transformResponse: (response) => response.data,
2639
- invalidatesTags: (_result, _error, { uid }) => [
2640
- { type: "ContentTypesConfiguration", id: uid },
2641
- { type: "ContentTypeSettings", id: "LIST" },
2642
- // Is this necessary?
2643
- { type: "InitialData" }
2644
- ]
2645
- })
2646
- })
2647
- });
2648
- const {
2649
- useGetContentTypeConfigurationQuery,
2650
- useGetAllContentTypeSettingsQuery,
2651
- useUpdateContentTypeConfigurationMutation
2652
- } = contentTypesApi;
2653
- const checkIfAttributeIsDisplayable = (attribute) => {
2654
- const { type } = attribute;
2655
- if (type === "relation") {
2656
- return !attribute.relation.toLowerCase().includes("morph");
2657
- }
2658
- return !["json", "dynamiczone", "richtext", "password", "blocks"].includes(type) && !!type;
2659
- };
2660
- const getMainField = (attribute, mainFieldName, { schemas, components }) => {
2661
- if (!mainFieldName) {
2662
- return void 0;
2663
- }
2664
- const mainFieldType = attribute.type === "component" ? components[attribute.component].attributes[mainFieldName].type : (
2665
- // @ts-expect-error – `targetModel` does exist on the attribute for a relation.
2666
- schemas.find((schema) => schema.uid === attribute.targetModel)?.attributes[mainFieldName].type
2667
- );
2668
- return {
2669
- name: mainFieldName,
2670
- type: mainFieldType ?? "string"
2671
- };
2672
- };
2673
- const DEFAULT_SETTINGS = {
2674
- bulkable: false,
2675
- filterable: false,
2676
- searchable: false,
2677
- pagination: false,
2678
- defaultSortBy: "",
2679
- defaultSortOrder: "asc",
2680
- mainField: "id",
2681
- pageSize: 10
2682
- };
2683
- const useDocumentLayout = (model) => {
2684
- const { schema, components } = useDocument({ model, collectionType: "" }, { skip: true });
2685
- const [{ query }] = strapiAdmin.useQueryParams();
2686
- const runHookWaterfall = strapiAdmin.useStrapiApp("useDocumentLayout", (state) => state.runHookWaterfall);
2687
- const { toggleNotification } = strapiAdmin.useNotification();
2688
- const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
2689
- const { isLoading: isLoadingSchemas, schemas } = useContentTypeSchema();
2690
- const {
2691
- data,
2692
- isLoading: isLoadingConfigs,
2693
- error,
2694
- isFetching: isFetchingConfigs
2695
- } = useGetContentTypeConfigurationQuery(model);
2696
- const isLoading = isLoadingSchemas || isFetchingConfigs || isLoadingConfigs;
2697
- React__namespace.useEffect(() => {
2698
- if (error) {
2699
- toggleNotification({
2700
- type: "danger",
2701
- message: formatAPIError(error)
2702
- });
2703
- }
2704
- }, [error, formatAPIError, toggleNotification]);
2705
- const editLayout = React__namespace.useMemo(
2706
- () => data && !isLoading ? formatEditLayout(data, { schemas, schema, components }) : {
2707
- layout: [],
2708
- components: {},
2709
- metadatas: {},
2710
- options: {},
2711
- settings: DEFAULT_SETTINGS
2712
- },
2713
- [data, isLoading, schemas, schema, components]
2714
- );
2715
- const listLayout = React__namespace.useMemo(() => {
2716
- return data && !isLoading ? formatListLayout(data, { schemas, schema, components }) : {
2717
- layout: [],
2718
- metadatas: {},
2719
- options: {},
2720
- settings: DEFAULT_SETTINGS
2721
- };
2722
- }, [data, isLoading, schemas, schema, components]);
2723
- const { layout: edit } = React__namespace.useMemo(
2724
- () => runHookWaterfall(HOOKS.MUTATE_EDIT_VIEW_LAYOUT, {
2725
- layout: editLayout,
2726
- query
2727
- }),
2728
- [editLayout, query, runHookWaterfall]
2729
- );
2730
- return {
2731
- error,
2732
- isLoading,
2733
- edit,
2734
- list: listLayout
2735
- };
2736
- };
2737
- const useDocLayout = () => {
2738
- const { model } = useDoc();
2739
- return useDocumentLayout(model);
2740
- };
2741
- const formatEditLayout = (data, {
2742
- schemas,
2743
- schema,
2744
- components
2745
- }) => {
2746
- let currentPanelIndex = 0;
2747
- const panelledEditAttributes = convertEditLayoutToFieldLayouts(
2748
- data.contentType.layouts.edit,
2749
- schema?.attributes,
2750
- data.contentType.metadatas,
2751
- { configurations: data.components, schemas: components },
2752
- schemas
2753
- ).reduce((panels, row) => {
2754
- if (row.some((field) => field.type === "dynamiczone")) {
2755
- panels.push([row]);
2756
- currentPanelIndex += 2;
2757
- } else {
2758
- if (!panels[currentPanelIndex]) {
2759
- panels.push([]);
2760
- }
2761
- panels[currentPanelIndex].push(row);
2762
- }
2763
- return panels;
2764
- }, []);
2765
- const componentEditAttributes = Object.entries(data.components).reduce(
2766
- (acc, [uid, configuration]) => {
2767
- acc[uid] = {
2768
- layout: convertEditLayoutToFieldLayouts(
2769
- configuration.layouts.edit,
2770
- components[uid].attributes,
2771
- configuration.metadatas
2772
- ),
2773
- settings: {
2774
- ...configuration.settings,
2775
- icon: components[uid].info.icon,
2776
- displayName: components[uid].info.displayName
2956
+ });
2957
+ if (!("error" in res)) {
2958
+ navigate({ pathname: `../${collectionType}/${model}` }, { replace: true });
2959
+ }
2960
+ } finally {
2961
+ if (!listViewPathMatch) {
2962
+ setSubmitting(false);
2963
+ }
2777
2964
  }
2778
- };
2779
- return acc;
2780
- },
2781
- {}
2782
- );
2783
- const editMetadatas = Object.entries(data.contentType.metadatas).reduce(
2784
- (acc, [attribute, metadata]) => {
2785
- return {
2786
- ...acc,
2787
- [attribute]: metadata.edit
2788
- };
2789
- },
2790
- {}
2791
- );
2792
- return {
2793
- layout: panelledEditAttributes,
2794
- components: componentEditAttributes,
2795
- metadatas: editMetadatas,
2796
- settings: {
2797
- ...data.contentType.settings,
2798
- displayName: schema?.info.displayName
2965
+ }
2799
2966
  },
2800
- options: {
2801
- ...schema?.options,
2802
- ...schema?.pluginOptions,
2803
- ...data.contentType.options
2804
- }
2967
+ variant: "danger",
2968
+ position: ["header", "table-row"]
2805
2969
  };
2806
2970
  };
2807
- const convertEditLayoutToFieldLayouts = (rows, attributes = {}, metadatas, components, schemas = []) => {
2808
- return rows.map(
2809
- (row) => row.map((field) => {
2810
- const attribute = attributes[field.name];
2811
- if (!attribute) {
2812
- return null;
2813
- }
2814
- const { edit: metadata } = metadatas[field.name];
2815
- const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
2816
- return {
2817
- attribute,
2818
- disabled: !metadata.editable,
2819
- hint: metadata.description,
2820
- label: metadata.label ?? "",
2821
- name: field.name,
2822
- // @ts-expect-error – mainField does exist on the metadata for a relation.
2823
- mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
2824
- schemas,
2825
- components: components?.schemas ?? {}
2826
- }),
2827
- placeholder: metadata.placeholder ?? "",
2828
- required: attribute.required ?? false,
2829
- size: field.size,
2830
- unique: "unique" in attribute ? attribute.unique : false,
2831
- visible: metadata.visible ?? true,
2832
- type: attribute.type
2833
- };
2834
- }).filter((field) => field !== null)
2835
- );
2971
+ DeleteAction$1.type = "delete";
2972
+ const DEFAULT_HEADER_ACTIONS = [EditTheModelAction, ConfigureTheViewAction, DeleteAction$1];
2973
+ const Panels = () => {
2974
+ const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
2975
+ const [
2976
+ {
2977
+ query: { status }
2978
+ }
2979
+ ] = strapiAdmin.useQueryParams({
2980
+ status: "draft"
2981
+ });
2982
+ const { model, id, document, meta, collectionType } = useDoc();
2983
+ const plugins = strapiAdmin.useStrapiApp("Panels", (state) => state.plugins);
2984
+ const props = {
2985
+ activeTab: status,
2986
+ model,
2987
+ documentId: id,
2988
+ document: isCloning ? void 0 : document,
2989
+ meta: isCloning ? void 0 : meta,
2990
+ collectionType
2991
+ };
2992
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: /* @__PURE__ */ jsxRuntime.jsx(
2993
+ strapiAdmin.DescriptionComponentRenderer,
2994
+ {
2995
+ props,
2996
+ descriptions: plugins["content-manager"].apis.getEditViewSidePanels(),
2997
+ children: (panels) => panels.map(({ content, id: id2, ...description }) => /* @__PURE__ */ jsxRuntime.jsx(Panel, { ...description, children: content }, id2))
2998
+ }
2999
+ ) });
2836
3000
  };
2837
- const formatListLayout = (data, {
2838
- schemas,
2839
- schema,
2840
- components
2841
- }) => {
2842
- const listMetadatas = Object.entries(data.contentType.metadatas).reduce(
2843
- (acc, [attribute, metadata]) => {
2844
- return {
2845
- ...acc,
2846
- [attribute]: metadata.list
2847
- };
2848
- },
2849
- {}
2850
- );
2851
- const listAttributes = convertListLayoutToFieldLayouts(
2852
- data.contentType.layouts.list,
2853
- schema?.attributes,
2854
- listMetadatas,
2855
- { configurations: data.components, schemas: components },
2856
- schemas
2857
- );
3001
+ const ActionsPanel = () => {
3002
+ const { formatMessage } = reactIntl.useIntl();
2858
3003
  return {
2859
- layout: listAttributes,
2860
- settings: { ...data.contentType.settings, displayName: schema?.info.displayName },
2861
- metadatas: listMetadatas,
2862
- options: {
2863
- ...schema?.options,
2864
- ...schema?.pluginOptions,
2865
- ...data.contentType.options
2866
- }
3004
+ title: formatMessage({
3005
+ id: "content-manager.containers.edit.panels.default.title",
3006
+ defaultMessage: "Entry"
3007
+ }),
3008
+ content: /* @__PURE__ */ jsxRuntime.jsx(ActionsPanelContent, {})
2867
3009
  };
2868
3010
  };
2869
- const convertListLayoutToFieldLayouts = (columns, attributes = {}, metadatas, components, schemas = []) => {
2870
- return columns.map((name) => {
2871
- const attribute = attributes[name];
2872
- if (!attribute) {
2873
- return null;
3011
+ ActionsPanel.type = "actions";
3012
+ const ActionsPanelContent = () => {
3013
+ const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
3014
+ const [
3015
+ {
3016
+ query: { status = "draft" }
2874
3017
  }
2875
- const metadata = metadatas[name];
2876
- const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
2877
- return {
2878
- attribute,
2879
- label: metadata.label ?? "",
2880
- mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
2881
- schemas,
2882
- components: components?.schemas ?? {}
2883
- }),
2884
- name,
2885
- searchable: metadata.searchable ?? true,
2886
- sortable: metadata.sortable ?? true
2887
- };
2888
- }).filter((field) => field !== null);
3018
+ ] = strapiAdmin.useQueryParams();
3019
+ const { model, id, document, meta, collectionType } = useDoc();
3020
+ const plugins = strapiAdmin.useStrapiApp("ActionsPanel", (state) => state.plugins);
3021
+ const props = {
3022
+ activeTab: status,
3023
+ model,
3024
+ documentId: id,
3025
+ document: isCloning ? void 0 : document,
3026
+ meta: isCloning ? void 0 : meta,
3027
+ collectionType
3028
+ };
3029
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 2, width: "100%", children: [
3030
+ /* @__PURE__ */ jsxRuntime.jsx(
3031
+ strapiAdmin.DescriptionComponentRenderer,
3032
+ {
3033
+ props,
3034
+ descriptions: plugins["content-manager"].apis.getDocumentActions(),
3035
+ children: (actions2) => /* @__PURE__ */ jsxRuntime.jsx(DocumentActions, { actions: actions2 })
3036
+ }
3037
+ ),
3038
+ /* @__PURE__ */ jsxRuntime.jsx(InjectionZone, { area: "editView.right-links", slug: model })
3039
+ ] });
2889
3040
  };
3041
+ const Panel = React__namespace.forwardRef(({ children, title }, ref) => {
3042
+ return /* @__PURE__ */ jsxRuntime.jsxs(
3043
+ designSystem.Flex,
3044
+ {
3045
+ ref,
3046
+ tag: "aside",
3047
+ "aria-labelledby": "additional-information",
3048
+ background: "neutral0",
3049
+ borderColor: "neutral150",
3050
+ hasRadius: true,
3051
+ paddingBottom: 4,
3052
+ paddingLeft: 4,
3053
+ paddingRight: 4,
3054
+ paddingTop: 4,
3055
+ shadow: "tableShadow",
3056
+ gap: 3,
3057
+ direction: "column",
3058
+ justifyContent: "stretch",
3059
+ alignItems: "flex-start",
3060
+ children: [
3061
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "h2", variant: "sigma", textTransform: "uppercase", textColor: "neutral600", children: title }),
3062
+ children
3063
+ ]
3064
+ }
3065
+ );
3066
+ });
2890
3067
  const ConfirmBulkActionDialog = ({
2891
3068
  onToggleDialog,
2892
3069
  isOpen = false,
@@ -2925,6 +3102,7 @@ const ConfirmDialogPublishAll = ({
2925
3102
  const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler(getTranslation);
2926
3103
  const { model, schema } = useDoc();
2927
3104
  const [{ query }] = strapiAdmin.useQueryParams();
3105
+ const enableDraftRelationsCount = false;
2928
3106
  const {
2929
3107
  data: countDraftRelations = 0,
2930
3108
  isLoading,
@@ -2936,7 +3114,7 @@ const ConfirmDialogPublishAll = ({
2936
3114
  locale: query?.plugins?.i18n?.locale
2937
3115
  },
2938
3116
  {
2939
- skip: selectedEntries.length === 0
3117
+ skip: !enableDraftRelationsCount
2940
3118
  }
2941
3119
  );
2942
3120
  React__namespace.useEffect(() => {
@@ -3121,7 +3299,7 @@ const SelectedEntriesTableContent = ({
3121
3299
  status: row.status
3122
3300
  }
3123
3301
  ) }),
3124
- /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Cell, { children: /* @__PURE__ */ jsxRuntime.jsx(
3302
+ /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Cell, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { children: /* @__PURE__ */ jsxRuntime.jsx(
3125
3303
  designSystem.IconButton,
3126
3304
  {
3127
3305
  tag: reactRouterDom.Link,
@@ -3130,23 +3308,16 @@ const SelectedEntriesTableContent = ({
3130
3308
  search: row.locale && `?plugins[i18n][locale]=${row.locale}`
3131
3309
  },
3132
3310
  state: { from: pathname },
3133
- label: formatMessage(
3134
- { id: "app.component.HelperPluginTable.edit", defaultMessage: "Edit {target}" },
3135
- {
3136
- target: formatMessage(
3137
- {
3138
- id: "content-manager.components.ListViewHelperPluginTable.row-line",
3139
- defaultMessage: "item line {number}"
3140
- },
3141
- { number: index2 + 1 }
3142
- )
3143
- }
3144
- ),
3311
+ label: formatMessage({
3312
+ id: "content-manager.bulk-publish.edit",
3313
+ defaultMessage: "Edit"
3314
+ }),
3145
3315
  target: "_blank",
3146
3316
  marginLeft: "auto",
3147
- children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Pencil, {})
3317
+ variant: "ghost",
3318
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Pencil, { width: "1.6rem", height: "1.6rem" })
3148
3319
  }
3149
- ) })
3320
+ ) }) })
3150
3321
  ] }, row.id)) })
3151
3322
  ] });
3152
3323
  };
@@ -3183,7 +3354,13 @@ const SelectedEntriesModalContent = ({
3183
3354
  );
3184
3355
  const { rows, validationErrors } = React__namespace.useMemo(() => {
3185
3356
  if (data.length > 0 && schema) {
3186
- const validate = createYupSchema(schema.attributes, components);
3357
+ const validate = createYupSchema(
3358
+ schema.attributes,
3359
+ components,
3360
+ // Since this is the "Publish" action, the validation
3361
+ // schema must enforce the rules for published entities
3362
+ { status: "published" }
3363
+ );
3187
3364
  const validationErrors2 = {};
3188
3365
  const rows2 = data.map((entry) => {
3189
3366
  try {
@@ -3308,8 +3485,7 @@ const PublishAction = ({ documents, model }) => {
3308
3485
  const refetchList = () => {
3309
3486
  contentManagerApi.util.invalidateTags([{ type: "Document", id: `${model}_LIST` }]);
3310
3487
  };
3311
- if (!showPublishButton)
3312
- return null;
3488
+ if (!showPublishButton) return null;
3313
3489
  return {
3314
3490
  actionType: "publish",
3315
3491
  variant: "tertiary",
@@ -3377,8 +3553,7 @@ const DeleteAction = ({ documents, model }) => {
3377
3553
  selectRow([]);
3378
3554
  }
3379
3555
  };
3380
- if (!hasDeletePermission)
3381
- return null;
3556
+ if (!hasDeletePermission) return null;
3382
3557
  return {
3383
3558
  variant: "danger-light",
3384
3559
  label: formatMessage({ id: "global.delete", defaultMessage: "Delete" }),
@@ -3427,8 +3602,7 @@ const UnpublishAction = ({ documents, model }) => {
3427
3602
  }
3428
3603
  };
3429
3604
  const showUnpublishButton = hasDraftAndPublishEnabled && hasPublishPermission && documents.some((entry) => entry.status === "published" || entry.status === "modified");
3430
- if (!showUnpublishButton)
3431
- return null;
3605
+ if (!showUnpublishButton) return null;
3432
3606
  return {
3433
3607
  variant: "tertiary",
3434
3608
  label: formatMessage({ id: "app.utils.unpublish", defaultMessage: "Unpublish" }),
@@ -3533,7 +3707,7 @@ const TableActions = ({ document }) => {
3533
3707
  strapiAdmin.DescriptionComponentRenderer,
3534
3708
  {
3535
3709
  props,
3536
- descriptions: plugins["content-manager"].apis.getDocumentActions(),
3710
+ descriptions: plugins["content-manager"].apis.getDocumentActions().filter((action) => action.name !== "PublishAction"),
3537
3711
  children: (actions2) => {
3538
3712
  const tableRowActions = actions2.filter((action) => {
3539
3713
  const positions = Array.isArray(action.position) ? action.position : [action.position];
@@ -3644,7 +3818,7 @@ const CloneAction = ({ model, documentId }) => {
3644
3818
  }),
3645
3819
  content: /* @__PURE__ */ jsxRuntime.jsx(AutoCloneFailureModalBody, { prohibitedFields }),
3646
3820
  footer: ({ onClose }) => {
3647
- return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", children: [
3821
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Footer, { children: [
3648
3822
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: onClose, variant: "tertiary", children: formatMessage({
3649
3823
  id: "cancel",
3650
3824
  defaultMessage: "Cancel"
@@ -3764,10 +3938,8 @@ class ContentManagerPlugin {
3764
3938
  const getPrintableType = (value) => {
3765
3939
  const nativeType = typeof value;
3766
3940
  if (nativeType === "object") {
3767
- if (value === null)
3768
- return "null";
3769
- if (Array.isArray(value))
3770
- return "array";
3941
+ if (value === null) return "null";
3942
+ if (Array.isArray(value)) return "array";
3771
3943
  if (value instanceof Object && value.constructor.name !== "Object") {
3772
3944
  return value.constructor.name;
3773
3945
  }
@@ -3778,17 +3950,27 @@ const HistoryAction = ({ model, document }) => {
3778
3950
  const { formatMessage } = reactIntl.useIntl();
3779
3951
  const [{ query }] = strapiAdmin.useQueryParams();
3780
3952
  const navigate = reactRouterDom.useNavigate();
3953
+ const { trackUsage } = strapiAdmin.useTracking();
3954
+ const { pathname } = reactRouterDom.useLocation();
3781
3955
  const pluginsQueryParams = qs.stringify({ plugins: query.plugins }, { encode: false });
3782
3956
  if (!window.strapi.features.isEnabled("cms-content-history")) {
3783
3957
  return null;
3784
3958
  }
3959
+ const handleOnClick = () => {
3960
+ const destination = { pathname: "history", search: pluginsQueryParams };
3961
+ trackUsage("willNavigate", {
3962
+ from: pathname,
3963
+ to: `${pathname}/${destination.pathname}`
3964
+ });
3965
+ navigate(destination);
3966
+ };
3785
3967
  return {
3786
3968
  icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.ClockCounterClockwise, {}),
3787
3969
  label: formatMessage({
3788
3970
  id: "content-manager.history.document-action",
3789
3971
  defaultMessage: "Content History"
3790
3972
  }),
3791
- onClick: () => navigate({ pathname: "history", search: pluginsQueryParams }),
3973
+ onClick: handleOnClick,
3792
3974
  disabled: (
3793
3975
  /**
3794
3976
  * The user is creating a new document.
@@ -3856,6 +4038,90 @@ const { setInitialData } = actions;
3856
4038
  const reducer = toolkit.combineReducers({
3857
4039
  app: reducer$1
3858
4040
  });
4041
+ const previewApi = contentManagerApi.injectEndpoints({
4042
+ endpoints: (builder) => ({
4043
+ getPreviewUrl: builder.query({
4044
+ query({ query, params }) {
4045
+ return {
4046
+ url: `/content-manager/preview/url/${params.contentType}`,
4047
+ method: "GET",
4048
+ config: {
4049
+ params: query
4050
+ }
4051
+ };
4052
+ }
4053
+ })
4054
+ })
4055
+ });
4056
+ const { useGetPreviewUrlQuery } = previewApi;
4057
+ const ConditionalTooltip = ({ isShown, label, children }) => {
4058
+ if (isShown) {
4059
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tooltip, { label, children });
4060
+ }
4061
+ return children;
4062
+ };
4063
+ const PreviewSidePanel = ({ model, documentId, document }) => {
4064
+ const { formatMessage } = reactIntl.useIntl();
4065
+ const { trackUsage } = strapiAdmin.useTracking();
4066
+ const { pathname } = reactRouterDom.useLocation();
4067
+ const [{ query }] = strapiAdmin.useQueryParams();
4068
+ const isModified = strapiAdmin.useForm("PreviewSidePanel", (state) => state.modified);
4069
+ const { data, error } = useGetPreviewUrlQuery({
4070
+ params: {
4071
+ contentType: model
4072
+ },
4073
+ query: {
4074
+ documentId,
4075
+ locale: document?.locale,
4076
+ status: document?.status
4077
+ }
4078
+ });
4079
+ if (!data?.data?.url || error) {
4080
+ return null;
4081
+ }
4082
+ const trackNavigation = () => {
4083
+ const destinationPathname = pathname.replace(/\/$/, "") + "/preview";
4084
+ trackUsage("willNavigate", { from: pathname, to: destinationPathname });
4085
+ };
4086
+ return {
4087
+ title: formatMessage({ id: "content-manager.preview.panel.title", defaultMessage: "Preview" }),
4088
+ content: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { gap: 2, width: "100%", children: /* @__PURE__ */ jsxRuntime.jsx(
4089
+ ConditionalTooltip,
4090
+ {
4091
+ label: formatMessage({
4092
+ id: "content-manager.preview.panel.button-disabled-tooltip",
4093
+ defaultMessage: "Please save to open the preview"
4094
+ }),
4095
+ isShown: isModified,
4096
+ children: /* @__PURE__ */ jsxRuntime.jsx(
4097
+ designSystem.Button,
4098
+ {
4099
+ variant: "tertiary",
4100
+ tag: reactRouterDom.Link,
4101
+ to: { pathname: "preview", search: qs.stringify(query, { encode: false }) },
4102
+ onClick: trackNavigation,
4103
+ flex: "auto",
4104
+ disabled: isModified,
4105
+ children: formatMessage({
4106
+ id: "content-manager.preview.panel.button",
4107
+ defaultMessage: "Open preview"
4108
+ })
4109
+ }
4110
+ )
4111
+ }
4112
+ ) })
4113
+ };
4114
+ };
4115
+ const FEATURE_ID = "preview";
4116
+ const previewAdmin = {
4117
+ bootstrap(app) {
4118
+ if (!window.strapi.future.isEnabled(FEATURE_ID)) {
4119
+ return;
4120
+ }
4121
+ const contentManagerPluginApis = app.getPlugin("content-manager").apis;
4122
+ contentManagerPluginApis.addEditViewSidePanel([PreviewSidePanel]);
4123
+ }
4124
+ };
3859
4125
  const index = {
3860
4126
  register(app) {
3861
4127
  const cm = new ContentManagerPlugin();
@@ -3875,7 +4141,7 @@ const index = {
3875
4141
  app.router.addRoute({
3876
4142
  path: "content-manager/*",
3877
4143
  lazy: async () => {
3878
- const { Layout } = await Promise.resolve().then(() => require("./layout-P3eKO1Qy.js"));
4144
+ const { Layout } = await Promise.resolve().then(() => require("./layout-7AsWJzZJ.js"));
3879
4145
  return {
3880
4146
  Component: Layout
3881
4147
  };
@@ -3888,11 +4154,14 @@ const index = {
3888
4154
  if (typeof historyAdmin.bootstrap === "function") {
3889
4155
  historyAdmin.bootstrap(app);
3890
4156
  }
4157
+ if (typeof previewAdmin.bootstrap === "function") {
4158
+ previewAdmin.bootstrap(app);
4159
+ }
3891
4160
  },
3892
4161
  async registerTrads({ locales }) {
3893
4162
  const importedTrads = await Promise.all(
3894
4163
  locales.map((locale) => {
3895
- return __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/ar.json": () => Promise.resolve().then(() => require("./ar-BUUWXIYu.js")), "./translations/ca.json": () => Promise.resolve().then(() => require("./ca-Cmk45QO6.js")), "./translations/cs.json": () => Promise.resolve().then(() => require("./cs-CkJy6B2v.js")), "./translations/de.json": () => Promise.resolve().then(() => require("./de-CCEmbAah.js")), "./translations/en.json": () => Promise.resolve().then(() => require("./en-uOUIxfcQ.js")), "./translations/es.json": () => Promise.resolve().then(() => require("./es-EUonQTon.js")), "./translations/eu.json": () => Promise.resolve().then(() => require("./eu-VDH-3ovk.js")), "./translations/fr.json": () => Promise.resolve().then(() => require("./fr-B7kGGg3E.js")), "./translations/gu.json": () => Promise.resolve().then(() => require("./gu-BRmF601H.js")), "./translations/hi.json": () => Promise.resolve().then(() => require("./hi-CCJBptSq.js")), "./translations/hu.json": () => Promise.resolve().then(() => require("./hu-sNV_yLYy.js")), "./translations/id.json": () => Promise.resolve().then(() => require("./id-B5Ser98A.js")), "./translations/it.json": () => Promise.resolve().then(() => require("./it-DkBIs7vD.js")), "./translations/ja.json": () => Promise.resolve().then(() => require("./ja-CcFe8diO.js")), "./translations/ko.json": () => Promise.resolve().then(() => require("./ko-woFZPmLk.js")), "./translations/ml.json": () => Promise.resolve().then(() => require("./ml-C2W8N8k1.js")), "./translations/ms.json": () => Promise.resolve().then(() => require("./ms-BuFotyP_.js")), "./translations/nl.json": () => Promise.resolve().then(() => require("./nl-bbEOHChV.js")), "./translations/pl.json": () => Promise.resolve().then(() => require("./pl-uzwG-hk7.js")), "./translations/pt-BR.json": () => Promise.resolve().then(() => require("./pt-BR-BiOz37D9.js")), "./translations/pt.json": () => Promise.resolve().then(() => require("./pt-CeXQuq50.js")), "./translations/ru.json": () => Promise.resolve().then(() => require("./ru-BT3ybNny.js")), "./translations/sa.json": () => Promise.resolve().then(() => require("./sa-CcvkYInH.js")), "./translations/sk.json": () => Promise.resolve().then(() => require("./sk-CvY09Xjv.js")), "./translations/sv.json": () => Promise.resolve().then(() => require("./sv-MYDuzgvT.js")), "./translations/th.json": () => Promise.resolve().then(() => require("./th-D9_GfAjc.js")), "./translations/tr.json": () => Promise.resolve().then(() => require("./tr-D9UH-O_R.js")), "./translations/uk.json": () => Promise.resolve().then(() => require("./uk-C8EiqJY7.js")), "./translations/vi.json": () => Promise.resolve().then(() => require("./vi-CJlYDheJ.js")), "./translations/zh-Hans.json": () => Promise.resolve().then(() => require("./zh-Hans-9kOncHGw.js")), "./translations/zh.json": () => Promise.resolve().then(() => require("./zh-CQQfszqR.js")) }), `./translations/${locale}.json`).then(({ default: data }) => {
4164
+ return __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/ar.json": () => Promise.resolve().then(() => require("./ar-BUUWXIYu.js")), "./translations/ca.json": () => Promise.resolve().then(() => require("./ca-Cmk45QO6.js")), "./translations/cs.json": () => Promise.resolve().then(() => require("./cs-CkJy6B2v.js")), "./translations/de.json": () => Promise.resolve().then(() => require("./de-CCEmbAah.js")), "./translations/en.json": () => Promise.resolve().then(() => require("./en-BK8Xyl5I.js")), "./translations/es.json": () => Promise.resolve().then(() => require("./es-9K52xZIr.js")), "./translations/eu.json": () => Promise.resolve().then(() => require("./eu-VDH-3ovk.js")), "./translations/fr.json": () => Promise.resolve().then(() => require("./fr-B2Kyv8Z9.js")), "./translations/gu.json": () => Promise.resolve().then(() => require("./gu-BRmF601H.js")), "./translations/hi.json": () => Promise.resolve().then(() => require("./hi-CCJBptSq.js")), "./translations/hu.json": () => Promise.resolve().then(() => require("./hu-sNV_yLYy.js")), "./translations/id.json": () => Promise.resolve().then(() => require("./id-B5Ser98A.js")), "./translations/it.json": () => Promise.resolve().then(() => require("./it-DkBIs7vD.js")), "./translations/ja.json": () => Promise.resolve().then(() => require("./ja-7sfIbjxE.js")), "./translations/ko.json": () => Promise.resolve().then(() => require("./ko-woFZPmLk.js")), "./translations/ml.json": () => Promise.resolve().then(() => require("./ml-C2W8N8k1.js")), "./translations/ms.json": () => Promise.resolve().then(() => require("./ms-BuFotyP_.js")), "./translations/nl.json": () => Promise.resolve().then(() => require("./nl-bbEOHChV.js")), "./translations/pl.json": () => Promise.resolve().then(() => require("./pl-uzwG-hk7.js")), "./translations/pt-BR.json": () => Promise.resolve().then(() => require("./pt-BR-BiOz37D9.js")), "./translations/pt.json": () => Promise.resolve().then(() => require("./pt-CeXQuq50.js")), "./translations/ru.json": () => Promise.resolve().then(() => require("./ru-BT3ybNny.js")), "./translations/sa.json": () => Promise.resolve().then(() => require("./sa-CcvkYInH.js")), "./translations/sk.json": () => Promise.resolve().then(() => require("./sk-CvY09Xjv.js")), "./translations/sv.json": () => Promise.resolve().then(() => require("./sv-MYDuzgvT.js")), "./translations/th.json": () => Promise.resolve().then(() => require("./th-D9_GfAjc.js")), "./translations/tr.json": () => Promise.resolve().then(() => require("./tr-D9UH-O_R.js")), "./translations/uk.json": () => Promise.resolve().then(() => require("./uk-C8EiqJY7.js")), "./translations/vi.json": () => Promise.resolve().then(() => require("./vi-CJlYDheJ.js")), "./translations/zh-Hans.json": () => Promise.resolve().then(() => require("./zh-Hans-9kOncHGw.js")), "./translations/zh.json": () => Promise.resolve().then(() => require("./zh-CQQfszqR.js")) }), `./translations/${locale}.json`, 3).then(({ default: data }) => {
3896
4165
  return {
3897
4166
  data: prefixPluginTranslations(data, PLUGIN_ID),
3898
4167
  locale
@@ -3910,6 +4179,7 @@ const index = {
3910
4179
  };
3911
4180
  exports.ATTRIBUTE_TYPES_THAT_CANNOT_BE_MAIN_FIELD = ATTRIBUTE_TYPES_THAT_CANNOT_BE_MAIN_FIELD;
3912
4181
  exports.BulkActionsRenderer = BulkActionsRenderer;
4182
+ exports.CLONE_PATH = CLONE_PATH;
3913
4183
  exports.COLLECTION_TYPES = COLLECTION_TYPES;
3914
4184
  exports.CREATOR_FIELDS = CREATOR_FIELDS;
3915
4185
  exports.DEFAULT_SETTINGS = DEFAULT_SETTINGS;
@@ -3937,6 +4207,7 @@ exports.getMainField = getMainField;
3937
4207
  exports.getTranslation = getTranslation;
3938
4208
  exports.index = index;
3939
4209
  exports.setInitialData = setInitialData;
4210
+ exports.useContentManagerContext = useContentManagerContext;
3940
4211
  exports.useContentTypeSchema = useContentTypeSchema;
3941
4212
  exports.useDoc = useDoc;
3942
4213
  exports.useDocLayout = useDocLayout;
@@ -3948,5 +4219,6 @@ exports.useGetAllContentTypeSettingsQuery = useGetAllContentTypeSettingsQuery;
3948
4219
  exports.useGetAllDocumentsQuery = useGetAllDocumentsQuery;
3949
4220
  exports.useGetContentTypeConfigurationQuery = useGetContentTypeConfigurationQuery;
3950
4221
  exports.useGetInitialDataQuery = useGetInitialDataQuery;
4222
+ exports.useGetPreviewUrlQuery = useGetPreviewUrlQuery;
3951
4223
  exports.useUpdateContentTypeConfigurationMutation = useUpdateContentTypeConfigurationMutation;
3952
- //# sourceMappingURL=index-5EMXLEM_.js.map
4224
+ //# sourceMappingURL=index-C2Q_PLWj.js.map