@strapi/content-manager 0.0.0-experimental.a6728ad43ac70ae19dabb624dbfca1f2d9610a86 → 0.0.0-experimental.a687a6977f91492ccfc6771bf398a5236ece3c94

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-_6osrv39.js → ComponentConfigurationPage-BebDdCkl.js} +4 -4
  2. package/dist/_chunks/{ComponentConfigurationPage-_6osrv39.js.map → ComponentConfigurationPage-BebDdCkl.js.map} +1 -1
  3. package/dist/_chunks/{ComponentConfigurationPage-DJ5voqEK.mjs → ComponentConfigurationPage-XdGcgtZh.mjs} +4 -4
  4. package/dist/_chunks/{ComponentConfigurationPage-DJ5voqEK.mjs.map → ComponentConfigurationPage-XdGcgtZh.mjs.map} +1 -1
  5. package/dist/_chunks/{EditConfigurationPage-CZofxSLy.mjs → EditConfigurationPage-DaNf9MoK.mjs} +4 -4
  6. package/dist/_chunks/{EditConfigurationPage-CZofxSLy.mjs.map → EditConfigurationPage-DaNf9MoK.mjs.map} +1 -1
  7. package/dist/_chunks/{EditConfigurationPage-ZN3s568V.js → EditConfigurationPage-sdGi-bna.js} +4 -4
  8. package/dist/_chunks/{EditConfigurationPage-ZN3s568V.js.map → EditConfigurationPage-sdGi-bna.js.map} +1 -1
  9. package/dist/_chunks/{EditViewPage-Co2IKQZH.js → EditViewPage-BRA-JSnw.js} +49 -9
  10. package/dist/_chunks/EditViewPage-BRA-JSnw.js.map +1 -0
  11. package/dist/_chunks/{EditViewPage-HYljoEY7.mjs → EditViewPage-DtbTsNeX.mjs} +50 -10
  12. package/dist/_chunks/EditViewPage-DtbTsNeX.mjs.map +1 -0
  13. package/dist/_chunks/{Field-BOPUMZ1u.mjs → Field-CDmB9zqh.mjs} +107 -44
  14. package/dist/_chunks/Field-CDmB9zqh.mjs.map +1 -0
  15. package/dist/_chunks/{Field-G9CkFUtP.js → Field-DoVRA4co.js} +107 -44
  16. package/dist/_chunks/Field-DoVRA4co.js.map +1 -0
  17. package/dist/_chunks/{Form-crsbkGxI.js → Form-BEh514bg.js} +3 -3
  18. package/dist/_chunks/Form-BEh514bg.js.map +1 -0
  19. package/dist/_chunks/{Form-CDwNp7pU.mjs → Form-Cle2X-4n.mjs} +3 -3
  20. package/dist/_chunks/Form-Cle2X-4n.mjs.map +1 -0
  21. package/dist/_chunks/{History-CWcM9HnW.js → History-BsPXl1XH.js} +40 -97
  22. package/dist/_chunks/History-BsPXl1XH.js.map +1 -0
  23. package/dist/_chunks/{History-BDZrgfZ3.mjs → History-ktAPcvHJ.mjs} +42 -99
  24. package/dist/_chunks/History-ktAPcvHJ.mjs.map +1 -0
  25. package/dist/_chunks/{ListConfigurationPage-BZ3ScUna.mjs → ListConfigurationPage-BNAS_v2s.mjs} +6 -5
  26. package/dist/_chunks/ListConfigurationPage-BNAS_v2s.mjs.map +1 -0
  27. package/dist/_chunks/{ListConfigurationPage-DGzoQD_I.js → ListConfigurationPage-CN1-7Pgi.js} +5 -4
  28. package/dist/_chunks/ListConfigurationPage-CN1-7Pgi.js.map +1 -0
  29. package/dist/_chunks/{ListViewPage-CsX7tWx-.mjs → ListViewPage-B15c_0Vt.mjs} +17 -6
  30. package/dist/_chunks/{ListViewPage-CsX7tWx-.mjs.map → ListViewPage-B15c_0Vt.mjs.map} +1 -1
  31. package/dist/_chunks/{ListViewPage-BBAC9aPu.js → ListViewPage-BUKFOJuS.js} +17 -6
  32. package/dist/_chunks/ListViewPage-BUKFOJuS.js.map +1 -0
  33. package/dist/_chunks/{NoContentTypePage-LClTUPWs.mjs → NoContentTypePage-CAgdmhlo.mjs} +2 -2
  34. package/dist/_chunks/{NoContentTypePage-LClTUPWs.mjs.map → NoContentTypePage-CAgdmhlo.mjs.map} +1 -1
  35. package/dist/_chunks/{NoContentTypePage-CwVDx_YC.js → NoContentTypePage-Cs7Kk9EW.js} +2 -2
  36. package/dist/_chunks/{NoContentTypePage-CwVDx_YC.js.map → NoContentTypePage-Cs7Kk9EW.js.map} +1 -1
  37. package/dist/_chunks/{NoPermissionsPage-D2iWw-sn.js → NoPermissionsPage-DRPnEq9t.js} +2 -2
  38. package/dist/_chunks/{NoPermissionsPage-D2iWw-sn.js.map → NoPermissionsPage-DRPnEq9t.js.map} +1 -1
  39. package/dist/_chunks/{NoPermissionsPage-S4Re3FwO.mjs → NoPermissionsPage-JxX4Y4RJ.mjs} +2 -2
  40. package/dist/_chunks/{NoPermissionsPage-S4Re3FwO.mjs.map → NoPermissionsPage-JxX4Y4RJ.mjs.map} +1 -1
  41. package/dist/_chunks/Preview-BKuVG1dV.js +286 -0
  42. package/dist/_chunks/Preview-BKuVG1dV.js.map +1 -0
  43. package/dist/_chunks/Preview-CQlTtbLc.mjs +267 -0
  44. package/dist/_chunks/Preview-CQlTtbLc.mjs.map +1 -0
  45. package/dist/_chunks/{Relations-Dmv0Tpe5.mjs → Relations-DMQ93R3L.mjs} +72 -36
  46. package/dist/_chunks/Relations-DMQ93R3L.mjs.map +1 -0
  47. package/dist/_chunks/{Relations-jwuTFGOV.js → Relations-DTEGSaM_.js} +71 -35
  48. package/dist/_chunks/Relations-DTEGSaM_.js.map +1 -0
  49. package/dist/_chunks/{en-C8YBvRrK.mjs → en-CfIXaZf9.mjs} +20 -9
  50. package/dist/_chunks/{en-C8YBvRrK.mjs.map → en-CfIXaZf9.mjs.map} +1 -1
  51. package/dist/_chunks/{en-BlhnxQfj.js → en-DTWPCdTS.js} +20 -9
  52. package/dist/_chunks/{en-BlhnxQfj.js.map → en-DTWPCdTS.js.map} +1 -1
  53. package/dist/_chunks/{es-EUonQTon.js → es-9K52xZIr.js} +2 -2
  54. package/dist/_chunks/{ja-CcFe8diO.js.map → es-9K52xZIr.js.map} +1 -1
  55. package/dist/_chunks/{es-CeXiYflN.mjs → es-D34tqjMw.mjs} +2 -2
  56. package/dist/_chunks/{es-CeXiYflN.mjs.map → es-D34tqjMw.mjs.map} +1 -1
  57. package/dist/_chunks/{fr-CD9VFbPM.mjs → fr--pg5jUbt.mjs} +13 -3
  58. package/dist/_chunks/{fr-CD9VFbPM.mjs.map → fr--pg5jUbt.mjs.map} +1 -1
  59. package/dist/_chunks/{fr-B7kGGg3E.js → fr-B2Kyv8Z9.js} +13 -3
  60. package/dist/_chunks/{fr-B7kGGg3E.js.map → fr-B2Kyv8Z9.js.map} +1 -1
  61. package/dist/_chunks/{index-BmUAydCA.mjs → index-BdUq-Dtg.mjs} +262 -156
  62. package/dist/_chunks/index-BdUq-Dtg.mjs.map +1 -0
  63. package/dist/_chunks/{index-CBX6KyXv.js → index-DjV7tyGu.js} +258 -151
  64. package/dist/_chunks/index-DjV7tyGu.js.map +1 -0
  65. package/dist/_chunks/{ja-CcFe8diO.js → ja-7sfIbjxE.js} +2 -2
  66. package/dist/_chunks/{es-EUonQTon.js.map → ja-7sfIbjxE.js.map} +1 -1
  67. package/dist/_chunks/{ja-CtsUxOvk.mjs → ja-BHqhDq4V.mjs} +2 -2
  68. package/dist/_chunks/{ja-CtsUxOvk.mjs.map → ja-BHqhDq4V.mjs.map} +1 -1
  69. package/dist/_chunks/{layout-ClP-DC72.mjs → layout-BJ8CpEJu.mjs} +3 -3
  70. package/dist/_chunks/{layout-ClP-DC72.mjs.map → layout-BJ8CpEJu.mjs.map} +1 -1
  71. package/dist/_chunks/{layout-CxxkX9jY.js → layout-Cx9LHtH5.js} +3 -3
  72. package/dist/_chunks/{layout-CxxkX9jY.js.map → layout-Cx9LHtH5.js.map} +1 -1
  73. package/dist/_chunks/{objects-gigeqt7s.js → objects-BcXOv6_9.js} +2 -4
  74. package/dist/_chunks/{objects-gigeqt7s.js.map → objects-BcXOv6_9.js.map} +1 -1
  75. package/dist/_chunks/{objects-mKMAmfec.mjs → objects-D6yBsdmx.mjs} +2 -4
  76. package/dist/_chunks/{objects-mKMAmfec.mjs.map → objects-D6yBsdmx.mjs.map} +1 -1
  77. package/dist/_chunks/{relations-DIjTADIu.js → relations-5bc76OJz.js} +6 -7
  78. package/dist/_chunks/relations-5bc76OJz.js.map +1 -0
  79. package/dist/_chunks/{relations-op89RClB.mjs → relations-BeezTo41.mjs} +6 -7
  80. package/dist/_chunks/relations-BeezTo41.mjs.map +1 -0
  81. package/dist/admin/index.js +1 -1
  82. package/dist/admin/index.mjs +4 -4
  83. package/dist/admin/src/hooks/useDocument.d.ts +2 -0
  84. package/dist/admin/src/pages/EditView/EditViewPage.d.ts +9 -1
  85. package/dist/admin/src/pages/EditView/components/DocumentStatus.d.ts +2 -2
  86. package/dist/admin/src/pages/EditView/components/Header.d.ts +1 -0
  87. package/dist/admin/src/preview/components/PreviewContent.d.ts +2 -0
  88. package/dist/admin/src/preview/components/PreviewHeader.d.ts +2 -0
  89. package/dist/admin/src/preview/components/PreviewSidePanel.d.ts +3 -0
  90. package/dist/admin/src/preview/constants.d.ts +1 -0
  91. package/dist/admin/src/preview/index.d.ts +4 -0
  92. package/dist/admin/src/preview/pages/Preview.d.ts +11 -0
  93. package/dist/admin/src/preview/routes.d.ts +3 -0
  94. package/dist/admin/src/preview/services/preview.d.ts +3 -0
  95. package/dist/admin/src/router.d.ts +1 -1
  96. package/dist/admin/src/services/documents.d.ts +0 -3
  97. package/dist/server/index.js +371 -158
  98. package/dist/server/index.js.map +1 -1
  99. package/dist/server/index.mjs +371 -158
  100. package/dist/server/index.mjs.map +1 -1
  101. package/dist/server/src/bootstrap.d.ts.map +1 -1
  102. package/dist/server/src/controllers/collection-types.d.ts.map +1 -1
  103. package/dist/server/src/controllers/index.d.ts.map +1 -1
  104. package/dist/server/src/controllers/relations.d.ts.map +1 -1
  105. package/dist/server/src/controllers/utils/metadata.d.ts +15 -1
  106. package/dist/server/src/controllers/utils/metadata.d.ts.map +1 -1
  107. package/dist/server/src/history/services/history.d.ts.map +1 -1
  108. package/dist/server/src/history/services/lifecycles.d.ts.map +1 -1
  109. package/dist/server/src/history/services/utils.d.ts +2 -3
  110. package/dist/server/src/history/services/utils.d.ts.map +1 -1
  111. package/dist/server/src/index.d.ts +4 -4
  112. package/dist/server/src/preview/constants.d.ts +2 -0
  113. package/dist/server/src/preview/constants.d.ts.map +1 -0
  114. package/dist/server/src/preview/controllers/index.d.ts +2 -0
  115. package/dist/server/src/preview/controllers/index.d.ts.map +1 -0
  116. package/dist/server/src/preview/controllers/preview.d.ts +13 -0
  117. package/dist/server/src/preview/controllers/preview.d.ts.map +1 -0
  118. package/dist/server/src/preview/controllers/validation/preview.d.ts +6 -0
  119. package/dist/server/src/preview/controllers/validation/preview.d.ts.map +1 -0
  120. package/dist/server/src/preview/index.d.ts +4 -0
  121. package/dist/server/src/preview/index.d.ts.map +1 -0
  122. package/dist/server/src/preview/routes/index.d.ts +8 -0
  123. package/dist/server/src/preview/routes/index.d.ts.map +1 -0
  124. package/dist/server/src/preview/routes/preview.d.ts +4 -0
  125. package/dist/server/src/preview/routes/preview.d.ts.map +1 -0
  126. package/dist/server/src/preview/services/index.d.ts +15 -0
  127. package/dist/server/src/preview/services/index.d.ts.map +1 -0
  128. package/dist/server/src/preview/services/preview-config.d.ts +30 -0
  129. package/dist/server/src/preview/services/preview-config.d.ts.map +1 -0
  130. package/dist/server/src/preview/services/preview.d.ts +12 -0
  131. package/dist/server/src/preview/services/preview.d.ts.map +1 -0
  132. package/dist/server/src/preview/utils.d.ts +18 -0
  133. package/dist/server/src/preview/utils.d.ts.map +1 -0
  134. package/dist/server/src/routes/index.d.ts.map +1 -1
  135. package/dist/server/src/services/document-manager.d.ts.map +1 -1
  136. package/dist/server/src/services/document-metadata.d.ts +8 -8
  137. package/dist/server/src/services/document-metadata.d.ts.map +1 -1
  138. package/dist/server/src/services/index.d.ts +4 -4
  139. package/dist/server/src/services/index.d.ts.map +1 -1
  140. package/dist/server/src/services/utils/configuration/index.d.ts +2 -2
  141. package/dist/server/src/services/utils/configuration/layouts.d.ts +2 -2
  142. package/dist/server/src/utils/index.d.ts +2 -0
  143. package/dist/server/src/utils/index.d.ts.map +1 -1
  144. package/dist/shared/contracts/index.d.ts +1 -0
  145. package/dist/shared/contracts/index.d.ts.map +1 -1
  146. package/dist/shared/contracts/preview.d.ts +27 -0
  147. package/dist/shared/contracts/preview.d.ts.map +1 -0
  148. package/dist/shared/index.js +4 -0
  149. package/dist/shared/index.js.map +1 -1
  150. package/dist/shared/index.mjs +4 -0
  151. package/dist/shared/index.mjs.map +1 -1
  152. package/package.json +11 -11
  153. package/dist/_chunks/EditViewPage-Co2IKQZH.js.map +0 -1
  154. package/dist/_chunks/EditViewPage-HYljoEY7.mjs.map +0 -1
  155. package/dist/_chunks/Field-BOPUMZ1u.mjs.map +0 -1
  156. package/dist/_chunks/Field-G9CkFUtP.js.map +0 -1
  157. package/dist/_chunks/Form-CDwNp7pU.mjs.map +0 -1
  158. package/dist/_chunks/Form-crsbkGxI.js.map +0 -1
  159. package/dist/_chunks/History-BDZrgfZ3.mjs.map +0 -1
  160. package/dist/_chunks/History-CWcM9HnW.js.map +0 -1
  161. package/dist/_chunks/ListConfigurationPage-BZ3ScUna.mjs.map +0 -1
  162. package/dist/_chunks/ListConfigurationPage-DGzoQD_I.js.map +0 -1
  163. package/dist/_chunks/ListViewPage-BBAC9aPu.js.map +0 -1
  164. package/dist/_chunks/Relations-Dmv0Tpe5.mjs.map +0 -1
  165. package/dist/_chunks/Relations-jwuTFGOV.js.map +0 -1
  166. package/dist/_chunks/index-BmUAydCA.mjs.map +0 -1
  167. package/dist/_chunks/index-CBX6KyXv.js.map +0 -1
  168. package/dist/_chunks/relations-DIjTADIu.js.map +0 -1
  169. package/dist/_chunks/relations-op89RClB.mjs.map +0 -1
