@strapi/content-manager 0.0.0-experimental.5691f94a497e119f564a7f60ce0830bf4c875eb9 → 0.0.0-experimental.58c6b635911a7cb83cd165b4e5abd75b8ec30893

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 (169) hide show
  1. package/dist/_chunks/{ComponentConfigurationPage-qemkOlnj.mjs → ComponentConfigurationPage-BpM_Hc7r.mjs} +4 -4
  2. package/dist/_chunks/{ComponentConfigurationPage-qemkOlnj.mjs.map → ComponentConfigurationPage-BpM_Hc7r.mjs.map} +1 -1
  3. package/dist/_chunks/{ComponentConfigurationPage-D_M8iBw5.js → ComponentConfigurationPage-CL9CAMaL.js} +4 -4
  4. package/dist/_chunks/{ComponentConfigurationPage-D_M8iBw5.js.map → ComponentConfigurationPage-CL9CAMaL.js.map} +1 -1
  5. package/dist/_chunks/{EditConfigurationPage-BePwPuHy.js → EditConfigurationPage-ILWo0h1e.js} +4 -4
  6. package/dist/_chunks/{EditConfigurationPage-BePwPuHy.js.map → EditConfigurationPage-ILWo0h1e.js.map} +1 -1
  7. package/dist/_chunks/{EditConfigurationPage-CjUrEewK.mjs → EditConfigurationPage-_prbqpTM.mjs} +4 -4
  8. package/dist/_chunks/{EditConfigurationPage-CjUrEewK.mjs.map → EditConfigurationPage-_prbqpTM.mjs.map} +1 -1
  9. package/dist/_chunks/{EditViewPage-B-RJeiJD.js → EditViewPage-BqZvBN4s.js} +15 -5
  10. package/dist/_chunks/EditViewPage-BqZvBN4s.js.map +1 -0
  11. package/dist/_chunks/{EditViewPage-De8GyU8P.mjs → EditViewPage-DAtscabN.mjs} +15 -5
  12. package/dist/_chunks/EditViewPage-DAtscabN.mjs.map +1 -0
  13. package/dist/_chunks/{Field-dq8Tg1M_.js → Field-CcoQiiz1.js} +92 -86
  14. package/dist/_chunks/Field-CcoQiiz1.js.map +1 -0
  15. package/dist/_chunks/{Field-pb2o8uBe.mjs → Field-D-mgn1tH.mjs} +88 -82
  16. package/dist/_chunks/Field-D-mgn1tH.mjs.map +1 -0
  17. package/dist/_chunks/{Form-DJn0Dxha.mjs → Form-BxyeWiXW.mjs} +16 -8
  18. package/dist/_chunks/Form-BxyeWiXW.mjs.map +1 -0
  19. package/dist/_chunks/{Form-DGIf4jQU.js → Form-CmLbZDfi.js} +16 -8
  20. package/dist/_chunks/Form-CmLbZDfi.js.map +1 -0
  21. package/dist/_chunks/{History-BowL3JKP.mjs → History-BOhLaq_g.mjs} +38 -41
  22. package/dist/_chunks/History-BOhLaq_g.mjs.map +1 -0
  23. package/dist/_chunks/{History-Dh2NEHnR.js → History-uECUbCZB.js} +37 -40
  24. package/dist/_chunks/History-uECUbCZB.js.map +1 -0
  25. package/dist/_chunks/{ListConfigurationPage-BpVOB-hn.mjs → ListConfigurationPage-D0vQez6F.mjs} +3 -3
  26. package/dist/_chunks/{ListConfigurationPage-BpVOB-hn.mjs.map → ListConfigurationPage-D0vQez6F.mjs.map} +1 -1
  27. package/dist/_chunks/{ListConfigurationPage-BxYCWz9e.js → ListConfigurationPage-D_bBSFNW.js} +3 -3
  28. package/dist/_chunks/{ListConfigurationPage-BxYCWz9e.js.map → ListConfigurationPage-D_bBSFNW.js.map} +1 -1
  29. package/dist/_chunks/{ListViewPage-4XsciqHZ.js → ListViewPage-BkZ83b1A.js} +55 -40
  30. package/dist/_chunks/ListViewPage-BkZ83b1A.js.map +1 -0
  31. package/dist/_chunks/{ListViewPage-CXFUjZQC.mjs → ListViewPage-ns-bmy5C.mjs} +52 -37
  32. package/dist/_chunks/ListViewPage-ns-bmy5C.mjs.map +1 -0
  33. package/dist/_chunks/{NoContentTypePage-DuhOTp3x.mjs → NoContentTypePage-BA5ZKMDR.mjs} +2 -2
  34. package/dist/_chunks/{NoContentTypePage-DuhOTp3x.mjs.map → NoContentTypePage-BA5ZKMDR.mjs.map} +1 -1
  35. package/dist/_chunks/{NoContentTypePage-C8OpoHeU.js → NoContentTypePage-C1439s4s.js} +2 -2
  36. package/dist/_chunks/{NoContentTypePage-C8OpoHeU.js.map → NoContentTypePage-C1439s4s.js.map} +1 -1
  37. package/dist/_chunks/{NoPermissionsPage-DVz3mzDz.mjs → NoPermissionsPage-B0GdMw1Q.mjs} +2 -2
  38. package/dist/_chunks/{NoPermissionsPage-DVz3mzDz.mjs.map → NoPermissionsPage-B0GdMw1Q.mjs.map} +1 -1
  39. package/dist/_chunks/{NoPermissionsPage-y_r7DVA2.js → NoPermissionsPage-CPGwsVfb.js} +2 -2
  40. package/dist/_chunks/{NoPermissionsPage-y_r7DVA2.js.map → NoPermissionsPage-CPGwsVfb.js.map} +1 -1
  41. package/dist/_chunks/{Relations-CVNLrn1Y.mjs → Relations-BIGPMSW4.mjs} +72 -36
  42. package/dist/_chunks/Relations-BIGPMSW4.mjs.map +1 -0
  43. package/dist/_chunks/{Relations-DPFCAa7b.js → Relations-d-8Uef_-.js} +71 -35
  44. package/dist/_chunks/Relations-d-8Uef_-.js.map +1 -0
  45. package/dist/_chunks/{en-uOUIxfcQ.js → en-Bdpa50w3.js} +18 -13
  46. package/dist/_chunks/{en-uOUIxfcQ.js.map → en-Bdpa50w3.js.map} +1 -1
  47. package/dist/_chunks/{en-BrCTWlZv.mjs → en-CZw4xdPY.mjs} +18 -13
  48. package/dist/_chunks/{en-BrCTWlZv.mjs.map → en-CZw4xdPY.mjs.map} +1 -1
  49. package/dist/_chunks/{es-EUonQTon.js → es-9K52xZIr.js} +2 -2
  50. package/dist/_chunks/{ja-CcFe8diO.js.map → es-9K52xZIr.js.map} +1 -1
  51. package/dist/_chunks/{es-CeXiYflN.mjs → es-D34tqjMw.mjs} +2 -2
  52. package/dist/_chunks/{es-CeXiYflN.mjs.map → es-D34tqjMw.mjs.map} +1 -1
  53. package/dist/_chunks/{fr-CD9VFbPM.mjs → fr--pg5jUbt.mjs} +13 -3
  54. package/dist/_chunks/{fr-CD9VFbPM.mjs.map → fr--pg5jUbt.mjs.map} +1 -1
  55. package/dist/_chunks/{fr-B7kGGg3E.js → fr-B2Kyv8Z9.js} +13 -3
  56. package/dist/_chunks/{fr-B7kGGg3E.js.map → fr-B2Kyv8Z9.js.map} +1 -1
  57. package/dist/_chunks/{index-DiMrfcfy.mjs → index-3_WeHXYp.mjs} +898 -698
  58. package/dist/_chunks/index-3_WeHXYp.mjs.map +1 -0
  59. package/dist/_chunks/{index-C3fJE-1-.js → index-BgaeYWIy.js} +895 -694
  60. package/dist/_chunks/index-BgaeYWIy.js.map +1 -0
  61. package/dist/_chunks/{ja-CcFe8diO.js → ja-7sfIbjxE.js} +2 -2
  62. package/dist/_chunks/{es-EUonQTon.js.map → ja-7sfIbjxE.js.map} +1 -1
  63. package/dist/_chunks/{ja-CtsUxOvk.mjs → ja-BHqhDq4V.mjs} +2 -2
  64. package/dist/_chunks/{ja-CtsUxOvk.mjs.map → ja-BHqhDq4V.mjs.map} +1 -1
  65. package/dist/_chunks/{layout-C788OmNr.js → layout-ByFyQRDH.js} +5 -4
  66. package/dist/_chunks/{layout-C788OmNr.js.map → layout-ByFyQRDH.js.map} +1 -1
  67. package/dist/_chunks/{layout-ls3gxfpH.mjs → layout-CrTxOnCy.mjs} +5 -4
  68. package/dist/_chunks/{layout-ls3gxfpH.mjs.map → layout-CrTxOnCy.mjs.map} +1 -1
  69. package/dist/_chunks/{objects-gigeqt7s.js → objects-BcXOv6_9.js} +2 -4
  70. package/dist/_chunks/{objects-gigeqt7s.js.map → objects-BcXOv6_9.js.map} +1 -1
  71. package/dist/_chunks/{objects-mKMAmfec.mjs → objects-D6yBsdmx.mjs} +2 -4
  72. package/dist/_chunks/{objects-mKMAmfec.mjs.map → objects-D6yBsdmx.mjs.map} +1 -1
  73. package/dist/_chunks/{relations-CLcOmGO0.mjs → relations-BlpLgngh.mjs} +3 -7
  74. package/dist/_chunks/relations-BlpLgngh.mjs.map +1 -0
  75. package/dist/_chunks/{relations-DYeotliT.js → relations-C5RSW926.js} +3 -7
  76. package/dist/_chunks/relations-C5RSW926.js.map +1 -0
  77. package/dist/_chunks/{usePrev-B9w_-eYc.js → useDebounce-CtcjDB3L.js} +14 -1
  78. package/dist/_chunks/useDebounce-CtcjDB3L.js.map +1 -0
  79. package/dist/_chunks/useDebounce-DmuSJIF3.mjs +29 -0
  80. package/dist/_chunks/useDebounce-DmuSJIF3.mjs.map +1 -0
  81. package/dist/admin/index.js +2 -1
  82. package/dist/admin/index.js.map +1 -1
  83. package/dist/admin/index.mjs +3 -2
  84. package/dist/admin/src/exports.d.ts +1 -1
  85. package/dist/admin/src/hooks/useDocument.d.ts +32 -1
  86. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygStyles.d.ts +0 -32
  87. package/dist/admin/src/pages/EditView/components/Header.d.ts +11 -11
  88. package/dist/admin/src/preview/components/PreviewSidePanel.d.ts +3 -0
  89. package/dist/admin/src/preview/constants.d.ts +1 -0
  90. package/dist/admin/src/preview/index.d.ts +4 -0
  91. package/dist/admin/src/preview/services/preview.d.ts +3 -0
  92. package/dist/admin/src/services/documents.d.ts +3 -1
  93. package/dist/server/index.js +392 -165
  94. package/dist/server/index.js.map +1 -1
  95. package/dist/server/index.mjs +392 -165
  96. package/dist/server/index.mjs.map +1 -1
  97. package/dist/server/src/bootstrap.d.ts.map +1 -1
  98. package/dist/server/src/controllers/collection-types.d.ts.map +1 -1
  99. package/dist/server/src/controllers/index.d.ts.map +1 -1
  100. package/dist/server/src/controllers/relations.d.ts.map +1 -1
  101. package/dist/server/src/controllers/utils/metadata.d.ts +15 -1
  102. package/dist/server/src/controllers/utils/metadata.d.ts.map +1 -1
  103. package/dist/server/src/history/services/history.d.ts.map +1 -1
  104. package/dist/server/src/history/services/lifecycles.d.ts.map +1 -1
  105. package/dist/server/src/history/services/utils.d.ts +3 -3
  106. package/dist/server/src/history/services/utils.d.ts.map +1 -1
  107. package/dist/server/src/index.d.ts +4 -4
  108. package/dist/server/src/preview/constants.d.ts +2 -0
  109. package/dist/server/src/preview/constants.d.ts.map +1 -0
  110. package/dist/server/src/preview/controllers/index.d.ts +2 -0
  111. package/dist/server/src/preview/controllers/index.d.ts.map +1 -0
  112. package/dist/server/src/preview/controllers/preview.d.ts +13 -0
  113. package/dist/server/src/preview/controllers/preview.d.ts.map +1 -0
  114. package/dist/server/src/preview/controllers/validation/preview.d.ts +6 -0
  115. package/dist/server/src/preview/controllers/validation/preview.d.ts.map +1 -0
  116. package/dist/server/src/preview/index.d.ts +4 -0
  117. package/dist/server/src/preview/index.d.ts.map +1 -0
  118. package/dist/server/src/preview/routes/index.d.ts +8 -0
  119. package/dist/server/src/preview/routes/index.d.ts.map +1 -0
  120. package/dist/server/src/preview/routes/preview.d.ts +4 -0
  121. package/dist/server/src/preview/routes/preview.d.ts.map +1 -0
  122. package/dist/server/src/preview/services/index.d.ts +15 -0
  123. package/dist/server/src/preview/services/index.d.ts.map +1 -0
  124. package/dist/server/src/preview/services/preview-config.d.ts +30 -0
  125. package/dist/server/src/preview/services/preview-config.d.ts.map +1 -0
  126. package/dist/server/src/preview/services/preview.d.ts +12 -0
  127. package/dist/server/src/preview/services/preview.d.ts.map +1 -0
  128. package/dist/server/src/preview/utils.d.ts +18 -0
  129. package/dist/server/src/preview/utils.d.ts.map +1 -0
  130. package/dist/server/src/routes/index.d.ts.map +1 -1
  131. package/dist/server/src/services/document-metadata.d.ts +8 -8
  132. package/dist/server/src/services/document-metadata.d.ts.map +1 -1
  133. package/dist/server/src/services/index.d.ts +4 -4
  134. package/dist/server/src/services/index.d.ts.map +1 -1
  135. package/dist/server/src/services/utils/configuration/index.d.ts +2 -2
  136. package/dist/server/src/services/utils/configuration/layouts.d.ts +2 -2
  137. package/dist/server/src/utils/index.d.ts +2 -0
  138. package/dist/server/src/utils/index.d.ts.map +1 -1
  139. package/dist/shared/contracts/collection-types.d.ts +3 -1
  140. package/dist/shared/contracts/collection-types.d.ts.map +1 -1
  141. package/dist/shared/contracts/index.d.ts +1 -0
  142. package/dist/shared/contracts/index.d.ts.map +1 -1
  143. package/dist/shared/contracts/preview.d.ts +27 -0
  144. package/dist/shared/contracts/preview.d.ts.map +1 -0
  145. package/dist/shared/index.js +4 -0
  146. package/dist/shared/index.js.map +1 -1
  147. package/dist/shared/index.mjs +4 -0
  148. package/dist/shared/index.mjs.map +1 -1
  149. package/package.json +13 -13
  150. package/dist/_chunks/EditViewPage-B-RJeiJD.js.map +0 -1
  151. package/dist/_chunks/EditViewPage-De8GyU8P.mjs.map +0 -1
  152. package/dist/_chunks/Field-dq8Tg1M_.js.map +0 -1
  153. package/dist/_chunks/Field-pb2o8uBe.mjs.map +0 -1
  154. package/dist/_chunks/Form-DGIf4jQU.js.map +0 -1
  155. package/dist/_chunks/Form-DJn0Dxha.mjs.map +0 -1
  156. package/dist/_chunks/History-BowL3JKP.mjs.map +0 -1
  157. package/dist/_chunks/History-Dh2NEHnR.js.map +0 -1
  158. package/dist/_chunks/ListViewPage-4XsciqHZ.js.map +0 -1
  159. package/dist/_chunks/ListViewPage-CXFUjZQC.mjs.map +0 -1
  160. package/dist/_chunks/Relations-CVNLrn1Y.mjs.map +0 -1
  161. package/dist/_chunks/Relations-DPFCAa7b.js.map +0 -1
  162. package/dist/_chunks/index-C3fJE-1-.js.map +0 -1
  163. package/dist/_chunks/index-DiMrfcfy.mjs.map +0 -1
  164. package/dist/_chunks/relations-CLcOmGO0.mjs.map +0 -1
  165. package/dist/_chunks/relations-DYeotliT.js.map +0 -1
  166. package/dist/_chunks/usePrev-B9w_-eYc.js.map +0 -1
  167. package/dist/_chunks/usePrev-DH6iah0A.mjs +0 -16
  168. package/dist/_chunks/usePrev-DH6iah0A.mjs.map +0 -1
  169. package/strapi-server.js +0 -3
