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

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 (154) hide show
  1. package/dist/_chunks/{ComponentConfigurationPage-_6osrv39.js → ComponentConfigurationPage-CpJNPBgk.js} +4 -4
  2. package/dist/_chunks/{ComponentConfigurationPage-_6osrv39.js.map → ComponentConfigurationPage-CpJNPBgk.js.map} +1 -1
  3. package/dist/_chunks/{ComponentConfigurationPage-DJ5voqEK.mjs → ComponentConfigurationPage-TYDPg5WG.mjs} +4 -4
  4. package/dist/_chunks/{ComponentConfigurationPage-DJ5voqEK.mjs.map → ComponentConfigurationPage-TYDPg5WG.mjs.map} +1 -1
  5. package/dist/_chunks/{EditConfigurationPage-ZN3s568V.js → EditConfigurationPage-CFDe6SA1.js} +4 -4
  6. package/dist/_chunks/{EditConfigurationPage-ZN3s568V.js.map → EditConfigurationPage-CFDe6SA1.js.map} +1 -1
  7. package/dist/_chunks/{EditConfigurationPage-CZofxSLy.mjs → EditConfigurationPage-DqL8Pq5r.mjs} +4 -4
  8. package/dist/_chunks/{EditConfigurationPage-CZofxSLy.mjs.map → EditConfigurationPage-DqL8Pq5r.mjs.map} +1 -1
  9. package/dist/_chunks/{EditViewPage-HYljoEY7.mjs → EditViewPage-RXrFLav2.mjs} +15 -5
  10. package/dist/_chunks/EditViewPage-RXrFLav2.mjs.map +1 -0
  11. package/dist/_chunks/{EditViewPage-Co2IKQZH.js → EditViewPage-khfP2CR3.js} +15 -5
  12. package/dist/_chunks/EditViewPage-khfP2CR3.js.map +1 -0
  13. package/dist/_chunks/{Field-BOPUMZ1u.mjs → Field--rQeS6Zj.mjs} +71 -27
  14. package/dist/_chunks/Field--rQeS6Zj.mjs.map +1 -0
  15. package/dist/_chunks/{Field-G9CkFUtP.js → Field-C1ftmTe9.js} +71 -27
  16. package/dist/_chunks/Field-C1ftmTe9.js.map +1 -0
  17. package/dist/_chunks/{Form-CDwNp7pU.mjs → Form-COtGXyUE.mjs} +3 -3
  18. package/dist/_chunks/Form-COtGXyUE.mjs.map +1 -0
  19. package/dist/_chunks/{Form-crsbkGxI.js → Form-CwdX5oLw.js} +3 -3
  20. package/dist/_chunks/Form-CwdX5oLw.js.map +1 -0
  21. package/dist/_chunks/{History-BDZrgfZ3.mjs → History-BevwkPO1.mjs} +38 -41
  22. package/dist/_chunks/History-BevwkPO1.mjs.map +1 -0
  23. package/dist/_chunks/{History-CWcM9HnW.js → History-DKS2aqqM.js} +37 -40
  24. package/dist/_chunks/History-DKS2aqqM.js.map +1 -0
  25. package/dist/_chunks/{ListConfigurationPage-BZ3ScUna.mjs → ListConfigurationPage-DNfZDtDA.mjs} +3 -3
  26. package/dist/_chunks/{ListConfigurationPage-BZ3ScUna.mjs.map → ListConfigurationPage-DNfZDtDA.mjs.map} +1 -1
  27. package/dist/_chunks/{ListConfigurationPage-DGzoQD_I.js → ListConfigurationPage-LSYSPZHH.js} +3 -3
  28. package/dist/_chunks/{ListConfigurationPage-DGzoQD_I.js.map → ListConfigurationPage-LSYSPZHH.js.map} +1 -1
  29. package/dist/_chunks/{ListViewPage-CsX7tWx-.mjs → ListViewPage-C1PyuYRS.mjs} +16 -5
  30. package/dist/_chunks/{ListViewPage-CsX7tWx-.mjs.map → ListViewPage-C1PyuYRS.mjs.map} +1 -1
  31. package/dist/_chunks/{ListViewPage-BBAC9aPu.js → ListViewPage-DlUpqLIo.js} +16 -5
  32. package/dist/_chunks/ListViewPage-DlUpqLIo.js.map +1 -0
  33. package/dist/_chunks/{NoContentTypePage-LClTUPWs.mjs → NoContentTypePage-C9q744z1.mjs} +2 -2
  34. package/dist/_chunks/{NoContentTypePage-LClTUPWs.mjs.map → NoContentTypePage-C9q744z1.mjs.map} +1 -1
  35. package/dist/_chunks/{NoContentTypePage-CwVDx_YC.js → NoContentTypePage-m8wt3sf6.js} +2 -2
  36. package/dist/_chunks/{NoContentTypePage-CwVDx_YC.js.map → NoContentTypePage-m8wt3sf6.js.map} +1 -1
  37. package/dist/_chunks/{NoPermissionsPage-S4Re3FwO.mjs → NoPermissionsPage-8BM-LWta.mjs} +2 -2
  38. package/dist/_chunks/{NoPermissionsPage-S4Re3FwO.mjs.map → NoPermissionsPage-8BM-LWta.mjs.map} +1 -1
  39. package/dist/_chunks/{NoPermissionsPage-D2iWw-sn.js → NoPermissionsPage-DLfPsA0Q.js} +2 -2
  40. package/dist/_chunks/{NoPermissionsPage-D2iWw-sn.js.map → NoPermissionsPage-DLfPsA0Q.js.map} +1 -1
  41. package/dist/_chunks/{Relations-Dmv0Tpe5.mjs → Relations-D25xRcFy.mjs} +72 -36
  42. package/dist/_chunks/Relations-D25xRcFy.mjs.map +1 -0
  43. package/dist/_chunks/{Relations-jwuTFGOV.js → Relations-OMriCP_L.js} +71 -35
  44. package/dist/_chunks/Relations-OMriCP_L.js.map +1 -0
  45. package/dist/_chunks/{en-BlhnxQfj.js → en-Bdpa50w3.js} +12 -8
  46. package/dist/_chunks/{en-BlhnxQfj.js.map → en-Bdpa50w3.js.map} +1 -1
  47. package/dist/_chunks/{en-C8YBvRrK.mjs → en-CZw4xdPY.mjs} +12 -8
  48. package/dist/_chunks/{en-C8YBvRrK.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-BmUAydCA.mjs → index-BvGihCJp.mjs} +206 -88
  58. package/dist/_chunks/index-BvGihCJp.mjs.map +1 -0
  59. package/dist/_chunks/{index-CBX6KyXv.js → index-DqZnjo8F.js} +205 -86
  60. package/dist/_chunks/index-DqZnjo8F.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-CxxkX9jY.js → layout-CmaemAO3.js} +3 -3
  66. package/dist/_chunks/{layout-CxxkX9jY.js.map → layout-CmaemAO3.js.map} +1 -1
  67. package/dist/_chunks/{layout-ClP-DC72.mjs → layout-ykHSe2KQ.mjs} +3 -3
  68. package/dist/_chunks/{layout-ClP-DC72.mjs.map → layout-ykHSe2KQ.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-DIjTADIu.js → relations-D9fKsCLY.js} +3 -7
  74. package/dist/_chunks/relations-D9fKsCLY.js.map +1 -0
  75. package/dist/_chunks/{relations-op89RClB.mjs → relations-u-Vz51Ea.mjs} +3 -7
  76. package/dist/_chunks/relations-u-Vz51Ea.mjs.map +1 -0
  77. package/dist/admin/index.js +1 -1
  78. package/dist/admin/index.mjs +1 -1
  79. package/dist/admin/src/hooks/useDocument.d.ts +2 -0
  80. package/dist/admin/src/pages/EditView/components/Header.d.ts +1 -0
  81. package/dist/admin/src/preview/components/PreviewSidePanel.d.ts +3 -0
  82. package/dist/admin/src/preview/constants.d.ts +1 -0
  83. package/dist/admin/src/preview/index.d.ts +4 -0
  84. package/dist/admin/src/preview/services/preview.d.ts +3 -0
  85. package/dist/server/index.js +371 -158
  86. package/dist/server/index.js.map +1 -1
  87. package/dist/server/index.mjs +371 -158
  88. package/dist/server/index.mjs.map +1 -1
  89. package/dist/server/src/bootstrap.d.ts.map +1 -1
  90. package/dist/server/src/controllers/collection-types.d.ts.map +1 -1
  91. package/dist/server/src/controllers/index.d.ts.map +1 -1
  92. package/dist/server/src/controllers/relations.d.ts.map +1 -1
  93. package/dist/server/src/controllers/utils/metadata.d.ts +15 -1
  94. package/dist/server/src/controllers/utils/metadata.d.ts.map +1 -1
  95. package/dist/server/src/history/services/history.d.ts.map +1 -1
  96. package/dist/server/src/history/services/lifecycles.d.ts.map +1 -1
  97. package/dist/server/src/history/services/utils.d.ts +2 -3
  98. package/dist/server/src/history/services/utils.d.ts.map +1 -1
  99. package/dist/server/src/index.d.ts +4 -4
  100. package/dist/server/src/preview/constants.d.ts +2 -0
  101. package/dist/server/src/preview/constants.d.ts.map +1 -0
  102. package/dist/server/src/preview/controllers/index.d.ts +2 -0
  103. package/dist/server/src/preview/controllers/index.d.ts.map +1 -0
  104. package/dist/server/src/preview/controllers/preview.d.ts +13 -0
  105. package/dist/server/src/preview/controllers/preview.d.ts.map +1 -0
  106. package/dist/server/src/preview/controllers/validation/preview.d.ts +6 -0
  107. package/dist/server/src/preview/controllers/validation/preview.d.ts.map +1 -0
  108. package/dist/server/src/preview/index.d.ts +4 -0
  109. package/dist/server/src/preview/index.d.ts.map +1 -0
  110. package/dist/server/src/preview/routes/index.d.ts +8 -0
  111. package/dist/server/src/preview/routes/index.d.ts.map +1 -0
  112. package/dist/server/src/preview/routes/preview.d.ts +4 -0
  113. package/dist/server/src/preview/routes/preview.d.ts.map +1 -0
  114. package/dist/server/src/preview/services/index.d.ts +15 -0
  115. package/dist/server/src/preview/services/index.d.ts.map +1 -0
  116. package/dist/server/src/preview/services/preview-config.d.ts +30 -0
  117. package/dist/server/src/preview/services/preview-config.d.ts.map +1 -0
  118. package/dist/server/src/preview/services/preview.d.ts +12 -0
  119. package/dist/server/src/preview/services/preview.d.ts.map +1 -0
  120. package/dist/server/src/preview/utils.d.ts +18 -0
  121. package/dist/server/src/preview/utils.d.ts.map +1 -0
  122. package/dist/server/src/routes/index.d.ts.map +1 -1
  123. package/dist/server/src/services/document-metadata.d.ts +8 -8
  124. package/dist/server/src/services/document-metadata.d.ts.map +1 -1
  125. package/dist/server/src/services/index.d.ts +4 -4
  126. package/dist/server/src/services/index.d.ts.map +1 -1
  127. package/dist/server/src/services/utils/configuration/index.d.ts +2 -2
  128. package/dist/server/src/services/utils/configuration/layouts.d.ts +2 -2
  129. package/dist/server/src/utils/index.d.ts +2 -0
  130. package/dist/server/src/utils/index.d.ts.map +1 -1
  131. package/dist/shared/contracts/index.d.ts +1 -0
  132. package/dist/shared/contracts/index.d.ts.map +1 -1
  133. package/dist/shared/contracts/preview.d.ts +27 -0
  134. package/dist/shared/contracts/preview.d.ts.map +1 -0
  135. package/dist/shared/index.js +4 -0
  136. package/dist/shared/index.js.map +1 -1
  137. package/dist/shared/index.mjs +4 -0
  138. package/dist/shared/index.mjs.map +1 -1
  139. package/package.json +10 -10
  140. package/dist/_chunks/EditViewPage-Co2IKQZH.js.map +0 -1
  141. package/dist/_chunks/EditViewPage-HYljoEY7.mjs.map +0 -1
  142. package/dist/_chunks/Field-BOPUMZ1u.mjs.map +0 -1
  143. package/dist/_chunks/Field-G9CkFUtP.js.map +0 -1
  144. package/dist/_chunks/Form-CDwNp7pU.mjs.map +0 -1
  145. package/dist/_chunks/Form-crsbkGxI.js.map +0 -1
  146. package/dist/_chunks/History-BDZrgfZ3.mjs.map +0 -1
  147. package/dist/_chunks/History-CWcM9HnW.js.map +0 -1
  148. package/dist/_chunks/ListViewPage-BBAC9aPu.js.map +0 -1
  149. package/dist/_chunks/Relations-Dmv0Tpe5.mjs.map +0 -1
  150. package/dist/_chunks/Relations-jwuTFGOV.js.map +0 -1
  151. package/dist/_chunks/index-BmUAydCA.mjs.map +0 -1
  152. package/dist/_chunks/index-CBX6KyXv.js.map +0 -1
  153. package/dist/_chunks/relations-DIjTADIu.js.map +0 -1
  154. package/dist/_chunks/relations-op89RClB.mjs.map +0 -1