@@ -4,13 +4,14 @@ 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");
10
+ const styledComponents = require("styled-components");
9
11
  const yup = require("yup");
12
+ const qs = require("qs");
10
13
  const pipe = require("lodash/fp/pipe");
11
14
  const dateFns = require("date-fns");
12
- const styledComponents = require("styled-components");
13
- const qs = require("qs");
14
15
  const toolkit = require("@reduxjs/toolkit");
15
16
  const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
16
17
  function _interopNamespace(e) {
@@ -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) : [];
@@ -286,7 +296,7 @@ const documentApi = contentManagerApi.injectEndpoints({
286
296
  url: `/content-manager/collection-types/${model}`,
287
297
  method: "GET",
288
298
  config: {
289
- params
299
+ params: qs.stringify(params, { encode: true })
290
300
  }
291
301
  }),
292
302
  providesTags: (result, _error, arg) => {
@@ -474,14 +484,29 @@ const buildValidParams = (query) => {
474
484
  {}
475
485
  )
476
486
  };
477
- if ("_q" in validQueryParams) {
478
- validQueryParams._q = encodeURIComponent(validQueryParams._q);
479
- }
480
487
  return validQueryParams;
481
488
  };
482
489
  const isBaseQueryError = (error) => {
483
490
  return error.name !== void 0;
484
491
  };