@@ -4,12 +4,13 @@ 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
- const styledComponents = require("styled-components");
10
10
  const yup = require("yup");
11
11
  const pipe = require("lodash/fp/pipe");
12
12
  const dateFns = require("date-fns");
13
+ const styledComponents = require("styled-components");
13
14
  const qs = require("qs");
14
15
  const toolkit = require("@reduxjs/toolkit");
15
16
  const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
@@ -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,98 +936,353 @@ 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",
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);
997
+ }
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
1014
+ }
1015
+ };
1016
+ return acc;
1017
+ },
1018
+ {}
1019
+ );
1020
+ const editMetadatas = Object.entries(data.contentType.metadatas).reduce(
1021
+ (acc, [attribute, metadata]) => {
1022
+ return {
1023
+ ...acc,
1024
+ [attribute]: metadata.edit
1025
+ };
1026
+ },
1027
+ {}
1028
+ );
1029
+ return {
1030
+ layout: panelledEditAttributes,
1031
+ components: componentEditAttributes,
1032
+ metadatas: editMetadatas,
1033
+ settings: {
1034
+ ...data.contentType.settings,
1035
+ displayName: schema?.info.displayName
1036
+ },
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;
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
+ },
1086
+ {}
1087
+ );
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
+ }
1166
+ try {
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);
1172
+ }
1173
+ throw error2;
1174
+ }
1175
+ },
1176
+ [validationSchema]
1177
+ );
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) => {
1275
+ try {
1276
+ trackUsage("willDeleteEntry", trackerProperty);
1277
+ const res = await deleteDocument({
1278
+ collectionType,
1279
+ model,
1280
+ documentId,
1281
+ params
1282
+ });
1283
+ if ("error" in res) {
1284
+ toggleNotification({
1285
+ type: "danger",
925
1286
  message: formatAPIError(res.error)
926
1287
  });
927
1288
  return { error: res.error };
@@ -1222,6 +1583,7 @@ const useDocumentActions = () => {
1222
1583
  defaultMessage: "Saved document"
1223
1584
  })
1224
1585
  });
1586
+ setCurrentStep("contentManager.success");
1225
1587
  return res.data;