@@ -1,9 +1,10 @@
1
- import { More, Cross, WarningCircle, ListPlus, Pencil, Trash, Check, CrossCircle, CheckCircle, ArrowsCounterClockwise, ChevronRight, Duplicate, ClockCounterClockwise, Feather } from "@strapi/icons";
1
+ import { More, Cross, WarningCircle, ListPlus, Pencil, Trash, Check, CrossCircle, CheckCircle, ArrowsCounterClockwise, ChevronRight, Duplicate, ClockCounterClockwise, Link as Link$1, Feather } from "@strapi/icons";
2
2
  import { jsx, Fragment, jsxs } from "react/jsx-runtime";
3
- import { useStrapiApp, createContext, useAuth, useRBAC, Page, adminApi, translatedErrors, useNotification, useAPIErrorHandler, useQueryParams, getYupValidationErrors, useForm, useTracking, useGuidedTour, BackButton, DescriptionComponentRenderer, useTable, Table } from "@strapi/admin/strapi-admin";
3
+ import { useStrapiApp, createContext, useQueryParams, useAuth, useRBAC, Page, adminApi, translatedErrors, useNotification, useAPIErrorHandler, getYupValidationErrors, useForm, useTracking, useGuidedTour, BackButton, DescriptionComponentRenderer, useTable, Table, useClipboard } from "@strapi/admin/strapi-admin";
4
4
  import * as React from "react";