492
+ const arrayValidator = (attribute, options) => ({
493
+ message: strapiAdmin.translatedErrors.required,
494
+ test(value) {
495
+ if (options.status === "draft") {
496
+ return true;
497
+ }
498
+ if (!attribute.required) {
499
+ return true;
500
+ }
501
+ if (!value) {
502
+ return false;
503
+ }
504
+ if (Array.isArray(value) && value.length === 0) {
505
+ return false;
506
+ }
507
+ return true;
508
+ }
509
+ });
485
510
  const createYupSchema = (attributes = {}, components = {}, options = { status: null }) => {
486
511
  const createModelSchema = (attributes2) => yup__namespace.object().shape(
487
512
  Object.entries(attributes2).reduce((acc, [name, attribute]) => {
@@ -489,6 +514,7 @@ const createYupSchema = (attributes = {}, components = {}, options = { status: n
489
514
  return acc;
490
515
  }
491
516
  const validations = [
517
+ addNullableValidation,
492
518
  addRequiredValidation,
493
519
  addMinLengthValidation,
494
520
  addMaxLengthValidation,
@@ -505,12 +531,12 @@ const createYupSchema = (attributes = {}, components = {}, options = { status: n
505
531
  ...acc,
506
532
  [name]: transformSchema(
507
533
  yup__namespace.array().of(createModelSchema(attributes3).nullable(false))
508
- )
534
+ ).test(arrayValidator(attribute, options))
509
535
  };
510
536
  } else {
511
537
  return {
512
538
  ...acc,
513
- [name]: transformSchema(createModelSchema(attributes3))
539
+ [name]: transformSchema(createModelSchema(attributes3).nullable())
514
540
  };
515
541
  }
516
542
  }
@@ -532,7 +558,7 @@ const createYupSchema = (attributes = {}, components = {}, options = { status: n
532
558
  }
533
559
  )
534
560
  )
535
- )
561
+ ).test(arrayValidator(attribute, options))
536
562
  };
