@strapi/content-manager 0.0.0-experimental.6d27139261823fc4b18da9f3c10b271d5010dbf0 → 0.0.0-experimental.702fcf7aec9be82c4485a8bd49e235293c37f022

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 (182) hide show
  1. package/dist/_chunks/{ComponentConfigurationPage-DyDkPajU.js → ComponentConfigurationPage-BaGEn2nd.js} +4 -4
  2. package/dist/_chunks/{ComponentConfigurationPage-DyDkPajU.js.map → ComponentConfigurationPage-BaGEn2nd.js.map} +1 -1
  3. package/dist/_chunks/{ComponentConfigurationPage-9lRmRdIr.mjs → ComponentConfigurationPage-EIYRzIr6.mjs} +4 -4
  4. package/dist/_chunks/{ComponentConfigurationPage-9lRmRdIr.mjs.map → ComponentConfigurationPage-EIYRzIr6.mjs.map} +1 -1
  5. package/dist/_chunks/{EditConfigurationPage-DValmA0m.js → EditConfigurationPage-BQGdJb6Z.js} +4 -4
  6. package/dist/_chunks/{EditConfigurationPage-DValmA0m.js.map → EditConfigurationPage-BQGdJb6Z.js.map} +1 -1
  7. package/dist/_chunks/{EditConfigurationPage-Bk893vVY.mjs → EditConfigurationPage-ByaNUj_q.mjs} +4 -4
  8. package/dist/_chunks/{EditConfigurationPage-Bk893vVY.mjs.map → EditConfigurationPage-ByaNUj_q.mjs.map} +1 -1
  9. package/dist/_chunks/{EditViewPage-DiNFdFqP.mjs → EditViewPage-BgeC8L9X.mjs} +50 -10
  10. package/dist/_chunks/EditViewPage-BgeC8L9X.mjs.map +1 -0
  11. package/dist/_chunks/{EditViewPage-Dk7Eaft4.js → EditViewPage-s_qVLiC6.js} +49 -9
  12. package/dist/_chunks/EditViewPage-s_qVLiC6.js.map +1 -0
  13. package/dist/_chunks/{Field-DH2OaqUP.js → Field-0AdG2t0D.js} +100 -46
  14. package/dist/_chunks/Field-0AdG2t0D.js.map +1 -0
  15. package/dist/_chunks/{Field-Dv_HTFTa.mjs → Field-DbpDop_h.mjs} +96 -42
  16. package/dist/_chunks/Field-DbpDop_h.mjs.map +1 -0
  17. package/dist/_chunks/{Form-B_dUDizM.js → Form-BpC9hWi-.js} +16 -8
  18. package/dist/_chunks/Form-BpC9hWi-.js.map +1 -0
  19. package/dist/_chunks/{Form-Dy6P4HgH.mjs → Form-Xb-u04dn.mjs} +16 -8
  20. package/dist/_chunks/Form-Xb-u04dn.mjs.map +1 -0
  21. package/dist/_chunks/{History-DrwsD1Vc.mjs → History-DLl10NEN.mjs} +42 -99
  22. package/dist/_chunks/History-DLl10NEN.mjs.map +1 -0
  23. package/dist/_chunks/{History-BT4w83Oa.js → History-sJ61vusJ.js} +40 -97
  24. package/dist/_chunks/History-sJ61vusJ.js.map +1 -0
  25. package/dist/_chunks/{ListConfigurationPage-CuYrMcW3.js → ListConfigurationPage-C00guBjQ.js} +5 -4
  26. package/dist/_chunks/ListConfigurationPage-C00guBjQ.js.map +1 -0
  27. package/dist/_chunks/{ListConfigurationPage-BxIP0jRy.mjs → ListConfigurationPage-mbZQmEZ3.mjs} +6 -5
  28. package/dist/_chunks/ListConfigurationPage-mbZQmEZ3.mjs.map +1 -0
  29. package/dist/_chunks/{ListViewPage-BvpwNur7.js → ListViewPage-DDVpN1ql.js} +53 -19
  30. package/dist/_chunks/ListViewPage-DDVpN1ql.js.map +1 -0
  31. package/dist/_chunks/{ListViewPage-5a1vw-OK.mjs → ListViewPage-iRJ5AUjS.mjs} +49 -15
  32. package/dist/_chunks/ListViewPage-iRJ5AUjS.mjs.map +1 -0
  33. package/dist/_chunks/{NoContentTypePage-UqEiWKkM.js → NoContentTypePage-BvkII4H4.js} +2 -2
  34. package/dist/_chunks/{NoContentTypePage-UqEiWKkM.js.map → NoContentTypePage-BvkII4H4.js.map} +1 -1
  35. package/dist/_chunks/{NoContentTypePage-Bm6tRcd3.mjs → NoContentTypePage-DI8VWkVK.mjs} +2 -2
  36. package/dist/_chunks/{NoContentTypePage-Bm6tRcd3.mjs.map → NoContentTypePage-DI8VWkVK.mjs.map} +1 -1
  37. package/dist/_chunks/{NoPermissionsPage-C_vGRo8Q.js → NoPermissionsPage-BZjHQTpb.js} +2 -2
  38. package/dist/_chunks/{NoPermissionsPage-C_vGRo8Q.js.map → NoPermissionsPage-BZjHQTpb.js.map} +1 -1
  39. package/dist/_chunks/{NoPermissionsPage-BHPqn_tQ.mjs → NoPermissionsPage-DckHN3oZ.mjs} +2 -2
  40. package/dist/_chunks/{NoPermissionsPage-BHPqn_tQ.mjs.map → NoPermissionsPage-DckHN3oZ.mjs.map} +1 -1
  41. package/dist/_chunks/Preview-BDOUHeaW.mjs +267 -0
  42. package/dist/_chunks/Preview-BDOUHeaW.mjs.map +1 -0
  43. package/dist/_chunks/Preview-CS2aV-BU.js +286 -0
  44. package/dist/_chunks/Preview-CS2aV-BU.js.map +1 -0
  45. package/dist/_chunks/{Relations-CznVF6LS.js → Relations-DEIQO39t.js} +71 -35
  46. package/dist/_chunks/Relations-DEIQO39t.js.map +1 -0
  47. package/dist/_chunks/{Relations-C7fPyh5P.mjs → Relations-J-8HC3zX.mjs} +72 -36
  48. package/dist/_chunks/Relations-J-8HC3zX.mjs.map +1 -0
  49. package/dist/_chunks/{en-CbaIuYoB.mjs → en-CfIXaZf9.mjs} +25 -13
  50. package/dist/_chunks/{en-CbaIuYoB.mjs.map → en-CfIXaZf9.mjs.map} +1 -1
  51. package/dist/_chunks/{en-otD_UBJi.js → en-DTWPCdTS.js} +25 -13
  52. package/dist/_chunks/{en-otD_UBJi.js.map → en-DTWPCdTS.js.map} +1 -1
  53. package/dist/_chunks/{es-EUonQTon.js → es-9K52xZIr.js} +2 -2
  54. package/dist/_chunks/{ja-CcFe8diO.js.map → es-9K52xZIr.js.map} +1 -1
  55. package/dist/_chunks/{es-CeXiYflN.mjs → es-D34tqjMw.mjs} +2 -2
  56. package/dist/_chunks/{es-CeXiYflN.mjs.map → es-D34tqjMw.mjs.map} +1 -1
  57. package/dist/_chunks/{fr-CD9VFbPM.mjs → fr--pg5jUbt.mjs} +13 -3
  58. package/dist/_chunks/{fr-CD9VFbPM.mjs.map → fr--pg5jUbt.mjs.map} +1 -1
  59. package/dist/_chunks/{fr-B7kGGg3E.js → fr-B2Kyv8Z9.js} +13 -3
  60. package/dist/_chunks/{fr-B7kGGg3E.js.map → fr-B2Kyv8Z9.js.map} +1 -1
  61. package/dist/_chunks/{index-BJ6uTqLL.mjs → index-DzTs9ga-.mjs} +1122 -911
  62. package/dist/_chunks/index-DzTs9ga-.mjs.map +1 -0
  63. package/dist/_chunks/{index-D9UmmBcM.js → index-uXHSvmlw.js} +1118 -906
  64. package/dist/_chunks/index-uXHSvmlw.js.map +1 -0
  65. package/dist/_chunks/{ja-CcFe8diO.js → ja-7sfIbjxE.js} +2 -2
  66. package/dist/_chunks/{es-EUonQTon.js.map → ja-7sfIbjxE.js.map} +1 -1
  67. package/dist/_chunks/{ja-CtsUxOvk.mjs → ja-BHqhDq4V.mjs} +2 -2
  68. package/dist/_chunks/{ja-CtsUxOvk.mjs.map → ja-BHqhDq4V.mjs.map} +1 -1
  69. package/dist/_chunks/{layout-uomiIGbG.mjs → layout-BhIZkPuB.mjs} +5 -4
  70. package/dist/_chunks/{layout-uomiIGbG.mjs.map → layout-BhIZkPuB.mjs.map} +1 -1
  71. package/dist/_chunks/{layout-kfu5Wtix.js → layout-zA_F2rU4.js} +5 -4
  72. package/dist/_chunks/{layout-kfu5Wtix.js.map → layout-zA_F2rU4.js.map} +1 -1
  73. package/dist/_chunks/{objects-gigeqt7s.js → objects-BcXOv6_9.js} +2 -4
  74. package/dist/_chunks/{objects-gigeqt7s.js.map → objects-BcXOv6_9.js.map} +1 -1
  75. package/dist/_chunks/{objects-mKMAmfec.mjs → objects-D6yBsdmx.mjs} +2 -4
  76. package/dist/_chunks/{objects-mKMAmfec.mjs.map → objects-D6yBsdmx.mjs.map} +1 -1
  77. package/dist/_chunks/{relations-DiDufGSA.mjs → relations-BoCufH_z.mjs} +6 -7
  78. package/dist/_chunks/relations-BoCufH_z.mjs.map +1 -0
  79. package/dist/_chunks/{relations-DKENrxko.js → relations-DnUyZQaL.js} +6 -7
  80. package/dist/_chunks/relations-DnUyZQaL.js.map +1 -0
  81. package/dist/_chunks/{usePrev-B9w_-eYc.js → useDebounce-CtcjDB3L.js} +14 -1
  82. package/dist/_chunks/useDebounce-CtcjDB3L.js.map +1 -0
  83. package/dist/_chunks/useDebounce-DmuSJIF3.mjs +29 -0
  84. package/dist/_chunks/useDebounce-DmuSJIF3.mjs.map +1 -0
  85. package/dist/admin/index.js +2 -1
  86. package/dist/admin/index.js.map +1 -1
  87. package/dist/admin/index.mjs +4 -3
  88. package/dist/admin/src/exports.d.ts +1 -1
  89. package/dist/admin/src/hooks/useDocument.d.ts +32 -1
  90. package/dist/admin/src/pages/EditView/EditViewPage.d.ts +9 -1
  91. package/dist/admin/src/pages/EditView/components/DocumentStatus.d.ts +2 -2
  92. package/dist/admin/src/pages/EditView/components/Header.d.ts +11 -11
  93. package/dist/admin/src/preview/components/PreviewContent.d.ts +2 -0
  94. package/dist/admin/src/preview/components/PreviewHeader.d.ts +2 -0
  95. package/dist/admin/src/preview/components/PreviewSidePanel.d.ts +3 -0
  96. package/dist/admin/src/preview/constants.d.ts +1 -0
  97. package/dist/admin/src/preview/index.d.ts +4 -0
  98. package/dist/admin/src/preview/pages/Preview.d.ts +11 -0
  99. package/dist/admin/src/preview/routes.d.ts +3 -0
  100. package/dist/admin/src/preview/services/preview.d.ts +3 -0
  101. package/dist/admin/src/router.d.ts +1 -1
  102. package/dist/admin/src/services/documents.d.ts +3 -1
  103. package/dist/server/index.js +378 -162
  104. package/dist/server/index.js.map +1 -1
  105. package/dist/server/index.mjs +378 -162
  106. package/dist/server/index.mjs.map +1 -1
  107. package/dist/server/src/bootstrap.d.ts.map +1 -1
  108. package/dist/server/src/controllers/collection-types.d.ts.map +1 -1
  109. package/dist/server/src/controllers/index.d.ts.map +1 -1
  110. package/dist/server/src/controllers/relations.d.ts.map +1 -1
  111. package/dist/server/src/controllers/utils/metadata.d.ts +15 -1
  112. package/dist/server/src/controllers/utils/metadata.d.ts.map +1 -1
  113. package/dist/server/src/history/services/history.d.ts.map +1 -1
  114. package/dist/server/src/history/services/lifecycles.d.ts.map +1 -1
  115. package/dist/server/src/history/services/utils.d.ts +2 -3
  116. package/dist/server/src/history/services/utils.d.ts.map +1 -1
  117. package/dist/server/src/index.d.ts +4 -4
  118. package/dist/server/src/preview/constants.d.ts +2 -0
  119. package/dist/server/src/preview/constants.d.ts.map +1 -0
  120. package/dist/server/src/preview/controllers/index.d.ts +2 -0
  121. package/dist/server/src/preview/controllers/index.d.ts.map +1 -0
  122. package/dist/server/src/preview/controllers/preview.d.ts +13 -0
  123. package/dist/server/src/preview/controllers/preview.d.ts.map +1 -0
  124. package/dist/server/src/preview/controllers/validation/preview.d.ts +6 -0
  125. package/dist/server/src/preview/controllers/validation/preview.d.ts.map +1 -0
  126. package/dist/server/src/preview/index.d.ts +4 -0
  127. package/dist/server/src/preview/index.d.ts.map +1 -0
  128. package/dist/server/src/preview/routes/index.d.ts +8 -0
  129. package/dist/server/src/preview/routes/index.d.ts.map +1 -0
  130. package/dist/server/src/preview/routes/preview.d.ts +4 -0
  131. package/dist/server/src/preview/routes/preview.d.ts.map +1 -0
  132. package/dist/server/src/preview/services/index.d.ts +15 -0
  133. package/dist/server/src/preview/services/index.d.ts.map +1 -0
  134. package/dist/server/src/preview/services/preview-config.d.ts +30 -0
  135. package/dist/server/src/preview/services/preview-config.d.ts.map +1 -0
  136. package/dist/server/src/preview/services/preview.d.ts +12 -0
  137. package/dist/server/src/preview/services/preview.d.ts.map +1 -0
  138. package/dist/server/src/preview/utils.d.ts +18 -0
  139. package/dist/server/src/preview/utils.d.ts.map +1 -0
  140. package/dist/server/src/routes/index.d.ts.map +1 -1
  141. package/dist/server/src/services/document-manager.d.ts.map +1 -1
  142. package/dist/server/src/services/document-metadata.d.ts +8 -8
  143. package/dist/server/src/services/document-metadata.d.ts.map +1 -1
  144. package/dist/server/src/services/index.d.ts +4 -4
  145. package/dist/server/src/services/index.d.ts.map +1 -1
  146. package/dist/server/src/services/utils/configuration/index.d.ts +2 -2
  147. package/dist/server/src/services/utils/configuration/layouts.d.ts +2 -2
  148. package/dist/server/src/utils/index.d.ts +2 -0
  149. package/dist/server/src/utils/index.d.ts.map +1 -1
  150. package/dist/shared/contracts/collection-types.d.ts +3 -1
  151. package/dist/shared/contracts/collection-types.d.ts.map +1 -1
  152. package/dist/shared/contracts/index.d.ts +1 -0
  153. package/dist/shared/contracts/index.d.ts.map +1 -1
  154. package/dist/shared/contracts/preview.d.ts +27 -0
  155. package/dist/shared/contracts/preview.d.ts.map +1 -0
  156. package/dist/shared/index.js +4 -0
  157. package/dist/shared/index.js.map +1 -1
  158. package/dist/shared/index.mjs +4 -0
  159. package/dist/shared/index.mjs.map +1 -1
  160. package/package.json +14 -14
  161. package/dist/_chunks/EditViewPage-DiNFdFqP.mjs.map +0 -1
  162. package/dist/_chunks/EditViewPage-Dk7Eaft4.js.map +0 -1
  163. package/dist/_chunks/Field-DH2OaqUP.js.map +0 -1
  164. package/dist/_chunks/Field-Dv_HTFTa.mjs.map +0 -1
  165. package/dist/_chunks/Form-B_dUDizM.js.map +0 -1
  166. package/dist/_chunks/Form-Dy6P4HgH.mjs.map +0 -1
  167. package/dist/_chunks/History-BT4w83Oa.js.map +0 -1
  168. package/dist/_chunks/History-DrwsD1Vc.mjs.map +0 -1
  169. package/dist/_chunks/ListConfigurationPage-BxIP0jRy.mjs.map +0 -1
  170. package/dist/_chunks/ListConfigurationPage-CuYrMcW3.js.map +0 -1
  171. package/dist/_chunks/ListViewPage-5a1vw-OK.mjs.map +0 -1
  172. package/dist/_chunks/ListViewPage-BvpwNur7.js.map +0 -1
  173. package/dist/_chunks/Relations-C7fPyh5P.mjs.map +0 -1
  174. package/dist/_chunks/Relations-CznVF6LS.js.map +0 -1
  175. package/dist/_chunks/index-BJ6uTqLL.mjs.map +0 -1
  176. package/dist/_chunks/index-D9UmmBcM.js.map +0 -1
  177. package/dist/_chunks/relations-DKENrxko.js.map +0 -1
  178. package/dist/_chunks/relations-DiDufGSA.mjs.map +0 -1
  179. package/dist/_chunks/usePrev-B9w_-eYc.js.map +0 -1
  180. package/dist/_chunks/usePrev-DH6iah0A.mjs +0 -16
  181. package/dist/_chunks/usePrev-DH6iah0A.mjs.map +0 -1
  182. package/strapi-server.js +0 -3