5
5
  import { lazy } from "react";
6
6
  import { Button, Menu, VisuallyHidden, Flex, Typography, Dialog, Modal, Radio, Status, Box, SingleSelect, SingleSelectOption, IconButton, Loader, Tooltip, LinkButton } from "@strapi/design-system";
7
+ import mapValues from "lodash/fp/mapValues";
7
8
  import { useIntl } from "react-intl";
8
9
  import { useParams, useNavigate, Navigate, useMatch, useLocation, Link, NavLink } from "react-router-dom";
9
10
  import * as yup from "yup";
@@ -100,6 +101,7 @@ const DocumentRBAC = ({ children, permissions }) => {
100
101
  if (!slug) {
101
102
  throw new Error("Cannot find the slug param in the URL");
102
103
  }
104
+ const [{ rawQuery }] = useQueryParams();
103
105
  const userPermissions = useAuth("DocumentRBAC", (state) => state.permissions);
104
106
  const contentTypePermissions = React.useMemo(() => {
105
107
  const contentTypePermissions2 = userPermissions.filter(
@@ -110,7 +112,14 @@ const DocumentRBAC = ({ children, permissions }) => {
110
112
  return { ...acc, [action]: [permission] };
111
113
  }, {});
112
114
  }, [slug, userPermissions]);
113
- const { isLoading, allowedActions } = useRBAC(contentTypePermissions, permissions ?? void 0);
115
+ const { isLoading, allowedActions } = useRBAC(
116
+ contentTypePermissions,
117
+ permissions ?? void 0,
118
+ // TODO: useRBAC context should be typed and built differently
119
+ // We are passing raw query as context to the hook so that it can
120
+ // rely on the locale provided from DocumentRBAC for its permission calculations.
121
+ rawQuery
122
+ );
114
123
  const canCreateFields = !isLoading && allowedActions.canCreate ? extractAndDedupeFields(contentTypePermissions.create) : [];
115
124
  const canReadFields = !isLoading && allowedActions.canRead ? extractAndDedupeFields(contentTypePermissions.read) : [];
116
125
  const canUpdateFields = !isLoading && allowedActions.canUpdate ? extractAndDedupeFields(contentTypePermissions.update) : [];
@@ -461,6 +470,24 @@ const buildValidParams = (query) => {
461
470
  const isBaseQueryError = (error) => {
462
471
  return error.name !== void 0;
463
472
  };
473
+ const arrayValidator = (attribute, options) => ({
474
+ message: translatedErrors.required,
475
+ test(value) {
476
+ if (options.status === "draft") {
477
+ return true;
478
+ }
479
+ if (!attribute.required) {
480
+ return true;
481
+ }
482
+ if (!value) {
483
+ return false;
484
+ }
485
+ if (Array.isArray(value) && value.length === 0) {
486
+ return false;
487
+ }
488
+ return true;
489
+ }
490
+ });
464
491
  const createYupSchema = (attributes = {}, components = {}, options = { status: null }) => {
465
492
  const createModelSchema = (attributes2) => yup.object().shape(
466
493
  Object.entries(attributes2).reduce((acc, [name, attribute]) => {
@@ -468,6 +495,7 @@ const createYupSchema = (attributes = {}, components = {}, options = { status: n
468
495
  return acc;
469
496
  }
470
497
  const validations = [
498
+ addNullableValidation,
471
499
  addRequiredValidation,
472
500
  addMinLengthValidation,
473
501
  addMaxLengthValidation,
@@ -484,12 +512,12 @@ const createYupSchema = (attributes = {}, components = {}, options = { status: n
484
512
  ...acc,
485
513
  [name]: transformSchema(
486
514
  yup.array().of(createModelSchema(attributes3).nullable(false))
487
- )
515
+ ).test(arrayValidator(attribute, options))
488
516
  };
489
517
  } else {
490
518
  return {
491
519
  ...acc,
492
- [name]: transformSchema(createModelSchema(attributes3))
520
+ [name]: transformSchema(createModelSchema(attributes3).nullable())
493
521
  };
494
522
  }
495
523
  }
@@ -511,7 +539,7 @@ const createYupSchema = (attributes = {}, components = {}, options = { status: n
511
539
  }
512
540
  )
513
541
  )
514
- )
542
+ ).test(arrayValidator(attribute, options))
515
543
  };
516
544
  case "relation":
517
545
  return {
@@ -523,7 +551,7 @@ const createYupSchema = (attributes = {}, components = {}, options = { status: n
523
551
  } else if (Array.isArray(value)) {
524
552
  return yup.array().of(
525
553
  yup.object().shape({
526
- id: yup.string().required()
554
+ id: yup.number().required()
527
555
  })
528
556
  );
529
557
  } else if (typeof value === "object") {
@@ -609,17 +637,17 @@ const nullableSchema = (schema) => {
609
637
  schema
610
638
  );
611
639
  };
640
+ const addNullableValidation = () => (schema) => {
641
+ return nullableSchema(schema);
642
+ };
612
643
  const addRequiredValidation = (attribute, options) => (schema) => {
613
- if (options.status === "draft") {
614
- return nullableSchema(schema);
615
- }
616
- if ((attribute.type === "component" && attribute.repeatable || attribute.type === "dynamiczone") && attribute.required && "min" in schema) {
617
- return schema.min(1, translatedErrors.required);
644
+ if (options.status === "draft" || !attribute.required) {
645
+ return schema;
618
646
  }
619
- if (attribute.required && attribute.type !== "relation") {
647
+ if (attribute.required && "required" in schema) {
620
648
  return schema.required(translatedErrors.required);
621
649
  }
622
- return nullableSchema(schema);
650
+ return schema;
623
651
  };
624
652
  const addMinLengthValidation = (attribute, options) => (schema) => {
625
653
  if (options.status === "draft") {
@@ -647,31 +675,12 @@ const addMaxLengthValidation = (attribute) => (schema) => {
647
675
  return schema;
648
676
  };
649
677
  const addMinValidation = (attribute, options) => (schema) => {
650
- if ("min" in attribute) {
678
+ if (options.status === "draft") {
679
+ return schema;
680
+ }
681
+ if ("min" in attribute && "min" in schema) {
651
682
  const min = toInteger(attribute.min);
652
- if (attribute.type === "component" && attribute.repeatable || attribute.type === "dynamiczone") {
653
- if (options.status !== "draft" && !attribute.required && "test" in schema && min) {
654
- return schema.test(
655
- "custom-min",
656
- {
657
- ...translatedErrors.min,
658
- values: {
659
- min: attribute.min
660
- }
661
- },
662
- (value) => {
663
- if (!value) {
664
- return true;
665
- }
666
- if (Array.isArray(value) && value.length === 0) {
667
- return true;
668
- }
669
- return value.length >= min;
670
- }
671
- );
672
- }
673
- }
674
- if ("min" in schema && min) {
683
+ if (min) {
675
684
  return schema.min(min, {
676
685
  ...translatedErrors.min,
677
686
  values: {
@@ -960,9 +969,10 @@ const formatEditLayout = (data, {
960
969
  currentPanelIndex += 2;
961
970
  } else {
962
971
  if (!panels[currentPanelIndex]) {
963
- panels.push([]);
972
+ panels.push([row]);
973
+ } else {
974
+ panels[currentPanelIndex].push(row);
964
975
  }
965
- panels[currentPanelIndex].push(row);
966
976
  }
967
977
  return panels;
968
978
  }, []);
@@ -1144,11 +1154,13 @@ const useDocument = (args, opts) => {
1144
1154
  [validationSchema]
1145
1155
  );
1146
1156
  const isLoading = isLoadingDocument || isFetchingDocument || isLoadingSchema;
1157
+ const hasError = !!error;
1147
1158
  return {
1148
1159
  components,
1149
1160
  document: data?.data,
1150
1161
  meta: data?.meta,
1151
1162
  isLoading,
1163
+ hasError,
1152
1164
  schema,
1153
1165
  schemas,
1154
1166
  validate
@@ -1164,16 +1176,18 @@ const useDoc = () => {
1164
1176
  if (!slug) {
1165
1177
  throw new Error("Could not find model in url params");
1166
1178
  }
1179
+ const document = useDocument(
1180
+ { documentId: origin || id, model: slug, collectionType, params },
1181
+ {
1182
+ skip: id === "create" || !origin && !id && collectionType !== SINGLE_TYPES
1183
+ }
1184
+ );
1185
+ const returnId = origin || id === "create" ? void 0 : id;
1167
1186
  return {
1168
1187
  collectionType,
1169
1188
  model: slug,
1170
- id: origin || id === "create" ? void 0 : id,
1171
- ...useDocument(
1172
- { documentId: origin || id, model: slug, collectionType, params },
1173
- {
1174
- skip: id === "create" || !origin && !id && collectionType !== SINGLE_TYPES
1175
- }
1176
- )
1189
+ id: returnId,
1190
+ ...document
1177
1191
  };
1178
1192
  };
1179
1193
  const useContentManagerContext = () => {
@@ -1216,9 +1230,6 @@ const useContentManagerContext = () => {
1216
1230
  };
1217
1231
  };
1218
1232
  const prefixPluginTranslations = (trad, pluginId) => {
1219
- if (!pluginId) {
1220
- throw new TypeError("pluginId can't be empty");
1221
- }
1222
1233
  return Object.keys(trad).reduce((acc, current) => {
1223
1234
  acc[`${pluginId}.${current}`] = trad[current];
1224
1235
  return acc;
@@ -1653,7 +1664,7 @@ const useDocumentActions = () => {
1653
1664
  };
1654
1665
  };
1655
1666
  const ProtectedHistoryPage = lazy(
1656
- () => import("./History-BDZrgfZ3.mjs").then((mod) => ({ default: mod.ProtectedHistoryPage }))
1667
+ () => import("./History-BevwkPO1.mjs").then((mod) => ({ default: mod.ProtectedHistoryPage }))
1657
1668
  );
1658
1669
  const routes$1 = [
1659
1670
  {
@@ -1666,31 +1677,31 @@ const routes$1 = [
1666
1677
  }
1667
1678
  ];
1668
1679
  const ProtectedEditViewPage = lazy(
1669
- () => import("./EditViewPage-HYljoEY7.mjs").then((mod) => ({ default: mod.ProtectedEditViewPage }))
1680
+ () => import("./EditViewPage-RXrFLav2.mjs").then((mod) => ({ default: mod.ProtectedEditViewPage }))
1670
1681
  );
1671
1682
  const ProtectedListViewPage = lazy(
1672
- () => import("./ListViewPage-CsX7tWx-.mjs").then((mod) => ({ default: mod.ProtectedListViewPage }))
1683
+ () => import("./ListViewPage-C1PyuYRS.mjs").then((mod) => ({ default: mod.ProtectedListViewPage }))
1673
1684
  );
1674
1685
  const ProtectedListConfiguration = lazy(
1675
- () => import("./ListConfigurationPage-BZ3ScUna.mjs").then((mod) => ({
1686
+ () => import("./ListConfigurationPage-DNfZDtDA.mjs").then((mod) => ({
1676
1687
  default: mod.ProtectedListConfiguration
1677
1688
  }))
1678
1689
  );
1679
1690
  const ProtectedEditConfigurationPage = lazy(
1680
- () => import("./EditConfigurationPage-CZofxSLy.mjs").then((mod) => ({
1691
+ () => import("./EditConfigurationPage-DqL8Pq5r.mjs").then((mod) => ({
1681
1692
  default: mod.ProtectedEditConfigurationPage
1682
1693
  }))
1683
1694
  );
1684
1695
  const ProtectedComponentConfigurationPage = lazy(
1685
- () => import("./ComponentConfigurationPage-DJ5voqEK.mjs").then((mod) => ({
1696
+ () => import("./ComponentConfigurationPage-TYDPg5WG.mjs").then((mod) => ({
1686
1697
  default: mod.ProtectedComponentConfigurationPage
1687
1698
  }))
1688
1699
  );
1689
1700
  const NoPermissions = lazy(
1690
- () => import("./NoPermissionsPage-S4Re3FwO.mjs").then((mod) => ({ default: mod.NoPermissions }))
1701
+ () => import("./NoPermissionsPage-8BM-LWta.mjs").then((mod) => ({ default: mod.NoPermissions }))
1691
1702
  );
1692
1703
  const NoContentType = lazy(
1693
- () => import("./NoContentTypePage-LClTUPWs.mjs").then((mod) => ({ default: mod.NoContentType }))
1704
+ () => import("./NoContentTypePage-C9q744z1.mjs").then((mod) => ({ default: mod.NoContentType }))
1694
1705
  );
1695
1706
  const CollectionTypePages = () => {
1696
1707
  const { collectionType } = useParams();
@@ -2044,6 +2055,18 @@ const DocumentActionModal = ({
2044
2055
  typeof Footer === "function" ? /* @__PURE__ */ jsx(Footer, { onClose: handleClose }) : Footer
2045
2056
  ] }) });
2046
2057
  };
2058
+ const transformData = (data) => {
2059
+ if (Array.isArray(data)) {
2060
+ return data.map(transformData);
2061
+ }
2062
+ if (typeof data === "object" && data !== null) {
2063
+ if ("apiData" in data) {
2064
+ return data.apiData;
2065
+ }
2066
+ return mapValues(transformData)(data);
2067
+ }
2068
+ return data;
2069
+ };
2047
2070
  const PublishAction$1 = ({
2048
2071
  activeTab,
2049
2072
  documentId,
@@ -2137,7 +2160,9 @@ const PublishAction$1 = ({
2137
2160
  const performPublish = async () => {
2138
2161
  setSubmitting(true);
2139
2162
  try {
2140
- const { errors } = await validate();
2163
+ const { errors } = await validate(true, {
2164
+ status: "published"
2165
+ });
2141
2166
  if (errors) {
2142
2167
  toggleNotification({
2143
2168
  type: "danger",
@@ -2155,7 +2180,7 @@ const PublishAction$1 = ({
2155
2180
  documentId,
2156
2181
  params
2157
2182
  },
2158
- formValues
2183
+ transformData(formValues)
2159
2184
  );
2160
2185
  if ("data" in res && collectionType !== SINGLE_TYPES) {
2161
2186
  navigate({
@@ -2251,18 +2276,18 @@ const UpdateAction = ({
2251
2276
  onClick: async () => {
2252
2277
  setSubmitting(true);
2253
2278
  try {
2254
- if (activeTab !== "draft") {
2255
- const { errors } = await validate();
2256
- if (errors) {
2257
- toggleNotification({
2258
- type: "danger",
2259
- message: formatMessage({
2260
- id: "content-manager.validation.error",
2261
- defaultMessage: "There are validation errors in your document. Please fix them before saving."
2262
- })
2263
- });
2264
- return;
2265
- }
2279
+ const { errors } = await validate(true, {
2280
+ status: "draft"
2281
+ });
2282
+ if (errors) {
2283
+ toggleNotification({
2284
+ type: "danger",
2285
+ message: formatMessage({
2286
+ id: "content-manager.validation.error",
2287
+ defaultMessage: "There are validation errors in your document. Please fix them before saving."
2288
+ })
2289
+ });
2290
+ return;
2266
2291
  }
2267
2292
  if (isCloning) {
2268
2293
  const res = await clone(
@@ -2271,7 +2296,7 @@ const UpdateAction = ({
2271
2296
  documentId: cloneMatch.params.origin,
2272
2297
  params
2273
2298
  },
2274
- document
2299
+ transformData(document)
2275
2300
  );
2276
2301
  if ("data" in res) {
2277
2302
  navigate(
@@ -2292,7 +2317,7 @@ const UpdateAction = ({
2292
2317
  documentId,
2293
2318
  params
2294
2319
  },
2295
- document
2320
+ transformData(document)
2296
2321
  );
2297
2322
  if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
2298
2323
  setErrors(formatValidationErrors(res.error));
@@ -2305,7 +2330,7 @@ const UpdateAction = ({
2305
2330
  model,
2306
2331
  params
2307
2332
  },
2308
- document
2333
+ transformData(document)
2309
2334
  );
2310
2335
  if ("data" in res && collectionType !== SINGLE_TYPES) {
2311
2336
  navigate(
@@ -2644,12 +2669,12 @@ const Information = ({ activeTab }) => {
2644
2669
  isDisplayed: !!publishDocument?.[PUBLISHED_AT_ATTRIBUTE_NAME],
2645
2670
  label: formatMessage({
2646
2671
  id: "content-manager.containers.edit.information.last-published.label",
2647
- defaultMessage: "Last published"
2672
+ defaultMessage: "Published"
2648
2673
  }),
2649
2674
  value: formatMessage(
2650
2675
  {
2651
2676
  id: "content-manager.containers.edit.information.last-published.value",
2652
- defaultMessage: `Published {time}{isAnonymous, select, true {} other { by {author}}}`
2677
+ defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
2653
2678
  },
2654
2679
  {
2655
2680
  time: /* @__PURE__ */ jsx(RelativeTime, { timestamp: new Date(publishDocument?.[PUBLISHED_AT_ATTRIBUTE_NAME]) }),
@@ -2662,12 +2687,12 @@ const Information = ({ activeTab }) => {
2662
2687
  isDisplayed: !!createAndUpdateDocument?.[UPDATED_AT_ATTRIBUTE_NAME],
2663
2688
  label: formatMessage({
2664
2689
  id: "content-manager.containers.edit.information.last-draft.label",
2665
- defaultMessage: "Last draft"
2690
+ defaultMessage: "Updated"
2666
2691
  }),
2667
2692
  value: formatMessage(
2668
2693
  {
2669
2694
  id: "content-manager.containers.edit.information.last-draft.value",
2670
- defaultMessage: `Modified {time}{isAnonymous, select, true {} other { by {author}}}`
2695
+ defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
2671
2696
  },
2672
2697
  {
2673
2698
  time: /* @__PURE__ */ jsx(
@@ -2685,12 +2710,12 @@ const Information = ({ activeTab }) => {
2685
2710
  isDisplayed: !!createAndUpdateDocument?.[CREATED_AT_ATTRIBUTE_NAME],
2686
2711
  label: formatMessage({
2687
2712
  id: "content-manager.containers.edit.information.document.label",
2688
- defaultMessage: "Document"
2713
+ defaultMessage: "Created"
2689
2714
  }),
2690
2715
  value: formatMessage(
2691
2716
  {
2692
2717
  id: "content-manager.containers.edit.information.document.value",
2693
- defaultMessage: `Created {time}{isAnonymous, select, true {} other { by {author}}}`
2718
+ defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
2694
2719
  },
2695
2720
  {
2696
2721
  time: /* @__PURE__ */ jsx(
@@ -2748,10 +2773,9 @@ const HeaderActions = ({ actions: actions2 }) => {
2748
2773
  SingleSelect,
2749
2774
  {
2750
2775
  size: "S",
2751
- disabled: action.disabled,
2752
- "aria-label": action.label,
2753
2776
  onChange: action.onSelect,
2754
- value: action.value,
2777
+ "aria-label": action.label,
2778
+ ...action,
2755
2779
  children: action.options.map(({ label, ...option }) => /* @__PURE__ */ jsx(SingleSelectOption, { ...option, children: label }, option.value))
2756
2780
  },
2757
2781
  action.id
@@ -2994,7 +3018,7 @@ const Panel = React.forwardRef(({ children, title }, ref) => {
2994
3018
  justifyContent: "stretch",
2995
3019
  alignItems: "flex-start",
2996
3020
  children: [
2997
- /* @__PURE__ */ jsx(Typography, { tag: "h2", variant: "sigma", textTransform: "uppercase", children: title }),
3021
+ /* @__PURE__ */ jsx(Typography, { tag: "h2", variant: "sigma", textTransform: "uppercase", textColor: "neutral600", children: title }),
2998
3022
  children
2999
3023
  ]
3000
3024
  }
@@ -3977,6 +4001,97 @@ const { setInitialData } = actions;
3977
4001
  const reducer = combineReducers({
3978
4002
  app: reducer$1
3979
4003
  });
4004
+ const previewApi = contentManagerApi.injectEndpoints({
4005
+ endpoints: (builder) => ({
4006
+ getPreviewUrl: builder.query({
4007
+ query({ query, params }) {
4008
+ return {
4009
+ url: `/content-manager/preview/url/${params.contentType}`,
4010
+ method: "GET",
4011
+ config: {
4012
+ params: query
4013
+ }
4014
+ };
4015
+ }
4016
+ })
4017
+ })
4018
+ });
4019
+ const { useGetPreviewUrlQuery } = previewApi;
4020
+ const PreviewSidePanel = ({ model, documentId, document }) => {
4021
+ const { formatMessage } = useIntl();
4022
+ const { toggleNotification } = useNotification();
4023
+ const { copy } = useClipboard();
4024
+ const { trackUsage } = useTracking();
4025
+ const { data, error } = useGetPreviewUrlQuery({
4026
+ params: {
4027
+ contentType: model
4028
+ },
4029
+ query: {
4030
+ documentId,
4031
+ locale: document?.locale,
4032
+ status: document?.status
4033
+ }
4034
+ });
4035
+ if (!data?.data?.url || error) {
4036
+ return null;
4037
+ }
4038
+ const { url } = data.data;
4039
+ const handleCopyLink = () => {
4040
+ copy(url);
4041
+ toggleNotification({
4042
+ message: formatMessage({
4043
+ id: "content-manager.preview.copy.success",
4044
+ defaultMessage: "Copied preview link"
4045
+ }),
4046
+ type: "success"
4047
+ });
4048
+ };
4049
+ const handleClick = () => {
4050
+ trackUsage("willOpenPreview");
4051
+ };
4052
+ return {
4053
+ title: formatMessage({ id: "content-manager.preview.panel.title", defaultMessage: "Preview" }),
4054
+ content: /* @__PURE__ */ jsxs(Flex, { gap: 2, width: "100%", children: [
4055
+ /* @__PURE__ */ jsx(
4056
+ Button,
4057
+ {
4058
+ variant: "tertiary",
4059
+ tag: Link,
4060
+ to: url,
4061
+ onClick: handleClick,
4062
+ target: "_blank",
4063
+ flex: "auto",
4064
+ children: formatMessage({
4065
+ id: "content-manager.preview.panel.button",
4066
+ defaultMessage: "Open preview"
4067
+ })
4068
+ }
4069
+ ),
4070
+ /* @__PURE__ */ jsx(
4071
+ IconButton,
4072
+ {
4073
+ type: "button",
4074
+ label: formatMessage({
4075
+ id: "preview.copy.label",
4076
+ defaultMessage: "Copy preview link"
4077
+ }),
4078
+ onClick: handleCopyLink,
4079
+ children: /* @__PURE__ */ jsx(Link$1, {})
4080
+ }
4081
+ )
4082
+ ] })
4083
+ };
4084
+ };
4085
+ const FEATURE_ID = "preview";
4086
+ const previewAdmin = {
4087
+ bootstrap(app) {
4088
+ if (!window.strapi.future.isEnabled(FEATURE_ID)) {
4089
+ return;
4090
+ }
4091
+ const contentManagerPluginApis = app.getPlugin("content-manager").apis;
4092
+ contentManagerPluginApis.addEditViewSidePanel([PreviewSidePanel]);
4093
+ }
4094
+ };
3980
4095
  const index = {
3981
4096
  register(app) {
3982
4097
  const cm = new ContentManagerPlugin();
@@ -3996,7 +4111,7 @@ const index = {
3996
4111
  app.router.addRoute({
3997
4112
  path: "content-manager/*",
3998
4113
  lazy: async () => {
3999
- const { Layout } = await import("./layout-ClP-DC72.mjs");
4114
+ const { Layout } = await import("./layout-ykHSe2KQ.mjs");
4000
4115
  return {
4001
4116
  Component: Layout
4002
4117
  };
@@ -4009,11 +4124,14 @@ const index = {
4009
4124
  if (typeof historyAdmin.bootstrap === "function") {
4010
4125
  historyAdmin.bootstrap(app);
4011
4126
  }
4127
+ if (typeof previewAdmin.bootstrap === "function") {
4128
+ previewAdmin.bootstrap(app);
4129
+ }
4012
4130
  },
4013
4131
  async registerTrads({ locales }) {
4014
4132
  const importedTrads = await Promise.all(
4015
4133
  locales.map((locale) => {
4016
- return __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/ar.json": () => import("./ar-CCEVvqGG.mjs"), "./translations/ca.json": () => import("./ca-5U32ON2v.mjs"), "./translations/cs.json": () => import("./cs-CM2aBUar.mjs"), "./translations/de.json": () => import("./de-C72KDNOl.mjs"), "./translations/en.json": () => import("./en-C8YBvRrK.mjs"), "./translations/es.json": () => import("./es-CeXiYflN.mjs"), "./translations/eu.json": () => import("./eu-CdALomew.mjs"), "./translations/fr.json": () => import("./fr-CD9VFbPM.mjs"), "./translations/gu.json": () => import("./gu-CNpaMDpH.mjs"), "./translations/hi.json": () => import("./hi-Dwvd04m3.mjs"), "./translations/hu.json": () => import("./hu-CeYvaaO0.mjs"), "./translations/id.json": () => import("./id-BtwA9WJT.mjs"), "./translations/it.json": () => import("./it-BrVPqaf1.mjs"), "./translations/ja.json": () => import("./ja-CtsUxOvk.mjs"), "./translations/ko.json": () => import("./ko-HVQRlfUI.mjs"), "./translations/ml.json": () => import("./ml-BihZwQit.mjs"), "./translations/ms.json": () => import("./ms-m_WjyWx7.mjs"), "./translations/nl.json": () => import("./nl-D4R9gHx5.mjs"), "./translations/pl.json": () => import("./pl-sbx9mSt_.mjs"), "./translations/pt-BR.json": () => import("./pt-BR-C71iDxnh.mjs"), "./translations/pt.json": () => import("./pt-BsaFvS8-.mjs"), "./translations/ru.json": () => import("./ru-BE6A4Exp.mjs"), "./translations/sa.json": () => import("./sa-Dag0k-Z8.mjs"), "./translations/sk.json": () => import("./sk-BFg-R8qJ.mjs"), "./translations/sv.json": () => import("./sv-CUnfWGsh.mjs"), "./translations/th.json": () => import("./th-BqbI8lIT.mjs"), "./translations/tr.json": () => import("./tr-CgeK3wJM.mjs"), "./translations/uk.json": () => import("./uk-CR-zDhAY.mjs"), "./translations/vi.json": () => import("./vi-DUXIk_fw.mjs"), "./translations/zh-Hans.json": () => import("./zh-Hans-BPQcRIyH.mjs"), "./translations/zh.json": () => import("./zh-BWZspA60.mjs") }), `./translations/${locale}.json`).then(({ default: data }) => {
4134
+ return __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/ar.json": () => import("./ar-CCEVvqGG.mjs"), "./translations/ca.json": () => import("./ca-5U32ON2v.mjs"), "./translations/cs.json": () => import("./cs-CM2aBUar.mjs"), "./translations/de.json": () => import("./de-C72KDNOl.mjs"), "./translations/en.json": () => import("./en-CZw4xdPY.mjs"), "./translations/es.json": () => import("./es-D34tqjMw.mjs"), "./translations/eu.json": () => import("./eu-CdALomew.mjs"), "./translations/fr.json": () => import("./fr--pg5jUbt.mjs"), "./translations/gu.json": () => import("./gu-CNpaMDpH.mjs"), "./translations/hi.json": () => import("./hi-Dwvd04m3.mjs"), "./translations/hu.json": () => import("./hu-CeYvaaO0.mjs"), "./translations/id.json": () => import("./id-BtwA9WJT.mjs"), "./translations/it.json": () => import("./it-BrVPqaf1.mjs"), "./translations/ja.json": () => import("./ja-BHqhDq4V.mjs"), "./translations/ko.json": () => import("./ko-HVQRlfUI.mjs"), "./translations/ml.json": () => import("./ml-BihZwQit.mjs"), "./translations/ms.json": () => import("./ms-m_WjyWx7.mjs"), "./translations/nl.json": () => import("./nl-D4R9gHx5.mjs"), "./translations/pl.json": () => import("./pl-sbx9mSt_.mjs"), "./translations/pt-BR.json": () => import("./pt-BR-C71iDxnh.mjs"), "./translations/pt.json": () => import("./pt-BsaFvS8-.mjs"), "./translations/ru.json": () => import("./ru-BE6A4Exp.mjs"), "./translations/sa.json": () => import("./sa-Dag0k-Z8.mjs"), "./translations/sk.json": () => import("./sk-BFg-R8qJ.mjs"), "./translations/sv.json": () => import("./sv-CUnfWGsh.mjs"), "./translations/th.json": () => import("./th-BqbI8lIT.mjs"), "./translations/tr.json": () => import("./tr-CgeK3wJM.mjs"), "./translations/uk.json": () => import("./uk-CR-zDhAY.mjs"), "./translations/vi.json": () => import("./vi-DUXIk_fw.mjs"), "./translations/zh-Hans.json": () => import("./zh-Hans-BPQcRIyH.mjs"), "./translations/zh.json": () => import("./zh-BWZspA60.mjs") }), `./translations/${locale}.json`).then(({ default: data }) => {
4017
4135
  return {
4018
4136
  data: prefixPluginTranslations(data, PLUGIN_ID),
4019
4137
  locale
@@ -4074,4 +4192,4 @@ export {
4074
4192
  capitalise as y,
4075
4193
  useUpdateContentTypeConfigurationMutation as z
4076
4194
  };
4077
- //# sourceMappingURL=index-BmUAydCA.mjs.map
4195
+ //# sourceMappingURL=index-BvGihCJp.mjs.map