537
563
  case "relation":
538
564
  return {
@@ -544,7 +570,7 @@ const createYupSchema = (attributes = {}, components = {}, options = { status: n
544
570
  } else if (Array.isArray(value)) {
545
571
  return yup__namespace.array().of(
546
572
  yup__namespace.object().shape({
547
- id: yup__namespace.string().required()
573
+ id: yup__namespace.number().required()
548
574
  })
549
575
  );
550
576
  } else if (typeof value === "object") {
@@ -630,17 +656,17 @@ const nullableSchema = (schema) => {
630
656
  schema
631
657
  );
632
658
  };
659
+ const addNullableValidation = () => (schema) => {
660
+ return nullableSchema(schema);
661
+ };
633
662
  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);
663
+ if (options.status === "draft" || !attribute.required) {
664
+ return schema;
639
665
  }
640
- if (attribute.required && attribute.type !== "relation") {
666
+ if (attribute.required && "required" in schema) {
641
667
  return schema.required(strapiAdmin.translatedErrors.required);
642
668
  }
643
- return nullableSchema(schema);
669
+ return schema;
644
670
  };
645
671
  const addMinLengthValidation = (attribute, options) => (schema) => {
646
672
  if (options.status === "draft") {
@@ -668,31 +694,12 @@ const addMaxLengthValidation = (attribute) => (schema) => {
668
694
  return schema;
669
695
  };
670
696
  const addMinValidation = (attribute, options) => (schema) => {
671
- if ("min" in attribute) {
697
+ if (options.status === "draft") {
698
+ return schema;
699
+ }
700
+ if ("min" in attribute && "min" in schema) {
672
701
  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) {
702
+ if (min) {
696
703
  return schema.min(min, {
697
704
  ...strapiAdmin.translatedErrors.min,
698
705
  values: {
@@ -981,9 +988,10 @@ const formatEditLayout = (data, {
981
988
  currentPanelIndex += 2;
982
989
  } else {
983
990
  if (!panels[currentPanelIndex]) {
984
- panels.push([]);
991
+ panels.push([row]);
992
+ } else {
993
+ panels[currentPanelIndex].push(row);
985
994
  }
986
- panels[currentPanelIndex].push(row);
987
995
  }
988
996
  return panels;
989
997
  }, []);
@@ -1165,11 +1173,13 @@ const useDocument = (args, opts) => {
1165
1173
  [validationSchema]
1166
1174
  );
1167
1175
  const isLoading = isLoadingDocument || isFetchingDocument || isLoadingSchema;
1176
+ const hasError = !!error;
1168
1177
  return {
1169
1178
  components,
1170
1179
  document: data?.data,
1171
1180
  meta: data?.meta,
1172
1181
  isLoading,
1182
+ hasError,
1173
1183
  schema,
1174
1184
  schemas,
1175
1185
  validate
@@ -1185,16 +1195,18 @@ const useDoc = () => {
1185
1195
  if (!slug) {
1186
1196
  throw new Error("Could not find model in url params");
1187
1197
  }
1198
+ const document = useDocument(
1199
+ { documentId: origin || id, model: slug, collectionType, params },
1200
+ {
1201
+ skip: id === "create" || !origin && !id && collectionType !== SINGLE_TYPES
1202
+ }
1203
+ );
1204
+ const returnId = origin || id === "create" ? void 0 : id;
1188
1205
  return {
1189
1206
  collectionType,
1190
1207
  model: slug,
1191
- id: origin || id === "create" ? void 0 : id,
1192
- ...useDocument(
1193
- { documentId: origin || id, model: slug, collectionType, params },
1194
- {
1195
- skip: id === "create" || !origin && !id && collectionType !== SINGLE_TYPES
1196
- }
1197
- )
1208
+ id: returnId,
1209
+ ...document
1198
1210
  };
1199
1211
  };
1200
1212
  const useContentManagerContext = () => {
@@ -1237,9 +1249,6 @@ const useContentManagerContext = () => {
1237
1249
  };
1238
1250
  };
1239
1251
  const prefixPluginTranslations = (trad, pluginId) => {
1240
- if (!pluginId) {
1241
- throw new TypeError("pluginId can't be empty");
1242
- }
1243
1252
  return Object.keys(trad).reduce((acc, current) => {
1244
1253
  acc[`${pluginId}.${current}`] = trad[current];
1245
1254
  return acc;
@@ -1673,10 +1682,10 @@ const useDocumentActions = () => {
1673
1682
  update
1674
1683
  };
1675
1684
  };
1676
- const ProtectedHistoryPage = React.lazy(
1677
- () => Promise.resolve().then(() => require("./History-CWcM9HnW.js")).then((mod) => ({ default: mod.ProtectedHistoryPage }))
1685
+ const ProtectedHistoryPage = React__namespace.lazy(
1686
+ () => Promise.resolve().then(() => require("./History-BsPXl1XH.js")).then((mod) => ({ default: mod.ProtectedHistoryPage }))
1678
1687
  );
1679
- const routes$1 = [
1688
+ const routes$2 = [
1680
1689
  {
1681
1690
  path: ":collectionType/:slug/:id/history",
1682
1691
  Component: ProtectedHistoryPage
@@ -1686,32 +1695,45 @@ const routes$1 = [
1686
1695
  Component: ProtectedHistoryPage
1687
1696
  }
1688
1697
  ];
1698
+ const ProtectedPreviewPage = React__namespace.lazy(
1699
+ () => Promise.resolve().then(() => require("./Preview-BKuVG1dV.js")).then((mod) => ({ default: mod.ProtectedPreviewPage }))
1700
+ );
1701
+ const routes$1 = [
1702
+ {
1703
+ path: ":collectionType/:slug/:id/preview",
1704
+ Component: ProtectedPreviewPage
1705
+ },
1706
+ {
1707
+ path: ":collectionType/:slug/preview",
1708
+ Component: ProtectedPreviewPage
1709
+ }
1710
+ ];
1689
1711
  const ProtectedEditViewPage = React.lazy(
1690
- () => Promise.resolve().then(() => require("./EditViewPage-Co2IKQZH.js")).then((mod) => ({ default: mod.ProtectedEditViewPage }))
1712
+ () => Promise.resolve().then(() => require("./EditViewPage-BRA-JSnw.js")).then((mod) => ({ default: mod.ProtectedEditViewPage }))
1691
1713
  );
1692
1714
  const ProtectedListViewPage = React.lazy(
1693
- () => Promise.resolve().then(() => require("./ListViewPage-BBAC9aPu.js")).then((mod) => ({ default: mod.ProtectedListViewPage }))
1715
+ () => Promise.resolve().then(() => require("./ListViewPage-BUKFOJuS.js")).then((mod) => ({ default: mod.ProtectedListViewPage }))
1694
1716
  );
1695
1717
  const ProtectedListConfiguration = React.lazy(
1696
- () => Promise.resolve().then(() => require("./ListConfigurationPage-DGzoQD_I.js")).then((mod) => ({
1718
+ () => Promise.resolve().then(() => require("./ListConfigurationPage-CN1-7Pgi.js")).then((mod) => ({
1697
1719
  default: mod.ProtectedListConfiguration
1698
1720
  }))
1699
1721
  );
1700
1722
  const ProtectedEditConfigurationPage = React.lazy(
1701
- () => Promise.resolve().then(() => require("./EditConfigurationPage-ZN3s568V.js")).then((mod) => ({
1723
+ () => Promise.resolve().then(() => require("./EditConfigurationPage-sdGi-bna.js")).then((mod) => ({
1702
1724
  default: mod.ProtectedEditConfigurationPage
1703
1725
  }))
1704
1726
  );
1705
1727
  const ProtectedComponentConfigurationPage = React.lazy(
1706
- () => Promise.resolve().then(() => require("./ComponentConfigurationPage-_6osrv39.js")).then((mod) => ({
1728
+ () => Promise.resolve().then(() => require("./ComponentConfigurationPage-BebDdCkl.js")).then((mod) => ({
1707
1729
  default: mod.ProtectedComponentConfigurationPage
1708
1730
  }))
1709
1731
  );
1710
1732
  const NoPermissions = React.lazy(
1711
- () => Promise.resolve().then(() => require("./NoPermissionsPage-D2iWw-sn.js")).then((mod) => ({ default: mod.NoPermissions }))
1733
+ () => Promise.resolve().then(() => require("./NoPermissionsPage-DRPnEq9t.js")).then((mod) => ({ default: mod.NoPermissions }))
1712
1734
  );
1713
1735
  const NoContentType = React.lazy(
1714
- () => Promise.resolve().then(() => require("./NoContentTypePage-CwVDx_YC.js")).then((mod) => ({ default: mod.NoContentType }))
1736
+ () => Promise.resolve().then(() => require("./NoContentTypePage-Cs7Kk9EW.js")).then((mod) => ({ default: mod.NoContentType }))
1715
1737
  );
1716
1738
  const CollectionTypePages = () => {
1717
1739
  const { collectionType } = reactRouterDom.useParams();
@@ -1723,7 +1745,7 @@ const CollectionTypePages = () => {
1723
1745
  const CLONE_RELATIVE_PATH = ":collectionType/:slug/clone/:origin";
1724
1746
  const CLONE_PATH = `/content-manager/${CLONE_RELATIVE_PATH}`;
1725
1747
  const LIST_RELATIVE_PATH = ":collectionType/:slug";
1726
- const LIST_PATH = `/content-manager/${LIST_RELATIVE_PATH}`;
1748
+ const LIST_PATH = `/content-manager/collection-types/:slug`;
1727
1749
  const routes = [
1728
1750
  {
1729
1751
  path: LIST_RELATIVE_PATH,
@@ -1757,6 +1779,7 @@ const routes = [
1757
1779
  path: "no-content-types",
1758
1780
  Component: NoContentType
1759
1781
  },
1782
+ ...routes$2,
1760
1783
  ...routes$1
1761
1784
  ];
1762
1785
  const DocumentActions = ({ actions: actions2 }) => {
@@ -1855,6 +1878,11 @@ const DocumentActionButton = (action) => {
1855
1878
  ) : null
1856
1879
  ] });
1857
1880
  };
1881
+ const MenuItem = styledComponents.styled(designSystem.Menu.Item)`
1882
+ &:hover {
1883
+ background: ${({ theme, isVariantDanger, isDisabled }) => isVariantDanger && !isDisabled ? theme.colors.danger100 : "neutral"};
1884
+ }
1885
+ `;
1858
1886
  const DocumentActionsMenu = ({
1859
1887
  actions: actions2,
1860
1888
  children,
@@ -1913,48 +1941,32 @@ const DocumentActionsMenu = ({
1913
1941
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.Content, { maxHeight: void 0, popoverPlacement: "bottom-end", children: [
1914
1942
  actions2.map((action) => {
1915
1943
  return /* @__PURE__ */ jsxRuntime.jsx(
1916
- designSystem.Menu.Item,
1944
+ MenuItem,
1917
1945
  {
1918
1946
  disabled: action.disabled,
1919
1947
  onSelect: handleClick(action),
1920
1948
  display: "block",
1921
- children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", gap: 4, children: [
1922
- /* @__PURE__ */ jsxRuntime.jsxs(
1923
- designSystem.Flex,
1924
- {
1925
- color: !action.disabled ? convertActionVariantToColor(action.variant) : "inherit",
1926
- gap: 2,
1927
- tag: "span",
1928
- children: [
1929
- /* @__PURE__ */ jsxRuntime.jsx(
1930
- designSystem.Flex,
1931
- {
1932
- tag: "span",
1933
- color: !action.disabled ? convertActionVariantToIconColor(action.variant) : "inherit",
1934
- children: action.icon
1935
- }
1936
- ),
1937
- action.label
1938
- ]
1939
- }
1940
- ),
1941
- action.id.startsWith("HistoryAction") && /* @__PURE__ */ jsxRuntime.jsx(
1942
- designSystem.Flex,
1943
- {
1944
- alignItems: "center",
1945
- background: "alternative100",
1946
- borderStyle: "solid",
1947
- borderColor: "alternative200",
1948
- borderWidth: "1px",
1949
- height: 5,
1950
- paddingLeft: 2,
1951
- paddingRight: 2,
1952
- hasRadius: true,
1953
- color: "alternative600",
1954
- children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", fontWeight: "bold", lineHeight: 1, children: formatMessage({ id: "global.new", defaultMessage: "New" }) })
1955
- }
1956
- )
1957
- ] })
1949
+ isVariantDanger: action.variant === "danger",
1950
+ isDisabled: action.disabled,
1951
+ children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "space-between", gap: 4, children: /* @__PURE__ */ jsxRuntime.jsxs(
1952
+ designSystem.Flex,
1953
+ {
1954
+ color: !action.disabled ? convertActionVariantToColor(action.variant) : "inherit",
1955
+ gap: 2,
1956
+ tag: "span",
1957
+ children: [
1958
+ /* @__PURE__ */ jsxRuntime.jsx(
1959
+ designSystem.Flex,
1960
+ {
1961
+ tag: "span",
1962
+ color: !action.disabled ? convertActionVariantToIconColor(action.variant) : "inherit",
1963
+ children: action.icon
1964
+ }
1965
+ ),
1966
+ action.label
1967
+ ]
1968
+ }
1969
+ ) })
1958
1970
  },
1959
1971
  action.id
1960
1972
  );
@@ -2065,6 +2077,18 @@ const DocumentActionModal = ({
2065
2077
  typeof Footer === "function" ? /* @__PURE__ */ jsxRuntime.jsx(Footer, { onClose: handleClose }) : Footer
2066
2078
  ] }) });
2067
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
+ };
2068
2092
  const PublishAction$1 = ({
2069
2093
  activeTab,
2070
2094
  documentId,
@@ -2158,7 +2182,9 @@ const PublishAction$1 = ({
2158
2182
  const performPublish = async () => {
2159
2183
  setSubmitting(true);
2160
2184
  try {
2161
- const { errors } = await validate();
2185
+ const { errors } = await validate(true, {
2186
+ status: "published"
2187
+ });
2162
2188
  if (errors) {
2163
2189
  toggleNotification({
2164
2190
  type: "danger",
@@ -2176,7 +2202,7 @@ const PublishAction$1 = ({
2176
2202
  documentId,
2177
2203
  params
2178
2204
  },
2179
- formValues
2205
+ transformData(formValues)
2180
2206
  );
2181
2207
  if ("data" in res && collectionType !== SINGLE_TYPES) {
2182
2208
  navigate({
@@ -2266,24 +2292,24 @@ const UpdateAction = ({
2266
2292
  */
2267
2293
  disabled: isSubmitting || !modified && !isCloning || activeTab === "published",
2268
2294
  label: formatMessage({
2269
- id: "content-manager.containers.Edit.save",
2295
+ id: "global.save",
2270
2296
  defaultMessage: "Save"
2271
2297
  }),
2272
2298
  onClick: async () => {
2273
2299
  setSubmitting(true);
2274
2300
  try {
2275
- if (activeTab !== "draft") {
2276
- const { errors } = await validate();
2277
- if (errors) {
2278
- toggleNotification({
2279
- type: "danger",
2280
- message: formatMessage({
2281
- id: "content-manager.validation.error",
2282
- defaultMessage: "There are validation errors in your document. Please fix them before saving."
2283
- })
2284
- });
2285
- return;
2286
- }
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;
2287
2313
  }
2288
2314
  if (isCloning) {
2289
2315
  const res = await clone(
@@ -2292,7 +2318,7 @@ const UpdateAction = ({
2292
2318
  documentId: cloneMatch.params.origin,
2293
2319
  params
2294
2320
  },
2295
- document
2321
+ transformData(document)
2296
2322
  );
2297
2323
  if ("data" in res) {
2298
2324
  navigate(
@@ -2313,7 +2339,7 @@ const UpdateAction = ({
2313
2339
  documentId,
2314
2340
  params
2315
2341
  },
2316
- document
2342
+ transformData(document)
2317
2343
  );
2318
2344
  if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
2319
2345
  setErrors(formatValidationErrors(res.error));
@@ -2326,7 +2352,7 @@ const UpdateAction = ({
2326
2352
  model,
2327
2353
  params
2328
2354
  },
2329
- document
2355
+ transformData(document)
2330
2356
  );
2331
2357
  if ("data" in res && collectionType !== SINGLE_TYPES) {
2332
2358
  navigate(
@@ -2531,7 +2557,7 @@ const RelativeTime = React__namespace.forwardRef(
2531
2557
  });
2532
2558
  const unit = intervals.find((intervalUnit) => {
2533
2559
  return interval[intervalUnit] > 0 && Object.keys(interval).includes(intervalUnit);
2534
- });
2560
+ }) ?? "seconds";
2535
2561
  const relativeTime = dateFns.isPast(timestamp) ? -interval[unit] : interval[unit];
2536
2562
  const customInterval = customIntervals.find(
2537
2563
  (custom) => interval[custom.unit] < custom.threshold
@@ -2565,19 +2591,29 @@ const getDisplayName = ({
2565
2591
  return email ?? "";
2566
2592
  };
2567
2593
  const capitalise = (str) => str.charAt(0).toUpperCase() + str.slice(1);
2568
- const DocumentStatus = ({ status = "draft", ...restProps }) => {
2594
+ const DocumentStatus = ({ status = "draft", size = "S", ...restProps }) => {
2569
2595
  const statusVariant = status === "draft" ? "secondary" : status === "published" ? "success" : "alternative";
2570
- 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) }) });
2596
+ const { formatMessage } = reactIntl.useIntl();
2597
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Status, { ...restProps, size, variant: statusVariant, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "span", variant: "omega", fontWeight: "bold", children: formatMessage({
2598
+ id: `content-manager.containers.List.${status}`,
2599
+ defaultMessage: capitalise(status)
2600
+ }) }) });
2571
2601
  };
2572
2602
  const Header = ({ isCreating, status, title: documentTitle = "Untitled" }) => {
2573
2603
  const { formatMessage } = reactIntl.useIntl();
2574
2604
  const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
2605
+ const params = reactRouterDom.useParams();
2575
2606
  const title = isCreating ? formatMessage({
2576
2607
  id: "content-manager.containers.edit.title.new",
2577
2608
  defaultMessage: "Create an entry"
2578
2609
  }) : documentTitle;
2579
2610
  return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", paddingTop: 6, paddingBottom: 4, gap: 2, children: [
2580
- /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.BackButton, {}),
2611
+ /* @__PURE__ */ jsxRuntime.jsx(
2612
+ strapiAdmin.BackButton,
2613
+ {
2614
+ fallback: params.collectionType === SINGLE_TYPES ? void 0 : `../${COLLECTION_TYPES}/${params.slug}`
2615
+ }
2616
+ ),
2581
2617
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { width: "100%", justifyContent: "space-between", gap: "80px", alignItems: "flex-start", children: [
2582
2618
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "alpha", tag: "h1", children: title }),
2583
2619
  /* @__PURE__ */ jsxRuntime.jsx(HeaderToolbar, {})
@@ -2665,12 +2701,12 @@ const Information = ({ activeTab }) => {
2665
2701
  isDisplayed: !!publishDocument?.[PUBLISHED_AT_ATTRIBUTE_NAME],
2666
2702
  label: formatMessage({
2667
2703
  id: "content-manager.containers.edit.information.last-published.label",
2668
- defaultMessage: "Last published"
2704
+ defaultMessage: "Published"
2669
2705
  }),
2670
2706
  value: formatMessage(
2671
2707
  {
2672
2708
  id: "content-manager.containers.edit.information.last-published.value",
2673
- defaultMessage: `Published {time}{isAnonymous, select, true {} other { by {author}}}`
2709
+ defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
2674
2710
  },
2675
2711
  {
2676
2712
  time: /* @__PURE__ */ jsxRuntime.jsx(RelativeTime, { timestamp: new Date(publishDocument?.[PUBLISHED_AT_ATTRIBUTE_NAME]) }),
@@ -2683,12 +2719,12 @@ const Information = ({ activeTab }) => {
2683
2719
  isDisplayed: !!createAndUpdateDocument?.[UPDATED_AT_ATTRIBUTE_NAME],
2684
2720
  label: formatMessage({
2685
2721
  id: "content-manager.containers.edit.information.last-draft.label",
2686
- defaultMessage: "Last draft"
2722
+ defaultMessage: "Updated"
2687
2723
  }),
2688
2724
  value: formatMessage(
2689
2725
  {
2690
2726
  id: "content-manager.containers.edit.information.last-draft.value",
2691
- defaultMessage: `Modified {time}{isAnonymous, select, true {} other { by {author}}}`
2727
+ defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
2692
2728
  },
2693
2729
  {
2694
2730
  time: /* @__PURE__ */ jsxRuntime.jsx(
@@ -2706,12 +2742,12 @@ const Information = ({ activeTab }) => {
2706
2742
  isDisplayed: !!createAndUpdateDocument?.[CREATED_AT_ATTRIBUTE_NAME],
2707
2743
  label: formatMessage({
2708
2744
  id: "content-manager.containers.edit.information.document.label",
2709
- defaultMessage: "Document"
2745
+ defaultMessage: "Created"
2710
2746
  }),
2711
2747
  value: formatMessage(
2712
2748
  {
2713
2749
  id: "content-manager.containers.edit.information.document.value",
2714
- defaultMessage: `Created {time}{isAnonymous, select, true {} other { by {author}}}`
2750
+ defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
2715
2751
  },
2716
2752
  {
2717
2753
  time: /* @__PURE__ */ jsxRuntime.jsx(
@@ -2769,10 +2805,9 @@ const HeaderActions = ({ actions: actions2 }) => {
2769
2805
  designSystem.SingleSelect,
2770
2806
  {
2771
2807
  size: "S",
2772
- disabled: action.disabled,
2773
- "aria-label": action.label,
2774
2808
  onChange: action.onSelect,
2775
- value: action.value,
2809
+ "aria-label": action.label,
2810
+ ...action,
2776
2811
  children: action.options.map(({ label, ...option }) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { ...option, children: label }, option.value))
2777
2812
  },
2778
2813
  action.id
@@ -3015,7 +3050,7 @@ const Panel = React__namespace.forwardRef(({ children, title }, ref) => {
3015
3050
  justifyContent: "stretch",
3016
3051
  alignItems: "flex-start",
3017
3052
  children: [
3018
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "h2", variant: "sigma", textTransform: "uppercase", children: title }),
3053
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "h2", variant: "sigma", textTransform: "uppercase", textColor: "neutral600", children: title }),
3019
3054
  children
3020
3055
  ]
3021
3056
  }
@@ -3265,18 +3300,10 @@ const SelectedEntriesTableContent = ({
3265
3300
  search: row.locale && `?plugins[i18n][locale]=${row.locale}`
3266
3301
  },
3267
3302
  state: { from: pathname },
3268
- label: formatMessage(
3269
- { id: "app.component.HelperPluginTable.edit", defaultMessage: "Edit {target}" },
3270
- {
3271
- target: formatMessage(
3272
- {
3273
- id: "content-manager.components.ListViewHelperPluginTable.row-line",
3274
- defaultMessage: "item line {number}"
3275
- },
3276
- { number: index2 + 1 }
3277
- )
3278
- }
3279
- ),
3303
+ label: formatMessage({
3304
+ id: "content-manager.bulk-publish.edit",
3305
+ defaultMessage: "Edit"
3306
+ }),
3280
3307
  target: "_blank",
3281
3308
  marginLeft: "auto",
3282
3309
  variant: "ghost",
@@ -3920,17 +3947,27 @@ const HistoryAction = ({ model, document }) => {
3920
3947
  const { formatMessage } = reactIntl.useIntl();
3921
3948
  const [{ query }] = strapiAdmin.useQueryParams();
3922
3949
  const navigate = reactRouterDom.useNavigate();
3950
+ const { trackUsage } = strapiAdmin.useTracking();
3951
+ const { pathname } = reactRouterDom.useLocation();
3923
3952
  const pluginsQueryParams = qs.stringify({ plugins: query.plugins }, { encode: false });
3924
3953
  if (!window.strapi.features.isEnabled("cms-content-history")) {
3925
3954
  return null;
3926
3955
  }
3956
+ const handleOnClick = () => {
3957
+ const destination = { pathname: "history", search: pluginsQueryParams };
3958
+ trackUsage("willNavigate", {
3959
+ from: pathname,
3960
+ to: `${pathname}/${destination.pathname}`
3961
+ });
3962
+ navigate(destination);
3963
+ };
3927
3964
  return {
3928
3965
  icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.ClockCounterClockwise, {}),
3929
3966
  label: formatMessage({
3930
3967
  id: "content-manager.history.document-action",
3931
3968
  defaultMessage: "Content History"
3932
3969
  }),
3933
- onClick: () => navigate({ pathname: "history", search: pluginsQueryParams }),
3970
+ onClick: handleOnClick,
3934
3971
  disabled: (
3935
3972
  /**
3936
3973
  * The user is creating a new document.
@@ -3998,6 +4035,72 @@ const { setInitialData } = actions;
3998
4035
  const reducer = toolkit.combineReducers({
3999
4036
  app: reducer$1
4000
4037
  });
4038
+ const previewApi = contentManagerApi.injectEndpoints({
4039
+ endpoints: (builder) => ({
4040
+ getPreviewUrl: builder.query({
4041
+ query({ query, params }) {
4042
+ return {
4043
+ url: `/content-manager/preview/url/${params.contentType}`,
4044
+ method: "GET",
4045
+ config: {
4046
+ params: query
4047
+ }
4048
+ };
4049
+ }
4050
+ })
4051
+ })
4052
+ });
4053
+ const { useGetPreviewUrlQuery } = previewApi;
4054
+ const PreviewSidePanel = ({ model, documentId, document }) => {
4055
+ const { formatMessage } = reactIntl.useIntl();
4056
+ const { trackUsage } = strapiAdmin.useTracking();
4057
+ const { pathname } = reactRouterDom.useLocation();
4058
+ const [{ query }] = strapiAdmin.useQueryParams();
4059
+ const { data, error } = useGetPreviewUrlQuery({
4060
+ params: {
4061
+ contentType: model
4062
+ },
4063
+ query: {
4064
+ documentId,
4065
+ locale: document?.locale,
4066
+ status: document?.status
4067
+ }
4068
+ });
4069
+ if (!data?.data?.url || error) {
4070
+ return null;
4071
+ }
4072
+ const trackNavigation = () => {
4073
+ const destinationPathname = pathname.replace(/\/$/, "") + "/preview";
4074
+ trackUsage("willNavigate", { from: pathname, to: destinationPathname });
4075
+ };
4076
+ return {
4077
+ title: formatMessage({ id: "content-manager.preview.panel.title", defaultMessage: "Preview" }),
4078
+ content: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { gap: 2, width: "100%", children: /* @__PURE__ */ jsxRuntime.jsx(
4079
+ designSystem.Button,
4080
+ {
4081
+ variant: "tertiary",
4082
+ tag: reactRouterDom.Link,
4083
+ to: { pathname: "preview", search: qs.stringify(query, { encode: false }) },
4084
+ onClick: trackNavigation,
4085
+ flex: "auto",
4086
+ children: formatMessage({
4087
+ id: "content-manager.preview.panel.button",
4088
+ defaultMessage: "Open preview"
4089
+ })
4090
+ }
4091
+ ) })
4092
+ };
4093
+ };
4094
+ const FEATURE_ID = "preview";
4095
+ const previewAdmin = {
4096
+ bootstrap(app) {
4097
+ if (!window.strapi.future.isEnabled(FEATURE_ID)) {
4098
+ return;
4099
+ }
4100
+ const contentManagerPluginApis = app.getPlugin("content-manager").apis;
4101
+ contentManagerPluginApis.addEditViewSidePanel([PreviewSidePanel]);
4102
+ }
4103
+ };
4001
4104
  const index = {
4002
4105
  register(app) {
4003
4106
  const cm = new ContentManagerPlugin();
@@ -4017,7 +4120,7 @@ const index = {
4017
4120
  app.router.addRoute({
4018
4121
  path: "content-manager/*",
4019
4122
  lazy: async () => {
4020
- const { Layout } = await Promise.resolve().then(() => require("./layout-CxxkX9jY.js"));
4123
+ const { Layout } = await Promise.resolve().then(() => require("./layout-Cx9LHtH5.js"));
4021
4124
  return {
4022
4125
  Component: Layout
4023
4126
  };
@@ -4030,11 +4133,14 @@ const index = {
4030
4133
  if (typeof historyAdmin.bootstrap === "function") {
4031
4134
  historyAdmin.bootstrap(app);
4032
4135
  }
4136
+ if (typeof previewAdmin.bootstrap === "function") {
4137
+ previewAdmin.bootstrap(app);
4138
+ }
4033
4139
  },
4034
4140
  async registerTrads({ locales }) {
4035
4141
  const importedTrads = await Promise.all(
4036
4142
  locales.map((locale) => {
4037
- 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-BlhnxQfj.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 }) => {
4143
+ return __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/ar.json": () => Promise.resolve().then(() => require("./ar-BUUWXIYu.js")), "./translations/ca.json": () => Promise.resolve().then(() => require("./ca-Cmk45QO6.js")), "./translations/cs.json": () => Promise.resolve().then(() => require("./cs-CkJy6B2v.js")), "./translations/de.json": () => Promise.resolve().then(() => require("./de-CCEmbAah.js")), "./translations/en.json": () => Promise.resolve().then(() => require("./en-DTWPCdTS.js")), "./translations/es.json": () => Promise.resolve().then(() => require("./es-9K52xZIr.js")), "./translations/eu.json": () => Promise.resolve().then(() => require("./eu-VDH-3ovk.js")), "./translations/fr.json": () => Promise.resolve().then(() => require("./fr-B2Kyv8Z9.js")), "./translations/gu.json": () => Promise.resolve().then(() => require("./gu-BRmF601H.js")), "./translations/hi.json": () => Promise.resolve().then(() => require("./hi-CCJBptSq.js")), "./translations/hu.json": () => Promise.resolve().then(() => require("./hu-sNV_yLYy.js")), "./translations/id.json": () => Promise.resolve().then(() => require("./id-B5Ser98A.js")), "./translations/it.json": () => Promise.resolve().then(() => require("./it-DkBIs7vD.js")), "./translations/ja.json": () => Promise.resolve().then(() => require("./ja-7sfIbjxE.js")), "./translations/ko.json": () => Promise.resolve().then(() => require("./ko-woFZPmLk.js")), "./translations/ml.json": () => Promise.resolve().then(() => require("./ml-C2W8N8k1.js")), "./translations/ms.json": () => Promise.resolve().then(() => require("./ms-BuFotyP_.js")), "./translations/nl.json": () => Promise.resolve().then(() => require("./nl-bbEOHChV.js")), "./translations/pl.json": () => Promise.resolve().then(() => require("./pl-uzwG-hk7.js")), "./translations/pt-BR.json": () => Promise.resolve().then(() => require("./pt-BR-BiOz37D9.js")), "./translations/pt.json": () => Promise.resolve().then(() => require("./pt-CeXQuq50.js")), "./translations/ru.json": () => Promise.resolve().then(() => require("./ru-BT3ybNny.js")), "./translations/sa.json": () => Promise.resolve().then(() => require("./sa-CcvkYInH.js")), "./translations/sk.json": () => Promise.resolve().then(() => require("./sk-CvY09Xjv.js")), "./translations/sv.json": () => Promise.resolve().then(() => require("./sv-MYDuzgvT.js")), "./translations/th.json": () => Promise.resolve().then(() => require("./th-D9_GfAjc.js")), "./translations/tr.json": () => Promise.resolve().then(() => require("./tr-D9UH-O_R.js")), "./translations/uk.json": () => Promise.resolve().then(() => require("./uk-C8EiqJY7.js")), "./translations/vi.json": () => Promise.resolve().then(() => require("./vi-CJlYDheJ.js")), "./translations/zh-Hans.json": () => Promise.resolve().then(() => require("./zh-Hans-9kOncHGw.js")), "./translations/zh.json": () => Promise.resolve().then(() => require("./zh-CQQfszqR.js")) }), `./translations/${locale}.json`).then(({ default: data }) => {
4038
4144
  return {
4039
4145
  data: prefixPluginTranslations(data, PLUGIN_ID),
4040
4146
  locale
@@ -4092,5 +4198,6 @@ exports.useGetAllContentTypeSettingsQuery = useGetAllContentTypeSettingsQuery;
4092
4198
  exports.useGetAllDocumentsQuery = useGetAllDocumentsQuery;
4093
4199
  exports.useGetContentTypeConfigurationQuery = useGetContentTypeConfigurationQuery;
4094
4200
  exports.useGetInitialDataQuery = useGetInitialDataQuery;
4201
+ exports.useGetPreviewUrlQuery = useGetPreviewUrlQuery;
4095
4202
  exports.useUpdateContentTypeConfigurationMutation = useUpdateContentTypeConfigurationMutation;
4096
- //# sourceMappingURL=index-CBX6KyXv.js.map
4203
+ //# sourceMappingURL=index-DjV7tyGu.js.map