@@ -4,6 +4,7 @@ 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");
@@ -32,6 +33,7 @@ function _interopNamespace(e) {
32
33
  return Object.freeze(n);
33
34
  }
34
35
  const React__namespace = /* @__PURE__ */ _interopNamespace(React);
36
+ const mapValues__default = /* @__PURE__ */ _interopDefault(mapValues);
35
37
  const yup__namespace = /* @__PURE__ */ _interopNamespace(yup);
36
38
  const pipe__default = /* @__PURE__ */ _interopDefault(pipe);
37
39
  const __variableDynamicImportRuntimeHelper = (glob, path) => {
@@ -121,6 +123,7 @@ const DocumentRBAC = ({ children, permissions }) => {
121
123
  if (!slug) {
122
124
  throw new Error("Cannot find the slug param in the URL");
123
125
  }
126
+ const [{ rawQuery }] = strapiAdmin.useQueryParams();
124
127
  const userPermissions = strapiAdmin.useAuth("DocumentRBAC", (state) => state.permissions);
125
128
  const contentTypePermissions = React__namespace.useMemo(() => {
126
129
  const contentTypePermissions2 = userPermissions.filter(
@@ -131,7 +134,14 @@ const DocumentRBAC = ({ children, permissions }) => {
131
134
  return { ...acc, [action]: [permission] };
132
135
  }, {});
133
136
  }, [slug, userPermissions]);
134
- const { isLoading, allowedActions } = strapiAdmin.useRBAC(contentTypePermissions, permissions ?? void 0);
137
+ const { isLoading, allowedActions } = strapiAdmin.useRBAC(
138
+ contentTypePermissions,
139
+ permissions ?? void 0,
140
+ // TODO: useRBAC context should be typed and built differently
141
+ // We are passing raw query as context to the hook so that it can
142
+ // rely on the locale provided from DocumentRBAC for its permission calculations.
143
+ rawQuery
144
+ );
135
145
  const canCreateFields = !isLoading && allowedActions.canCreate ? extractAndDedupeFields(contentTypePermissions.create) : [];
136
146
  const canReadFields = !isLoading && allowedActions.canRead ? extractAndDedupeFields(contentTypePermissions.read) : [];
137
147
  const canUpdateFields = !isLoading && allowedActions.canUpdate ? extractAndDedupeFields(contentTypePermissions.update) : [];
@@ -482,6 +492,24 @@ const buildValidParams = (query) => {
482
492
  const isBaseQueryError = (error) => {
483
493
  return error.name !== void 0;
484
494
  };
495
+ const arrayValidator = (attribute, options) => ({
496
+ message: strapiAdmin.translatedErrors.required,
497
+ test(value) {
498
+ if (options.status === "draft") {
499
+ return true;
500
+ }
501
+ if (!attribute.required) {
502
+ return true;
503
+ }
504
+ if (!value) {
505
+ return false;
506
+ }
507
+ if (Array.isArray(value) && value.length === 0) {
508
+ return false;
509
+ }
510
+ return true;
511
+ }
512
+ });
485
513
  const createYupSchema = (attributes = {}, components = {}, options = { status: null }) => {
486
514
  const createModelSchema = (attributes2) => yup__namespace.object().shape(
487
515
  Object.entries(attributes2).reduce((acc, [name, attribute]) => {
@@ -489,6 +517,7 @@ const createYupSchema = (attributes = {}, components = {}, options = { status: n
489
517
  return acc;
490
518
  }
491
519
  const validations = [
520
+ addNullableValidation,
492
521
  addRequiredValidation,
493
522
  addMinLengthValidation,
494
523
  addMaxLengthValidation,
@@ -505,12 +534,12 @@ const createYupSchema = (attributes = {}, components = {}, options = { status: n
505
534
  ...acc,
506
535
  [name]: transformSchema(
507
536
  yup__namespace.array().of(createModelSchema(attributes3).nullable(false))
508
- )
537
+ ).test(arrayValidator(attribute, options))
509
538
  };
510
539
  } else {
511
540
  return {
512
541
  ...acc,
513
- [name]: transformSchema(createModelSchema(attributes3))
542
+ [name]: transformSchema(createModelSchema(attributes3).nullable())
514
543
  };
515
544
  }
516
545
  }
@@ -532,7 +561,7 @@ const createYupSchema = (attributes = {}, components = {}, options = { status: n
532
561
  }
533
562
  )
534
563
  )
535
- )
564
+ ).test(arrayValidator(attribute, options))
536
565
  };
537
566
  case "relation":
538
567
  return {
@@ -544,7 +573,7 @@ const createYupSchema = (attributes = {}, components = {}, options = { status: n
544
573
  } else if (Array.isArray(value)) {
545
574
  return yup__namespace.array().of(
546
575
  yup__namespace.object().shape({
547
- id: yup__namespace.string().required()
576
+ id: yup__namespace.number().required()
548
577
  })
549
578
  );
550
579
  } else if (typeof value === "object") {
@@ -630,17 +659,17 @@ const nullableSchema = (schema) => {
630
659
  schema
631
660
  );
632
661
  };
662
+ const addNullableValidation = () => (schema) => {
663
+ return nullableSchema(schema);
664
+ };
633
665
  const addRequiredValidation = (attribute, options) => (schema) => {
634
- if (options.status === "draft") {
635
- return nullableSchema(schema);
636
- }
637
- if ((attribute.type === "component" && attribute.repeatable || attribute.type === "dynamiczone") && attribute.required && "min" in schema) {
638
- return schema.min(1, strapiAdmin.translatedErrors.required);
666
+ if (options.status === "draft" || !attribute.required) {
667
+ return schema;
639
668
  }
640
- if (attribute.required && attribute.type !== "relation") {
669
+ if (attribute.required && "required" in schema) {
641
670
  return schema.required(strapiAdmin.translatedErrors.required);
642
671
  }
643
- return nullableSchema(schema);
672
+ return schema;
644
673
  };
645
674
  const addMinLengthValidation = (attribute, options) => (schema) => {
646
675
  if (options.status === "draft") {
@@ -668,31 +697,12 @@ const addMaxLengthValidation = (attribute) => (schema) => {
668
697
  return schema;
669
698
  };
670
699
  const addMinValidation = (attribute, options) => (schema) => {
671
- if ("min" in attribute) {
700
+ if (options.status === "draft") {
701
+ return schema;
702
+ }
703
+ if ("min" in attribute && "min" in schema) {
672
704
  const min = toInteger(attribute.min);
673
- if (attribute.type === "component" && attribute.repeatable || attribute.type === "dynamiczone") {
674
- if (options.status !== "draft" && !attribute.required && "test" in schema && min) {
675
- return schema.test(
676
- "custom-min",
677
- {
678
- ...strapiAdmin.translatedErrors.min,
679
- values: {
680
- min: attribute.min
681
- }
682
- },
683
- (value) => {
684
- if (!value) {
685
- return true;
686
- }
687
- if (Array.isArray(value) && value.length === 0) {
688
- return true;
689
- }
690
- return value.length >= min;
691
- }
692
- );
693
- }
694
- }
695
- if ("min" in schema && min) {
705
+ if (min) {
696
706
  return schema.min(min, {
697
707
  ...strapiAdmin.translatedErrors.min,
698
708
  values: {
@@ -810,19 +820,115 @@ const extractContentTypeComponents = (attributes = {}, allComponents = {}) => {
810
820
  }, {});
811
821
  return componentsByKey;
812
822
  };
813
- const useDocument = (args, opts) => {
823
+ const HOOKS = {
824
+ /**
825
+ * Hook that allows to mutate the displayed headers of the list view table
826
+ * @constant
827
+ * @type {string}
828
+ */
829
+ INJECT_COLUMN_IN_TABLE: "Admin/CM/pages/ListView/inject-column-in-table",
830
+ /**
831
+ * Hook that allows to mutate the CM's collection types links pre-set filters
832
+ * @constant
833
+ * @type {string}
834
+ */
835
+ MUTATE_COLLECTION_TYPES_LINKS: "Admin/CM/pages/App/mutate-collection-types-links",
836
+ /**
837
+ * Hook that allows to mutate the CM's edit view layout
838
+ * @constant
839
+ * @type {string}
840
+ */
841
+ MUTATE_EDIT_VIEW_LAYOUT: "Admin/CM/pages/EditView/mutate-edit-view-layout",
842
+ /**
843
+ * Hook that allows to mutate the CM's single types links pre-set filters
844
+ * @constant
845
+ * @type {string}
846
+ */
847
+ MUTATE_SINGLE_TYPES_LINKS: "Admin/CM/pages/App/mutate-single-types-links"
848
+ };
849
+ const contentTypesApi = contentManagerApi.injectEndpoints({
850
+ endpoints: (builder) => ({
851
+ getContentTypeConfiguration: builder.query({
852
+ query: (uid) => ({
853
+ url: `/content-manager/content-types/${uid}/configuration`,
854
+ method: "GET"
855
+ }),
856
+ transformResponse: (response) => response.data,
857
+ providesTags: (_result, _error, uid) => [
858
+ { type: "ContentTypesConfiguration", id: uid },
859
+ { type: "ContentTypeSettings", id: "LIST" }
860
+ ]
861
+ }),
862
+ getAllContentTypeSettings: builder.query({
863
+ query: () => "/content-manager/content-types-settings",
864
+ transformResponse: (response) => response.data,
865
+ providesTags: [{ type: "ContentTypeSettings", id: "LIST" }]
866
+ }),
867
+ updateContentTypeConfiguration: builder.mutation({
868
+ query: ({ uid, ...body }) => ({
869
+ url: `/content-manager/content-types/${uid}/configuration`,
870
+ method: "PUT",
871
+ data: body
872
+ }),
873
+ transformResponse: (response) => response.data,
874
+ invalidatesTags: (_result, _error, { uid }) => [
875
+ { type: "ContentTypesConfiguration", id: uid },
876
+ { type: "ContentTypeSettings", id: "LIST" },
877
+ // Is this necessary?
878
+ { type: "InitialData" }
879
+ ]
880
+ })
881
+ })
882
+ });
883
+ const {
884
+ useGetContentTypeConfigurationQuery,
885
+ useGetAllContentTypeSettingsQuery,
886
+ useUpdateContentTypeConfigurationMutation
887
+ } = contentTypesApi;
888
+ const checkIfAttributeIsDisplayable = (attribute) => {
889
+ const { type } = attribute;
890
+ if (type === "relation") {
891
+ return !attribute.relation.toLowerCase().includes("morph");
892
+ }
893
+ return !["json", "dynamiczone", "richtext", "password", "blocks"].includes(type) && !!type;
894
+ };
895
+ const getMainField = (attribute, mainFieldName, { schemas, components }) => {
896
+ if (!mainFieldName) {
897
+ return void 0;
898
+ }
899
+ const mainFieldType = attribute.type === "component" ? components[attribute.component].attributes[mainFieldName].type : (
900
+ // @ts-expect-error – `targetModel` does exist on the attribute for a relation.
901
+ schemas.find((schema) => schema.uid === attribute.targetModel)?.attributes[mainFieldName].type
902
+ );
903
+ return {
904
+ name: mainFieldName,
905
+ type: mainFieldType ?? "string"
906
+ };
907
+ };
908
+ const DEFAULT_SETTINGS = {
909
+ bulkable: false,
910
+ filterable: false,
911
+ searchable: false,
912
+ pagination: false,
913
+ defaultSortBy: "",
914
+ defaultSortOrder: "asc",
915
+ mainField: "id",
916
+ pageSize: 10
917
+ };
918
+ const useDocumentLayout = (model) => {
919
+ const { schema, components } = useDocument({ model, collectionType: "" }, { skip: true });
920
+ const [{ query }] = strapiAdmin.useQueryParams();
921
+ const runHookWaterfall = strapiAdmin.useStrapiApp("useDocumentLayout", (state) => state.runHookWaterfall);
814
922
  const { toggleNotification } = strapiAdmin.useNotification();
815
923
  const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
924
+ const { isLoading: isLoadingSchemas, schemas } = useContentTypeSchema();
816
925
  const {
817
- currentData: data,
818
- isLoading: isLoadingDocument,
819
- isFetching: isFetchingDocument,
820
- error
821
- } = useGetDocumentQuery(args, {
822
- ...opts,
823
- skip: !args.documentId && args.collectionType !== SINGLE_TYPES || opts?.skip
824
- });
825
- const { components, schema, isLoading: isLoadingSchema } = useContentTypeSchema(args.model);
926
+ data,
927
+ isLoading: isLoadingConfigs,
928
+ error,
929
+ isFetching: isFetchingConfigs
930
+ } = useGetContentTypeConfigurationQuery(model);
931
+ const isLoading = isLoadingSchemas || isFetchingConfigs || isLoadingConfigs;
826
932
  React__namespace.useEffect(() => {
827
933
  if (error) {
828
934
  toggleNotification({
@@ -830,396 +936,437 @@ const useDocument = (args, opts) => {
830
936
  message: formatAPIError(error)
831
937
  });
832
938
  }
833
- }, [toggleNotification, error, formatAPIError, args.collectionType]);
834
- const validationSchema = React__namespace.useMemo(() => {
835
- if (!schema) {
836
- return null;
837
- }
838
- return createYupSchema(schema.attributes, components);
839
- }, [schema, components]);
840
- const validate = React__namespace.useCallback(
841
- (document) => {
842
- if (!validationSchema) {
843
- throw new Error(
844
- "There is no validation schema generated, this is likely due to the schema not being loaded yet."
845
- );
846
- }
847
- try {
848
- validationSchema.validateSync(document, { abortEarly: false, strict: true });
849
- return null;
850
- } catch (error2) {
851
- if (error2 instanceof yup.ValidationError) {
852
- return strapiAdmin.getYupValidationErrors(error2);
853
- }
854
- throw error2;
855
- }
939
+ }, [error, formatAPIError, toggleNotification]);
940
+ const editLayout = React__namespace.useMemo(
941
+ () => data && !isLoading ? formatEditLayout(data, { schemas, schema, components }) : {
942
+ layout: [],
943
+ components: {},
944
+ metadatas: {},
945
+ options: {},
946
+ settings: DEFAULT_SETTINGS
856
947
  },
857
- [validationSchema]
948
+ [data, isLoading, schemas, schema, components]
949
+ );
950
+ const listLayout = React__namespace.useMemo(() => {
951
+ return data && !isLoading ? formatListLayout(data, { schemas, schema, components }) : {
952
+ layout: [],
953
+ metadatas: {},
954
+ options: {},
955
+ settings: DEFAULT_SETTINGS
956
+ };
957
+ }, [data, isLoading, schemas, schema, components]);
958
+ const { layout: edit } = React__namespace.useMemo(
959
+ () => runHookWaterfall(HOOKS.MUTATE_EDIT_VIEW_LAYOUT, {
960
+ layout: editLayout,
961
+ query
962
+ }),
963
+ [editLayout, query, runHookWaterfall]
858
964
  );
859
- const isLoading = isLoadingDocument || isFetchingDocument || isLoadingSchema;
860
965
  return {
861
- components,
862
- document: data?.data,
863
- meta: data?.meta,
966
+ error,
864
967
  isLoading,
865
- schema,
866
- validate
867
- };
868
- };
869
- const useDoc = () => {
870
- const { id, slug, collectionType, origin } = reactRouterDom.useParams();
871
- const [{ query }] = strapiAdmin.useQueryParams();
872
- const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
873
- if (!collectionType) {
874
- throw new Error("Could not find collectionType in url params");
875
- }
876
- if (!slug) {
877
- throw new Error("Could not find model in url params");
878
- }
879
- return {
880
- collectionType,
881
- model: slug,
882
- id: origin || id === "create" ? void 0 : id,
883
- ...useDocument(
884
- { documentId: origin || id, model: slug, collectionType, params },
885
- {
886
- skip: id === "create" || !origin && !id && collectionType !== SINGLE_TYPES
887
- }
888
- )
968
+ edit,
969
+ list: listLayout
889
970
  };
890
971
  };
891
- const prefixPluginTranslations = (trad, pluginId) => {
892
- if (!pluginId) {
893
- throw new TypeError("pluginId can't be empty");
894
- }
895
- return Object.keys(trad).reduce((acc, current) => {
896
- acc[`${pluginId}.${current}`] = trad[current];
897
- return acc;
898
- }, {});
899
- };
900
- const getTranslation = (id) => `content-manager.${id}`;
901
- const DEFAULT_UNEXPECTED_ERROR_MSG = {
902
- id: "notification.error",
903
- defaultMessage: "An error occurred, please try again"
972
+ const useDocLayout = () => {
973
+ const { model } = useDoc();
974
+ return useDocumentLayout(model);
904
975
  };
905
- const useDocumentActions = () => {
906
- const { toggleNotification } = strapiAdmin.useNotification();
907
- const { formatMessage } = reactIntl.useIntl();
908
- const { trackUsage } = strapiAdmin.useTracking();
909
- const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
910
- const navigate = reactRouterDom.useNavigate();
911
- const [deleteDocument] = useDeleteDocumentMutation();
912
- const _delete = React__namespace.useCallback(
913
- async ({ collectionType, model, documentId, params }, trackerProperty) => {
914
- try {
915
- trackUsage("willDeleteEntry", trackerProperty);
916
- const res = await deleteDocument({
917
- collectionType,
918
- model,
919
- documentId,
920
- params
921
- });
922
- if ("error" in res) {
923
- toggleNotification({
924
- type: "danger",
925
- message: formatAPIError(res.error)
926
- });
927
- return { error: res.error };
928
- }
929
- toggleNotification({
930
- type: "success",
931
- message: formatMessage({
932
- id: getTranslation("success.record.delete"),
933
- defaultMessage: "Deleted document"
934
- })
935
- });
936
- trackUsage("didDeleteEntry", trackerProperty);
937
- return res.data;
938
- } catch (err) {
939
- toggleNotification({
940
- type: "danger",
941
- message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
942
- });
943
- trackUsage("didNotDeleteEntry", { error: err, ...trackerProperty });
944
- throw err;
976
+ const formatEditLayout = (data, {
977
+ schemas,
978
+ schema,
979
+ components
980
+ }) => {
981
+ let currentPanelIndex = 0;
982
+ const panelledEditAttributes = convertEditLayoutToFieldLayouts(
983
+ data.contentType.layouts.edit,
984
+ schema?.attributes,
985
+ data.contentType.metadatas,
986
+ { configurations: data.components, schemas: components },
987
+ schemas
988
+ ).reduce((panels, row) => {
989
+ if (row.some((field) => field.type === "dynamiczone")) {
990
+ panels.push([row]);
991
+ currentPanelIndex += 2;
992
+ } else {
993
+ if (!panels[currentPanelIndex]) {
994
+ panels.push([row]);
995
+ } else {
996
+ panels[currentPanelIndex].push(row);
945
997
  }
946
- },
947
- [trackUsage, deleteDocument, toggleNotification, formatMessage, formatAPIError]
948
- );
949
- const [deleteManyDocuments] = useDeleteManyDocumentsMutation();
950
- const deleteMany = React__namespace.useCallback(
951
- async ({ model, documentIds, params }) => {
952
- try {
953
- trackUsage("willBulkDeleteEntries");
954
- const res = await deleteManyDocuments({
955
- model,
956
- documentIds,
957
- params
958
- });
959
- if ("error" in res) {
960
- toggleNotification({
961
- type: "danger",
962
- message: formatAPIError(res.error)
963
- });
964
- return { error: res.error };
998
+ }
999
+ return panels;
1000
+ }, []);
1001
+ const componentEditAttributes = Object.entries(data.components).reduce(
1002
+ (acc, [uid, configuration]) => {
1003
+ acc[uid] = {
1004
+ layout: convertEditLayoutToFieldLayouts(
1005
+ configuration.layouts.edit,
1006
+ components[uid].attributes,
1007
+ configuration.metadatas,
1008
+ { configurations: data.components, schemas: components }
1009
+ ),
1010
+ settings: {
1011
+ ...configuration.settings,
1012
+ icon: components[uid].info.icon,
1013
+ displayName: components[uid].info.displayName
965
1014
  }
966
- toggleNotification({
967
- type: "success",
968
- title: formatMessage({
969
- id: getTranslation("success.records.delete"),
970
- defaultMessage: "Successfully deleted."
971
- }),
972
- message: ""
973
- });
974
- trackUsage("didBulkDeleteEntries");
975
- return res.data;
976
- } catch (err) {
977
- toggleNotification({
978
- type: "danger",
979
- message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
980
- });
981
- trackUsage("didNotBulkDeleteEntries");
982
- throw err;
983
- }
1015
+ };
1016
+ return acc;
984
1017
  },
985
- [trackUsage, deleteManyDocuments, toggleNotification, formatMessage, formatAPIError]
1018
+ {}
986
1019
  );
987
- const [discardDocument] = useDiscardDocumentMutation();
988
- const discard = React__namespace.useCallback(
989
- async ({ collectionType, model, documentId, params }) => {
990
- try {
991
- const res = await discardDocument({
992
- collectionType,
993
- model,
994
- documentId,
995
- params
996
- });
997
- if ("error" in res) {
998
- toggleNotification({
999
- type: "danger",
1000
- message: formatAPIError(res.error)
1001
- });
1002
- return { error: res.error };
1003
- }
1004
- toggleNotification({
1005
- type: "success",
1006
- message: formatMessage({
1007
- id: "content-manager.success.record.discard",
1008
- defaultMessage: "Changes discarded"
1009
- })
1010
- });
1011
- return res.data;
1012
- } catch (err) {
1013
- toggleNotification({
1014
- type: "danger",
1015
- message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
1016
- });
1017
- throw err;
1018
- }
1020
+ const editMetadatas = Object.entries(data.contentType.metadatas).reduce(
1021
+ (acc, [attribute, metadata]) => {
1022
+ return {
1023
+ ...acc,
1024
+ [attribute]: metadata.edit
1025
+ };
1019
1026
  },
1020
- [discardDocument, formatAPIError, formatMessage, toggleNotification]
1027
+ {}
1021
1028
  );
1022
- const [publishDocument] = usePublishDocumentMutation();
1023
- const publish = React__namespace.useCallback(
1024
- async ({ collectionType, model, documentId, params }, data) => {
1025
- try {
1026
- trackUsage("willPublishEntry");
1027
- const res = await publishDocument({
1028
- collectionType,
1029
- model,
1030
- documentId,
1031
- data,
1032
- params
1033
- });
1034
- if ("error" in res) {
1035
- toggleNotification({ type: "danger", message: formatAPIError(res.error) });
1036
- return { error: res.error };
1037
- }
1038
- trackUsage("didPublishEntry");
1039
- toggleNotification({
1040
- type: "success",
1041
- message: formatMessage({
1042
- id: getTranslation("success.record.publish"),
1043
- defaultMessage: "Published document"
1044
- })
1045
- });
1046
- return res.data;
1047
- } catch (err) {
1048
- toggleNotification({
1049
- type: "danger",
1050
- message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
1051
- });
1052
- throw err;
1053
- }
1029
+ return {
1030
+ layout: panelledEditAttributes,
1031
+ components: componentEditAttributes,
1032
+ metadatas: editMetadatas,
1033
+ settings: {
1034
+ ...data.contentType.settings,
1035
+ displayName: schema?.info.displayName
1054
1036
  },
1055
- [trackUsage, publishDocument, toggleNotification, formatMessage, formatAPIError]
1056
- );
1057
- const [publishManyDocuments] = usePublishManyDocumentsMutation();
1058
- const publishMany = React__namespace.useCallback(
1059
- async ({ model, documentIds, params }) => {
1060
- try {
1061
- const res = await publishManyDocuments({
1062
- model,
1063
- documentIds,
1064
- params
1065
- });
1066
- if ("error" in res) {
1067
- toggleNotification({ type: "danger", message: formatAPIError(res.error) });
1068
- return { error: res.error };
1069
- }
1070
- toggleNotification({
1071
- type: "success",
1072
- message: formatMessage({
1073
- id: getTranslation("success.record.publish"),
1074
- defaultMessage: "Published document"
1075
- })
1076
- });
1077
- return res.data;
1078
- } catch (err) {
1079
- toggleNotification({
1080
- type: "danger",
1081
- message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
1082
- });
1083
- throw err;
1037
+ options: {
1038
+ ...schema?.options,
1039
+ ...schema?.pluginOptions,
1040
+ ...data.contentType.options
1041
+ }
1042
+ };
1043
+ };
1044
+ const convertEditLayoutToFieldLayouts = (rows, attributes = {}, metadatas, components, schemas = []) => {
1045
+ return rows.map(
1046
+ (row) => row.map((field) => {
1047
+ const attribute = attributes[field.name];
1048
+ if (!attribute) {
1049
+ return null;
1084
1050
  }
1051
+ const { edit: metadata } = metadatas[field.name];
1052
+ const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
1053
+ return {
1054
+ attribute,
1055
+ disabled: !metadata.editable,
1056
+ hint: metadata.description,
1057
+ label: metadata.label ?? "",
1058
+ name: field.name,
1059
+ // @ts-expect-error – mainField does exist on the metadata for a relation.
1060
+ mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
1061
+ schemas,
1062
+ components: components?.schemas ?? {}
1063
+ }),
1064
+ placeholder: metadata.placeholder ?? "",
1065
+ required: attribute.required ?? false,
1066
+ size: field.size,
1067
+ unique: "unique" in attribute ? attribute.unique : false,
1068
+ visible: metadata.visible ?? true,
1069
+ type: attribute.type
1070
+ };
1071
+ }).filter((field) => field !== null)
1072
+ );
1073
+ };
1074
+ const formatListLayout = (data, {
1075
+ schemas,
1076
+ schema,
1077
+ components
1078
+ }) => {
1079
+ const listMetadatas = Object.entries(data.contentType.metadatas).reduce(
1080
+ (acc, [attribute, metadata]) => {
1081
+ return {
1082
+ ...acc,
1083
+ [attribute]: metadata.list
1084
+ };
1085
1085
  },
1086
- [
1087
- // trackUsage,
1088
- publishManyDocuments,
1089
- toggleNotification,
1090
- formatMessage,
1091
- formatAPIError
1092
- ]
1086
+ {}
1093
1087
  );
1094
- const [updateDocument] = useUpdateDocumentMutation();
1095
- const update = React__namespace.useCallback(
1096
- async ({ collectionType, model, documentId, params }, data, trackerProperty) => {
1088
+ const listAttributes = convertListLayoutToFieldLayouts(
1089
+ data.contentType.layouts.list,
1090
+ schema?.attributes,
1091
+ listMetadatas,
1092
+ { configurations: data.components, schemas: components },
1093
+ schemas
1094
+ );
1095
+ return {
1096
+ layout: listAttributes,
1097
+ settings: { ...data.contentType.settings, displayName: schema?.info.displayName },
1098
+ metadatas: listMetadatas,
1099
+ options: {
1100
+ ...schema?.options,
1101
+ ...schema?.pluginOptions,
1102
+ ...data.contentType.options
1103
+ }
1104
+ };
1105
+ };
1106
+ const convertListLayoutToFieldLayouts = (columns, attributes = {}, metadatas, components, schemas = []) => {
1107
+ return columns.map((name) => {
1108
+ const attribute = attributes[name];
1109
+ if (!attribute) {
1110
+ return null;
1111
+ }
1112
+ const metadata = metadatas[name];
1113
+ const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
1114
+ return {
1115
+ attribute,
1116
+ label: metadata.label ?? "",
1117
+ mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
1118
+ schemas,
1119
+ components: components?.schemas ?? {}
1120
+ }),
1121
+ name,
1122
+ searchable: metadata.searchable ?? true,
1123
+ sortable: metadata.sortable ?? true
1124
+ };
1125
+ }).filter((field) => field !== null);
1126
+ };
1127
+ const useDocument = (args, opts) => {
1128
+ const { toggleNotification } = strapiAdmin.useNotification();
1129
+ const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
1130
+ const {
1131
+ currentData: data,
1132
+ isLoading: isLoadingDocument,
1133
+ isFetching: isFetchingDocument,
1134
+ error
1135
+ } = useGetDocumentQuery(args, {
1136
+ ...opts,
1137
+ skip: !args.documentId && args.collectionType !== SINGLE_TYPES || opts?.skip
1138
+ });
1139
+ const {
1140
+ components,
1141
+ schema,
1142
+ schemas,
1143
+ isLoading: isLoadingSchema
1144
+ } = useContentTypeSchema(args.model);
1145
+ React__namespace.useEffect(() => {
1146
+ if (error) {
1147
+ toggleNotification({
1148
+ type: "danger",
1149
+ message: formatAPIError(error)
1150
+ });
1151
+ }
1152
+ }, [toggleNotification, error, formatAPIError, args.collectionType]);
1153
+ const validationSchema = React__namespace.useMemo(() => {
1154
+ if (!schema) {
1155
+ return null;
1156
+ }
1157
+ return createYupSchema(schema.attributes, components);
1158
+ }, [schema, components]);
1159
+ const validate = React__namespace.useCallback(
1160
+ (document) => {
1161
+ if (!validationSchema) {
1162
+ throw new Error(
1163
+ "There is no validation schema generated, this is likely due to the schema not being loaded yet."
1164
+ );
1165
+ }
1097
1166
  try {
1098
- trackUsage("willEditEntry", trackerProperty);
1099
- const res = await updateDocument({
1100
- collectionType,
1101
- model,
1102
- documentId,
1103
- data,
1104
- params
1105
- });
1106
- if ("error" in res) {
1107
- toggleNotification({ type: "danger", message: formatAPIError(res.error) });
1108
- trackUsage("didNotEditEntry", { error: res.error, ...trackerProperty });
1109
- return { error: res.error };
1167
+ validationSchema.validateSync(document, { abortEarly: false, strict: true });
1168
+ return null;
1169
+ } catch (error2) {
1170
+ if (error2 instanceof yup.ValidationError) {
1171
+ return strapiAdmin.getYupValidationErrors(error2);
1110
1172
  }
1111
- trackUsage("didEditEntry", trackerProperty);
1112
- toggleNotification({
1113
- type: "success",
1114
- message: formatMessage({
1115
- id: getTranslation("success.record.save"),
1116
- defaultMessage: "Saved document"
1117
- })
1118
- });
1119
- return res.data;
1120
- } catch (err) {
1121
- trackUsage("didNotEditEntry", { error: err, ...trackerProperty });
1122
- toggleNotification({
1123
- type: "danger",
1124
- message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
1125
- });
1126
- throw err;
1173
+ throw error2;
1127
1174
  }
1128
1175
  },
1129
- [trackUsage, updateDocument, toggleNotification, formatMessage, formatAPIError]
1176
+ [validationSchema]
1130
1177
  );
1131
- const [unpublishDocument] = useUnpublishDocumentMutation();
1132
- const unpublish = React__namespace.useCallback(
1133
- async ({ collectionType, model, documentId, params }, discardDraft = false) => {
1178
+ const isLoading = isLoadingDocument || isFetchingDocument || isLoadingSchema;
1179
+ const hasError = !!error;
1180
+ return {
1181
+ components,
1182
+ document: data?.data,
1183
+ meta: data?.meta,
1184
+ isLoading,
1185
+ hasError,
1186
+ schema,
1187
+ schemas,
1188
+ validate
1189
+ };
1190
+ };
1191
+ const useDoc = () => {
1192
+ const { id, slug, collectionType, origin } = reactRouterDom.useParams();
1193
+ const [{ query }] = strapiAdmin.useQueryParams();
1194
+ const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
1195
+ if (!collectionType) {
1196
+ throw new Error("Could not find collectionType in url params");
1197
+ }
1198
+ if (!slug) {
1199
+ throw new Error("Could not find model in url params");
1200
+ }
1201
+ const document = useDocument(
1202
+ { documentId: origin || id, model: slug, collectionType, params },
1203
+ {
1204
+ skip: id === "create" || !origin && !id && collectionType !== SINGLE_TYPES
1205
+ }
1206
+ );
1207
+ const returnId = origin || id === "create" ? void 0 : id;
1208
+ return {
1209
+ collectionType,
1210
+ model: slug,
1211
+ id: returnId,
1212
+ ...document
1213
+ };
1214
+ };
1215
+ const useContentManagerContext = () => {
1216
+ const {
1217
+ collectionType,
1218
+ model,
1219
+ id,
1220
+ components,
1221
+ isLoading: isLoadingDoc,
1222
+ schema,
1223
+ schemas
1224
+ } = useDoc();
1225
+ const layout = useDocumentLayout(model);
1226
+ const form = strapiAdmin.useForm("useContentManagerContext", (state) => state);
1227
+ const isSingleType = collectionType === SINGLE_TYPES;
1228
+ const slug = model;
1229
+ const isCreatingEntry = id === "create";
1230
+ useContentTypeSchema();
1231
+ const isLoading = isLoadingDoc || layout.isLoading;
1232
+ const error = layout.error;
1233
+ return {
1234
+ error,
1235
+ isLoading,
1236
+ // Base metadata
1237
+ model,
1238
+ collectionType,
1239
+ id,
1240
+ slug,
1241
+ isCreatingEntry,
1242
+ isSingleType,
1243
+ hasDraftAndPublish: schema?.options?.draftAndPublish ?? false,
1244
+ // All schema infos
1245
+ components,
1246
+ contentType: schema,
1247
+ contentTypes: schemas,
1248
+ // Form state
1249
+ form,
1250
+ // layout infos
1251
+ layout
1252
+ };
1253
+ };
1254
+ const prefixPluginTranslations = (trad, pluginId) => {
1255
+ return Object.keys(trad).reduce((acc, current) => {
1256
+ acc[`${pluginId}.${current}`] = trad[current];
1257
+ return acc;
1258
+ }, {});
1259
+ };
1260
+ const getTranslation = (id) => `content-manager.${id}`;
1261
+ const DEFAULT_UNEXPECTED_ERROR_MSG = {
1262
+ id: "notification.error",
1263
+ defaultMessage: "An error occurred, please try again"
1264
+ };
1265
+ const useDocumentActions = () => {
1266
+ const { toggleNotification } = strapiAdmin.useNotification();
1267
+ const { formatMessage } = reactIntl.useIntl();
1268
+ const { trackUsage } = strapiAdmin.useTracking();
1269
+ const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
1270
+ const navigate = reactRouterDom.useNavigate();
1271
+ const setCurrentStep = strapiAdmin.useGuidedTour("useDocumentActions", (state) => state.setCurrentStep);
1272
+ const [deleteDocument] = useDeleteDocumentMutation();
1273
+ const _delete = React__namespace.useCallback(
1274
+ async ({ collectionType, model, documentId, params }, trackerProperty) => {
1134
1275
  try {
1135
- trackUsage("willUnpublishEntry");
1136
- const res = await unpublishDocument({
1276
+ trackUsage("willDeleteEntry", trackerProperty);
1277
+ const res = await deleteDocument({
1137
1278
  collectionType,
1138
1279
  model,
1139
1280
  documentId,
1140
- params,
1141
- data: {
1142
- discardDraft
1143
- }
1281
+ params
1144
1282
  });
1145
1283
  if ("error" in res) {
1146
- toggleNotification({ type: "danger", message: formatAPIError(res.error) });
1284
+ toggleNotification({
1285
+ type: "danger",
1286
+ message: formatAPIError(res.error)
1287
+ });
1147
1288
  return { error: res.error };
1148
1289
  }
1149
- trackUsage("didUnpublishEntry");
1150
1290
  toggleNotification({
1151
1291
  type: "success",
1152
1292
  message: formatMessage({
1153
- id: getTranslation("success.record.unpublish"),
1154
- defaultMessage: "Unpublished document"
1293
+ id: getTranslation("success.record.delete"),
1294
+ defaultMessage: "Deleted document"
1155
1295
  })
1156
1296
  });
1297
+ trackUsage("didDeleteEntry", trackerProperty);
1157
1298
  return res.data;
1158
1299
  } catch (err) {
1159
1300
  toggleNotification({
1160
1301
  type: "danger",
1161
1302
  message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
1162
1303
  });
1304
+ trackUsage("didNotDeleteEntry", { error: err, ...trackerProperty });
1163
1305
  throw err;
1164
1306
  }
1165
1307
  },
1166
- [trackUsage, unpublishDocument, toggleNotification, formatMessage, formatAPIError]
1308
+ [trackUsage, deleteDocument, toggleNotification, formatMessage, formatAPIError]
1167
1309
  );
1168
- const [unpublishManyDocuments] = useUnpublishManyDocumentsMutation();
1169
- const unpublishMany = React__namespace.useCallback(
1310
+ const [deleteManyDocuments] = useDeleteManyDocumentsMutation();
1311
+ const deleteMany = React__namespace.useCallback(
1170
1312
  async ({ model, documentIds, params }) => {
1171
1313
  try {
1172
- trackUsage("willBulkUnpublishEntries");
1173
- const res = await unpublishManyDocuments({
1314
+ trackUsage("willBulkDeleteEntries");
1315
+ const res = await deleteManyDocuments({
1174
1316
  model,
1175
1317
  documentIds,
1176
1318
  params
1177
1319
  });
1178
1320
  if ("error" in res) {
1179
- toggleNotification({ type: "danger", message: formatAPIError(res.error) });
1321
+ toggleNotification({
1322
+ type: "danger",
1323
+ message: formatAPIError(res.error)
1324
+ });
1180
1325
  return { error: res.error };
1181
1326
  }
1182
- trackUsage("didBulkUnpublishEntries");
1183
1327
  toggleNotification({
1184
1328
  type: "success",
1185
1329
  title: formatMessage({
1186
- id: getTranslation("success.records.unpublish"),
1187
- defaultMessage: "Successfully unpublished."
1330
+ id: getTranslation("success.records.delete"),
1331
+ defaultMessage: "Successfully deleted."
1188
1332
  }),
1189
1333
  message: ""
1190
1334
  });
1335
+ trackUsage("didBulkDeleteEntries");
1191
1336
  return res.data;
1192
1337
  } catch (err) {
1193
1338
  toggleNotification({
1194
1339
  type: "danger",
1195
1340
  message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
1196
1341
  });
1197
- trackUsage("didNotBulkUnpublishEntries");
1342
+ trackUsage("didNotBulkDeleteEntries");
1198
1343
  throw err;
1199
1344
  }
1200
1345
  },
1201
- [trackUsage, unpublishManyDocuments, toggleNotification, formatMessage, formatAPIError]
1346
+ [trackUsage, deleteManyDocuments, toggleNotification, formatMessage, formatAPIError]
1202
1347
  );
1203
- const [createDocument] = useCreateDocumentMutation();
1204
- const create = React__namespace.useCallback(
1205
- async ({ model, params }, data, trackerProperty) => {
1348
+ const [discardDocument] = useDiscardDocumentMutation();
1349
+ const discard = React__namespace.useCallback(
1350
+ async ({ collectionType, model, documentId, params }) => {
1206
1351
  try {
1207
- const res = await createDocument({
1352
+ const res = await discardDocument({
1353
+ collectionType,
1208
1354
  model,
1209
- data,
1355
+ documentId,
1210
1356
  params
1211
1357
  });
1212
1358
  if ("error" in res) {
1213
- toggleNotification({ type: "danger", message: formatAPIError(res.error) });
1214
- trackUsage("didNotCreateEntry", { error: res.error, ...trackerProperty });
1359
+ toggleNotification({
1360
+ type: "danger",
1361
+ message: formatAPIError(res.error)
1362
+ });
1215
1363
  return { error: res.error };
1216
1364
  }
1217
- trackUsage("didCreateEntry", trackerProperty);
1218
1365
  toggleNotification({
1219
1366
  type: "success",
1220
1367
  message: formatMessage({
1221
- id: getTranslation("success.record.save"),
1222
- defaultMessage: "Saved document"
1368
+ id: "content-manager.success.record.discard",
1369
+ defaultMessage: "Changes discarded"
1223
1370
  })
1224
1371
  });
1225
1372
  return res.data;
@@ -1228,17 +1375,232 @@ const useDocumentActions = () => {
1228
1375
  type: "danger",
1229
1376
  message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
1230
1377
  });
1231
- trackUsage("didNotCreateEntry", { error: err, ...trackerProperty });
1232
1378
  throw err;
1233
1379
  }
1234
1380
  },
1235
- [createDocument, formatAPIError, formatMessage, toggleNotification, trackUsage]
1381
+ [discardDocument, formatAPIError, formatMessage, toggleNotification]
1236
1382
  );
1237
- const [autoCloneDocument] = useAutoCloneDocumentMutation();
1238
- const autoClone = React__namespace.useCallback(
1239
- async ({ model, sourceId }) => {
1383
+ const [publishDocument] = usePublishDocumentMutation();
1384
+ const publish = React__namespace.useCallback(
1385
+ async ({ collectionType, model, documentId, params }, data) => {
1240
1386
  try {
1241
- const res = await autoCloneDocument({
1387
+ trackUsage("willPublishEntry");
1388
+ const res = await publishDocument({
1389
+ collectionType,
1390
+ model,
1391
+ documentId,
1392
+ data,
1393
+ params
1394
+ });
1395
+ if ("error" in res) {
1396
+ toggleNotification({ type: "danger", message: formatAPIError(res.error) });
1397
+ return { error: res.error };
1398
+ }
1399
+ trackUsage("didPublishEntry");
1400
+ toggleNotification({
1401
+ type: "success",
1402
+ message: formatMessage({
1403
+ id: getTranslation("success.record.publish"),
1404
+ defaultMessage: "Published document"
1405
+ })
1406
+ });
1407
+ return res.data;
1408
+ } catch (err) {
1409
+ toggleNotification({
1410
+ type: "danger",
1411
+ message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
1412
+ });
1413
+ throw err;
1414
+ }
1415
+ },
1416
+ [trackUsage, publishDocument, toggleNotification, formatMessage, formatAPIError]
1417
+ );
1418
+ const [publishManyDocuments] = usePublishManyDocumentsMutation();
1419
+ const publishMany = React__namespace.useCallback(
1420
+ async ({ model, documentIds, params }) => {
1421
+ try {
1422
+ const res = await publishManyDocuments({
1423
+ model,
1424
+ documentIds,
1425
+ params
1426
+ });
1427
+ if ("error" in res) {
1428
+ toggleNotification({ type: "danger", message: formatAPIError(res.error) });
1429
+ return { error: res.error };
1430
+ }
1431
+ toggleNotification({
1432
+ type: "success",
1433
+ message: formatMessage({
1434
+ id: getTranslation("success.record.publish"),
1435
+ defaultMessage: "Published document"
1436
+ })
1437
+ });
1438
+ return res.data;
1439
+ } catch (err) {
1440
+ toggleNotification({
1441
+ type: "danger",
1442
+ message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
1443
+ });
1444
+ throw err;
1445
+ }
1446
+ },
1447
+ [
1448
+ // trackUsage,
1449
+ publishManyDocuments,
1450
+ toggleNotification,
1451
+ formatMessage,
1452
+ formatAPIError
1453
+ ]
1454
+ );
1455
+ const [updateDocument] = useUpdateDocumentMutation();
1456
+ const update = React__namespace.useCallback(
1457
+ async ({ collectionType, model, documentId, params }, data, trackerProperty) => {
1458
+ try {
1459
+ trackUsage("willEditEntry", trackerProperty);
1460
+ const res = await updateDocument({
1461
+ collectionType,
1462
+ model,
1463
+ documentId,
1464
+ data,
1465
+ params
1466
+ });
1467
+ if ("error" in res) {
1468
+ toggleNotification({ type: "danger", message: formatAPIError(res.error) });
1469
+ trackUsage("didNotEditEntry", { error: res.error, ...trackerProperty });
1470
+ return { error: res.error };
1471
+ }
1472
+ trackUsage("didEditEntry", trackerProperty);
1473
+ toggleNotification({
1474
+ type: "success",
1475
+ message: formatMessage({
1476
+ id: getTranslation("success.record.save"),
1477
+ defaultMessage: "Saved document"
1478
+ })
1479
+ });
1480
+ return res.data;
1481
+ } catch (err) {
1482
+ trackUsage("didNotEditEntry", { error: err, ...trackerProperty });
1483
+ toggleNotification({
1484
+ type: "danger",
1485
+ message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
1486
+ });
1487
+ throw err;
1488
+ }
1489
+ },
1490
+ [trackUsage, updateDocument, toggleNotification, formatMessage, formatAPIError]
1491
+ );
1492
+ const [unpublishDocument] = useUnpublishDocumentMutation();
1493
+ const unpublish = React__namespace.useCallback(
1494
+ async ({ collectionType, model, documentId, params }, discardDraft = false) => {
1495
+ try {
1496
+ trackUsage("willUnpublishEntry");
1497
+ const res = await unpublishDocument({
1498
+ collectionType,
1499
+ model,
1500
+ documentId,
1501
+ params,
1502
+ data: {
1503
+ discardDraft
1504
+ }
1505
+ });
1506
+ if ("error" in res) {
1507
+ toggleNotification({ type: "danger", message: formatAPIError(res.error) });
1508
+ return { error: res.error };
1509
+ }
1510
+ trackUsage("didUnpublishEntry");
1511
+ toggleNotification({
1512
+ type: "success",
1513
+ message: formatMessage({
1514
+ id: getTranslation("success.record.unpublish"),
1515
+ defaultMessage: "Unpublished document"
1516
+ })
1517
+ });
1518
+ return res.data;
1519
+ } catch (err) {
1520
+ toggleNotification({
1521
+ type: "danger",
1522
+ message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
1523
+ });
1524
+ throw err;
1525
+ }
1526
+ },
1527
+ [trackUsage, unpublishDocument, toggleNotification, formatMessage, formatAPIError]
1528
+ );
1529
+ const [unpublishManyDocuments] = useUnpublishManyDocumentsMutation();
1530
+ const unpublishMany = React__namespace.useCallback(
1531
+ async ({ model, documentIds, params }) => {
1532
+ try {
1533
+ trackUsage("willBulkUnpublishEntries");
1534
+ const res = await unpublishManyDocuments({
1535
+ model,
1536
+ documentIds,
1537
+ params
1538
+ });
1539
+ if ("error" in res) {
1540
+ toggleNotification({ type: "danger", message: formatAPIError(res.error) });
1541
+ return { error: res.error };
1542
+ }
1543
+ trackUsage("didBulkUnpublishEntries");
1544
+ toggleNotification({
1545
+ type: "success",
1546
+ title: formatMessage({
1547
+ id: getTranslation("success.records.unpublish"),
1548
+ defaultMessage: "Successfully unpublished."
1549
+ }),
1550
+ message: ""
1551
+ });
1552
+ return res.data;
1553
+ } catch (err) {
1554
+ toggleNotification({
1555
+ type: "danger",
1556
+ message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
1557
+ });
1558
+ trackUsage("didNotBulkUnpublishEntries");
1559
+ throw err;
1560
+ }
1561
+ },
1562
+ [trackUsage, unpublishManyDocuments, toggleNotification, formatMessage, formatAPIError]
1563
+ );
1564
+ const [createDocument] = useCreateDocumentMutation();
1565
+ const create = React__namespace.useCallback(
1566
+ async ({ model, params }, data, trackerProperty) => {
1567
+ try {
1568
+ const res = await createDocument({
1569
+ model,
1570
+ data,
1571
+ params
1572
+ });
1573
+ if ("error" in res) {
1574
+ toggleNotification({ type: "danger", message: formatAPIError(res.error) });
1575
+ trackUsage("didNotCreateEntry", { error: res.error, ...trackerProperty });
1576
+ return { error: res.error };
1577
+ }
1578
+ trackUsage("didCreateEntry", trackerProperty);
1579
+ toggleNotification({
1580
+ type: "success",
1581
+ message: formatMessage({
1582
+ id: getTranslation("success.record.save"),
1583
+ defaultMessage: "Saved document"
1584
+ })
1585
+ });
1586
+ setCurrentStep("contentManager.success");
1587
+ return res.data;
1588
+ } catch (err) {
1589
+ toggleNotification({
1590
+ type: "danger",
1591
+ message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
1592
+ });
1593
+ trackUsage("didNotCreateEntry", { error: err, ...trackerProperty });
1594
+ throw err;
1595
+ }
1596
+ },
1597
+ [createDocument, formatAPIError, formatMessage, toggleNotification, trackUsage]
1598
+ );
1599
+ const [autoCloneDocument] = useAutoCloneDocumentMutation();
1600
+ const autoClone = React__namespace.useCallback(
1601
+ async ({ model, sourceId }) => {
1602
+ try {
1603
+ const res = await autoCloneDocument({
1242
1604
  model,
1243
1605
  sourceId
1244
1606
  });
@@ -1323,10 +1685,10 @@ const useDocumentActions = () => {
1323
1685
  update
1324
1686
  };
1325
1687
  };
1326
- const ProtectedHistoryPage = React.lazy(
1327
- () => Promise.resolve().then(() => require("./History-BT4w83Oa.js")).then((mod) => ({ default: mod.ProtectedHistoryPage }))
1688
+ const ProtectedHistoryPage = React__namespace.lazy(
1689
+ () => Promise.resolve().then(() => require("./History-sJ61vusJ.js")).then((mod) => ({ default: mod.ProtectedHistoryPage }))
1328
1690
  );
1329
- const routes$1 = [
1691
+ const routes$2 = [
1330
1692
  {
1331
1693
  path: ":collectionType/:slug/:id/history",
1332
1694
  Component: ProtectedHistoryPage
@@ -1336,32 +1698,45 @@ const routes$1 = [
1336
1698
  Component: ProtectedHistoryPage
1337
1699
  }
1338
1700
  ];
1701
+ const ProtectedPreviewPage = React__namespace.lazy(
1702
+ () => Promise.resolve().then(() => require("./Preview-CS2aV-BU.js")).then((mod) => ({ default: mod.ProtectedPreviewPage }))
1703
+ );
1704
+ const routes$1 = [
1705
+ {
1706
+ path: ":collectionType/:slug/:id/preview",
1707
+ Component: ProtectedPreviewPage
1708
+ },
1709
+ {
1710
+ path: ":collectionType/:slug/preview",
1711
+ Component: ProtectedPreviewPage
1712
+ }
1713
+ ];
1339
1714
  const ProtectedEditViewPage = React.lazy(
1340
- () => Promise.resolve().then(() => require("./EditViewPage-Dk7Eaft4.js")).then((mod) => ({ default: mod.ProtectedEditViewPage }))
1715
+ () => Promise.resolve().then(() => require("./EditViewPage-s_qVLiC6.js")).then((mod) => ({ default: mod.ProtectedEditViewPage }))
1341
1716
  );
1342
1717
  const ProtectedListViewPage = React.lazy(
1343
- () => Promise.resolve().then(() => require("./ListViewPage-BvpwNur7.js")).then((mod) => ({ default: mod.ProtectedListViewPage }))
1718
+ () => Promise.resolve().then(() => require("./ListViewPage-DDVpN1ql.js")).then((mod) => ({ default: mod.ProtectedListViewPage }))
1344
1719
  );
1345
1720
  const ProtectedListConfiguration = React.lazy(
1346
- () => Promise.resolve().then(() => require("./ListConfigurationPage-CuYrMcW3.js")).then((mod) => ({
1721
+ () => Promise.resolve().then(() => require("./ListConfigurationPage-C00guBjQ.js")).then((mod) => ({
1347
1722
  default: mod.ProtectedListConfiguration
1348
1723
  }))
1349
1724
  );
1350
1725
  const ProtectedEditConfigurationPage = React.lazy(
1351
- () => Promise.resolve().then(() => require("./EditConfigurationPage-DValmA0m.js")).then((mod) => ({
1726
+ () => Promise.resolve().then(() => require("./EditConfigurationPage-BQGdJb6Z.js")).then((mod) => ({
1352
1727
  default: mod.ProtectedEditConfigurationPage
1353
1728
  }))
1354
1729
  );
1355
1730
  const ProtectedComponentConfigurationPage = React.lazy(
1356
- () => Promise.resolve().then(() => require("./ComponentConfigurationPage-DyDkPajU.js")).then((mod) => ({
1731
+ () => Promise.resolve().then(() => require("./ComponentConfigurationPage-BaGEn2nd.js")).then((mod) => ({
1357
1732
  default: mod.ProtectedComponentConfigurationPage
1358
1733
  }))
1359
1734
  );
1360
1735
  const NoPermissions = React.lazy(
1361
- () => Promise.resolve().then(() => require("./NoPermissionsPage-C_vGRo8Q.js")).then((mod) => ({ default: mod.NoPermissions }))
1736
+ () => Promise.resolve().then(() => require("./NoPermissionsPage-BZjHQTpb.js")).then((mod) => ({ default: mod.NoPermissions }))
1362
1737
  );
1363
1738
  const NoContentType = React.lazy(
1364
- () => Promise.resolve().then(() => require("./NoContentTypePage-UqEiWKkM.js")).then((mod) => ({ default: mod.NoContentType }))
1739
+ () => Promise.resolve().then(() => require("./NoContentTypePage-BvkII4H4.js")).then((mod) => ({ default: mod.NoContentType }))
1365
1740
  );
1366
1741
  const CollectionTypePages = () => {
1367
1742
  const { collectionType } = reactRouterDom.useParams();
@@ -1373,7 +1748,7 @@ const CollectionTypePages = () => {
1373
1748
  const CLONE_RELATIVE_PATH = ":collectionType/:slug/clone/:origin";
1374
1749
  const CLONE_PATH = `/content-manager/${CLONE_RELATIVE_PATH}`;
1375
1750
  const LIST_RELATIVE_PATH = ":collectionType/:slug";
1376
- const LIST_PATH = `/content-manager/${LIST_RELATIVE_PATH}`;
1751
+ const LIST_PATH = `/content-manager/collection-types/:slug`;
1377
1752
  const routes = [
1378
1753
  {
1379
1754
  path: LIST_RELATIVE_PATH,
@@ -1407,6 +1782,7 @@ const routes = [
1407
1782
  path: "no-content-types",
1408
1783
  Component: NoContentType
1409
1784
  },
1785
+ ...routes$2,
1410
1786
  ...routes$1
1411
1787
  ];
1412
1788
  const DocumentActions = ({ actions: actions2 }) => {
@@ -1505,6 +1881,11 @@ const DocumentActionButton = (action) => {
1505
1881
  ) : null
1506
1882
  ] });
1507
1883
  };
1884
+ const MenuItem = styledComponents.styled(designSystem.Menu.Item)`
1885
+ &:hover {
1886
+ background: ${({ theme, isVariantDanger, isDisabled }) => isVariantDanger && !isDisabled ? theme.colors.danger100 : "neutral"};
1887
+ }
1888
+ `;
1508
1889
  const DocumentActionsMenu = ({
1509
1890
  actions: actions2,
1510
1891
  children,
@@ -1560,51 +1941,35 @@ const DocumentActionsMenu = ({
1560
1941
  ]
1561
1942
  }
1562
1943
  ),
1563
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.Content, { top: "4px", maxHeight: void 0, popoverPlacement: "bottom-end", children: [
1944
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.Content, { maxHeight: void 0, popoverPlacement: "bottom-end", children: [
1564
1945
  actions2.map((action) => {
1565
1946
  return /* @__PURE__ */ jsxRuntime.jsx(
1566
- designSystem.Menu.Item,
1947
+ MenuItem,
1567
1948
  {
1568
1949
  disabled: action.disabled,
1569
1950
  onSelect: handleClick(action),
1570
1951
  display: "block",
1571
- children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", gap: 4, children: [
1572
- /* @__PURE__ */ jsxRuntime.jsxs(
1573
- designSystem.Flex,
1574
- {
1575
- color: !action.disabled ? convertActionVariantToColor(action.variant) : "inherit",
1576
- gap: 2,
1577
- tag: "span",
1578
- children: [
1579
- /* @__PURE__ */ jsxRuntime.jsx(
1580
- designSystem.Flex,
1581
- {
1582
- tag: "span",
1583
- color: !action.disabled ? convertActionVariantToIconColor(action.variant) : "inherit",
1584
- children: action.icon
1585
- }
1586
- ),
1587
- action.label
1588
- ]
1589
- }
1590
- ),
1591
- action.id.startsWith("HistoryAction") && /* @__PURE__ */ jsxRuntime.jsx(
1592
- designSystem.Flex,
1593
- {
1594
- alignItems: "center",
1595
- background: "alternative100",
1596
- borderStyle: "solid",
1597
- borderColor: "alternative200",
1598
- borderWidth: "1px",
1599
- height: 5,
1600
- paddingLeft: 2,
1601
- paddingRight: 2,
1602
- hasRadius: true,
1603
- color: "alternative600",
1604
- children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", fontWeight: "bold", lineHeight: 1, children: formatMessage({ id: "global.new", defaultMessage: "New" }) })
1605
- }
1606
- )
1607
- ] })
1952
+ isVariantDanger: action.variant === "danger",
1953
+ isDisabled: action.disabled,
1954
+ children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "space-between", gap: 4, children: /* @__PURE__ */ jsxRuntime.jsxs(
1955
+ designSystem.Flex,
1956
+ {
1957
+ color: !action.disabled ? convertActionVariantToColor(action.variant) : "inherit",
1958
+ gap: 2,
1959
+ tag: "span",
1960
+ children: [
1961
+ /* @__PURE__ */ jsxRuntime.jsx(
1962
+ designSystem.Flex,
1963
+ {
1964
+ tag: "span",
1965
+ color: !action.disabled ? convertActionVariantToIconColor(action.variant) : "inherit",
1966
+ children: action.icon
1967
+ }
1968
+ ),
1969
+ action.label
1970
+ ]
1971
+ }
1972
+ ) })
1608
1973
  },
1609
1974
  action.id
1610
1975
  );
@@ -1684,11 +2049,11 @@ const DocumentActionConfirmDialog = ({
1684
2049
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Header, { children: title }),
1685
2050
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Body, { children: content }),
1686
2051
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Footer, { children: [
1687
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Cancel, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", children: formatMessage({
2052
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Cancel, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", fullWidth: true, children: formatMessage({
1688
2053
  id: "app.components.Button.cancel",
1689
2054
  defaultMessage: "Cancel"
1690
2055
  }) }) }),
1691
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: handleConfirm, variant, children: formatMessage({
2056
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: handleConfirm, variant, fullWidth: true, children: formatMessage({
1692
2057
  id: "app.components.Button.confirm",
1693
2058
  defaultMessage: "Confirm"
1694
2059
  }) })
@@ -1715,6 +2080,18 @@ const DocumentActionModal = ({
1715
2080
  typeof Footer === "function" ? /* @__PURE__ */ jsxRuntime.jsx(Footer, { onClose: handleClose }) : Footer
1716
2081
  ] }) });
1717
2082
  };
2083
+ const transformData = (data) => {
2084
+ if (Array.isArray(data)) {
2085
+ return data.map(transformData);
2086
+ }
2087
+ if (typeof data === "object" && data !== null) {
2088
+ if ("apiData" in data) {
2089
+ return data.apiData;
2090
+ }
2091
+ return mapValues__default.default(transformData)(data);
2092
+ }
2093
+ return data;
2094
+ };
1718
2095
  const PublishAction$1 = ({
1719
2096
  activeTab,
1720
2097
  documentId,
@@ -1782,24 +2159,25 @@ const PublishAction$1 = ({
1782
2159
  }
1783
2160
  }, [documentId, modified, formValues, setLocalCountOfDraftRelations]);
1784
2161
  React__namespace.useEffect(() => {
1785
- if (documentId && !isListView) {
1786
- const fetchDraftRelationsCount = async () => {
1787
- const { data, error } = await countDraftRelations({
1788
- collectionType,
1789
- model,
1790
- documentId,
1791
- params
1792
- });
1793
- if (error) {
1794
- throw error;
1795
- }
1796
- if (data) {
1797
- setServerCountOfDraftRelations(data.data);
1798
- }
1799
- };
1800
- fetchDraftRelationsCount();
2162
+ if (!document || !document.documentId || isListView) {
2163
+ return;
1801
2164
  }
1802
- }, [isListView, documentId, countDraftRelations, collectionType, model, params]);
2165
+ const fetchDraftRelationsCount = async () => {
2166
+ const { data, error } = await countDraftRelations({
2167
+ collectionType,
2168
+ model,
2169
+ documentId,
2170
+ params
2171
+ });
2172
+ if (error) {
2173
+ throw error;
2174
+ }
2175
+ if (data) {
2176
+ setServerCountOfDraftRelations(data.data);
2177
+ }
2178
+ };
2179
+ fetchDraftRelationsCount();
2180
+ }, [isListView, document, documentId, countDraftRelations, collectionType, model, params]);
1803
2181
  const isDocumentPublished = (document?.[PUBLISHED_AT_ATTRIBUTE_NAME] || meta?.availableStatus.some((doc) => doc[PUBLISHED_AT_ATTRIBUTE_NAME] !== null)) && document?.status !== "modified";
1804
2182
  if (!schema?.options?.draftAndPublish) {
1805
2183
  return null;
@@ -1807,7 +2185,9 @@ const PublishAction$1 = ({
1807
2185
  const performPublish = async () => {
1808
2186
  setSubmitting(true);
1809
2187
  try {
1810
- const { errors } = await validate();
2188
+ const { errors } = await validate(true, {
2189
+ status: "published"
2190
+ });
1811
2191
  if (errors) {
1812
2192
  toggleNotification({
1813
2193
  type: "danger",
@@ -1825,7 +2205,7 @@ const PublishAction$1 = ({
1825
2205
  documentId,
1826
2206
  params
1827
2207
  },
1828
- formValues
2208
+ transformData(formValues)
1829
2209
  );
1830
2210
  if ("data" in res && collectionType !== SINGLE_TYPES) {
1831
2211
  navigate({
@@ -1921,18 +2301,18 @@ const UpdateAction = ({
1921
2301
  onClick: async () => {
1922
2302
  setSubmitting(true);
1923
2303
  try {
1924
- if (activeTab !== "draft") {
1925
- const { errors } = await validate();
1926
- if (errors) {
1927
- toggleNotification({
1928
- type: "danger",
1929
- message: formatMessage({
1930
- id: "content-manager.validation.error",
1931
- defaultMessage: "There are validation errors in your document. Please fix them before saving."
1932
- })
1933
- });
1934
- return;
1935
- }
2304
+ const { errors } = await validate(true, {
2305
+ status: "draft"
2306
+ });
2307
+ if (errors) {
2308
+ toggleNotification({
2309
+ type: "danger",
2310
+ message: formatMessage({
2311
+ id: "content-manager.validation.error",
2312
+ defaultMessage: "There are validation errors in your document. Please fix them before saving."
2313
+ })
2314
+ });
2315
+ return;
1936
2316
  }
1937
2317
  if (isCloning) {
1938
2318
  const res = await clone(
@@ -1941,7 +2321,7 @@ const UpdateAction = ({
1941
2321
  documentId: cloneMatch.params.origin,
1942
2322
  params
1943
2323
  },
1944
- document
2324
+ transformData(document)
1945
2325
  );
1946
2326
  if ("data" in res) {
1947
2327
  navigate(
@@ -1962,7 +2342,7 @@ const UpdateAction = ({
1962
2342
  documentId,
1963
2343
  params
1964
2344
  },
1965
- document
2345
+ transformData(document)
1966
2346
  );
1967
2347
  if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
1968
2348
  setErrors(formatValidationErrors(res.error));
@@ -1975,7 +2355,7 @@ const UpdateAction = ({
1975
2355
  model,
1976
2356
  params
1977
2357
  },
1978
- document
2358
+ transformData(document)
1979
2359
  );
1980
2360
  if ("data" in res && collectionType !== SINGLE_TYPES) {
1981
2361
  navigate(
@@ -2028,7 +2408,7 @@ const UnpublishAction$1 = ({
2028
2408
  id: "app.utils.unpublish",
2029
2409
  defaultMessage: "Unpublish"
2030
2410
  }),
2031
- icon: /* @__PURE__ */ jsxRuntime.jsx(StyledCrossCircle, {}),
2411
+ icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Cross, {}),
2032
2412
  onClick: async () => {
2033
2413
  if (!documentId && collectionType !== SINGLE_TYPES || isDocumentModified) {
2034
2414
  if (!documentId) {
@@ -2140,7 +2520,7 @@ const DiscardAction = ({
2140
2520
  id: "content-manager.actions.discard.label",
2141
2521
  defaultMessage: "Discard changes"
2142
2522
  }),
2143
- icon: /* @__PURE__ */ jsxRuntime.jsx(StyledCrossCircle, {}),
2523
+ icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Cross, {}),
2144
2524
  position: ["panel", "table-row"],
2145
2525
  variant: "danger",
2146
2526
  dialog: {
@@ -2168,11 +2548,6 @@ const DiscardAction = ({
2168
2548
  };
2169
2549
  };
2170
2550
  DiscardAction.type = "discard";
2171
- const StyledCrossCircle = styledComponents.styled(Icons.CrossCircle)`
2172
- path {
2173
- fill: currentColor;
2174
- }
2175
- `;
2176
2551
  const DEFAULT_ACTIONS = [PublishAction$1, UpdateAction, UnpublishAction$1, DiscardAction];
2177
2552
  const intervals = ["years", "months", "days", "hours", "minutes", "seconds"];
2178
2553
  const RelativeTime = React__namespace.forwardRef(
@@ -2185,7 +2560,7 @@ const RelativeTime = React__namespace.forwardRef(
2185
2560
  });
2186
2561
  const unit = intervals.find((intervalUnit) => {
2187
2562
  return interval[intervalUnit] > 0 && Object.keys(interval).includes(intervalUnit);
2188
- });
2563
+ }) ?? "seconds";
2189
2564
  const relativeTime = dateFns.isPast(timestamp) ? -interval[unit] : interval[unit];
2190
2565
  const customInterval = customIntervals.find(
2191
2566
  (custom) => interval[custom.unit] < custom.threshold
@@ -2219,19 +2594,29 @@ const getDisplayName = ({
2219
2594
  return email ?? "";
2220
2595
  };
2221
2596
  const capitalise = (str) => str.charAt(0).toUpperCase() + str.slice(1);
2222
- const DocumentStatus = ({ status = "draft", ...restProps }) => {
2223
- const statusVariant = status === "draft" ? "primary" : status === "published" ? "success" : "alternative";
2224
- 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) }) });
2597
+ const DocumentStatus = ({ status = "draft", size = "S", ...restProps }) => {
2598
+ const statusVariant = status === "draft" ? "secondary" : status === "published" ? "success" : "alternative";
2599
+ const { formatMessage } = reactIntl.useIntl();
2600
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Status, { ...restProps, size, variant: statusVariant, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "span", variant: "omega", fontWeight: "bold", children: formatMessage({
2601
+ id: `content-manager.containers.List.${status}`,
2602
+ defaultMessage: capitalise(status)
2603
+ }) }) });
2225
2604
  };
2226
2605
  const Header = ({ isCreating, status, title: documentTitle = "Untitled" }) => {
2227
2606
  const { formatMessage } = reactIntl.useIntl();
2228
2607
  const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
2608
+ const params = reactRouterDom.useParams();
2229
2609
  const title = isCreating ? formatMessage({
2230
2610
  id: "content-manager.containers.edit.title.new",
2231
2611
  defaultMessage: "Create an entry"
2232
2612
  }) : documentTitle;
2233
2613
  return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", paddingTop: 6, paddingBottom: 4, gap: 2, children: [
2234
- /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.BackButton, {}),
2614
+ /* @__PURE__ */ jsxRuntime.jsx(
2615
+ strapiAdmin.BackButton,
2616
+ {
2617
+ fallback: params.collectionType === SINGLE_TYPES ? void 0 : `../${COLLECTION_TYPES}/${params.slug}`
2618
+ }
2619
+ ),
2235
2620
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { width: "100%", justifyContent: "space-between", gap: "80px", alignItems: "flex-start", children: [
2236
2621
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "alpha", tag: "h1", children: title }),
2237
2622
  /* @__PURE__ */ jsxRuntime.jsx(HeaderToolbar, {})
@@ -2319,12 +2704,12 @@ const Information = ({ activeTab }) => {
2319
2704
  isDisplayed: !!publishDocument?.[PUBLISHED_AT_ATTRIBUTE_NAME],
2320
2705
  label: formatMessage({
2321
2706
  id: "content-manager.containers.edit.information.last-published.label",
2322
- defaultMessage: "Last published"
2707
+ defaultMessage: "Published"
2323
2708
  }),
2324
2709
  value: formatMessage(
2325
2710
  {
2326
2711
  id: "content-manager.containers.edit.information.last-published.value",
2327
- defaultMessage: `Published {time}{isAnonymous, select, true {} other { by {author}}}`
2712
+ defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
2328
2713
  },
2329
2714
  {
2330
2715
  time: /* @__PURE__ */ jsxRuntime.jsx(RelativeTime, { timestamp: new Date(publishDocument?.[PUBLISHED_AT_ATTRIBUTE_NAME]) }),
@@ -2337,12 +2722,12 @@ const Information = ({ activeTab }) => {
2337
2722
  isDisplayed: !!createAndUpdateDocument?.[UPDATED_AT_ATTRIBUTE_NAME],
2338
2723
  label: formatMessage({
2339
2724
  id: "content-manager.containers.edit.information.last-draft.label",
2340
- defaultMessage: "Last draft"
2725
+ defaultMessage: "Updated"
2341
2726
  }),
2342
2727
  value: formatMessage(
2343
2728
  {
2344
2729
  id: "content-manager.containers.edit.information.last-draft.value",
2345
- defaultMessage: `Modified {time}{isAnonymous, select, true {} other { by {author}}}`
2730
+ defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
2346
2731
  },
2347
2732
  {
2348
2733
  time: /* @__PURE__ */ jsxRuntime.jsx(
@@ -2360,12 +2745,12 @@ const Information = ({ activeTab }) => {
2360
2745
  isDisplayed: !!createAndUpdateDocument?.[CREATED_AT_ATTRIBUTE_NAME],
2361
2746
  label: formatMessage({
2362
2747
  id: "content-manager.containers.edit.information.document.label",
2363
- defaultMessage: "Document"
2748
+ defaultMessage: "Created"
2364
2749
  }),
2365
2750
  value: formatMessage(
2366
2751
  {
2367
2752
  id: "content-manager.containers.edit.information.document.value",
2368
- defaultMessage: `Created {time}{isAnonymous, select, true {} other { by {author}}}`
2753
+ defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
2369
2754
  },
2370
2755
  {
2371
2756
  time: /* @__PURE__ */ jsxRuntime.jsx(
@@ -2403,25 +2788,77 @@ const Information = ({ activeTab }) => {
2403
2788
  );
2404
2789
  };
2405
2790
  const HeaderActions = ({ actions: actions2 }) => {
2406
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { children: actions2.map((action) => {
2407
- if ("options" in action) {
2791
+ const [dialogId, setDialogId] = React__namespace.useState(null);
2792
+ const handleClick = (action) => async (e) => {
2793
+ if (!("options" in action)) {
2794
+ const { onClick = () => false, dialog, id } = action;
2795
+ const muteDialog = await onClick(e);
2796
+ if (dialog && !muteDialog) {
2797
+ e.preventDefault();
2798
+ setDialogId(id);
2799
+ }
2800
+ }
2801
+ };
2802
+ const handleClose = () => {
2803
+ setDialogId(null);
2804
+ };
2805
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { gap: 1, children: actions2.map((action) => {
2806
+ if (action.options) {
2408
2807
  return /* @__PURE__ */ jsxRuntime.jsx(
2409
2808
  designSystem.SingleSelect,
2410
2809
  {
2411
2810
  size: "S",
2412
- disabled: action.disabled,
2413
- "aria-label": action.label,
2414
2811
  onChange: action.onSelect,
2415
- value: action.value,
2812
+ "aria-label": action.label,
2813
+ ...action,
2416
2814
  children: action.options.map(({ label, ...option }) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { ...option, children: label }, option.value))
2417
2815
  },
2418
2816
  action.id
2419
2817
  );
2420
2818
  } else {
2421
- return null;
2819
+ if (action.type === "icon") {
2820
+ return /* @__PURE__ */ jsxRuntime.jsxs(React__namespace.Fragment, { children: [
2821
+ /* @__PURE__ */ jsxRuntime.jsx(
2822
+ designSystem.IconButton,
2823
+ {
2824
+ disabled: action.disabled,
2825
+ label: action.label,
2826
+ size: "S",
2827
+ onClick: handleClick(action),
2828
+ children: action.icon
2829
+ }
2830
+ ),
2831
+ action.dialog ? /* @__PURE__ */ jsxRuntime.jsx(
2832
+ HeaderActionDialog,
2833
+ {
2834
+ ...action.dialog,
2835
+ isOpen: dialogId === action.id,
2836
+ onClose: handleClose
2837
+ }
2838
+ ) : null
2839
+ ] }, action.id);
2840
+ }
2422
2841
  }
2423
2842
  }) });
2424
2843
  };
2844
+ const HeaderActionDialog = ({
2845
+ onClose,
2846
+ onCancel,
2847
+ title,
2848
+ content: Content,
2849
+ isOpen
2850
+ }) => {
2851
+ const handleClose = async () => {
2852
+ if (onCancel) {
2853
+ await onCancel();
2854
+ }
2855
+ onClose();
2856
+ };
2857
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Root, { open: isOpen, onOpenChange: handleClose, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Content, { children: [
2858
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Header, { children: title }),
2859
+ typeof Content === "function" ? /* @__PURE__ */ jsxRuntime.jsx(Content, { onClose: handleClose }) : Content
2860
+ ] }) });
2861
+ };
2425
2862
  const ConfigureTheViewAction = ({ collectionType, model }) => {
2426
2863
  const navigate = reactRouterDom.useNavigate();
2427
2864
  const { formatMessage } = reactIntl.useIntl();
@@ -2462,12 +2899,16 @@ const DeleteAction$1 = ({ documentId, model, collectionType, document }) => {
2462
2899
  const { delete: deleteAction } = useDocumentActions();
2463
2900
  const { toggleNotification } = strapiAdmin.useNotification();
2464
2901
  const setSubmitting = strapiAdmin.useForm("DeleteAction", (state) => state.setSubmitting);
2902
+ const isLocalized = document?.locale != null;
2465
2903
  return {
2466
2904
  disabled: !canDelete || !document,
2467
- label: formatMessage({
2468
- id: "content-manager.actions.delete.label",
2469
- defaultMessage: "Delete document"
2470
- }),
2905
+ label: formatMessage(
2906
+ {
2907
+ id: "content-manager.actions.delete.label",
2908
+ defaultMessage: "Delete entry{isLocalized, select, true { (all locales)} other {}}"
2909
+ },
2910
+ { isLocalized }
2911
+ ),
2471
2912
  icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Trash, {}),
2472
2913
  dialog: {
2473
2914
  type: "dialog",
@@ -2496,430 +2937,128 @@ const DeleteAction$1 = ({ documentId, model, collectionType, document }) => {
2496
2937
  id: "content-manager.actions.delete.error",
2497
2938
  defaultMessage: "An error occurred while trying to delete the document."
2498
2939
  }),
2499
- type: "danger"
2500
- });
2501
- return;
2502
- }
2503
- const res = await deleteAction({
2504
- documentId,
2505
- model,
2506
- collectionType,
2507
- params: {
2508
- locale: "*"
2509
- }
2510
- });
2511
- if (!("error" in res)) {
2512
- navigate({ pathname: `../${collectionType}/${model}` }, { replace: true });
2513
- }
2514
- } finally {
2515
- if (!listViewPathMatch) {
2516
- setSubmitting(false);
2517
- }
2518
- }
2519
- }
2520
- },
2521
- variant: "danger",
2522
- position: ["header", "table-row"]
2523
- };
2524
- };
2525
- DeleteAction$1.type = "delete";
2526
- const DEFAULT_HEADER_ACTIONS = [EditTheModelAction, ConfigureTheViewAction, DeleteAction$1];
2527
- const Panels = () => {
2528
- const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
2529
- const [
2530
- {
2531
- query: { status }
2532
- }
2533
- ] = strapiAdmin.useQueryParams({
2534
- status: "draft"
2535
- });
2536
- const { model, id, document, meta, collectionType } = useDoc();
2537
- const plugins = strapiAdmin.useStrapiApp("Panels", (state) => state.plugins);
2538
- const props = {
2539
- activeTab: status,
2540
- model,
2541
- documentId: id,
2542
- document: isCloning ? void 0 : document,
2543
- meta: isCloning ? void 0 : meta,
2544
- collectionType
2545
- };
2546
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: /* @__PURE__ */ jsxRuntime.jsx(
2547
- strapiAdmin.DescriptionComponentRenderer,
2548
- {
2549
- props,
2550
- descriptions: plugins["content-manager"].apis.getEditViewSidePanels(),
2551
- children: (panels) => panels.map(({ content, id: id2, ...description }) => /* @__PURE__ */ jsxRuntime.jsx(Panel, { ...description, children: content }, id2))
2552
- }
2553
- ) });
2554
- };
2555
- const ActionsPanel = () => {
2556
- const { formatMessage } = reactIntl.useIntl();
2557
- return {
2558
- title: formatMessage({
2559
- id: "content-manager.containers.edit.panels.default.title",
2560
- defaultMessage: "Document"
2561
- }),
2562
- content: /* @__PURE__ */ jsxRuntime.jsx(ActionsPanelContent, {})
2563
- };
2564
- };
2565
- ActionsPanel.type = "actions";
2566
- const ActionsPanelContent = () => {
2567
- const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
2568
- const [
2569
- {
2570
- query: { status = "draft" }
2571
- }
2572
- ] = strapiAdmin.useQueryParams();
2573
- const { model, id, document, meta, collectionType } = useDoc();
2574
- const plugins = strapiAdmin.useStrapiApp("ActionsPanel", (state) => state.plugins);
2575
- const props = {
2576
- activeTab: status,
2577
- model,
2578
- documentId: id,
2579
- document: isCloning ? void 0 : document,
2580
- meta: isCloning ? void 0 : meta,
2581
- collectionType
2582
- };
2583
- return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 2, width: "100%", children: [
2584
- /* @__PURE__ */ jsxRuntime.jsx(
2585
- strapiAdmin.DescriptionComponentRenderer,
2586
- {
2587
- props,
2588
- descriptions: plugins["content-manager"].apis.getDocumentActions(),
2589
- children: (actions2) => /* @__PURE__ */ jsxRuntime.jsx(DocumentActions, { actions: actions2 })
2590
- }
2591
- ),
2592
- /* @__PURE__ */ jsxRuntime.jsx(InjectionZone, { area: "editView.right-links", slug: model })
2593
- ] });
2594
- };
2595
- const Panel = React__namespace.forwardRef(({ children, title }, ref) => {
2596
- return /* @__PURE__ */ jsxRuntime.jsxs(
2597
- designSystem.Flex,
2598
- {
2599
- ref,
2600
- tag: "aside",
2601
- "aria-labelledby": "additional-information",
2602
- background: "neutral0",
2603
- borderColor: "neutral150",
2604
- hasRadius: true,
2605
- paddingBottom: 4,
2606
- paddingLeft: 4,
2607
- paddingRight: 4,
2608
- paddingTop: 4,
2609
- shadow: "tableShadow",
2610
- gap: 3,
2611
- direction: "column",
2612
- justifyContent: "stretch",
2613
- alignItems: "flex-start",
2614
- children: [
2615
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "h2", variant: "sigma", textTransform: "uppercase", children: title }),
2616
- children
2617
- ]
2618
- }
2619
- );
2620
- });
2621
- const HOOKS = {
2622
- /**
2623
- * Hook that allows to mutate the displayed headers of the list view table
2624
- * @constant
2625
- * @type {string}
2626
- */
2627
- INJECT_COLUMN_IN_TABLE: "Admin/CM/pages/ListView/inject-column-in-table",
2628
- /**
2629
- * Hook that allows to mutate the CM's collection types links pre-set filters
2630
- * @constant
2631
- * @type {string}
2632
- */
2633
- MUTATE_COLLECTION_TYPES_LINKS: "Admin/CM/pages/App/mutate-collection-types-links",
2634
- /**
2635
- * Hook that allows to mutate the CM's edit view layout
2636
- * @constant
2637
- * @type {string}
2638
- */
2639
- MUTATE_EDIT_VIEW_LAYOUT: "Admin/CM/pages/EditView/mutate-edit-view-layout",
2640
- /**
2641
- * Hook that allows to mutate the CM's single types links pre-set filters
2642
- * @constant
2643
- * @type {string}
2644
- */
2645
- MUTATE_SINGLE_TYPES_LINKS: "Admin/CM/pages/App/mutate-single-types-links"
2646
- };
2647
- const contentTypesApi = contentManagerApi.injectEndpoints({
2648
- endpoints: (builder) => ({
2649
- getContentTypeConfiguration: builder.query({
2650
- query: (uid) => ({
2651
- url: `/content-manager/content-types/${uid}/configuration`,
2652
- method: "GET"
2653
- }),
2654
- transformResponse: (response) => response.data,
2655
- providesTags: (_result, _error, uid) => [
2656
- { type: "ContentTypesConfiguration", id: uid },
2657
- { type: "ContentTypeSettings", id: "LIST" }
2658
- ]
2659
- }),
2660
- getAllContentTypeSettings: builder.query({
2661
- query: () => "/content-manager/content-types-settings",
2662
- transformResponse: (response) => response.data,
2663
- providesTags: [{ type: "ContentTypeSettings", id: "LIST" }]
2664
- }),
2665
- updateContentTypeConfiguration: builder.mutation({
2666
- query: ({ uid, ...body }) => ({
2667
- url: `/content-manager/content-types/${uid}/configuration`,
2668
- method: "PUT",
2669
- data: body
2670
- }),
2671
- transformResponse: (response) => response.data,
2672
- invalidatesTags: (_result, _error, { uid }) => [
2673
- { type: "ContentTypesConfiguration", id: uid },
2674
- { type: "ContentTypeSettings", id: "LIST" },
2675
- // Is this necessary?
2676
- { type: "InitialData" }
2677
- ]
2678
- })
2679
- })
2680
- });
2681
- const {
2682
- useGetContentTypeConfigurationQuery,
2683
- useGetAllContentTypeSettingsQuery,
2684
- useUpdateContentTypeConfigurationMutation
2685
- } = contentTypesApi;
2686
- const checkIfAttributeIsDisplayable = (attribute) => {
2687
- const { type } = attribute;
2688
- if (type === "relation") {
2689
- return !attribute.relation.toLowerCase().includes("morph");
2690
- }
2691
- return !["json", "dynamiczone", "richtext", "password", "blocks"].includes(type) && !!type;
2692
- };
2693
- const getMainField = (attribute, mainFieldName, { schemas, components }) => {
2694
- if (!mainFieldName) {
2695
- return void 0;
2696
- }
2697
- const mainFieldType = attribute.type === "component" ? components[attribute.component].attributes[mainFieldName].type : (
2698
- // @ts-expect-error – `targetModel` does exist on the attribute for a relation.
2699
- schemas.find((schema) => schema.uid === attribute.targetModel)?.attributes[mainFieldName].type
2700
- );
2701
- return {
2702
- name: mainFieldName,
2703
- type: mainFieldType ?? "string"
2704
- };
2705
- };
2706
- const DEFAULT_SETTINGS = {
2707
- bulkable: false,
2708
- filterable: false,
2709
- searchable: false,
2710
- pagination: false,
2711
- defaultSortBy: "",
2712
- defaultSortOrder: "asc",
2713
- mainField: "id",
2714
- pageSize: 10
2715
- };
2716
- const useDocumentLayout = (model) => {
2717
- const { schema, components } = useDocument({ model, collectionType: "" }, { skip: true });
2718
- const [{ query }] = strapiAdmin.useQueryParams();
2719
- const runHookWaterfall = strapiAdmin.useStrapiApp("useDocumentLayout", (state) => state.runHookWaterfall);
2720
- const { toggleNotification } = strapiAdmin.useNotification();
2721
- const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
2722
- const { isLoading: isLoadingSchemas, schemas } = useContentTypeSchema();
2723
- const {
2724
- data,
2725
- isLoading: isLoadingConfigs,
2726
- error,
2727
- isFetching: isFetchingConfigs
2728
- } = useGetContentTypeConfigurationQuery(model);
2729
- const isLoading = isLoadingSchemas || isFetchingConfigs || isLoadingConfigs;
2730
- React__namespace.useEffect(() => {
2731
- if (error) {
2732
- toggleNotification({
2733
- type: "danger",
2734
- message: formatAPIError(error)
2735
- });
2736
- }
2737
- }, [error, formatAPIError, toggleNotification]);
2738
- const editLayout = React__namespace.useMemo(
2739
- () => data && !isLoading ? formatEditLayout(data, { schemas, schema, components }) : {
2740
- layout: [],
2741
- components: {},
2742
- metadatas: {},
2743
- options: {},
2744
- settings: DEFAULT_SETTINGS
2745
- },
2746
- [data, isLoading, schemas, schema, components]
2747
- );
2748
- const listLayout = React__namespace.useMemo(() => {
2749
- return data && !isLoading ? formatListLayout(data, { schemas, schema, components }) : {
2750
- layout: [],
2751
- metadatas: {},
2752
- options: {},
2753
- settings: DEFAULT_SETTINGS
2754
- };
2755
- }, [data, isLoading, schemas, schema, components]);
2756
- const { layout: edit } = React__namespace.useMemo(
2757
- () => runHookWaterfall(HOOKS.MUTATE_EDIT_VIEW_LAYOUT, {
2758
- layout: editLayout,
2759
- query
2760
- }),
2761
- [editLayout, query, runHookWaterfall]
2762
- );
2763
- return {
2764
- error,
2765
- isLoading,
2766
- edit,
2767
- list: listLayout
2768
- };
2769
- };
2770
- const useDocLayout = () => {
2771
- const { model } = useDoc();
2772
- return useDocumentLayout(model);
2773
- };
2774
- const formatEditLayout = (data, {
2775
- schemas,
2776
- schema,
2777
- components
2778
- }) => {
2779
- let currentPanelIndex = 0;
2780
- const panelledEditAttributes = convertEditLayoutToFieldLayouts(
2781
- data.contentType.layouts.edit,
2782
- schema?.attributes,
2783
- data.contentType.metadatas,
2784
- { configurations: data.components, schemas: components },
2785
- schemas
2786
- ).reduce((panels, row) => {
2787
- if (row.some((field) => field.type === "dynamiczone")) {
2788
- panels.push([row]);
2789
- currentPanelIndex += 2;
2790
- } else {
2791
- if (!panels[currentPanelIndex]) {
2792
- panels.push([]);
2793
- }
2794
- panels[currentPanelIndex].push(row);
2795
- }
2796
- return panels;
2797
- }, []);
2798
- const componentEditAttributes = Object.entries(data.components).reduce(
2799
- (acc, [uid, configuration]) => {
2800
- acc[uid] = {
2801
- layout: convertEditLayoutToFieldLayouts(
2802
- configuration.layouts.edit,
2803
- components[uid].attributes,
2804
- configuration.metadatas
2805
- ),
2806
- settings: {
2807
- ...configuration.settings,
2808
- icon: components[uid].info.icon,
2809
- displayName: components[uid].info.displayName
2940
+ type: "danger"
2941
+ });
2942
+ return;
2943
+ }
2944
+ const res = await deleteAction({
2945
+ documentId,
2946
+ model,
2947
+ collectionType,
2948
+ params: {
2949
+ locale: "*"
2950
+ }
2951
+ });
2952
+ if (!("error" in res)) {
2953
+ navigate({ pathname: `../${collectionType}/${model}` }, { replace: true });
2954
+ }
2955
+ } finally {
2956
+ if (!listViewPathMatch) {
2957
+ setSubmitting(false);
2958
+ }
2810
2959
  }
2811
- };
2812
- return acc;
2813
- },
2814
- {}
2815
- );
2816
- const editMetadatas = Object.entries(data.contentType.metadatas).reduce(
2817
- (acc, [attribute, metadata]) => {
2818
- return {
2819
- ...acc,
2820
- [attribute]: metadata.edit
2821
- };
2822
- },
2823
- {}
2824
- );
2825
- return {
2826
- layout: panelledEditAttributes,
2827
- components: componentEditAttributes,
2828
- metadatas: editMetadatas,
2829
- settings: {
2830
- ...data.contentType.settings,
2831
- displayName: schema?.info.displayName
2960
+ }
2832
2961
  },
2833
- options: {
2834
- ...schema?.options,
2835
- ...schema?.pluginOptions,
2836
- ...data.contentType.options
2837
- }
2962
+ variant: "danger",
2963
+ position: ["header", "table-row"]
2838
2964
  };
2839
2965
  };
2840
- const convertEditLayoutToFieldLayouts = (rows, attributes = {}, metadatas, components, schemas = []) => {
2841
- return rows.map(
2842
- (row) => row.map((field) => {
2843
- const attribute = attributes[field.name];
2844
- if (!attribute) {
2845
- return null;
2846
- }
2847
- const { edit: metadata } = metadatas[field.name];
2848
- const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
2849
- return {
2850
- attribute,
2851
- disabled: !metadata.editable,
2852
- hint: metadata.description,
2853
- label: metadata.label ?? "",
2854
- name: field.name,
2855
- // @ts-expect-error – mainField does exist on the metadata for a relation.
2856
- mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
2857
- schemas,
2858
- components: components?.schemas ?? {}
2859
- }),
2860
- placeholder: metadata.placeholder ?? "",
2861
- required: attribute.required ?? false,
2862
- size: field.size,
2863
- unique: "unique" in attribute ? attribute.unique : false,
2864
- visible: metadata.visible ?? true,
2865
- type: attribute.type
2866
- };
2867
- }).filter((field) => field !== null)
2868
- );
2966
+ DeleteAction$1.type = "delete";
2967
+ const DEFAULT_HEADER_ACTIONS = [EditTheModelAction, ConfigureTheViewAction, DeleteAction$1];
2968
+ const Panels = () => {
2969
+ const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
2970
+ const [
2971
+ {
2972
+ query: { status }
2973
+ }
2974
+ ] = strapiAdmin.useQueryParams({
2975
+ status: "draft"
2976
+ });
2977
+ const { model, id, document, meta, collectionType } = useDoc();
2978
+ const plugins = strapiAdmin.useStrapiApp("Panels", (state) => state.plugins);
2979
+ const props = {
2980
+ activeTab: status,
2981
+ model,
2982
+ documentId: id,
2983
+ document: isCloning ? void 0 : document,
2984
+ meta: isCloning ? void 0 : meta,
2985
+ collectionType
2986
+ };
2987
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: /* @__PURE__ */ jsxRuntime.jsx(
2988
+ strapiAdmin.DescriptionComponentRenderer,
2989
+ {
2990
+ props,
2991
+ descriptions: plugins["content-manager"].apis.getEditViewSidePanels(),
2992
+ children: (panels) => panels.map(({ content, id: id2, ...description }) => /* @__PURE__ */ jsxRuntime.jsx(Panel, { ...description, children: content }, id2))
2993
+ }
2994
+ ) });
2869
2995
  };
2870
- const formatListLayout = (data, {
2871
- schemas,
2872
- schema,
2873
- components
2874
- }) => {
2875
- const listMetadatas = Object.entries(data.contentType.metadatas).reduce(
2876
- (acc, [attribute, metadata]) => {
2877
- return {
2878
- ...acc,
2879
- [attribute]: metadata.list
2880
- };
2881
- },
2882
- {}
2883
- );
2884
- const listAttributes = convertListLayoutToFieldLayouts(
2885
- data.contentType.layouts.list,
2886
- schema?.attributes,
2887
- listMetadatas,
2888
- { configurations: data.components, schemas: components },
2889
- schemas
2890
- );
2996
+ const ActionsPanel = () => {
2997
+ const { formatMessage } = reactIntl.useIntl();
2891
2998
  return {
2892
- layout: listAttributes,
2893
- settings: { ...data.contentType.settings, displayName: schema?.info.displayName },
2894
- metadatas: listMetadatas,
2895
- options: {
2896
- ...schema?.options,
2897
- ...schema?.pluginOptions,
2898
- ...data.contentType.options
2899
- }
2999
+ title: formatMessage({
3000
+ id: "content-manager.containers.edit.panels.default.title",
3001
+ defaultMessage: "Entry"
3002
+ }),
3003
+ content: /* @__PURE__ */ jsxRuntime.jsx(ActionsPanelContent, {})
2900
3004
  };
2901
3005
  };
2902
- const convertListLayoutToFieldLayouts = (columns, attributes = {}, metadatas, components, schemas = []) => {
2903
- return columns.map((name) => {
2904
- const attribute = attributes[name];
2905
- if (!attribute) {
2906
- return null;
3006
+ ActionsPanel.type = "actions";
3007
+ const ActionsPanelContent = () => {
3008
+ const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
3009
+ const [
3010
+ {
3011
+ query: { status = "draft" }
2907
3012
  }
2908
- const metadata = metadatas[name];
2909
- const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
2910
- return {
2911
- attribute,
2912
- label: metadata.label ?? "",
2913
- mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
2914
- schemas,
2915
- components: components?.schemas ?? {}
2916
- }),
2917
- name,
2918
- searchable: metadata.searchable ?? true,
2919
- sortable: metadata.sortable ?? true
2920
- };
2921
- }).filter((field) => field !== null);
3013
+ ] = strapiAdmin.useQueryParams();
3014
+ const { model, id, document, meta, collectionType } = useDoc();
3015
+ const plugins = strapiAdmin.useStrapiApp("ActionsPanel", (state) => state.plugins);
3016
+ const props = {
3017
+ activeTab: status,
3018
+ model,
3019
+ documentId: id,
3020
+ document: isCloning ? void 0 : document,
3021
+ meta: isCloning ? void 0 : meta,
3022
+ collectionType
3023
+ };
3024
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 2, width: "100%", children: [
3025
+ /* @__PURE__ */ jsxRuntime.jsx(
3026
+ strapiAdmin.DescriptionComponentRenderer,
3027
+ {
3028
+ props,
3029
+ descriptions: plugins["content-manager"].apis.getDocumentActions(),
3030
+ children: (actions2) => /* @__PURE__ */ jsxRuntime.jsx(DocumentActions, { actions: actions2 })
3031
+ }
3032
+ ),
3033
+ /* @__PURE__ */ jsxRuntime.jsx(InjectionZone, { area: "editView.right-links", slug: model })
3034
+ ] });
2922
3035
  };
3036
+ const Panel = React__namespace.forwardRef(({ children, title }, ref) => {
3037
+ return /* @__PURE__ */ jsxRuntime.jsxs(
3038
+ designSystem.Flex,
3039
+ {
3040
+ ref,
3041
+ tag: "aside",
3042
+ "aria-labelledby": "additional-information",
3043
+ background: "neutral0",
3044
+ borderColor: "neutral150",
3045
+ hasRadius: true,
3046
+ paddingBottom: 4,
3047
+ paddingLeft: 4,
3048
+ paddingRight: 4,
3049
+ paddingTop: 4,
3050
+ shadow: "tableShadow",
3051
+ gap: 3,
3052
+ direction: "column",
3053
+ justifyContent: "stretch",
3054
+ alignItems: "flex-start",
3055
+ children: [
3056
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "h2", variant: "sigma", textTransform: "uppercase", textColor: "neutral600", children: title }),
3057
+ children
3058
+ ]
3059
+ }
3060
+ );
3061
+ });
2923
3062
  const ConfirmBulkActionDialog = ({
2924
3063
  onToggleDialog,
2925
3064
  isOpen = false,
@@ -3164,18 +3303,10 @@ const SelectedEntriesTableContent = ({
3164
3303
  search: row.locale && `?plugins[i18n][locale]=${row.locale}`
3165
3304
  },
3166
3305
  state: { from: pathname },
3167
- label: formatMessage(
3168
- { id: "app.component.HelperPluginTable.edit", defaultMessage: "Edit {target}" },
3169
- {
3170
- target: formatMessage(
3171
- {
3172
- id: "content-manager.components.ListViewHelperPluginTable.row-line",
3173
- defaultMessage: "item line {number}"
3174
- },
3175
- { number: index2 + 1 }
3176
- )
3177
- }
3178
- ),
3306
+ label: formatMessage({
3307
+ id: "content-manager.bulk-publish.edit",
3308
+ defaultMessage: "Edit"
3309
+ }),
3179
3310
  target: "_blank",
3180
3311
  marginLeft: "auto",
3181
3312
  variant: "ghost",
@@ -3819,17 +3950,27 @@ const HistoryAction = ({ model, document }) => {
3819
3950
  const { formatMessage } = reactIntl.useIntl();
3820
3951
  const [{ query }] = strapiAdmin.useQueryParams();
3821
3952
  const navigate = reactRouterDom.useNavigate();
3953
+ const { trackUsage } = strapiAdmin.useTracking();
3954
+ const { pathname } = reactRouterDom.useLocation();
3822
3955
  const pluginsQueryParams = qs.stringify({ plugins: query.plugins }, { encode: false });
3823
3956
  if (!window.strapi.features.isEnabled("cms-content-history")) {
3824
3957
  return null;
3825
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
+ };
3826
3967
  return {
3827
3968
  icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.ClockCounterClockwise, {}),
3828
3969
  label: formatMessage({
3829
3970
  id: "content-manager.history.document-action",
3830
3971
  defaultMessage: "Content History"
3831
3972
  }),
3832
- onClick: () => navigate({ pathname: "history", search: pluginsQueryParams }),
3973
+ onClick: handleOnClick,
3833
3974
  disabled: (
3834
3975
  /**
3835
3976
  * The user is creating a new document.
@@ -3897,6 +4038,72 @@ const { setInitialData } = actions;
3897
4038
  const reducer = toolkit.combineReducers({
3898
4039
  app: reducer$1
3899
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 PreviewSidePanel = ({ model, documentId, document }) => {
4058
+ const { formatMessage } = reactIntl.useIntl();
4059
+ const { trackUsage } = strapiAdmin.useTracking();
4060
+ const { pathname } = reactRouterDom.useLocation();
4061
+ const [{ query }] = strapiAdmin.useQueryParams();
4062
+ const { data, error } = useGetPreviewUrlQuery({
4063
+ params: {
4064
+ contentType: model
4065
+ },
4066
+ query: {
4067
+ documentId,
4068
+ locale: document?.locale,
4069
+ status: document?.status
4070
+ }
4071
+ });
4072
+ if (!data?.data?.url || error) {
4073
+ return null;
4074
+ }
4075
+ const trackNavigation = () => {
4076
+ const destinationPathname = pathname.replace(/\/$/, "") + "/preview";
4077
+ trackUsage("willNavigate", { from: pathname, to: destinationPathname });
4078
+ };
4079
+ return {
4080
+ title: formatMessage({ id: "content-manager.preview.panel.title", defaultMessage: "Preview" }),
4081
+ content: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { gap: 2, width: "100%", children: /* @__PURE__ */ jsxRuntime.jsx(
4082
+ designSystem.Button,
4083
+ {
4084
+ variant: "tertiary",
4085
+ tag: reactRouterDom.Link,
4086
+ to: { pathname: "preview", search: qs.stringify(query, { encode: false }) },
4087
+ onClick: trackNavigation,
4088
+ flex: "auto",
4089
+ children: formatMessage({
4090
+ id: "content-manager.preview.panel.button",
4091
+ defaultMessage: "Open preview"
4092
+ })
4093
+ }
4094
+ ) })
4095
+ };
4096
+ };
4097
+ const FEATURE_ID = "preview";
4098
+ const previewAdmin = {
4099
+ bootstrap(app) {
4100
+ if (!window.strapi.future.isEnabled(FEATURE_ID)) {
4101
+ return;
4102
+ }
4103
+ const contentManagerPluginApis = app.getPlugin("content-manager").apis;
4104
+ contentManagerPluginApis.addEditViewSidePanel([PreviewSidePanel]);
4105
+ }
4106
+ };
3900
4107
  const index = {
3901
4108
  register(app) {
3902
4109
  const cm = new ContentManagerPlugin();
@@ -3916,7 +4123,7 @@ const index = {
3916
4123
  app.router.addRoute({
3917
4124
  path: "content-manager/*",
3918
4125
  lazy: async () => {
3919
- const { Layout } = await Promise.resolve().then(() => require("./layout-kfu5Wtix.js"));
4126
+ const { Layout } = await Promise.resolve().then(() => require("./layout-zA_F2rU4.js"));
3920
4127
  return {
3921
4128
  Component: Layout
3922
4129
  };
@@ -3929,11 +4136,14 @@ const index = {
3929
4136
  if (typeof historyAdmin.bootstrap === "function") {
3930
4137
  historyAdmin.bootstrap(app);
3931
4138
  }
4139
+ if (typeof previewAdmin.bootstrap === "function") {
4140
+ previewAdmin.bootstrap(app);
4141
+ }
3932
4142
  },
3933
4143
  async registerTrads({ locales }) {
3934
4144
  const importedTrads = await Promise.all(
3935
4145
  locales.map((locale) => {
3936
- 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-otD_UBJi.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 }) => {
4146
+ 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-DTWPCdTS.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`).then(({ default: data }) => {
3937
4147
  return {
3938
4148
  data: prefixPluginTranslations(data, PLUGIN_ID),
3939
4149
  locale
@@ -3979,6 +4189,7 @@ exports.getMainField = getMainField;
3979
4189
  exports.getTranslation = getTranslation;
3980
4190
  exports.index = index;
3981
4191
  exports.setInitialData = setInitialData;
4192
+ exports.useContentManagerContext = useContentManagerContext;
3982
4193
  exports.useContentTypeSchema = useContentTypeSchema;
3983
4194
  exports.useDoc = useDoc;
3984
4195
  exports.useDocLayout = useDocLayout;
@@ -3990,5 +4201,6 @@ exports.useGetAllContentTypeSettingsQuery = useGetAllContentTypeSettingsQuery;
3990
4201
  exports.useGetAllDocumentsQuery = useGetAllDocumentsQuery;
3991
4202
  exports.useGetContentTypeConfigurationQuery = useGetContentTypeConfigurationQuery;
3992
4203
  exports.useGetInitialDataQuery = useGetInitialDataQuery;
4204
+ exports.useGetPreviewUrlQuery = useGetPreviewUrlQuery;
3993
4205
  exports.useUpdateContentTypeConfigurationMutation = useUpdateContentTypeConfigurationMutation;
3994
- //# sourceMappingURL=index-D9UmmBcM.js.map
4206
+ //# sourceMappingURL=index-uXHSvmlw.js.map