1226
1588
  } catch (err) {
1227
1589
  toggleNotification({
@@ -1324,7 +1686,7 @@ const useDocumentActions = () => {
1324
1686
  };
1325
1687
  };
1326
1688
  const ProtectedHistoryPage = React.lazy(
1327
- () => Promise.resolve().then(() => require("./History-Dh2NEHnR.js")).then((mod) => ({ default: mod.ProtectedHistoryPage }))
1689
+ () => Promise.resolve().then(() => require("./History-uECUbCZB.js")).then((mod) => ({ default: mod.ProtectedHistoryPage }))
1328
1690
  );
1329
1691
  const routes$1 = [
1330
1692
  {
@@ -1337,31 +1699,31 @@ const routes$1 = [
1337
1699
  }
1338
1700
  ];
1339
1701
  const ProtectedEditViewPage = React.lazy(
1340
- () => Promise.resolve().then(() => require("./EditViewPage-B-RJeiJD.js")).then((mod) => ({ default: mod.ProtectedEditViewPage }))
1702
+ () => Promise.resolve().then(() => require("./EditViewPage-BqZvBN4s.js")).then((mod) => ({ default: mod.ProtectedEditViewPage }))
1341
1703
  );
1342
1704
  const ProtectedListViewPage = React.lazy(
1343
- () => Promise.resolve().then(() => require("./ListViewPage-4XsciqHZ.js")).then((mod) => ({ default: mod.ProtectedListViewPage }))
1705
+ () => Promise.resolve().then(() => require("./ListViewPage-BkZ83b1A.js")).then((mod) => ({ default: mod.ProtectedListViewPage }))
1344
1706
  );
1345
1707
  const ProtectedListConfiguration = React.lazy(
1346
- () => Promise.resolve().then(() => require("./ListConfigurationPage-BxYCWz9e.js")).then((mod) => ({
1708
+ () => Promise.resolve().then(() => require("./ListConfigurationPage-D_bBSFNW.js")).then((mod) => ({
1347
1709
  default: mod.ProtectedListConfiguration
1348
1710
  }))
1349
1711
  );
1350
1712
  const ProtectedEditConfigurationPage = React.lazy(
1351
- () => Promise.resolve().then(() => require("./EditConfigurationPage-BePwPuHy.js")).then((mod) => ({
1713
+ () => Promise.resolve().then(() => require("./EditConfigurationPage-ILWo0h1e.js")).then((mod) => ({
1352
1714
  default: mod.ProtectedEditConfigurationPage
1353
1715
  }))
1354
1716
  );
1355
1717
  const ProtectedComponentConfigurationPage = React.lazy(
1356
- () => Promise.resolve().then(() => require("./ComponentConfigurationPage-D_M8iBw5.js")).then((mod) => ({
1718
+ () => Promise.resolve().then(() => require("./ComponentConfigurationPage-CL9CAMaL.js")).then((mod) => ({
1357
1719
  default: mod.ProtectedComponentConfigurationPage
1358
1720
  }))
1359
1721
  );
1360
1722
  const NoPermissions = React.lazy(
1361
- () => Promise.resolve().then(() => require("./NoPermissionsPage-y_r7DVA2.js")).then((mod) => ({ default: mod.NoPermissions }))
1723
+ () => Promise.resolve().then(() => require("./NoPermissionsPage-CPGwsVfb.js")).then((mod) => ({ default: mod.NoPermissions }))
1362
1724
  );
1363
1725
  const NoContentType = React.lazy(
1364
- () => Promise.resolve().then(() => require("./NoContentTypePage-C8OpoHeU.js")).then((mod) => ({ default: mod.NoContentType }))
1726
+ () => Promise.resolve().then(() => require("./NoContentTypePage-C1439s4s.js")).then((mod) => ({ default: mod.NoContentType }))
1365
1727
  );
1366
1728
  const CollectionTypePages = () => {
1367
1729
  const { collectionType } = reactRouterDom.useParams();
@@ -1542,7 +1904,7 @@ const DocumentActionsMenu = ({
1542
1904
  };
1543
1905
  return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.Root, { open: isOpen, onOpenChange: setIsOpen, children: [
1544
1906
  /* @__PURE__ */ jsxRuntime.jsxs(
1545
- StyledMoreButton,
1907
+ designSystem.Menu.Trigger,
1546
1908
  {
1547
1909
  disabled: isDisabled,
1548
1910
  size: "S",
@@ -1560,7 +1922,7 @@ const DocumentActionsMenu = ({
1560
1922
  ]
1561
1923
  }
1562
1924
  ),
1563
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.Content, { top: "4px", maxHeight: void 0, popoverPlacement: "bottom-end", children: [
1925
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.Content, { maxHeight: void 0, popoverPlacement: "bottom-end", children: [
1564
1926
  actions2.map((action) => {
1565
1927
  return /* @__PURE__ */ jsxRuntime.jsx(
1566
1928
  designSystem.Menu.Item,
@@ -1658,11 +2020,6 @@ const convertActionVariantToIconColor = (variant = "secondary") => {
1658
2020
  return "primary600";
1659
2021
  }
1660
2022
  };
1661
- const StyledMoreButton = styledComponents.styled(designSystem.Menu.Trigger)`
1662
- & > span {
1663
- display: flex;
1664
- }
1665
- `;
1666
2023
  const DocumentActionConfirmDialog = ({
1667
2024
  onClose,
1668
2025
  onCancel,
@@ -1689,11 +2046,11 @@ const DocumentActionConfirmDialog = ({
1689
2046
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Header, { children: title }),
1690
2047
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Body, { children: content }),
1691
2048
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Footer, { children: [
1692
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Cancel, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", children: formatMessage({
2049
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Cancel, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", fullWidth: true, children: formatMessage({
1693
2050
  id: "app.components.Button.cancel",
1694
2051
  defaultMessage: "Cancel"
1695
2052
  }) }) }),
1696
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: handleConfirm, variant, children: formatMessage({
2053
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: handleConfirm, variant, fullWidth: true, children: formatMessage({
1697
2054
  id: "app.components.Button.confirm",
1698
2055
  defaultMessage: "Confirm"
1699
2056
  }) })
@@ -1720,6 +2077,18 @@ const DocumentActionModal = ({
1720
2077
  typeof Footer === "function" ? /* @__PURE__ */ jsxRuntime.jsx(Footer, { onClose: handleClose }) : Footer
1721
2078
  ] }) });
1722
2079
  };
2080
+ const transformData = (data) => {
2081
+ if (Array.isArray(data)) {
2082
+ return data.map(transformData);
2083
+ }
2084
+ if (typeof data === "object" && data !== null) {
2085
+ if ("apiData" in data) {
2086
+ return data.apiData;
2087
+ }
2088
+ return mapValues__default.default(transformData)(data);
2089
+ }
2090
+ return data;
2091
+ };
1723
2092
  const PublishAction$1 = ({
1724
2093
  activeTab,
1725
2094
  documentId,
@@ -1787,24 +2156,25 @@ const PublishAction$1 = ({
1787
2156
  }
1788
2157
  }, [documentId, modified, formValues, setLocalCountOfDraftRelations]);
1789
2158
  React__namespace.useEffect(() => {
1790
- if (documentId && !isListView) {
1791
- const fetchDraftRelationsCount = async () => {
1792
- const { data, error } = await countDraftRelations({
1793
- collectionType,
1794
- model,
1795
- documentId,
1796
- params
1797
- });
1798
- if (error) {
1799
- throw error;
1800
- }
1801
- if (data) {
1802
- setServerCountOfDraftRelations(data.data);
1803
- }
1804
- };
1805
- fetchDraftRelationsCount();
2159
+ if (!document || !document.documentId || isListView) {
2160
+ return;
1806
2161
  }
1807
- }, [isListView, documentId, countDraftRelations, collectionType, model, params]);
2162
+ const fetchDraftRelationsCount = async () => {
2163
+ const { data, error } = await countDraftRelations({
2164
+ collectionType,
2165
+ model,
2166
+ documentId,
2167
+ params
2168
+ });
2169
+ if (error) {
2170
+ throw error;
2171
+ }
2172
+ if (data) {
2173
+ setServerCountOfDraftRelations(data.data);
2174
+ }
2175
+ };
2176
+ fetchDraftRelationsCount();
2177
+ }, [isListView, document, documentId, countDraftRelations, collectionType, model, params]);
1808
2178
  const isDocumentPublished = (document?.[PUBLISHED_AT_ATTRIBUTE_NAME] || meta?.availableStatus.some((doc) => doc[PUBLISHED_AT_ATTRIBUTE_NAME] !== null)) && document?.status !== "modified";
1809
2179
  if (!schema?.options?.draftAndPublish) {
1810
2180
  return null;
@@ -1812,7 +2182,9 @@ const PublishAction$1 = ({
1812
2182
  const performPublish = async () => {
1813
2183
  setSubmitting(true);
1814
2184
  try {
1815
- const { errors } = await validate();
2185
+ const { errors } = await validate(true, {
2186
+ status: "published"
2187
+ });
1816
2188
  if (errors) {
1817
2189
  toggleNotification({
1818
2190
  type: "danger",
@@ -1830,7 +2202,7 @@ const PublishAction$1 = ({
1830
2202
  documentId,
1831
2203
  params
1832
2204
  },
1833
- formValues
2205
+ transformData(formValues)
1834
2206
  );
1835
2207
  if ("data" in res && collectionType !== SINGLE_TYPES) {
1836
2208
  navigate({
@@ -1845,7 +2217,8 @@ const PublishAction$1 = ({
1845
2217
  }
1846
2218
  };
1847
2219
  const totalDraftRelations = localCountOfDraftRelations + serverCountOfDraftRelations;
1848
- const hasDraftRelations = totalDraftRelations > 0;
2220
+ const enableDraftRelationsCount = false;
2221
+ const hasDraftRelations = enableDraftRelationsCount;
1849
2222
  return {
1850
2223
  /**
1851
2224
  * Disabled when:
@@ -1862,9 +2235,6 @@ const PublishAction$1 = ({
1862
2235
  defaultMessage: "Publish"
1863
2236
  }),
1864
2237
  onClick: async () => {
1865
- if (hasDraftRelations) {
1866
- return;
1867
- }
1868
2238
  await performPublish();
1869
2239
  },
1870
2240
  dialog: hasDraftRelations ? {
@@ -1928,18 +2298,18 @@ const UpdateAction = ({
1928
2298
  onClick: async () => {
1929
2299
  setSubmitting(true);
1930
2300
  try {
1931
- if (activeTab !== "draft") {
1932
- const { errors } = await validate();
1933
- if (errors) {
1934
- toggleNotification({
1935
- type: "danger",
1936
- message: formatMessage({
1937
- id: "content-manager.validation.error",
1938
- defaultMessage: "There are validation errors in your document. Please fix them before saving."
1939
- })
1940
- });
1941
- return;
1942
- }
2301
+ const { errors } = await validate(true, {
2302
+ status: "draft"
2303
+ });
2304
+ if (errors) {
2305
+ toggleNotification({
2306
+ type: "danger",
2307
+ message: formatMessage({
2308
+ id: "content-manager.validation.error",
2309
+ defaultMessage: "There are validation errors in your document. Please fix them before saving."
2310
+ })
2311
+ });
2312
+ return;
1943
2313
  }
1944
2314
  if (isCloning) {
1945
2315
  const res = await clone(
@@ -1948,7 +2318,7 @@ const UpdateAction = ({
1948
2318
  documentId: cloneMatch.params.origin,
1949
2319
  params
1950
2320
  },
1951
- document
2321
+ transformData(document)
1952
2322
  );
1953
2323
  if ("data" in res) {
1954
2324
  navigate(
@@ -1969,7 +2339,7 @@ const UpdateAction = ({
1969
2339
  documentId,
1970
2340
  params
1971
2341
  },
1972
- document
2342
+ transformData(document)
1973
2343
  );
1974
2344
  if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
1975
2345
  setErrors(formatValidationErrors(res.error));
@@ -1982,7 +2352,7 @@ const UpdateAction = ({
1982
2352
  model,
1983
2353
  params
1984
2354
  },
1985
- document
2355
+ transformData(document)
1986
2356
  );
1987
2357
  if ("data" in res && collectionType !== SINGLE_TYPES) {
1988
2358
  navigate(
@@ -2035,7 +2405,7 @@ const UnpublishAction$1 = ({
2035
2405
  id: "app.utils.unpublish",
2036
2406
  defaultMessage: "Unpublish"
2037
2407
  }),
2038
- icon: /* @__PURE__ */ jsxRuntime.jsx(StyledCrossCircle, {}),
2408
+ icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Cross, {}),
2039
2409
  onClick: async () => {
2040
2410
  if (!documentId && collectionType !== SINGLE_TYPES || isDocumentModified) {
2041
2411
  if (!documentId) {
@@ -2147,7 +2517,7 @@ const DiscardAction = ({
2147
2517
  id: "content-manager.actions.discard.label",
2148
2518
  defaultMessage: "Discard changes"
2149
2519
  }),
2150
- icon: /* @__PURE__ */ jsxRuntime.jsx(StyledCrossCircle, {}),
2520
+ icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Cross, {}),
2151
2521
  position: ["panel", "table-row"],
2152
2522
  variant: "danger",
2153
2523
  dialog: {
@@ -2175,11 +2545,6 @@ const DiscardAction = ({
2175
2545
  };
2176
2546
  };
2177
2547
  DiscardAction.type = "discard";
2178
- const StyledCrossCircle = styledComponents.styled(Icons.CrossCircle)`
2179
- path {
2180
- fill: currentColor;
2181
- }
2182
- `;
2183
2548
  const DEFAULT_ACTIONS = [PublishAction$1, UpdateAction, UnpublishAction$1, DiscardAction];
2184
2549
  const intervals = ["years", "months", "days", "hours", "minutes", "seconds"];
2185
2550
  const RelativeTime = React__namespace.forwardRef(
@@ -2227,7 +2592,7 @@ const getDisplayName = ({
2227
2592
  };
2228
2593
  const capitalise = (str) => str.charAt(0).toUpperCase() + str.slice(1);
2229
2594
  const DocumentStatus = ({ status = "draft", ...restProps }) => {
2230
- const statusVariant = status === "draft" ? "primary" : status === "published" ? "success" : "alternative";
2595
+ const statusVariant = status === "draft" ? "secondary" : status === "published" ? "success" : "alternative";
2231
2596
  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) }) });
2232
2597
  };
2233
2598
  const Header = ({ isCreating, status, title: documentTitle = "Untitled" }) => {
@@ -2326,12 +2691,12 @@ const Information = ({ activeTab }) => {
2326
2691
  isDisplayed: !!publishDocument?.[PUBLISHED_AT_ATTRIBUTE_NAME],
2327
2692
  label: formatMessage({
2328
2693
  id: "content-manager.containers.edit.information.last-published.label",
2329
- defaultMessage: "Last published"
2694
+ defaultMessage: "Published"
2330
2695
  }),
2331
2696
  value: formatMessage(
2332
2697
  {
2333
2698
  id: "content-manager.containers.edit.information.last-published.value",
2334
- defaultMessage: `Published {time}{isAnonymous, select, true {} other { by {author}}}`
2699
+ defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
2335
2700
  },
2336
2701
  {
2337
2702
  time: /* @__PURE__ */ jsxRuntime.jsx(RelativeTime, { timestamp: new Date(publishDocument?.[PUBLISHED_AT_ATTRIBUTE_NAME]) }),
@@ -2344,12 +2709,12 @@ const Information = ({ activeTab }) => {
2344
2709
  isDisplayed: !!createAndUpdateDocument?.[UPDATED_AT_ATTRIBUTE_NAME],
2345
2710
  label: formatMessage({
2346
2711
  id: "content-manager.containers.edit.information.last-draft.label",
2347
- defaultMessage: "Last draft"
2712
+ defaultMessage: "Updated"
2348
2713
  }),
2349
2714
  value: formatMessage(
2350
2715
  {
2351
2716
  id: "content-manager.containers.edit.information.last-draft.value",
2352
- defaultMessage: `Modified {time}{isAnonymous, select, true {} other { by {author}}}`
2717
+ defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
2353
2718
  },
2354
2719
  {
2355
2720
  time: /* @__PURE__ */ jsxRuntime.jsx(
@@ -2367,12 +2732,12 @@ const Information = ({ activeTab }) => {
2367
2732
  isDisplayed: !!createAndUpdateDocument?.[CREATED_AT_ATTRIBUTE_NAME],
2368
2733
  label: formatMessage({
2369
2734
  id: "content-manager.containers.edit.information.document.label",
2370
- defaultMessage: "Document"
2735
+ defaultMessage: "Created"
2371
2736
  }),
2372
2737
  value: formatMessage(
2373
2738
  {
2374
2739
  id: "content-manager.containers.edit.information.document.value",
2375
- defaultMessage: `Created {time}{isAnonymous, select, true {} other { by {author}}}`
2740
+ defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
2376
2741
  },
2377
2742
  {
2378
2743
  time: /* @__PURE__ */ jsxRuntime.jsx(
@@ -2410,523 +2775,277 @@ const Information = ({ activeTab }) => {
2410
2775
  );
2411
2776
  };
2412
2777
  const HeaderActions = ({ actions: actions2 }) => {
2413
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { children: actions2.map((action) => {
2414
- if ("options" in action) {
2778
+ const [dialogId, setDialogId] = React__namespace.useState(null);
2779
+ const handleClick = (action) => async (e) => {
2780
+ if (!("options" in action)) {
2781
+ const { onClick = () => false, dialog, id } = action;
2782
+ const muteDialog = await onClick(e);
2783
+ if (dialog && !muteDialog) {
2784
+ e.preventDefault();
2785
+ setDialogId(id);
2786
+ }
2787
+ }
2788
+ };
2789
+ const handleClose = () => {
2790
+ setDialogId(null);
2791
+ };
2792
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { gap: 1, children: actions2.map((action) => {
2793
+ if (action.options) {
2415
2794
  return /* @__PURE__ */ jsxRuntime.jsx(
2416
2795
  designSystem.SingleSelect,
2417
2796
  {
2418
2797
  size: "S",
2419
- disabled: action.disabled,
2420
- "aria-label": action.label,
2421
2798
  onChange: action.onSelect,
2422
- value: action.value,
2799
+ "aria-label": action.label,
2800
+ ...action,
2423
2801
  children: action.options.map(({ label, ...option }) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { ...option, children: label }, option.value))
2424
2802
  },
2425
2803
  action.id
2426
2804
  );
2427
2805
  } else {
2428
- return null;
2429
- }
2430
- }) });
2431
- };
2432
- const ConfigureTheViewAction = ({ collectionType, model }) => {
2433
- const navigate = reactRouterDom.useNavigate();
2434
- const { formatMessage } = reactIntl.useIntl();
2435
- return {
2436
- label: formatMessage({
2437
- id: "app.links.configure-view",
2438
- defaultMessage: "Configure the view"
2439
- }),
2440
- icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.ListPlus, {}),
2441
- onClick: () => {
2442
- navigate(`../${collectionType}/${model}/configurations/edit`);
2443
- },
2444
- position: "header"
2445
- };
2446
- };
2447
- ConfigureTheViewAction.type = "configure-the-view";
2448
- const EditTheModelAction = ({ model }) => {
2449
- const navigate = reactRouterDom.useNavigate();
2450
- const { formatMessage } = reactIntl.useIntl();
2451
- return {
2452
- label: formatMessage({
2453
- id: "content-manager.link-to-ctb",
2454
- defaultMessage: "Edit the model"
2455
- }),
2456
- icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Pencil, {}),
2457
- onClick: () => {
2458
- navigate(`/plugins/content-type-builder/content-types/${model}`);
2459
- },
2460
- position: "header"
2461
- };
2462
- };
2463
- EditTheModelAction.type = "edit-the-model";
2464
- const DeleteAction$1 = ({ documentId, model, collectionType, document }) => {
2465
- const navigate = reactRouterDom.useNavigate();
2466
- const { formatMessage } = reactIntl.useIntl();
2467
- const listViewPathMatch = reactRouterDom.useMatch(LIST_PATH);
2468
- const canDelete = useDocumentRBAC("DeleteAction", (state) => state.canDelete);
2469
- const { delete: deleteAction } = useDocumentActions();
2470
- const { toggleNotification } = strapiAdmin.useNotification();
2471
- const setSubmitting = strapiAdmin.useForm("DeleteAction", (state) => state.setSubmitting);
2472
- return {
2473
- disabled: !canDelete || !document,
2474
- label: formatMessage({
2475
- id: "content-manager.actions.delete.label",
2476
- defaultMessage: "Delete document"
2477
- }),
2478
- icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Trash, {}),
2479
- dialog: {
2480
- type: "dialog",
2481
- title: formatMessage({
2482
- id: "app.components.ConfirmDialog.title",
2483
- defaultMessage: "Confirmation"
2484
- }),
2485
- content: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 2, children: [
2486
- /* @__PURE__ */ jsxRuntime.jsx(Icons.WarningCircle, { width: "24px", height: "24px", fill: "danger600" }),
2487
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "p", variant: "omega", textAlign: "center", children: formatMessage({
2488
- id: "content-manager.actions.delete.dialog.body",
2489
- defaultMessage: "Are you sure?"
2490
- }) })
2491
- ] }),
2492
- onConfirm: async () => {
2493
- if (!listViewPathMatch) {
2494
- setSubmitting(true);
2495
- }
2496
- try {
2497
- if (!documentId && collectionType !== SINGLE_TYPES) {
2498
- console.error(
2499
- "You're trying to delete a document without an id, this is likely a bug with Strapi. Please open an issue."
2500
- );
2501
- toggleNotification({
2502
- message: formatMessage({
2503
- id: "content-manager.actions.delete.error",
2504
- defaultMessage: "An error occurred while trying to delete the document."
2505
- }),
2506
- type: "danger"
2507
- });
2508
- return;
2509
- }
2510
- const res = await deleteAction({
2511
- documentId,
2512
- model,
2513
- collectionType,
2514
- params: {
2515
- locale: "*"
2806
+ if (action.type === "icon") {
2807
+ return /* @__PURE__ */ jsxRuntime.jsxs(React__namespace.Fragment, { children: [
2808
+ /* @__PURE__ */ jsxRuntime.jsx(
2809
+ designSystem.IconButton,
2810
+ {
2811
+ disabled: action.disabled,
2812
+ label: action.label,
2813
+ size: "S",
2814
+ onClick: handleClick(action),
2815
+ children: action.icon
2516
2816
  }
2517
- });
2518
- if (!("error" in res)) {
2519
- navigate({ pathname: `../${collectionType}/${model}` }, { replace: true });
2520
- }
2521
- } finally {
2522
- if (!listViewPathMatch) {
2523
- setSubmitting(false);
2524
- }
2525
- }
2526
- }
2527
- },
2528
- variant: "danger",
2529
- position: ["header", "table-row"]
2530
- };
2531
- };
2532
- DeleteAction$1.type = "delete";
2533
- const DEFAULT_HEADER_ACTIONS = [EditTheModelAction, ConfigureTheViewAction, DeleteAction$1];
2534
- const Panels = () => {
2535
- const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
2536
- const [
2537
- {
2538
- query: { status }
2539
- }
2540
- ] = strapiAdmin.useQueryParams({
2541
- status: "draft"
2542
- });
2543
- const { model, id, document, meta, collectionType } = useDoc();
2544
- const plugins = strapiAdmin.useStrapiApp("Panels", (state) => state.plugins);
2545
- const props = {
2546
- activeTab: status,
2547
- model,
2548
- documentId: id,
2549
- document: isCloning ? void 0 : document,
2550
- meta: isCloning ? void 0 : meta,
2551
- collectionType
2552
- };
2553
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: /* @__PURE__ */ jsxRuntime.jsx(
2554
- strapiAdmin.DescriptionComponentRenderer,
2555
- {
2556
- props,
2557
- descriptions: plugins["content-manager"].apis.getEditViewSidePanels(),
2558
- children: (panels) => panels.map(({ content, id: id2, ...description }) => /* @__PURE__ */ jsxRuntime.jsx(Panel, { ...description, children: content }, id2))
2559
- }
2560
- ) });
2561
- };
2562
- const ActionsPanel = () => {
2563
- const { formatMessage } = reactIntl.useIntl();
2564
- return {
2565
- title: formatMessage({
2566
- id: "content-manager.containers.edit.panels.default.title",
2567
- defaultMessage: "Document"
2568
- }),
2569
- content: /* @__PURE__ */ jsxRuntime.jsx(ActionsPanelContent, {})
2570
- };
2571
- };
2572
- ActionsPanel.type = "actions";
2573
- const ActionsPanelContent = () => {
2574
- const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
2575
- const [
2576
- {
2577
- query: { status = "draft" }
2578
- }
2579
- ] = strapiAdmin.useQueryParams();
2580
- const { model, id, document, meta, collectionType } = useDoc();
2581
- const plugins = strapiAdmin.useStrapiApp("ActionsPanel", (state) => state.plugins);
2582
- const props = {
2583
- activeTab: status,
2584
- model,
2585
- documentId: id,
2586
- document: isCloning ? void 0 : document,
2587
- meta: isCloning ? void 0 : meta,
2588
- collectionType
2589
- };
2590
- return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 2, width: "100%", children: [
2591
- /* @__PURE__ */ jsxRuntime.jsx(
2592
- strapiAdmin.DescriptionComponentRenderer,
2593
- {
2594
- props,
2595
- descriptions: plugins["content-manager"].apis.getDocumentActions(),
2596
- children: (actions2) => /* @__PURE__ */ jsxRuntime.jsx(DocumentActions, { actions: actions2 })
2817
+ ),
2818
+ action.dialog ? /* @__PURE__ */ jsxRuntime.jsx(
2819
+ HeaderActionDialog,
2820
+ {
2821
+ ...action.dialog,
2822
+ isOpen: dialogId === action.id,
2823
+ onClose: handleClose
2824
+ }
2825
+ ) : null
2826
+ ] }, action.id);
2597
2827
  }
2598
- ),
2599
- /* @__PURE__ */ jsxRuntime.jsx(InjectionZone, { area: "editView.right-links", slug: model })
2600
- ] });
2601
- };
2602
- const Panel = React__namespace.forwardRef(({ children, title }, ref) => {
2603
- return /* @__PURE__ */ jsxRuntime.jsxs(
2604
- designSystem.Flex,
2605
- {
2606
- ref,
2607
- tag: "aside",
2608
- "aria-labelledby": "additional-information",
2609
- background: "neutral0",
2610
- borderColor: "neutral150",
2611
- hasRadius: true,
2612
- paddingBottom: 4,
2613
- paddingLeft: 4,
2614
- paddingRight: 4,
2615
- paddingTop: 4,
2616
- shadow: "tableShadow",
2617
- gap: 3,
2618
- direction: "column",
2619
- justifyContent: "stretch",
2620
- alignItems: "flex-start",
2621
- children: [
2622
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "h2", variant: "sigma", textTransform: "uppercase", children: title }),
2623
- children
2624
- ]
2625
2828
  }
2626
- );
2627
- });
2628
- const HOOKS = {
2629
- /**
2630
- * Hook that allows to mutate the displayed headers of the list view table
2631
- * @constant
2632
- * @type {string}
2633
- */
2634
- INJECT_COLUMN_IN_TABLE: "Admin/CM/pages/ListView/inject-column-in-table",
2635
- /**
2636
- * Hook that allows to mutate the CM's collection types links pre-set filters
2637
- * @constant
2638
- * @type {string}
2639
- */
2640
- MUTATE_COLLECTION_TYPES_LINKS: "Admin/CM/pages/App/mutate-collection-types-links",
2641
- /**
2642
- * Hook that allows to mutate the CM's edit view layout
2643
- * @constant
2644
- * @type {string}
2645
- */
2646
- MUTATE_EDIT_VIEW_LAYOUT: "Admin/CM/pages/EditView/mutate-edit-view-layout",
2647
- /**
2648
- * Hook that allows to mutate the CM's single types links pre-set filters
2649
- * @constant
2650
- * @type {string}
2651
- */
2652
- MUTATE_SINGLE_TYPES_LINKS: "Admin/CM/pages/App/mutate-single-types-links"
2829
+ }) });
2653
2830
  };
2654
- const contentTypesApi = contentManagerApi.injectEndpoints({
2655
- endpoints: (builder) => ({
2656
- getContentTypeConfiguration: builder.query({
2657
- query: (uid) => ({
2658
- url: `/content-manager/content-types/${uid}/configuration`,
2659
- method: "GET"
2660
- }),
2661
- transformResponse: (response) => response.data,
2662
- providesTags: (_result, _error, uid) => [
2663
- { type: "ContentTypesConfiguration", id: uid },
2664
- { type: "ContentTypeSettings", id: "LIST" }
2665
- ]
2666
- }),
2667
- getAllContentTypeSettings: builder.query({
2668
- query: () => "/content-manager/content-types-settings",
2669
- transformResponse: (response) => response.data,
2670
- providesTags: [{ type: "ContentTypeSettings", id: "LIST" }]
2671
- }),
2672
- updateContentTypeConfiguration: builder.mutation({
2673
- query: ({ uid, ...body }) => ({
2674
- url: `/content-manager/content-types/${uid}/configuration`,
2675
- method: "PUT",
2676
- data: body
2677
- }),
2678
- transformResponse: (response) => response.data,
2679
- invalidatesTags: (_result, _error, { uid }) => [
2680
- { type: "ContentTypesConfiguration", id: uid },
2681
- { type: "ContentTypeSettings", id: "LIST" },
2682
- // Is this necessary?
2683
- { type: "InitialData" }
2684
- ]
2685
- })
2686
- })
2687
- });
2688
- const {
2689
- useGetContentTypeConfigurationQuery,
2690
- useGetAllContentTypeSettingsQuery,
2691
- useUpdateContentTypeConfigurationMutation
2692
- } = contentTypesApi;
2693
- const checkIfAttributeIsDisplayable = (attribute) => {
2694
- const { type } = attribute;
2695
- if (type === "relation") {
2696
- return !attribute.relation.toLowerCase().includes("morph");
2697
- }
2698
- return !["json", "dynamiczone", "richtext", "password", "blocks"].includes(type) && !!type;
2831
+ const HeaderActionDialog = ({
2832
+ onClose,
2833
+ onCancel,
2834
+ title,
2835
+ content: Content,
2836
+ isOpen
2837
+ }) => {
2838
+ const handleClose = async () => {
2839
+ if (onCancel) {
2840
+ await onCancel();
2841
+ }
2842
+ onClose();
2843
+ };
2844
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Root, { open: isOpen, onOpenChange: handleClose, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Content, { children: [
2845
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Header, { children: title }),
2846
+ typeof Content === "function" ? /* @__PURE__ */ jsxRuntime.jsx(Content, { onClose: handleClose }) : Content
2847
+ ] }) });
2699
2848
  };
2700
- const getMainField = (attribute, mainFieldName, { schemas, components }) => {
2701
- if (!mainFieldName) {
2702
- return void 0;
2703
- }
2704
- const mainFieldType = attribute.type === "component" ? components[attribute.component].attributes[mainFieldName].type : (
2705
- // @ts-expect-error – `targetModel` does exist on the attribute for a relation.
2706
- schemas.find((schema) => schema.uid === attribute.targetModel)?.attributes[mainFieldName].type
2707
- );
2849
+ const ConfigureTheViewAction = ({ collectionType, model }) => {
2850
+ const navigate = reactRouterDom.useNavigate();
2851
+ const { formatMessage } = reactIntl.useIntl();
2708
2852
  return {
2709
- name: mainFieldName,
2710
- type: mainFieldType ?? "string"
2853
+ label: formatMessage({
2854
+ id: "app.links.configure-view",
2855
+ defaultMessage: "Configure the view"
2856
+ }),
2857
+ icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.ListPlus, {}),
2858
+ onClick: () => {
2859
+ navigate(`../${collectionType}/${model}/configurations/edit`);
2860
+ },
2861
+ position: "header"
2711
2862
  };
2712
2863
  };
2713
- const DEFAULT_SETTINGS = {
2714
- bulkable: false,
2715
- filterable: false,
2716
- searchable: false,
2717
- pagination: false,
2718
- defaultSortBy: "",
2719
- defaultSortOrder: "asc",
2720
- mainField: "id",
2721
- pageSize: 10
2722
- };
2723
- const useDocumentLayout = (model) => {
2724
- const { schema, components } = useDocument({ model, collectionType: "" }, { skip: true });
2725
- const [{ query }] = strapiAdmin.useQueryParams();
2726
- const runHookWaterfall = strapiAdmin.useStrapiApp("useDocumentLayout", (state) => state.runHookWaterfall);
2727
- const { toggleNotification } = strapiAdmin.useNotification();
2728
- const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
2729
- const { isLoading: isLoadingSchemas, schemas } = useContentTypeSchema();
2730
- const {
2731
- data,
2732
- isLoading: isLoadingConfigs,
2733
- error,
2734
- isFetching: isFetchingConfigs
2735
- } = useGetContentTypeConfigurationQuery(model);
2736
- const isLoading = isLoadingSchemas || isFetchingConfigs || isLoadingConfigs;
2737
- React__namespace.useEffect(() => {
2738
- if (error) {
2739
- toggleNotification({
2740
- type: "danger",
2741
- message: formatAPIError(error)
2742
- });
2743
- }
2744
- }, [error, formatAPIError, toggleNotification]);
2745
- const editLayout = React__namespace.useMemo(
2746
- () => data && !isLoading ? formatEditLayout(data, { schemas, schema, components }) : {
2747
- layout: [],
2748
- components: {},
2749
- metadatas: {},
2750
- options: {},
2751
- settings: DEFAULT_SETTINGS
2752
- },
2753
- [data, isLoading, schemas, schema, components]
2754
- );
2755
- const listLayout = React__namespace.useMemo(() => {
2756
- return data && !isLoading ? formatListLayout(data, { schemas, schema, components }) : {
2757
- layout: [],
2758
- metadatas: {},
2759
- options: {},
2760
- settings: DEFAULT_SETTINGS
2761
- };
2762
- }, [data, isLoading, schemas, schema, components]);
2763
- const { layout: edit } = React__namespace.useMemo(
2764
- () => runHookWaterfall(HOOKS.MUTATE_EDIT_VIEW_LAYOUT, {
2765
- layout: editLayout,
2766
- query
2767
- }),
2768
- [editLayout, query, runHookWaterfall]
2769
- );
2864
+ ConfigureTheViewAction.type = "configure-the-view";
2865
+ const EditTheModelAction = ({ model }) => {
2866
+ const navigate = reactRouterDom.useNavigate();
2867
+ const { formatMessage } = reactIntl.useIntl();
2770
2868
  return {
2771
- error,
2772
- isLoading,
2773
- edit,
2774
- list: listLayout
2869
+ label: formatMessage({
2870
+ id: "content-manager.link-to-ctb",
2871
+ defaultMessage: "Edit the model"
2872
+ }),
2873
+ icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Pencil, {}),
2874
+ onClick: () => {
2875
+ navigate(`/plugins/content-type-builder/content-types/${model}`);
2876
+ },
2877
+ position: "header"
2775
2878
  };
2776
2879
  };
2777
- const useDocLayout = () => {
2778
- const { model } = useDoc();
2779
- return useDocumentLayout(model);
2780
- };
2781
- const formatEditLayout = (data, {
2782
- schemas,
2783
- schema,
2784
- components
2785
- }) => {
2786
- let currentPanelIndex = 0;
2787
- const panelledEditAttributes = convertEditLayoutToFieldLayouts(
2788
- data.contentType.layouts.edit,
2789
- schema?.attributes,
2790
- data.contentType.metadatas,
2791
- { configurations: data.components, schemas: components },
2792
- schemas
2793
- ).reduce((panels, row) => {
2794
- if (row.some((field) => field.type === "dynamiczone")) {
2795
- panels.push([row]);
2796
- currentPanelIndex += 2;
2797
- } else {
2798
- if (!panels[currentPanelIndex]) {
2799
- panels.push([]);
2800
- }
2801
- panels[currentPanelIndex].push(row);
2802
- }
2803
- return panels;
2804
- }, []);
2805
- const componentEditAttributes = Object.entries(data.components).reduce(
2806
- (acc, [uid, configuration]) => {
2807
- acc[uid] = {
2808
- layout: convertEditLayoutToFieldLayouts(
2809
- configuration.layouts.edit,
2810
- components[uid].attributes,
2811
- configuration.metadatas
2812
- ),
2813
- settings: {
2814
- ...configuration.settings,
2815
- icon: components[uid].info.icon,
2816
- displayName: components[uid].info.displayName
2880
+ EditTheModelAction.type = "edit-the-model";
2881
+ const DeleteAction$1 = ({ documentId, model, collectionType, document }) => {
2882
+ const navigate = reactRouterDom.useNavigate();
2883
+ const { formatMessage } = reactIntl.useIntl();
2884
+ const listViewPathMatch = reactRouterDom.useMatch(LIST_PATH);
2885
+ const canDelete = useDocumentRBAC("DeleteAction", (state) => state.canDelete);
2886
+ const { delete: deleteAction } = useDocumentActions();
2887
+ const { toggleNotification } = strapiAdmin.useNotification();
2888
+ const setSubmitting = strapiAdmin.useForm("DeleteAction", (state) => state.setSubmitting);
2889
+ const isLocalized = document?.locale != null;
2890
+ return {
2891
+ disabled: !canDelete || !document,
2892
+ label: formatMessage(
2893
+ {
2894
+ id: "content-manager.actions.delete.label",
2895
+ defaultMessage: "Delete entry{isLocalized, select, true { (all locales)} other {}}"
2896
+ },
2897
+ { isLocalized }
2898
+ ),
2899
+ icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Trash, {}),
2900
+ dialog: {
2901
+ type: "dialog",
2902
+ title: formatMessage({
2903
+ id: "app.components.ConfirmDialog.title",
2904
+ defaultMessage: "Confirmation"
2905
+ }),
2906
+ content: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 2, children: [
2907
+ /* @__PURE__ */ jsxRuntime.jsx(Icons.WarningCircle, { width: "24px", height: "24px", fill: "danger600" }),
2908
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "p", variant: "omega", textAlign: "center", children: formatMessage({
2909
+ id: "content-manager.actions.delete.dialog.body",
2910
+ defaultMessage: "Are you sure?"
2911
+ }) })
2912
+ ] }),
2913
+ onConfirm: async () => {
2914
+ if (!listViewPathMatch) {
2915
+ setSubmitting(true);
2916
+ }
2917
+ try {
2918
+ if (!documentId && collectionType !== SINGLE_TYPES) {
2919
+ console.error(
2920
+ "You're trying to delete a document without an id, this is likely a bug with Strapi. Please open an issue."
2921
+ );
2922
+ toggleNotification({
2923
+ message: formatMessage({
2924
+ id: "content-manager.actions.delete.error",
2925
+ defaultMessage: "An error occurred while trying to delete the document."
2926
+ }),
2927
+ type: "danger"
2928
+ });
2929
+ return;
2930
+ }
2931
+ const res = await deleteAction({
2932
+ documentId,
2933
+ model,
2934
+ collectionType,
2935
+ params: {
2936
+ locale: "*"
2937
+ }
2938
+ });
2939
+ if (!("error" in res)) {
2940
+ navigate({ pathname: `../${collectionType}/${model}` }, { replace: true });
2941
+ }
2942
+ } finally {
2943
+ if (!listViewPathMatch) {
2944
+ setSubmitting(false);
2945
+ }
2817
2946
  }
2818
- };
2819
- return acc;
2820
- },
2821
- {}
2822
- );
2823
- const editMetadatas = Object.entries(data.contentType.metadatas).reduce(
2824
- (acc, [attribute, metadata]) => {
2825
- return {
2826
- ...acc,
2827
- [attribute]: metadata.edit
2828
- };
2829
- },
2830
- {}
2831
- );
2832
- return {
2833
- layout: panelledEditAttributes,
2834
- components: componentEditAttributes,
2835
- metadatas: editMetadatas,
2836
- settings: {
2837
- ...data.contentType.settings,
2838
- displayName: schema?.info.displayName
2947
+ }
2839
2948
  },
2840
- options: {
2841
- ...schema?.options,
2842
- ...schema?.pluginOptions,
2843
- ...data.contentType.options
2844
- }
2949
+ variant: "danger",
2950
+ position: ["header", "table-row"]
2845
2951
  };
2846
2952
  };
2847
- const convertEditLayoutToFieldLayouts = (rows, attributes = {}, metadatas, components, schemas = []) => {
2848
- return rows.map(
2849
- (row) => row.map((field) => {
2850
- const attribute = attributes[field.name];
2851
- if (!attribute) {
2852
- return null;
2853
- }
2854
- const { edit: metadata } = metadatas[field.name];
2855
- const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
2856
- return {
2857
- attribute,
2858
- disabled: !metadata.editable,
2859
- hint: metadata.description,
2860
- label: metadata.label ?? "",
2861
- name: field.name,
2862
- // @ts-expect-error – mainField does exist on the metadata for a relation.
2863
- mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
2864
- schemas,
2865
- components: components?.schemas ?? {}
2866
- }),
2867
- placeholder: metadata.placeholder ?? "",
2868
- required: attribute.required ?? false,
2869
- size: field.size,
2870
- unique: "unique" in attribute ? attribute.unique : false,
2871
- visible: metadata.visible ?? true,
2872
- type: attribute.type
2873
- };
2874
- }).filter((field) => field !== null)
2875
- );
2953
+ DeleteAction$1.type = "delete";
2954
+ const DEFAULT_HEADER_ACTIONS = [EditTheModelAction, ConfigureTheViewAction, DeleteAction$1];
2955
+ const Panels = () => {
2956
+ const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
2957
+ const [
2958
+ {
2959
+ query: { status }
2960
+ }
2961
+ ] = strapiAdmin.useQueryParams({
2962
+ status: "draft"
2963
+ });
2964
+ const { model, id, document, meta, collectionType } = useDoc();
2965
+ const plugins = strapiAdmin.useStrapiApp("Panels", (state) => state.plugins);
2966
+ const props = {
2967
+ activeTab: status,
2968
+ model,
2969
+ documentId: id,
2970
+ document: isCloning ? void 0 : document,
2971
+ meta: isCloning ? void 0 : meta,
2972
+ collectionType
2973
+ };
2974
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: /* @__PURE__ */ jsxRuntime.jsx(
2975
+ strapiAdmin.DescriptionComponentRenderer,
2976
+ {
2977
+ props,
2978
+ descriptions: plugins["content-manager"].apis.getEditViewSidePanels(),
2979
+ children: (panels) => panels.map(({ content, id: id2, ...description }) => /* @__PURE__ */ jsxRuntime.jsx(Panel, { ...description, children: content }, id2))
2980
+ }
2981
+ ) });
2876
2982
  };
2877
- const formatListLayout = (data, {
2878
- schemas,
2879
- schema,
2880
- components
2881
- }) => {
2882
- const listMetadatas = Object.entries(data.contentType.metadatas).reduce(
2883
- (acc, [attribute, metadata]) => {
2884
- return {
2885
- ...acc,
2886
- [attribute]: metadata.list
2887
- };
2888
- },
2889
- {}
2890
- );
2891
- const listAttributes = convertListLayoutToFieldLayouts(
2892
- data.contentType.layouts.list,
2893
- schema?.attributes,
2894
- listMetadatas,
2895
- { configurations: data.components, schemas: components },
2896
- schemas
2897
- );
2983
+ const ActionsPanel = () => {
2984
+ const { formatMessage } = reactIntl.useIntl();
2898
2985
  return {
2899
- layout: listAttributes,
2900
- settings: { ...data.contentType.settings, displayName: schema?.info.displayName },
2901
- metadatas: listMetadatas,
2902
- options: {
2903
- ...schema?.options,
2904
- ...schema?.pluginOptions,
2905
- ...data.contentType.options
2906
- }
2986
+ title: formatMessage({
2987
+ id: "content-manager.containers.edit.panels.default.title",
2988
+ defaultMessage: "Entry"
2989
+ }),
2990
+ content: /* @__PURE__ */ jsxRuntime.jsx(ActionsPanelContent, {})
2907
2991
  };
2908
2992
  };
2909
- const convertListLayoutToFieldLayouts = (columns, attributes = {}, metadatas, components, schemas = []) => {
2910
- return columns.map((name) => {
2911
- const attribute = attributes[name];
2912
- if (!attribute) {
2913
- return null;
2993
+ ActionsPanel.type = "actions";
2994
+ const ActionsPanelContent = () => {
2995
+ const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
2996
+ const [
2997
+ {
2998
+ query: { status = "draft" }
2914
2999
  }
2915
- const metadata = metadatas[name];
2916
- const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
2917
- return {
2918
- attribute,
2919
- label: metadata.label ?? "",
2920
- mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
2921
- schemas,
2922
- components: components?.schemas ?? {}
2923
- }),
2924
- name,
2925
- searchable: metadata.searchable ?? true,
2926
- sortable: metadata.sortable ?? true
2927
- };
2928
- }).filter((field) => field !== null);
3000
+ ] = strapiAdmin.useQueryParams();
3001
+ const { model, id, document, meta, collectionType } = useDoc();
3002
+ const plugins = strapiAdmin.useStrapiApp("ActionsPanel", (state) => state.plugins);
3003
+ const props = {
3004
+ activeTab: status,
3005
+ model,
3006
+ documentId: id,
3007
+ document: isCloning ? void 0 : document,
3008
+ meta: isCloning ? void 0 : meta,
3009
+ collectionType
3010
+ };
3011
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 2, width: "100%", children: [
3012
+ /* @__PURE__ */ jsxRuntime.jsx(
3013
+ strapiAdmin.DescriptionComponentRenderer,
3014
+ {
3015
+ props,
3016
+ descriptions: plugins["content-manager"].apis.getDocumentActions(),
3017
+ children: (actions2) => /* @__PURE__ */ jsxRuntime.jsx(DocumentActions, { actions: actions2 })
3018
+ }
3019
+ ),
3020
+ /* @__PURE__ */ jsxRuntime.jsx(InjectionZone, { area: "editView.right-links", slug: model })
3021
+ ] });
2929
3022
  };
3023
+ const Panel = React__namespace.forwardRef(({ children, title }, ref) => {
3024
+ return /* @__PURE__ */ jsxRuntime.jsxs(
3025
+ designSystem.Flex,
3026
+ {
3027
+ ref,
3028
+ tag: "aside",
3029
+ "aria-labelledby": "additional-information",
3030
+ background: "neutral0",
3031
+ borderColor: "neutral150",
3032
+ hasRadius: true,
3033
+ paddingBottom: 4,
3034
+ paddingLeft: 4,
3035
+ paddingRight: 4,
3036
+ paddingTop: 4,
3037
+ shadow: "tableShadow",
3038
+ gap: 3,
3039
+ direction: "column",
3040
+ justifyContent: "stretch",
3041
+ alignItems: "flex-start",
3042
+ children: [
3043
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "h2", variant: "sigma", textTransform: "uppercase", textColor: "neutral600", children: title }),
3044
+ children
3045
+ ]
3046
+ }
3047
+ );
3048
+ });
2930
3049
  const ConfirmBulkActionDialog = ({
2931
3050
  onToggleDialog,
2932
3051
  isOpen = false,
@@ -2965,6 +3084,7 @@ const ConfirmDialogPublishAll = ({
2965
3084
  const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler(getTranslation);
2966
3085
  const { model, schema } = useDoc();
2967
3086
  const [{ query }] = strapiAdmin.useQueryParams();
3087
+ const enableDraftRelationsCount = false;
2968
3088
  const {
2969
3089
  data: countDraftRelations = 0,
2970
3090
  isLoading,
@@ -2976,7 +3096,7 @@ const ConfirmDialogPublishAll = ({
2976
3096
  locale: query?.plugins?.i18n?.locale
2977
3097
  },
2978
3098
  {
2979
- skip: selectedEntries.length === 0
3099
+ skip: !enableDraftRelationsCount
2980
3100
  }
2981
3101
  );
2982
3102
  React__namespace.useEffect(() => {
@@ -3161,7 +3281,7 @@ const SelectedEntriesTableContent = ({
3161
3281
  status: row.status
3162
3282
  }
3163
3283
  ) }),
3164
- /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Cell, { children: /* @__PURE__ */ jsxRuntime.jsx(
3284
+ /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Cell, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { children: /* @__PURE__ */ jsxRuntime.jsx(
3165
3285
  designSystem.IconButton,
3166
3286
  {
3167
3287
  tag: reactRouterDom.Link,
@@ -3184,9 +3304,10 @@ const SelectedEntriesTableContent = ({
3184
3304
  ),
3185
3305
  target: "_blank",
3186
3306
  marginLeft: "auto",
3187
- children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Pencil, {})
3307
+ variant: "ghost",
3308
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Pencil, { width: "1.6rem", height: "1.6rem" })
3188
3309
  }
3189
- ) })
3310
+ ) }) })
3190
3311
  ] }, row.id)) })
3191
3312
  ] });
3192
3313
  };
@@ -3902,6 +4023,82 @@ const { setInitialData } = actions;
3902
4023
  const reducer = toolkit.combineReducers({
3903
4024
  app: reducer$1
3904
4025
  });
4026
+ const previewApi = contentManagerApi.injectEndpoints({
4027
+ endpoints: (builder) => ({
4028
+ getPreviewUrl: builder.query({
4029
+ query({ query, params }) {
4030
+ return {
4031
+ url: `/content-manager/preview/url/${params.contentType}`,
4032
+ method: "GET",
4033
+ config: {
4034
+ params: query
4035
+ }
4036
+ };
4037
+ }
4038
+ })
4039
+ })
4040
+ });
4041
+ const { useGetPreviewUrlQuery } = previewApi;
4042
+ const PreviewSidePanel = ({ model, documentId, document }) => {
4043
+ const { formatMessage } = reactIntl.useIntl();
4044
+ const { toggleNotification } = strapiAdmin.useNotification();
4045
+ const { copy } = strapiAdmin.useClipboard();
4046
+ const { data, error } = useGetPreviewUrlQuery({
4047
+ params: {
4048
+ contentType: model
4049
+ },
4050
+ query: {
4051
+ documentId,
4052
+ locale: document?.locale,
4053
+ status: document?.status
4054
+ }
4055
+ });
4056
+ if (!data?.data?.url || error) {
4057
+ return null;
4058
+ }
4059
+ const { url } = data.data;
4060
+ const handleCopyLink = () => {
4061
+ copy(url);
4062
+ toggleNotification({
4063
+ message: formatMessage({
4064
+ id: "content-manager.preview.copy.success",
4065
+ defaultMessage: "Copied preview link"
4066
+ }),
4067
+ type: "success"
4068
+ });
4069
+ };
4070
+ return {
4071
+ title: formatMessage({ id: "content-manager.preview.panel.title", defaultMessage: "Preview" }),
4072
+ content: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, width: "100%", children: [
4073
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", tag: reactRouterDom.Link, to: url, target: "_blank", flex: "auto", children: formatMessage({
4074
+ id: "content-manager.preview.panel.button",
4075
+ defaultMessage: "Open preview"
4076
+ }) }),
4077
+ /* @__PURE__ */ jsxRuntime.jsx(
4078
+ designSystem.IconButton,
4079
+ {
4080
+ type: "button",
4081
+ label: formatMessage({
4082
+ id: "preview.copy.label",
4083
+ defaultMessage: "Copy preview link"
4084
+ }),
4085
+ onClick: handleCopyLink,
4086
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Link, {})
4087
+ }
4088
+ )
4089
+ ] })
4090
+ };
4091
+ };
4092
+ const FEATURE_ID = "preview";
4093
+ const previewAdmin = {
4094
+ bootstrap(app) {
4095
+ if (!window.strapi.future.isEnabled(FEATURE_ID)) {
4096
+ return;
4097
+ }
4098
+ const contentManagerPluginApis = app.getPlugin("content-manager").apis;
4099
+ contentManagerPluginApis.addEditViewSidePanel([PreviewSidePanel]);
4100
+ }
4101
+ };
3905
4102
  const index = {
3906
4103
  register(app) {
3907
4104
  const cm = new ContentManagerPlugin();
@@ -3921,7 +4118,7 @@ const index = {
3921
4118
  app.router.addRoute({
3922
4119
  path: "content-manager/*",
3923
4120
  lazy: async () => {
3924
- const { Layout } = await Promise.resolve().then(() => require("./layout-C788OmNr.js"));
4121
+ const { Layout } = await Promise.resolve().then(() => require("./layout-ByFyQRDH.js"));
3925
4122
  return {
3926
4123
  Component: Layout
3927
4124
  };
@@ -3934,11 +4131,14 @@ const index = {
3934
4131
  if (typeof historyAdmin.bootstrap === "function") {
3935
4132
  historyAdmin.bootstrap(app);
3936
4133
  }
4134
+ if (typeof previewAdmin.bootstrap === "function") {
4135
+ previewAdmin.bootstrap(app);
4136
+ }
3937
4137
  },
3938
4138
  async registerTrads({ locales }) {
3939
4139
  const importedTrads = await Promise.all(
3940
4140
  locales.map((locale) => {
3941
- return __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/ar.json": () => Promise.resolve().then(() => require("./ar-BUUWXIYu.js")), "./translations/ca.json": () => Promise.resolve().then(() => require("./ca-Cmk45QO6.js")), "./translations/cs.json": () => Promise.resolve().then(() => require("./cs-CkJy6B2v.js")), "./translations/de.json": () => Promise.resolve().then(() => require("./de-CCEmbAah.js")), "./translations/en.json": () => Promise.resolve().then(() => require("./en-uOUIxfcQ.js")), "./translations/es.json": () => Promise.resolve().then(() => require("./es-EUonQTon.js")), "./translations/eu.json": () => Promise.resolve().then(() => require("./eu-VDH-3ovk.js")), "./translations/fr.json": () => Promise.resolve().then(() => require("./fr-B7kGGg3E.js")), "./translations/gu.json": () => Promise.resolve().then(() => require("./gu-BRmF601H.js")), "./translations/hi.json": () => Promise.resolve().then(() => require("./hi-CCJBptSq.js")), "./translations/hu.json": () => Promise.resolve().then(() => require("./hu-sNV_yLYy.js")), "./translations/id.json": () => Promise.resolve().then(() => require("./id-B5Ser98A.js")), "./translations/it.json": () => Promise.resolve().then(() => require("./it-DkBIs7vD.js")), "./translations/ja.json": () => Promise.resolve().then(() => require("./ja-CcFe8diO.js")), "./translations/ko.json": () => Promise.resolve().then(() => require("./ko-woFZPmLk.js")), "./translations/ml.json": () => Promise.resolve().then(() => require("./ml-C2W8N8k1.js")), "./translations/ms.json": () => Promise.resolve().then(() => require("./ms-BuFotyP_.js")), "./translations/nl.json": () => Promise.resolve().then(() => require("./nl-bbEOHChV.js")), "./translations/pl.json": () => Promise.resolve().then(() => require("./pl-uzwG-hk7.js")), "./translations/pt-BR.json": () => Promise.resolve().then(() => require("./pt-BR-BiOz37D9.js")), "./translations/pt.json": () => Promise.resolve().then(() => require("./pt-CeXQuq50.js")), "./translations/ru.json": () => Promise.resolve().then(() => require("./ru-BT3ybNny.js")), "./translations/sa.json": () => Promise.resolve().then(() => require("./sa-CcvkYInH.js")), "./translations/sk.json": () => Promise.resolve().then(() => require("./sk-CvY09Xjv.js")), "./translations/sv.json": () => Promise.resolve().then(() => require("./sv-MYDuzgvT.js")), "./translations/th.json": () => Promise.resolve().then(() => require("./th-D9_GfAjc.js")), "./translations/tr.json": () => Promise.resolve().then(() => require("./tr-D9UH-O_R.js")), "./translations/uk.json": () => Promise.resolve().then(() => require("./uk-C8EiqJY7.js")), "./translations/vi.json": () => Promise.resolve().then(() => require("./vi-CJlYDheJ.js")), "./translations/zh-Hans.json": () => Promise.resolve().then(() => require("./zh-Hans-9kOncHGw.js")), "./translations/zh.json": () => Promise.resolve().then(() => require("./zh-CQQfszqR.js")) }), `./translations/${locale}.json`).then(({ default: data }) => {
4141
+ 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-Bdpa50w3.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 }) => {
3942
4142
  return {
3943
4143
  data: prefixPluginTranslations(data, PLUGIN_ID),
3944
4144
  locale
@@ -3984,6 +4184,7 @@ exports.getMainField = getMainField;
3984
4184
  exports.getTranslation = getTranslation;
3985
4185
  exports.index = index;
3986
4186
  exports.setInitialData = setInitialData;
4187
+ exports.useContentManagerContext = useContentManagerContext;
3987
4188
  exports.useContentTypeSchema = useContentTypeSchema;
3988
4189
  exports.useDoc = useDoc;
3989
4190
  exports.useDocLayout = useDocLayout;
@@ -3996,4 +4197,4 @@ exports.useGetAllDocumentsQuery = useGetAllDocumentsQuery;
3996
4197
  exports.useGetContentTypeConfigurationQuery = useGetContentTypeConfigurationQuery;
3997
4198
  exports.useGetInitialDataQuery = useGetInitialDataQuery;
3998
4199
  exports.useUpdateContentTypeConfigurationMutation = useUpdateContentTypeConfigurationMutation;
3999
- //# sourceMappingURL=index-C3fJE-1-.js.map
4200
+ //# sourceMappingURL=index-BgaeYWIy.js.map