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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (182) hide show
  1. package/dist/_chunks/{ComponentConfigurationPage-DyDkPajU.js → ComponentConfigurationPage-BaGEn2nd.js} +4 -4
  2. package/dist/_chunks/{ComponentConfigurationPage-DyDkPajU.js.map → ComponentConfigurationPage-BaGEn2nd.js.map} +1 -1
  3. package/dist/_chunks/{ComponentConfigurationPage-9lRmRdIr.mjs → ComponentConfigurationPage-EIYRzIr6.mjs} +4 -4
  4. package/dist/_chunks/{ComponentConfigurationPage-9lRmRdIr.mjs.map → ComponentConfigurationPage-EIYRzIr6.mjs.map} +1 -1
  5. package/dist/_chunks/{EditConfigurationPage-DValmA0m.js → EditConfigurationPage-BQGdJb6Z.js} +4 -4
  6. package/dist/_chunks/{EditConfigurationPage-DValmA0m.js.map → EditConfigurationPage-BQGdJb6Z.js.map} +1 -1
  7. package/dist/_chunks/{EditConfigurationPage-Bk893vVY.mjs → EditConfigurationPage-ByaNUj_q.mjs} +4 -4
  8. package/dist/_chunks/{EditConfigurationPage-Bk893vVY.mjs.map → EditConfigurationPage-ByaNUj_q.mjs.map} +1 -1
  9. package/dist/_chunks/{EditViewPage-DiNFdFqP.mjs → EditViewPage-BgeC8L9X.mjs} +50 -10
  10. package/dist/_chunks/EditViewPage-BgeC8L9X.mjs.map +1 -0
  11. package/dist/_chunks/{EditViewPage-Dk7Eaft4.js → EditViewPage-s_qVLiC6.js} +49 -9
  12. package/dist/_chunks/EditViewPage-s_qVLiC6.js.map +1 -0
  13. package/dist/_chunks/{Field-DH2OaqUP.js → Field-0AdG2t0D.js} +100 -46
  14. package/dist/_chunks/Field-0AdG2t0D.js.map +1 -0
  15. package/dist/_chunks/{Field-Dv_HTFTa.mjs → Field-DbpDop_h.mjs} +96 -42
  16. package/dist/_chunks/Field-DbpDop_h.mjs.map +1 -0
  17. package/dist/_chunks/{Form-B_dUDizM.js → Form-BpC9hWi-.js} +16 -8
  18. package/dist/_chunks/Form-BpC9hWi-.js.map +1 -0
  19. package/dist/_chunks/{Form-Dy6P4HgH.mjs → Form-Xb-u04dn.mjs} +16 -8
  20. package/dist/_chunks/Form-Xb-u04dn.mjs.map +1 -0
  21. package/dist/_chunks/{History-DrwsD1Vc.mjs → History-DLl10NEN.mjs} +42 -99
  22. package/dist/_chunks/History-DLl10NEN.mjs.map +1 -0
  23. package/dist/_chunks/{History-BT4w83Oa.js → History-sJ61vusJ.js} +40 -97
  24. package/dist/_chunks/History-sJ61vusJ.js.map +1 -0
  25. package/dist/_chunks/{ListConfigurationPage-CuYrMcW3.js → ListConfigurationPage-C00guBjQ.js} +5 -4
  26. package/dist/_chunks/ListConfigurationPage-C00guBjQ.js.map +1 -0
  27. package/dist/_chunks/{ListConfigurationPage-BxIP0jRy.mjs → ListConfigurationPage-mbZQmEZ3.mjs} +6 -5
  28. package/dist/_chunks/ListConfigurationPage-mbZQmEZ3.mjs.map +1 -0
  29. package/dist/_chunks/{ListViewPage-BvpwNur7.js → ListViewPage-DDVpN1ql.js} +53 -19
  30. package/dist/_chunks/ListViewPage-DDVpN1ql.js.map +1 -0
  31. package/dist/_chunks/{ListViewPage-5a1vw-OK.mjs → ListViewPage-iRJ5AUjS.mjs} +49 -15
  32. package/dist/_chunks/ListViewPage-iRJ5AUjS.mjs.map +1 -0
  33. package/dist/_chunks/{NoContentTypePage-UqEiWKkM.js → NoContentTypePage-BvkII4H4.js} +2 -2
  34. package/dist/_chunks/{NoContentTypePage-UqEiWKkM.js.map → NoContentTypePage-BvkII4H4.js.map} +1 -1
  35. package/dist/_chunks/{NoContentTypePage-Bm6tRcd3.mjs → NoContentTypePage-DI8VWkVK.mjs} +2 -2
  36. package/dist/_chunks/{NoContentTypePage-Bm6tRcd3.mjs.map → NoContentTypePage-DI8VWkVK.mjs.map} +1 -1
  37. package/dist/_chunks/{NoPermissionsPage-C_vGRo8Q.js → NoPermissionsPage-BZjHQTpb.js} +2 -2
  38. package/dist/_chunks/{NoPermissionsPage-C_vGRo8Q.js.map → NoPermissionsPage-BZjHQTpb.js.map} +1 -1
  39. package/dist/_chunks/{NoPermissionsPage-BHPqn_tQ.mjs → NoPermissionsPage-DckHN3oZ.mjs} +2 -2
  40. package/dist/_chunks/{NoPermissionsPage-BHPqn_tQ.mjs.map → NoPermissionsPage-DckHN3oZ.mjs.map} +1 -1
  41. package/dist/_chunks/Preview-BDOUHeaW.mjs +267 -0
  42. package/dist/_chunks/Preview-BDOUHeaW.mjs.map +1 -0
  43. package/dist/_chunks/Preview-CS2aV-BU.js +286 -0
  44. package/dist/_chunks/Preview-CS2aV-BU.js.map +1 -0
  45. package/dist/_chunks/{Relations-CznVF6LS.js → Relations-DEIQO39t.js} +71 -35
  46. package/dist/_chunks/Relations-DEIQO39t.js.map +1 -0
  47. package/dist/_chunks/{Relations-C7fPyh5P.mjs → Relations-J-8HC3zX.mjs} +72 -36
  48. package/dist/_chunks/Relations-J-8HC3zX.mjs.map +1 -0
  49. package/dist/_chunks/{en-CbaIuYoB.mjs → en-CfIXaZf9.mjs} +25 -13
  50. package/dist/_chunks/{en-CbaIuYoB.mjs.map → en-CfIXaZf9.mjs.map} +1 -1
  51. package/dist/_chunks/{en-otD_UBJi.js → en-DTWPCdTS.js} +25 -13
  52. package/dist/_chunks/{en-otD_UBJi.js.map → en-DTWPCdTS.js.map} +1 -1
  53. package/dist/_chunks/{es-EUonQTon.js → es-9K52xZIr.js} +2 -2
  54. package/dist/_chunks/{ja-CcFe8diO.js.map → es-9K52xZIr.js.map} +1 -1
  55. package/dist/_chunks/{es-CeXiYflN.mjs → es-D34tqjMw.mjs} +2 -2
  56. package/dist/_chunks/{es-CeXiYflN.mjs.map → es-D34tqjMw.mjs.map} +1 -1
  57. package/dist/_chunks/{fr-CD9VFbPM.mjs → fr--pg5jUbt.mjs} +13 -3
  58. package/dist/_chunks/{fr-CD9VFbPM.mjs.map → fr--pg5jUbt.mjs.map} +1 -1
  59. package/dist/_chunks/{fr-B7kGGg3E.js → fr-B2Kyv8Z9.js} +13 -3
  60. package/dist/_chunks/{fr-B7kGGg3E.js.map → fr-B2Kyv8Z9.js.map} +1 -1
  61. package/dist/_chunks/{index-BJ6uTqLL.mjs → index-DzTs9ga-.mjs} +1122 -911
  62. package/dist/_chunks/index-DzTs9ga-.mjs.map +1 -0
  63. package/dist/_chunks/{index-D9UmmBcM.js → index-uXHSvmlw.js} +1118 -906
  64. package/dist/_chunks/index-uXHSvmlw.js.map +1 -0
  65. package/dist/_chunks/{ja-CcFe8diO.js → ja-7sfIbjxE.js} +2 -2
  66. package/dist/_chunks/{es-EUonQTon.js.map → ja-7sfIbjxE.js.map} +1 -1
  67. package/dist/_chunks/{ja-CtsUxOvk.mjs → ja-BHqhDq4V.mjs} +2 -2
  68. package/dist/_chunks/{ja-CtsUxOvk.mjs.map → ja-BHqhDq4V.mjs.map} +1 -1
  69. package/dist/_chunks/{layout-uomiIGbG.mjs → layout-BhIZkPuB.mjs} +5 -4
  70. package/dist/_chunks/{layout-uomiIGbG.mjs.map → layout-BhIZkPuB.mjs.map} +1 -1
  71. package/dist/_chunks/{layout-kfu5Wtix.js → layout-zA_F2rU4.js} +5 -4
  72. package/dist/_chunks/{layout-kfu5Wtix.js.map → layout-zA_F2rU4.js.map} +1 -1
  73. package/dist/_chunks/{objects-gigeqt7s.js → objects-BcXOv6_9.js} +2 -4
  74. package/dist/_chunks/{objects-gigeqt7s.js.map → objects-BcXOv6_9.js.map} +1 -1
  75. package/dist/_chunks/{objects-mKMAmfec.mjs → objects-D6yBsdmx.mjs} +2 -4
  76. package/dist/_chunks/{objects-mKMAmfec.mjs.map → objects-D6yBsdmx.mjs.map} +1 -1
  77. package/dist/_chunks/{relations-DiDufGSA.mjs → relations-BoCufH_z.mjs} +6 -7
  78. package/dist/_chunks/relations-BoCufH_z.mjs.map +1 -0
  79. package/dist/_chunks/{relations-DKENrxko.js → relations-DnUyZQaL.js} +6 -7
  80. package/dist/_chunks/relations-DnUyZQaL.js.map +1 -0
  81. package/dist/_chunks/{usePrev-B9w_-eYc.js → useDebounce-CtcjDB3L.js} +14 -1
  82. package/dist/_chunks/useDebounce-CtcjDB3L.js.map +1 -0
  83. package/dist/_chunks/useDebounce-DmuSJIF3.mjs +29 -0
  84. package/dist/_chunks/useDebounce-DmuSJIF3.mjs.map +1 -0
  85. package/dist/admin/index.js +2 -1
  86. package/dist/admin/index.js.map +1 -1
  87. package/dist/admin/index.mjs +4 -3
  88. package/dist/admin/src/exports.d.ts +1 -1
  89. package/dist/admin/src/hooks/useDocument.d.ts +32 -1
  90. package/dist/admin/src/pages/EditView/EditViewPage.d.ts +9 -1
  91. package/dist/admin/src/pages/EditView/components/DocumentStatus.d.ts +2 -2
  92. package/dist/admin/src/pages/EditView/components/Header.d.ts +11 -11
  93. package/dist/admin/src/preview/components/PreviewContent.d.ts +2 -0
  94. package/dist/admin/src/preview/components/PreviewHeader.d.ts +2 -0
  95. package/dist/admin/src/preview/components/PreviewSidePanel.d.ts +3 -0
  96. package/dist/admin/src/preview/constants.d.ts +1 -0
  97. package/dist/admin/src/preview/index.d.ts +4 -0
  98. package/dist/admin/src/preview/pages/Preview.d.ts +11 -0
  99. package/dist/admin/src/preview/routes.d.ts +3 -0
  100. package/dist/admin/src/preview/services/preview.d.ts +3 -0
  101. package/dist/admin/src/router.d.ts +1 -1
  102. package/dist/admin/src/services/documents.d.ts +3 -1
  103. package/dist/server/index.js +378 -162
  104. package/dist/server/index.js.map +1 -1
  105. package/dist/server/index.mjs +378 -162
  106. package/dist/server/index.mjs.map +1 -1
  107. package/dist/server/src/bootstrap.d.ts.map +1 -1
  108. package/dist/server/src/controllers/collection-types.d.ts.map +1 -1
  109. package/dist/server/src/controllers/index.d.ts.map +1 -1
  110. package/dist/server/src/controllers/relations.d.ts.map +1 -1
  111. package/dist/server/src/controllers/utils/metadata.d.ts +15 -1
  112. package/dist/server/src/controllers/utils/metadata.d.ts.map +1 -1
  113. package/dist/server/src/history/services/history.d.ts.map +1 -1
  114. package/dist/server/src/history/services/lifecycles.d.ts.map +1 -1
  115. package/dist/server/src/history/services/utils.d.ts +2 -3
  116. package/dist/server/src/history/services/utils.d.ts.map +1 -1
  117. package/dist/server/src/index.d.ts +4 -4
  118. package/dist/server/src/preview/constants.d.ts +2 -0
  119. package/dist/server/src/preview/constants.d.ts.map +1 -0
  120. package/dist/server/src/preview/controllers/index.d.ts +2 -0
  121. package/dist/server/src/preview/controllers/index.d.ts.map +1 -0
  122. package/dist/server/src/preview/controllers/preview.d.ts +13 -0
  123. package/dist/server/src/preview/controllers/preview.d.ts.map +1 -0
  124. package/dist/server/src/preview/controllers/validation/preview.d.ts +6 -0
  125. package/dist/server/src/preview/controllers/validation/preview.d.ts.map +1 -0
  126. package/dist/server/src/preview/index.d.ts +4 -0
  127. package/dist/server/src/preview/index.d.ts.map +1 -0
  128. package/dist/server/src/preview/routes/index.d.ts +8 -0
  129. package/dist/server/src/preview/routes/index.d.ts.map +1 -0
  130. package/dist/server/src/preview/routes/preview.d.ts +4 -0
  131. package/dist/server/src/preview/routes/preview.d.ts.map +1 -0
  132. package/dist/server/src/preview/services/index.d.ts +15 -0
  133. package/dist/server/src/preview/services/index.d.ts.map +1 -0
  134. package/dist/server/src/preview/services/preview-config.d.ts +30 -0
  135. package/dist/server/src/preview/services/preview-config.d.ts.map +1 -0
  136. package/dist/server/src/preview/services/preview.d.ts +12 -0
  137. package/dist/server/src/preview/services/preview.d.ts.map +1 -0
  138. package/dist/server/src/preview/utils.d.ts +18 -0
  139. package/dist/server/src/preview/utils.d.ts.map +1 -0
  140. package/dist/server/src/routes/index.d.ts.map +1 -1
  141. package/dist/server/src/services/document-manager.d.ts.map +1 -1
  142. package/dist/server/src/services/document-metadata.d.ts +8 -8
  143. package/dist/server/src/services/document-metadata.d.ts.map +1 -1
  144. package/dist/server/src/services/index.d.ts +4 -4
  145. package/dist/server/src/services/index.d.ts.map +1 -1
  146. package/dist/server/src/services/utils/configuration/index.d.ts +2 -2
  147. package/dist/server/src/services/utils/configuration/layouts.d.ts +2 -2
  148. package/dist/server/src/utils/index.d.ts +2 -0
  149. package/dist/server/src/utils/index.d.ts.map +1 -1
  150. package/dist/shared/contracts/collection-types.d.ts +3 -1
  151. package/dist/shared/contracts/collection-types.d.ts.map +1 -1
  152. package/dist/shared/contracts/index.d.ts +1 -0
  153. package/dist/shared/contracts/index.d.ts.map +1 -1
  154. package/dist/shared/contracts/preview.d.ts +27 -0
  155. package/dist/shared/contracts/preview.d.ts.map +1 -0
  156. package/dist/shared/index.js +4 -0
  157. package/dist/shared/index.js.map +1 -1
  158. package/dist/shared/index.mjs +4 -0
  159. package/dist/shared/index.mjs.map +1 -1
  160. package/package.json +14 -14
  161. package/dist/_chunks/EditViewPage-DiNFdFqP.mjs.map +0 -1
  162. package/dist/_chunks/EditViewPage-Dk7Eaft4.js.map +0 -1
  163. package/dist/_chunks/Field-DH2OaqUP.js.map +0 -1
  164. package/dist/_chunks/Field-Dv_HTFTa.mjs.map +0 -1
  165. package/dist/_chunks/Form-B_dUDizM.js.map +0 -1
  166. package/dist/_chunks/Form-Dy6P4HgH.mjs.map +0 -1
  167. package/dist/_chunks/History-BT4w83Oa.js.map +0 -1
  168. package/dist/_chunks/History-DrwsD1Vc.mjs.map +0 -1
  169. package/dist/_chunks/ListConfigurationPage-BxIP0jRy.mjs.map +0 -1
  170. package/dist/_chunks/ListConfigurationPage-CuYrMcW3.js.map +0 -1
  171. package/dist/_chunks/ListViewPage-5a1vw-OK.mjs.map +0 -1
  172. package/dist/_chunks/ListViewPage-BvpwNur7.js.map +0 -1
  173. package/dist/_chunks/Relations-C7fPyh5P.mjs.map +0 -1
  174. package/dist/_chunks/Relations-CznVF6LS.js.map +0 -1
  175. package/dist/_chunks/index-BJ6uTqLL.mjs.map +0 -1
  176. package/dist/_chunks/index-D9UmmBcM.js.map +0 -1
  177. package/dist/_chunks/relations-DKENrxko.js.map +0 -1
  178. package/dist/_chunks/relations-DiDufGSA.mjs.map +0 -1
  179. package/dist/_chunks/usePrev-B9w_-eYc.js.map +0 -1
  180. package/dist/_chunks/usePrev-DH6iah0A.mjs +0 -16
  181. package/dist/_chunks/usePrev-DH6iah0A.mjs.map +0 -1
  182. package/strapi-server.js +0 -3
@@ -1,9 +1,10 @@
1
- import { CrossCircle, More, WarningCircle, ListPlus, Pencil, Trash, Check, CheckCircle, ArrowsCounterClockwise, ChevronRight, Duplicate, ClockCounterClockwise, Feather } from "@strapi/icons";
1
+ import { More, Cross, WarningCircle, ListPlus, Pencil, Trash, Check, CrossCircle, CheckCircle, ArrowsCounterClockwise, ChevronRight, Duplicate, ClockCounterClockwise, 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, getYupValidationErrors, useQueryParams, useTracking, useForm, 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 } from "@strapi/admin/strapi-admin";
4
4
  import * as React from "react";
5
5
  import { lazy } from "react";
6
- import { Button, Menu, VisuallyHidden, Flex, Typography, Dialog, Modal, Radio, Status, Box, SingleSelect, SingleSelectOption, Loader, IconButton, Tooltip, LinkButton } from "@strapi/design-system";
6
+ import { Menu, Button, VisuallyHidden, Flex, Dialog, Modal, Typography, 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 { styled } from "styled-components";
@@ -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: {
@@ -789,19 +798,115 @@ const extractContentTypeComponents = (attributes = {}, allComponents = {}) => {
789
798
  }, {});
790
799
  return componentsByKey;
791
800
  };
792
- const useDocument = (args, opts) => {
801
+ const HOOKS = {
802
+ /**
803
+ * Hook that allows to mutate the displayed headers of the list view table
804
+ * @constant
805
+ * @type {string}
806
+ */
807
+ INJECT_COLUMN_IN_TABLE: "Admin/CM/pages/ListView/inject-column-in-table",
808
+ /**
809
+ * Hook that allows to mutate the CM's collection types links pre-set filters
810
+ * @constant
811
+ * @type {string}
812
+ */
813
+ MUTATE_COLLECTION_TYPES_LINKS: "Admin/CM/pages/App/mutate-collection-types-links",
814
+ /**
815
+ * Hook that allows to mutate the CM's edit view layout
816
+ * @constant
817
+ * @type {string}
818
+ */
819
+ MUTATE_EDIT_VIEW_LAYOUT: "Admin/CM/pages/EditView/mutate-edit-view-layout",
820
+ /**
821
+ * Hook that allows to mutate the CM's single types links pre-set filters
822
+ * @constant
823
+ * @type {string}
824
+ */
825
+ MUTATE_SINGLE_TYPES_LINKS: "Admin/CM/pages/App/mutate-single-types-links"
826
+ };
827
+ const contentTypesApi = contentManagerApi.injectEndpoints({
828
+ endpoints: (builder) => ({
829
+ getContentTypeConfiguration: builder.query({
830
+ query: (uid) => ({
831
+ url: `/content-manager/content-types/${uid}/configuration`,
832
+ method: "GET"
833
+ }),
834
+ transformResponse: (response) => response.data,
835
+ providesTags: (_result, _error, uid) => [
836
+ { type: "ContentTypesConfiguration", id: uid },
837
+ { type: "ContentTypeSettings", id: "LIST" }
838
+ ]
839
+ }),
840
+ getAllContentTypeSettings: builder.query({
841
+ query: () => "/content-manager/content-types-settings",
842
+ transformResponse: (response) => response.data,
843
+ providesTags: [{ type: "ContentTypeSettings", id: "LIST" }]
844
+ }),
845
+ updateContentTypeConfiguration: builder.mutation({
846
+ query: ({ uid, ...body }) => ({
847
+ url: `/content-manager/content-types/${uid}/configuration`,
848
+ method: "PUT",
849
+ data: body
850
+ }),
851
+ transformResponse: (response) => response.data,
852
+ invalidatesTags: (_result, _error, { uid }) => [
853
+ { type: "ContentTypesConfiguration", id: uid },
854
+ { type: "ContentTypeSettings", id: "LIST" },
855
+ // Is this necessary?
856
+ { type: "InitialData" }
857
+ ]
858
+ })
859
+ })
860
+ });
861
+ const {
862
+ useGetContentTypeConfigurationQuery,
863
+ useGetAllContentTypeSettingsQuery,
864
+ useUpdateContentTypeConfigurationMutation
865
+ } = contentTypesApi;
866
+ const checkIfAttributeIsDisplayable = (attribute) => {
867
+ const { type } = attribute;
868
+ if (type === "relation") {
869
+ return !attribute.relation.toLowerCase().includes("morph");
870
+ }
871
+ return !["json", "dynamiczone", "richtext", "password", "blocks"].includes(type) && !!type;
872
+ };
873
+ const getMainField = (attribute, mainFieldName, { schemas, components }) => {
874
+ if (!mainFieldName) {
875
+ return void 0;
876
+ }
877
+ const mainFieldType = attribute.type === "component" ? components[attribute.component].attributes[mainFieldName].type : (
878
+ // @ts-expect-error – `targetModel` does exist on the attribute for a relation.
879
+ schemas.find((schema) => schema.uid === attribute.targetModel)?.attributes[mainFieldName].type
880
+ );
881
+ return {
882
+ name: mainFieldName,
883
+ type: mainFieldType ?? "string"
884
+ };
885
+ };
886
+ const DEFAULT_SETTINGS = {
887
+ bulkable: false,
888
+ filterable: false,
889
+ searchable: false,
890
+ pagination: false,
891
+ defaultSortBy: "",
892
+ defaultSortOrder: "asc",
893
+ mainField: "id",
894
+ pageSize: 10
895
+ };
896
+ const useDocumentLayout = (model) => {
897
+ const { schema, components } = useDocument({ model, collectionType: "" }, { skip: true });
898
+ const [{ query }] = useQueryParams();
899
+ const runHookWaterfall = useStrapiApp("useDocumentLayout", (state) => state.runHookWaterfall);
793
900
  const { toggleNotification } = useNotification();
794
901
  const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();
902
+ const { isLoading: isLoadingSchemas, schemas } = useContentTypeSchema();
795
903
  const {
796
- currentData: data,
797
- isLoading: isLoadingDocument,
798
- isFetching: isFetchingDocument,
799
- error
800
- } = useGetDocumentQuery(args, {
801
- ...opts,
802
- skip: !args.documentId && args.collectionType !== SINGLE_TYPES || opts?.skip
803
- });
804
- const { components, schema, isLoading: isLoadingSchema } = useContentTypeSchema(args.model);
904
+ data,
905
+ isLoading: isLoadingConfigs,
906
+ error,
907
+ isFetching: isFetchingConfigs
908
+ } = useGetContentTypeConfigurationQuery(model);
909
+ const isLoading = isLoadingSchemas || isFetchingConfigs || isLoadingConfigs;
805
910
  React.useEffect(() => {
806
911
  if (error) {
807
912
  toggleNotification({
@@ -809,396 +914,437 @@ const useDocument = (args, opts) => {
809
914
  message: formatAPIError(error)
810
915
  });
811
916
  }
812
- }, [toggleNotification, error, formatAPIError, args.collectionType]);
813
- const validationSchema = React.useMemo(() => {
814
- if (!schema) {
815
- return null;
816
- }
817
- return createYupSchema(schema.attributes, components);
818
- }, [schema, components]);
819
- const validate = React.useCallback(
820
- (document) => {
821
- if (!validationSchema) {
822
- throw new Error(
823
- "There is no validation schema generated, this is likely due to the schema not being loaded yet."
824
- );
825
- }
826
- try {
827
- validationSchema.validateSync(document, { abortEarly: false, strict: true });
828
- return null;
829
- } catch (error2) {
830
- if (error2 instanceof ValidationError) {
831
- return getYupValidationErrors(error2);
832
- }
833
- throw error2;
834
- }
917
+ }, [error, formatAPIError, toggleNotification]);
918
+ const editLayout = React.useMemo(
919
+ () => data && !isLoading ? formatEditLayout(data, { schemas, schema, components }) : {
920
+ layout: [],
921
+ components: {},
922
+ metadatas: {},
923
+ options: {},
924
+ settings: DEFAULT_SETTINGS
835
925
  },
836
- [validationSchema]
926
+ [data, isLoading, schemas, schema, components]
927
+ );
928
+ const listLayout = React.useMemo(() => {
929
+ return data && !isLoading ? formatListLayout(data, { schemas, schema, components }) : {
930
+ layout: [],
931
+ metadatas: {},
932
+ options: {},
933
+ settings: DEFAULT_SETTINGS
934
+ };
935
+ }, [data, isLoading, schemas, schema, components]);
936
+ const { layout: edit } = React.useMemo(
937
+ () => runHookWaterfall(HOOKS.MUTATE_EDIT_VIEW_LAYOUT, {
938
+ layout: editLayout,
939
+ query
940
+ }),
941
+ [editLayout, query, runHookWaterfall]
837
942
  );
838
- const isLoading = isLoadingDocument || isFetchingDocument || isLoadingSchema;
839
943
  return {
840
- components,
841
- document: data?.data,
842
- meta: data?.meta,
944
+ error,
843
945
  isLoading,
844
- schema,
845
- validate
846
- };
847
- };
848
- const useDoc = () => {
849
- const { id, slug, collectionType, origin } = useParams();
850
- const [{ query }] = useQueryParams();
851
- const params = React.useMemo(() => buildValidParams(query), [query]);
852
- if (!collectionType) {
853
- throw new Error("Could not find collectionType in url params");
854
- }
855
- if (!slug) {
856
- throw new Error("Could not find model in url params");
857
- }
858
- return {
859
- collectionType,
860
- model: slug,
861
- id: origin || id === "create" ? void 0 : id,
862
- ...useDocument(
863
- { documentId: origin || id, model: slug, collectionType, params },
864
- {
865
- skip: id === "create" || !origin && !id && collectionType !== SINGLE_TYPES
866
- }
867
- )
946
+ edit,
947
+ list: listLayout
868
948
  };
869
949
  };
870
- const prefixPluginTranslations = (trad, pluginId) => {
871
- if (!pluginId) {
872
- throw new TypeError("pluginId can't be empty");
873
- }
874
- return Object.keys(trad).reduce((acc, current) => {
875
- acc[`${pluginId}.${current}`] = trad[current];
876
- return acc;
877
- }, {});
878
- };
879
- const getTranslation = (id) => `content-manager.${id}`;
880
- const DEFAULT_UNEXPECTED_ERROR_MSG = {
881
- id: "notification.error",
882
- defaultMessage: "An error occurred, please try again"
950
+ const useDocLayout = () => {
951
+ const { model } = useDoc();
952
+ return useDocumentLayout(model);
883
953
  };
884
- const useDocumentActions = () => {
885
- const { toggleNotification } = useNotification();
886
- const { formatMessage } = useIntl();
887
- const { trackUsage } = useTracking();
888
- const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();
889
- const navigate = useNavigate();
890
- const [deleteDocument] = useDeleteDocumentMutation();
891
- const _delete = React.useCallback(
892
- async ({ collectionType, model, documentId, params }, trackerProperty) => {
893
- try {
894
- trackUsage("willDeleteEntry", trackerProperty);
895
- const res = await deleteDocument({
896
- collectionType,
897
- model,
898
- documentId,
899
- params
900
- });
901
- if ("error" in res) {
902
- toggleNotification({
903
- type: "danger",
904
- message: formatAPIError(res.error)
905
- });
906
- return { error: res.error };
907
- }
908
- toggleNotification({
909
- type: "success",
910
- message: formatMessage({
911
- id: getTranslation("success.record.delete"),
912
- defaultMessage: "Deleted document"
913
- })
914
- });
915
- trackUsage("didDeleteEntry", trackerProperty);
916
- return res.data;
917
- } catch (err) {
918
- toggleNotification({
919
- type: "danger",
920
- message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
921
- });
922
- trackUsage("didNotDeleteEntry", { error: err, ...trackerProperty });
923
- throw err;
954
+ const formatEditLayout = (data, {
955
+ schemas,
956
+ schema,
957
+ components
958
+ }) => {
959
+ let currentPanelIndex = 0;
960
+ const panelledEditAttributes = convertEditLayoutToFieldLayouts(
961
+ data.contentType.layouts.edit,
962
+ schema?.attributes,
963
+ data.contentType.metadatas,
964
+ { configurations: data.components, schemas: components },
965
+ schemas
966
+ ).reduce((panels, row) => {
967
+ if (row.some((field) => field.type === "dynamiczone")) {
968
+ panels.push([row]);
969
+ currentPanelIndex += 2;
970
+ } else {
971
+ if (!panels[currentPanelIndex]) {
972
+ panels.push([row]);
973
+ } else {
974
+ panels[currentPanelIndex].push(row);
924
975
  }
925
- },
926
- [trackUsage, deleteDocument, toggleNotification, formatMessage, formatAPIError]
927
- );
928
- const [deleteManyDocuments] = useDeleteManyDocumentsMutation();
929
- const deleteMany = React.useCallback(
930
- async ({ model, documentIds, params }) => {
931
- try {
932
- trackUsage("willBulkDeleteEntries");
933
- const res = await deleteManyDocuments({
934
- model,
935
- documentIds,
936
- params
937
- });
938
- if ("error" in res) {
939
- toggleNotification({
940
- type: "danger",
941
- message: formatAPIError(res.error)
942
- });
943
- return { error: res.error };
976
+ }
977
+ return panels;
978
+ }, []);
979
+ const componentEditAttributes = Object.entries(data.components).reduce(
980
+ (acc, [uid, configuration]) => {
981
+ acc[uid] = {
982
+ layout: convertEditLayoutToFieldLayouts(
983
+ configuration.layouts.edit,
984
+ components[uid].attributes,
985
+ configuration.metadatas,
986
+ { configurations: data.components, schemas: components }
987
+ ),
988
+ settings: {
989
+ ...configuration.settings,
990
+ icon: components[uid].info.icon,
991
+ displayName: components[uid].info.displayName
944
992
  }
945
- toggleNotification({
946
- type: "success",
947
- title: formatMessage({
948
- id: getTranslation("success.records.delete"),
949
- defaultMessage: "Successfully deleted."
950
- }),
951
- message: ""
952
- });
953
- trackUsage("didBulkDeleteEntries");
954
- return res.data;
955
- } catch (err) {
956
- toggleNotification({
957
- type: "danger",
958
- message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
959
- });
960
- trackUsage("didNotBulkDeleteEntries");
961
- throw err;
962
- }
993
+ };
994
+ return acc;
963
995
  },
964
- [trackUsage, deleteManyDocuments, toggleNotification, formatMessage, formatAPIError]
996
+ {}
965
997
  );
966
- const [discardDocument] = useDiscardDocumentMutation();
967
- const discard = React.useCallback(
968
- async ({ collectionType, model, documentId, params }) => {
969
- try {
970
- const res = await discardDocument({
971
- collectionType,
972
- model,
973
- documentId,
974
- params
975
- });
976
- if ("error" in res) {
977
- toggleNotification({
978
- type: "danger",
979
- message: formatAPIError(res.error)
980
- });
981
- return { error: res.error };
982
- }
983
- toggleNotification({
984
- type: "success",
985
- message: formatMessage({
986
- id: "content-manager.success.record.discard",
987
- defaultMessage: "Changes discarded"
988
- })
989
- });
990
- return res.data;
991
- } catch (err) {
992
- toggleNotification({
993
- type: "danger",
994
- message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
995
- });
996
- throw err;
997
- }
998
+ const editMetadatas = Object.entries(data.contentType.metadatas).reduce(
999
+ (acc, [attribute, metadata]) => {
1000
+ return {
1001
+ ...acc,
1002
+ [attribute]: metadata.edit
1003
+ };
998
1004
  },
999
- [discardDocument, formatAPIError, formatMessage, toggleNotification]
1005
+ {}
1000
1006
  );
1001
- const [publishDocument] = usePublishDocumentMutation();
1002
- const publish = React.useCallback(
1003
- async ({ collectionType, model, documentId, params }, data) => {
1004
- try {
1005
- trackUsage("willPublishEntry");
1006
- const res = await publishDocument({
1007
- collectionType,
1008
- model,
1009
- documentId,
1010
- data,
1011
- params
1012
- });
1013
- if ("error" in res) {
1014
- toggleNotification({ type: "danger", message: formatAPIError(res.error) });
1015
- return { error: res.error };
1016
- }
1017
- trackUsage("didPublishEntry");
1018
- toggleNotification({
1019
- type: "success",
1020
- message: formatMessage({
1021
- id: getTranslation("success.record.publish"),
1022
- defaultMessage: "Published document"
1023
- })
1024
- });
1025
- return res.data;
1026
- } catch (err) {
1027
- toggleNotification({
1028
- type: "danger",
1029
- message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
1030
- });
1031
- throw err;
1032
- }
1007
+ return {
1008
+ layout: panelledEditAttributes,
1009
+ components: componentEditAttributes,
1010
+ metadatas: editMetadatas,
1011
+ settings: {
1012
+ ...data.contentType.settings,
1013
+ displayName: schema?.info.displayName
1033
1014
  },
1034
- [trackUsage, publishDocument, toggleNotification, formatMessage, formatAPIError]
1035
- );
1036
- const [publishManyDocuments] = usePublishManyDocumentsMutation();
1037
- const publishMany = React.useCallback(
1038
- async ({ model, documentIds, params }) => {
1039
- try {
1040
- const res = await publishManyDocuments({
1041
- model,
1042
- documentIds,
1043
- params
1044
- });
1045
- if ("error" in res) {
1046
- toggleNotification({ type: "danger", message: formatAPIError(res.error) });
1047
- return { error: res.error };
1048
- }
1049
- toggleNotification({
1050
- type: "success",
1051
- message: formatMessage({
1052
- id: getTranslation("success.record.publish"),
1053
- defaultMessage: "Published document"
1054
- })
1055
- });
1056
- return res.data;
1057
- } catch (err) {
1058
- toggleNotification({
1059
- type: "danger",
1060
- message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
1061
- });
1062
- throw err;
1015
+ options: {
1016
+ ...schema?.options,
1017
+ ...schema?.pluginOptions,
1018
+ ...data.contentType.options
1019
+ }
1020
+ };
1021
+ };
1022
+ const convertEditLayoutToFieldLayouts = (rows, attributes = {}, metadatas, components, schemas = []) => {
1023
+ return rows.map(
1024
+ (row) => row.map((field) => {
1025
+ const attribute = attributes[field.name];
1026
+ if (!attribute) {
1027
+ return null;
1063
1028
  }
1029
+ const { edit: metadata } = metadatas[field.name];
1030
+ const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
1031
+ return {
1032
+ attribute,
1033
+ disabled: !metadata.editable,
1034
+ hint: metadata.description,
1035
+ label: metadata.label ?? "",
1036
+ name: field.name,
1037
+ // @ts-expect-error – mainField does exist on the metadata for a relation.
1038
+ mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
1039
+ schemas,
1040
+ components: components?.schemas ?? {}
1041
+ }),
1042
+ placeholder: metadata.placeholder ?? "",
1043
+ required: attribute.required ?? false,
1044
+ size: field.size,
1045
+ unique: "unique" in attribute ? attribute.unique : false,
1046
+ visible: metadata.visible ?? true,
1047
+ type: attribute.type
1048
+ };
1049
+ }).filter((field) => field !== null)
1050
+ );
1051
+ };
1052
+ const formatListLayout = (data, {
1053
+ schemas,
1054
+ schema,
1055
+ components
1056
+ }) => {
1057
+ const listMetadatas = Object.entries(data.contentType.metadatas).reduce(
1058
+ (acc, [attribute, metadata]) => {
1059
+ return {
1060
+ ...acc,
1061
+ [attribute]: metadata.list
1062
+ };
1064
1063
  },
1065
- [
1066
- // trackUsage,
1067
- publishManyDocuments,
1068
- toggleNotification,
1069
- formatMessage,
1070
- formatAPIError
1071
- ]
1064
+ {}
1072
1065
  );
1073
- const [updateDocument] = useUpdateDocumentMutation();
1074
- const update = React.useCallback(
1075
- async ({ collectionType, model, documentId, params }, data, trackerProperty) => {
1066
+ const listAttributes = convertListLayoutToFieldLayouts(
1067
+ data.contentType.layouts.list,
1068
+ schema?.attributes,
1069
+ listMetadatas,
1070
+ { configurations: data.components, schemas: components },
1071
+ schemas
1072
+ );
1073
+ return {
1074
+ layout: listAttributes,
1075
+ settings: { ...data.contentType.settings, displayName: schema?.info.displayName },
1076
+ metadatas: listMetadatas,
1077
+ options: {
1078
+ ...schema?.options,
1079
+ ...schema?.pluginOptions,
1080
+ ...data.contentType.options
1081
+ }
1082
+ };
1083
+ };
1084
+ const convertListLayoutToFieldLayouts = (columns, attributes = {}, metadatas, components, schemas = []) => {
1085
+ return columns.map((name) => {
1086
+ const attribute = attributes[name];
1087
+ if (!attribute) {
1088
+ return null;
1089
+ }
1090
+ const metadata = metadatas[name];
1091
+ const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
1092
+ return {
1093
+ attribute,
1094
+ label: metadata.label ?? "",
1095
+ mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
1096
+ schemas,
1097
+ components: components?.schemas ?? {}
1098
+ }),
1099
+ name,
1100
+ searchable: metadata.searchable ?? true,
1101
+ sortable: metadata.sortable ?? true
1102
+ };
1103
+ }).filter((field) => field !== null);
1104
+ };
1105
+ const useDocument = (args, opts) => {
1106
+ const { toggleNotification } = useNotification();
1107
+ const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();
1108
+ const {
1109
+ currentData: data,
1110
+ isLoading: isLoadingDocument,
1111
+ isFetching: isFetchingDocument,
1112
+ error
1113
+ } = useGetDocumentQuery(args, {
1114
+ ...opts,
1115
+ skip: !args.documentId && args.collectionType !== SINGLE_TYPES || opts?.skip
1116
+ });
1117
+ const {
1118
+ components,
1119
+ schema,
1120
+ schemas,
1121
+ isLoading: isLoadingSchema
1122
+ } = useContentTypeSchema(args.model);
1123
+ React.useEffect(() => {
1124
+ if (error) {
1125
+ toggleNotification({
1126
+ type: "danger",
1127
+ message: formatAPIError(error)
1128
+ });
1129
+ }
1130
+ }, [toggleNotification, error, formatAPIError, args.collectionType]);
1131
+ const validationSchema = React.useMemo(() => {
1132
+ if (!schema) {
1133
+ return null;
1134
+ }
1135
+ return createYupSchema(schema.attributes, components);
1136
+ }, [schema, components]);
1137
+ const validate = React.useCallback(
1138
+ (document) => {
1139
+ if (!validationSchema) {
1140
+ throw new Error(
1141
+ "There is no validation schema generated, this is likely due to the schema not being loaded yet."
1142
+ );
1143
+ }
1076
1144
  try {
1077
- trackUsage("willEditEntry", trackerProperty);
1078
- const res = await updateDocument({
1079
- collectionType,
1080
- model,
1081
- documentId,
1082
- data,
1083
- params
1084
- });
1085
- if ("error" in res) {
1086
- toggleNotification({ type: "danger", message: formatAPIError(res.error) });
1087
- trackUsage("didNotEditEntry", { error: res.error, ...trackerProperty });
1088
- return { error: res.error };
1145
+ validationSchema.validateSync(document, { abortEarly: false, strict: true });
1146
+ return null;
1147
+ } catch (error2) {
1148
+ if (error2 instanceof ValidationError) {
1149
+ return getYupValidationErrors(error2);
1089
1150
  }
1090
- trackUsage("didEditEntry", trackerProperty);
1091
- toggleNotification({
1092
- type: "success",
1093
- message: formatMessage({
1094
- id: getTranslation("success.record.save"),
1095
- defaultMessage: "Saved document"
1096
- })
1097
- });
1098
- return res.data;
1099
- } catch (err) {
1100
- trackUsage("didNotEditEntry", { error: err, ...trackerProperty });
1101
- toggleNotification({
1102
- type: "danger",
1103
- message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
1104
- });
1105
- throw err;
1151
+ throw error2;
1106
1152
  }
1107
1153
  },
1108
- [trackUsage, updateDocument, toggleNotification, formatMessage, formatAPIError]
1154
+ [validationSchema]
1109
1155
  );
1110
- const [unpublishDocument] = useUnpublishDocumentMutation();
1111
- const unpublish = React.useCallback(
1112
- async ({ collectionType, model, documentId, params }, discardDraft = false) => {
1156
+ const isLoading = isLoadingDocument || isFetchingDocument || isLoadingSchema;
1157
+ const hasError = !!error;
1158
+ return {
1159
+ components,
1160
+ document: data?.data,
1161
+ meta: data?.meta,
1162
+ isLoading,
1163
+ hasError,
1164
+ schema,
1165
+ schemas,
1166
+ validate
1167
+ };
1168
+ };
1169
+ const useDoc = () => {
1170
+ const { id, slug, collectionType, origin } = useParams();
1171
+ const [{ query }] = useQueryParams();
1172
+ const params = React.useMemo(() => buildValidParams(query), [query]);
1173
+ if (!collectionType) {
1174
+ throw new Error("Could not find collectionType in url params");
1175
+ }
1176
+ if (!slug) {
1177
+ throw new Error("Could not find model in url params");
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;
1186
+ return {
1187
+ collectionType,
1188
+ model: slug,
1189
+ id: returnId,
1190
+ ...document
1191
+ };
1192
+ };
1193
+ const useContentManagerContext = () => {
1194
+ const {
1195
+ collectionType,
1196
+ model,
1197
+ id,
1198
+ components,
1199
+ isLoading: isLoadingDoc,
1200
+ schema,
1201
+ schemas
1202
+ } = useDoc();
1203
+ const layout = useDocumentLayout(model);
1204
+ const form = useForm("useContentManagerContext", (state) => state);
1205
+ const isSingleType = collectionType === SINGLE_TYPES;
1206
+ const slug = model;
1207
+ const isCreatingEntry = id === "create";
1208
+ useContentTypeSchema();
1209
+ const isLoading = isLoadingDoc || layout.isLoading;
1210
+ const error = layout.error;
1211
+ return {
1212
+ error,
1213
+ isLoading,
1214
+ // Base metadata
1215
+ model,
1216
+ collectionType,
1217
+ id,
1218
+ slug,
1219
+ isCreatingEntry,
1220
+ isSingleType,
1221
+ hasDraftAndPublish: schema?.options?.draftAndPublish ?? false,
1222
+ // All schema infos
1223
+ components,
1224
+ contentType: schema,
1225
+ contentTypes: schemas,
1226
+ // Form state
1227
+ form,
1228
+ // layout infos
1229
+ layout
1230
+ };
1231
+ };
1232
+ const prefixPluginTranslations = (trad, pluginId) => {
1233
+ return Object.keys(trad).reduce((acc, current) => {
1234
+ acc[`${pluginId}.${current}`] = trad[current];
1235
+ return acc;
1236
+ }, {});
1237
+ };
1238
+ const getTranslation = (id) => `content-manager.${id}`;
1239
+ const DEFAULT_UNEXPECTED_ERROR_MSG = {
1240
+ id: "notification.error",
1241
+ defaultMessage: "An error occurred, please try again"
1242
+ };
1243
+ const useDocumentActions = () => {
1244
+ const { toggleNotification } = useNotification();
1245
+ const { formatMessage } = useIntl();
1246
+ const { trackUsage } = useTracking();
1247
+ const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();
1248
+ const navigate = useNavigate();
1249
+ const setCurrentStep = useGuidedTour("useDocumentActions", (state) => state.setCurrentStep);
1250
+ const [deleteDocument] = useDeleteDocumentMutation();
1251
+ const _delete = React.useCallback(
1252
+ async ({ collectionType, model, documentId, params }, trackerProperty) => {
1113
1253
  try {
1114
- trackUsage("willUnpublishEntry");
1115
- const res = await unpublishDocument({
1254
+ trackUsage("willDeleteEntry", trackerProperty);
1255
+ const res = await deleteDocument({
1116
1256
  collectionType,
1117
1257
  model,
1118
1258
  documentId,
1119
- params,
1120
- data: {
1121
- discardDraft
1122
- }
1259
+ params
1123
1260
  });
1124
1261
  if ("error" in res) {
1125
- toggleNotification({ type: "danger", message: formatAPIError(res.error) });
1262
+ toggleNotification({
1263
+ type: "danger",
1264
+ message: formatAPIError(res.error)
1265
+ });
1126
1266
  return { error: res.error };
1127
1267
  }
1128
- trackUsage("didUnpublishEntry");
1129
1268
  toggleNotification({
1130
1269
  type: "success",
1131
1270
  message: formatMessage({
1132
- id: getTranslation("success.record.unpublish"),
1133
- defaultMessage: "Unpublished document"
1271
+ id: getTranslation("success.record.delete"),
1272
+ defaultMessage: "Deleted document"
1134
1273
  })
1135
1274
  });
1275
+ trackUsage("didDeleteEntry", trackerProperty);
1136
1276
  return res.data;
1137
1277
  } catch (err) {
1138
1278
  toggleNotification({
1139
1279
  type: "danger",
1140
1280
  message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
1141
1281
  });
1282
+ trackUsage("didNotDeleteEntry", { error: err, ...trackerProperty });
1142
1283
  throw err;
1143
1284
  }
1144
1285
  },
1145
- [trackUsage, unpublishDocument, toggleNotification, formatMessage, formatAPIError]
1286
+ [trackUsage, deleteDocument, toggleNotification, formatMessage, formatAPIError]
1146
1287
  );
1147
- const [unpublishManyDocuments] = useUnpublishManyDocumentsMutation();
1148
- const unpublishMany = React.useCallback(
1288
+ const [deleteManyDocuments] = useDeleteManyDocumentsMutation();
1289
+ const deleteMany = React.useCallback(
1149
1290
  async ({ model, documentIds, params }) => {
1150
1291
  try {
1151
- trackUsage("willBulkUnpublishEntries");
1152
- const res = await unpublishManyDocuments({
1292
+ trackUsage("willBulkDeleteEntries");
1293
+ const res = await deleteManyDocuments({
1153
1294
  model,
1154
1295
  documentIds,
1155
1296
  params
1156
1297
  });
1157
1298
  if ("error" in res) {
1158
- toggleNotification({ type: "danger", message: formatAPIError(res.error) });
1299
+ toggleNotification({
1300
+ type: "danger",
1301
+ message: formatAPIError(res.error)
1302
+ });
1159
1303
  return { error: res.error };
1160
1304
  }
1161
- trackUsage("didBulkUnpublishEntries");
1162
1305
  toggleNotification({
1163
1306
  type: "success",
1164
1307
  title: formatMessage({
1165
- id: getTranslation("success.records.unpublish"),
1166
- defaultMessage: "Successfully unpublished."
1308
+ id: getTranslation("success.records.delete"),
1309
+ defaultMessage: "Successfully deleted."
1167
1310
  }),
1168
1311
  message: ""
1169
1312
  });
1313
+ trackUsage("didBulkDeleteEntries");
1170
1314
  return res.data;
1171
1315
  } catch (err) {
1172
1316
  toggleNotification({
1173
1317
  type: "danger",
1174
1318
  message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
1175
1319
  });
1176
- trackUsage("didNotBulkUnpublishEntries");
1320
+ trackUsage("didNotBulkDeleteEntries");
1177
1321
  throw err;
1178
1322
  }
1179
1323
  },
1180
- [trackUsage, unpublishManyDocuments, toggleNotification, formatMessage, formatAPIError]
1324
+ [trackUsage, deleteManyDocuments, toggleNotification, formatMessage, formatAPIError]
1181
1325
  );
1182
- const [createDocument] = useCreateDocumentMutation();
1183
- const create = React.useCallback(
1184
- async ({ model, params }, data, trackerProperty) => {
1326
+ const [discardDocument] = useDiscardDocumentMutation();
1327
+ const discard = React.useCallback(
1328
+ async ({ collectionType, model, documentId, params }) => {
1185
1329
  try {
1186
- const res = await createDocument({
1330
+ const res = await discardDocument({
1331
+ collectionType,
1187
1332
  model,
1188
- data,
1333
+ documentId,
1189
1334
  params
1190
1335
  });
1191
1336
  if ("error" in res) {
1192
- toggleNotification({ type: "danger", message: formatAPIError(res.error) });
1193
- trackUsage("didNotCreateEntry", { error: res.error, ...trackerProperty });
1337
+ toggleNotification({
1338
+ type: "danger",
1339
+ message: formatAPIError(res.error)
1340
+ });
1194
1341
  return { error: res.error };
1195
1342
  }
1196
- trackUsage("didCreateEntry", trackerProperty);
1197
1343
  toggleNotification({
1198
1344
  type: "success",
1199
1345
  message: formatMessage({
1200
- id: getTranslation("success.record.save"),
1201
- defaultMessage: "Saved document"
1346
+ id: "content-manager.success.record.discard",
1347
+ defaultMessage: "Changes discarded"
1202
1348
  })
1203
1349
  });
1204
1350
  return res.data;
@@ -1207,17 +1353,232 @@ const useDocumentActions = () => {
1207
1353
  type: "danger",
1208
1354
  message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
1209
1355
  });
1210
- trackUsage("didNotCreateEntry", { error: err, ...trackerProperty });
1211
1356
  throw err;
1212
1357
  }
1213
1358
  },
1214
- [createDocument, formatAPIError, formatMessage, toggleNotification, trackUsage]
1359
+ [discardDocument, formatAPIError, formatMessage, toggleNotification]
1215
1360
  );
1216
- const [autoCloneDocument] = useAutoCloneDocumentMutation();
1217
- const autoClone = React.useCallback(
1218
- async ({ model, sourceId }) => {
1361
+ const [publishDocument] = usePublishDocumentMutation();
1362
+ const publish = React.useCallback(
1363
+ async ({ collectionType, model, documentId, params }, data) => {
1219
1364
  try {
1220
- const res = await autoCloneDocument({
1365
+ trackUsage("willPublishEntry");
1366
+ const res = await publishDocument({
1367
+ collectionType,
1368
+ model,
1369
+ documentId,
1370
+ data,
1371
+ params
1372
+ });
1373
+ if ("error" in res) {
1374
+ toggleNotification({ type: "danger", message: formatAPIError(res.error) });
1375
+ return { error: res.error };
1376
+ }
1377
+ trackUsage("didPublishEntry");
1378
+ toggleNotification({
1379
+ type: "success",
1380
+ message: formatMessage({
1381
+ id: getTranslation("success.record.publish"),
1382
+ defaultMessage: "Published document"
1383
+ })
1384
+ });
1385
+ return res.data;
1386
+ } catch (err) {
1387
+ toggleNotification({
1388
+ type: "danger",
1389
+ message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
1390
+ });
1391
+ throw err;
1392
+ }
1393
+ },
1394
+ [trackUsage, publishDocument, toggleNotification, formatMessage, formatAPIError]
1395
+ );
1396
+ const [publishManyDocuments] = usePublishManyDocumentsMutation();
1397
+ const publishMany = React.useCallback(
1398
+ async ({ model, documentIds, params }) => {
1399
+ try {
1400
+ const res = await publishManyDocuments({
1401
+ model,
1402
+ documentIds,
1403
+ params
1404
+ });
1405
+ if ("error" in res) {
1406
+ toggleNotification({ type: "danger", message: formatAPIError(res.error) });
1407
+ return { error: res.error };
1408
+ }
1409
+ toggleNotification({
1410
+ type: "success",
1411
+ message: formatMessage({
1412
+ id: getTranslation("success.record.publish"),
1413
+ defaultMessage: "Published document"
1414
+ })
1415
+ });
1416
+ return res.data;
1417
+ } catch (err) {
1418
+ toggleNotification({
1419
+ type: "danger",
1420
+ message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
1421
+ });
1422
+ throw err;
1423
+ }
1424
+ },
1425
+ [
1426
+ // trackUsage,
1427
+ publishManyDocuments,
1428
+ toggleNotification,
1429
+ formatMessage,
1430
+ formatAPIError
1431
+ ]
1432
+ );
1433
+ const [updateDocument] = useUpdateDocumentMutation();
1434
+ const update = React.useCallback(
1435
+ async ({ collectionType, model, documentId, params }, data, trackerProperty) => {
1436
+ try {
1437
+ trackUsage("willEditEntry", trackerProperty);
1438
+ const res = await updateDocument({
1439
+ collectionType,
1440
+ model,
1441
+ documentId,
1442
+ data,
1443
+ params
1444
+ });
1445
+ if ("error" in res) {
1446
+ toggleNotification({ type: "danger", message: formatAPIError(res.error) });
1447
+ trackUsage("didNotEditEntry", { error: res.error, ...trackerProperty });
1448
+ return { error: res.error };
1449
+ }
1450
+ trackUsage("didEditEntry", trackerProperty);
1451
+ toggleNotification({
1452
+ type: "success",
1453
+ message: formatMessage({
1454
+ id: getTranslation("success.record.save"),
1455
+ defaultMessage: "Saved document"
1456
+ })
1457
+ });
1458
+ return res.data;
1459
+ } catch (err) {
1460
+ trackUsage("didNotEditEntry", { error: err, ...trackerProperty });
1461
+ toggleNotification({
1462
+ type: "danger",
1463
+ message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
1464
+ });
1465
+ throw err;
1466
+ }
1467
+ },
1468
+ [trackUsage, updateDocument, toggleNotification, formatMessage, formatAPIError]
1469
+ );
1470
+ const [unpublishDocument] = useUnpublishDocumentMutation();
1471
+ const unpublish = React.useCallback(
1472
+ async ({ collectionType, model, documentId, params }, discardDraft = false) => {
1473
+ try {
1474
+ trackUsage("willUnpublishEntry");
1475
+ const res = await unpublishDocument({
1476
+ collectionType,
1477
+ model,
1478
+ documentId,
1479
+ params,
1480
+ data: {
1481
+ discardDraft
1482
+ }
1483
+ });
1484
+ if ("error" in res) {
1485
+ toggleNotification({ type: "danger", message: formatAPIError(res.error) });
1486
+ return { error: res.error };
1487
+ }
1488
+ trackUsage("didUnpublishEntry");
1489
+ toggleNotification({
1490
+ type: "success",
1491
+ message: formatMessage({
1492
+ id: getTranslation("success.record.unpublish"),
1493
+ defaultMessage: "Unpublished document"
1494
+ })
1495
+ });
1496
+ return res.data;
1497
+ } catch (err) {
1498
+ toggleNotification({
1499
+ type: "danger",
1500
+ message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
1501
+ });
1502
+ throw err;
1503
+ }
1504
+ },
1505
+ [trackUsage, unpublishDocument, toggleNotification, formatMessage, formatAPIError]
1506
+ );
1507
+ const [unpublishManyDocuments] = useUnpublishManyDocumentsMutation();
1508
+ const unpublishMany = React.useCallback(
1509
+ async ({ model, documentIds, params }) => {
1510
+ try {
1511
+ trackUsage("willBulkUnpublishEntries");
1512
+ const res = await unpublishManyDocuments({
1513
+ model,
1514
+ documentIds,
1515
+ params
1516
+ });
1517
+ if ("error" in res) {
1518
+ toggleNotification({ type: "danger", message: formatAPIError(res.error) });
1519
+ return { error: res.error };
1520
+ }
1521
+ trackUsage("didBulkUnpublishEntries");
1522
+ toggleNotification({
1523
+ type: "success",
1524
+ title: formatMessage({
1525
+ id: getTranslation("success.records.unpublish"),
1526
+ defaultMessage: "Successfully unpublished."
1527
+ }),
1528
+ message: ""
1529
+ });
1530
+ return res.data;
1531
+ } catch (err) {
1532
+ toggleNotification({
1533
+ type: "danger",
1534
+ message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
1535
+ });
1536
+ trackUsage("didNotBulkUnpublishEntries");
1537
+ throw err;
1538
+ }
1539
+ },
1540
+ [trackUsage, unpublishManyDocuments, toggleNotification, formatMessage, formatAPIError]
1541
+ );
1542
+ const [createDocument] = useCreateDocumentMutation();
1543
+ const create = React.useCallback(
1544
+ async ({ model, params }, data, trackerProperty) => {
1545
+ try {
1546
+ const res = await createDocument({
1547
+ model,
1548
+ data,
1549
+ params
1550
+ });
1551
+ if ("error" in res) {
1552
+ toggleNotification({ type: "danger", message: formatAPIError(res.error) });
1553
+ trackUsage("didNotCreateEntry", { error: res.error, ...trackerProperty });
1554
+ return { error: res.error };
1555
+ }
1556
+ trackUsage("didCreateEntry", trackerProperty);
1557
+ toggleNotification({
1558
+ type: "success",
1559
+ message: formatMessage({
1560
+ id: getTranslation("success.record.save"),
1561
+ defaultMessage: "Saved document"
1562
+ })
1563
+ });
1564
+ setCurrentStep("contentManager.success");
1565
+ return res.data;
1566
+ } catch (err) {
1567
+ toggleNotification({
1568
+ type: "danger",
1569
+ message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
1570
+ });
1571
+ trackUsage("didNotCreateEntry", { error: err, ...trackerProperty });
1572
+ throw err;
1573
+ }
1574
+ },
1575
+ [createDocument, formatAPIError, formatMessage, toggleNotification, trackUsage]
1576
+ );
1577
+ const [autoCloneDocument] = useAutoCloneDocumentMutation();
1578
+ const autoClone = React.useCallback(
1579
+ async ({ model, sourceId }) => {
1580
+ try {
1581
+ const res = await autoCloneDocument({
1221
1582
  model,
1222
1583
  sourceId
1223
1584
  });
@@ -1302,10 +1663,10 @@ const useDocumentActions = () => {
1302
1663
  update
1303
1664
  };
1304
1665
  };
1305
- const ProtectedHistoryPage = lazy(
1306
- () => import("./History-DrwsD1Vc.mjs").then((mod) => ({ default: mod.ProtectedHistoryPage }))
1666
+ const ProtectedHistoryPage = React.lazy(
1667
+ () => import("./History-DLl10NEN.mjs").then((mod) => ({ default: mod.ProtectedHistoryPage }))
1307
1668
  );
1308
- const routes$1 = [
1669
+ const routes$2 = [
1309
1670
  {
1310
1671
  path: ":collectionType/:slug/:id/history",
1311
1672
  Component: ProtectedHistoryPage
@@ -1315,32 +1676,45 @@ const routes$1 = [
1315
1676
  Component: ProtectedHistoryPage
1316
1677
  }
1317
1678
  ];
1679
+ const ProtectedPreviewPage = React.lazy(
1680
+ () => import("./Preview-BDOUHeaW.mjs").then((mod) => ({ default: mod.ProtectedPreviewPage }))
1681
+ );
1682
+ const routes$1 = [
1683
+ {
1684
+ path: ":collectionType/:slug/:id/preview",
1685
+ Component: ProtectedPreviewPage
1686
+ },
1687
+ {
1688
+ path: ":collectionType/:slug/preview",
1689
+ Component: ProtectedPreviewPage
1690
+ }
1691
+ ];
1318
1692
  const ProtectedEditViewPage = lazy(
1319
- () => import("./EditViewPage-DiNFdFqP.mjs").then((mod) => ({ default: mod.ProtectedEditViewPage }))
1693
+ () => import("./EditViewPage-BgeC8L9X.mjs").then((mod) => ({ default: mod.ProtectedEditViewPage }))
1320
1694
  );
1321
1695
  const ProtectedListViewPage = lazy(
1322
- () => import("./ListViewPage-5a1vw-OK.mjs").then((mod) => ({ default: mod.ProtectedListViewPage }))
1696
+ () => import("./ListViewPage-iRJ5AUjS.mjs").then((mod) => ({ default: mod.ProtectedListViewPage }))
1323
1697
  );
1324
1698
  const ProtectedListConfiguration = lazy(
1325
- () => import("./ListConfigurationPage-BxIP0jRy.mjs").then((mod) => ({
1699
+ () => import("./ListConfigurationPage-mbZQmEZ3.mjs").then((mod) => ({
1326
1700
  default: mod.ProtectedListConfiguration
1327
1701
  }))
1328
1702
  );
1329
1703
  const ProtectedEditConfigurationPage = lazy(
1330
- () => import("./EditConfigurationPage-Bk893vVY.mjs").then((mod) => ({
1704
+ () => import("./EditConfigurationPage-ByaNUj_q.mjs").then((mod) => ({
1331
1705
  default: mod.ProtectedEditConfigurationPage
1332
1706
  }))
1333
1707
  );
1334
1708
  const ProtectedComponentConfigurationPage = lazy(
1335
- () => import("./ComponentConfigurationPage-9lRmRdIr.mjs").then((mod) => ({
1709
+ () => import("./ComponentConfigurationPage-EIYRzIr6.mjs").then((mod) => ({
1336
1710
  default: mod.ProtectedComponentConfigurationPage
1337
1711
  }))
1338
1712
  );
1339
1713
  const NoPermissions = lazy(
1340
- () => import("./NoPermissionsPage-BHPqn_tQ.mjs").then((mod) => ({ default: mod.NoPermissions }))
1714
+ () => import("./NoPermissionsPage-DckHN3oZ.mjs").then((mod) => ({ default: mod.NoPermissions }))
1341
1715
  );
1342
1716
  const NoContentType = lazy(
1343
- () => import("./NoContentTypePage-Bm6tRcd3.mjs").then((mod) => ({ default: mod.NoContentType }))
1717
+ () => import("./NoContentTypePage-DI8VWkVK.mjs").then((mod) => ({ default: mod.NoContentType }))
1344
1718
  );
1345
1719
  const CollectionTypePages = () => {
1346
1720
  const { collectionType } = useParams();
@@ -1352,7 +1726,7 @@ const CollectionTypePages = () => {
1352
1726
  const CLONE_RELATIVE_PATH = ":collectionType/:slug/clone/:origin";
1353
1727
  const CLONE_PATH = `/content-manager/${CLONE_RELATIVE_PATH}`;
1354
1728
  const LIST_RELATIVE_PATH = ":collectionType/:slug";
1355
- const LIST_PATH = `/content-manager/${LIST_RELATIVE_PATH}`;
1729
+ const LIST_PATH = `/content-manager/collection-types/:slug`;
1356
1730
  const routes = [
1357
1731
  {
1358
1732
  path: LIST_RELATIVE_PATH,
@@ -1386,6 +1760,7 @@ const routes = [
1386
1760
  path: "no-content-types",
1387
1761
  Component: NoContentType
1388
1762
  },
1763
+ ...routes$2,
1389
1764
  ...routes$1
1390
1765
  ];
1391
1766
  const DocumentActions = ({ actions: actions2 }) => {
@@ -1484,6 +1859,11 @@ const DocumentActionButton = (action) => {
1484
1859
  ) : null
1485
1860
  ] });
1486
1861
  };
1862
+ const MenuItem = styled(Menu.Item)`
1863
+ &:hover {
1864
+ background: ${({ theme, isVariantDanger, isDisabled }) => isVariantDanger && !isDisabled ? theme.colors.danger100 : "neutral"};
1865
+ }
1866
+ `;
1487
1867
  const DocumentActionsMenu = ({
1488
1868
  actions: actions2,
1489
1869
  children,
@@ -1539,51 +1919,35 @@ const DocumentActionsMenu = ({
1539
1919
  ]
1540
1920
  }
1541
1921
  ),
1542
- /* @__PURE__ */ jsxs(Menu.Content, { top: "4px", maxHeight: void 0, popoverPlacement: "bottom-end", children: [
1922
+ /* @__PURE__ */ jsxs(Menu.Content, { maxHeight: void 0, popoverPlacement: "bottom-end", children: [
1543
1923
  actions2.map((action) => {
1544
1924
  return /* @__PURE__ */ jsx(
1545
- Menu.Item,
1925
+ MenuItem,
1546
1926
  {
1547
1927
  disabled: action.disabled,
1548
1928
  onSelect: handleClick(action),
1549
1929
  display: "block",
1550
- children: /* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", gap: 4, children: [
1551
- /* @__PURE__ */ jsxs(
1552
- Flex,
1553
- {
1554
- color: !action.disabled ? convertActionVariantToColor(action.variant) : "inherit",
1555
- gap: 2,
1556
- tag: "span",
1557
- children: [
1558
- /* @__PURE__ */ jsx(
1559
- Flex,
1560
- {
1561
- tag: "span",
1562
- color: !action.disabled ? convertActionVariantToIconColor(action.variant) : "inherit",
1563
- children: action.icon
1564
- }
1565
- ),
1566
- action.label
1567
- ]
1568
- }
1569
- ),
1570
- action.id.startsWith("HistoryAction") && /* @__PURE__ */ jsx(
1571
- Flex,
1572
- {
1573
- alignItems: "center",
1574
- background: "alternative100",
1575
- borderStyle: "solid",
1576
- borderColor: "alternative200",
1577
- borderWidth: "1px",
1578
- height: 5,
1579
- paddingLeft: 2,
1580
- paddingRight: 2,
1581
- hasRadius: true,
1582
- color: "alternative600",
1583
- children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", fontWeight: "bold", lineHeight: 1, children: formatMessage({ id: "global.new", defaultMessage: "New" }) })
1584
- }
1585
- )
1586
- ] })
1930
+ isVariantDanger: action.variant === "danger",
1931
+ isDisabled: action.disabled,
1932
+ children: /* @__PURE__ */ jsx(Flex, { justifyContent: "space-between", gap: 4, children: /* @__PURE__ */ jsxs(
1933
+ Flex,
1934
+ {
1935
+ color: !action.disabled ? convertActionVariantToColor(action.variant) : "inherit",
1936
+ gap: 2,
1937
+ tag: "span",
1938
+ children: [
1939
+ /* @__PURE__ */ jsx(
1940
+ Flex,
1941
+ {
1942
+ tag: "span",
1943
+ color: !action.disabled ? convertActionVariantToIconColor(action.variant) : "inherit",
1944
+ children: action.icon
1945
+ }
1946
+ ),
1947
+ action.label
1948
+ ]
1949
+ }
1950
+ ) })
1587
1951
  },
1588
1952
  action.id
1589
1953
  );
@@ -1663,11 +2027,11 @@ const DocumentActionConfirmDialog = ({
1663
2027
  /* @__PURE__ */ jsx(Dialog.Header, { children: title }),
1664
2028
  /* @__PURE__ */ jsx(Dialog.Body, { children: content }),
1665
2029
  /* @__PURE__ */ jsxs(Dialog.Footer, { children: [
1666
- /* @__PURE__ */ jsx(Dialog.Cancel, { children: /* @__PURE__ */ jsx(Button, { variant: "tertiary", children: formatMessage({
2030
+ /* @__PURE__ */ jsx(Dialog.Cancel, { children: /* @__PURE__ */ jsx(Button, { variant: "tertiary", fullWidth: true, children: formatMessage({
1667
2031
  id: "app.components.Button.cancel",
1668
2032
  defaultMessage: "Cancel"
1669
2033
  }) }) }),
1670
- /* @__PURE__ */ jsx(Button, { onClick: handleConfirm, variant, children: formatMessage({
2034
+ /* @__PURE__ */ jsx(Button, { onClick: handleConfirm, variant, fullWidth: true, children: formatMessage({
1671
2035
  id: "app.components.Button.confirm",
1672
2036
  defaultMessage: "Confirm"
1673
2037
  }) })
@@ -1694,6 +2058,18 @@ const DocumentActionModal = ({
1694
2058
  typeof Footer === "function" ? /* @__PURE__ */ jsx(Footer, { onClose: handleClose }) : Footer
1695
2059
  ] }) });
1696
2060
  };
2061
+ const transformData = (data) => {
2062
+ if (Array.isArray(data)) {
2063
+ return data.map(transformData);
2064
+ }
2065
+ if (typeof data === "object" && data !== null) {
2066
+ if ("apiData" in data) {
2067
+ return data.apiData;
2068
+ }
2069
+ return mapValues(transformData)(data);
2070
+ }
2071
+ return data;
2072
+ };
1697
2073
  const PublishAction$1 = ({
1698
2074
  activeTab,
1699
2075
  documentId,
@@ -1761,24 +2137,25 @@ const PublishAction$1 = ({
1761
2137
  }
1762
2138
  }, [documentId, modified, formValues, setLocalCountOfDraftRelations]);
1763
2139
  React.useEffect(() => {
1764
- if (documentId && !isListView) {
1765
- const fetchDraftRelationsCount = async () => {
1766
- const { data, error } = await countDraftRelations({
1767
- collectionType,
1768
- model,
1769
- documentId,
1770
- params
1771
- });
1772
- if (error) {
1773
- throw error;
1774
- }
1775
- if (data) {
1776
- setServerCountOfDraftRelations(data.data);
1777
- }
1778
- };
1779
- fetchDraftRelationsCount();
2140
+ if (!document || !document.documentId || isListView) {
2141
+ return;
1780
2142
  }
1781
- }, [isListView, documentId, countDraftRelations, collectionType, model, params]);
2143
+ const fetchDraftRelationsCount = async () => {
2144
+ const { data, error } = await countDraftRelations({
2145
+ collectionType,
2146
+ model,
2147
+ documentId,
2148
+ params
2149
+ });
2150
+ if (error) {
2151
+ throw error;
2152
+ }
2153
+ if (data) {
2154
+ setServerCountOfDraftRelations(data.data);
2155
+ }
2156
+ };
2157
+ fetchDraftRelationsCount();
2158
+ }, [isListView, document, documentId, countDraftRelations, collectionType, model, params]);
1782
2159
  const isDocumentPublished = (document?.[PUBLISHED_AT_ATTRIBUTE_NAME] || meta?.availableStatus.some((doc) => doc[PUBLISHED_AT_ATTRIBUTE_NAME] !== null)) && document?.status !== "modified";
1783
2160
  if (!schema?.options?.draftAndPublish) {
1784
2161
  return null;
@@ -1786,7 +2163,9 @@ const PublishAction$1 = ({
1786
2163
  const performPublish = async () => {
1787
2164
  setSubmitting(true);
1788
2165
  try {
1789
- const { errors } = await validate();
2166
+ const { errors } = await validate(true, {
2167
+ status: "published"
2168
+ });
1790
2169
  if (errors) {
1791
2170
  toggleNotification({
1792
2171
  type: "danger",
@@ -1804,7 +2183,7 @@ const PublishAction$1 = ({
1804
2183
  documentId,
1805
2184
  params
1806
2185
  },
1807
- formValues
2186
+ transformData(formValues)
1808
2187
  );
1809
2188
  if ("data" in res && collectionType !== SINGLE_TYPES) {
1810
2189
  navigate({
@@ -1900,18 +2279,18 @@ const UpdateAction = ({
1900
2279
  onClick: async () => {
1901
2280
  setSubmitting(true);
1902
2281
  try {
1903
- if (activeTab !== "draft") {
1904
- const { errors } = await validate();
1905
- if (errors) {
1906
- toggleNotification({
1907
- type: "danger",
1908
- message: formatMessage({
1909
- id: "content-manager.validation.error",
1910
- defaultMessage: "There are validation errors in your document. Please fix them before saving."
1911
- })
1912
- });
1913
- return;
1914
- }
2282
+ const { errors } = await validate(true, {
2283
+ status: "draft"
2284
+ });
2285
+ if (errors) {
2286
+ toggleNotification({
2287
+ type: "danger",
2288
+ message: formatMessage({
2289
+ id: "content-manager.validation.error",
2290
+ defaultMessage: "There are validation errors in your document. Please fix them before saving."
2291
+ })
2292
+ });
2293
+ return;
1915
2294
  }
1916
2295
  if (isCloning) {
1917
2296
  const res = await clone(
@@ -1920,7 +2299,7 @@ const UpdateAction = ({
1920
2299
  documentId: cloneMatch.params.origin,
1921
2300
  params
1922
2301
  },
1923
- document
2302
+ transformData(document)
1924
2303
  );
1925
2304
  if ("data" in res) {
1926
2305
  navigate(
@@ -1941,7 +2320,7 @@ const UpdateAction = ({
1941
2320
  documentId,
1942
2321
  params
1943
2322
  },
1944
- document
2323
+ transformData(document)
1945
2324
  );
1946
2325
  if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
1947
2326
  setErrors(formatValidationErrors(res.error));
@@ -1954,7 +2333,7 @@ const UpdateAction = ({
1954
2333
  model,
1955
2334
  params
1956
2335
  },
1957
- document
2336
+ transformData(document)
1958
2337
  );
1959
2338
  if ("data" in res && collectionType !== SINGLE_TYPES) {
1960
2339
  navigate(
@@ -2007,7 +2386,7 @@ const UnpublishAction$1 = ({
2007
2386
  id: "app.utils.unpublish",
2008
2387
  defaultMessage: "Unpublish"
2009
2388
  }),
2010
- icon: /* @__PURE__ */ jsx(StyledCrossCircle, {}),
2389
+ icon: /* @__PURE__ */ jsx(Cross, {}),
2011
2390
  onClick: async () => {
2012
2391
  if (!documentId && collectionType !== SINGLE_TYPES || isDocumentModified) {
2013
2392
  if (!documentId) {
@@ -2119,7 +2498,7 @@ const DiscardAction = ({
2119
2498
  id: "content-manager.actions.discard.label",
2120
2499
  defaultMessage: "Discard changes"
2121
2500
  }),
2122
- icon: /* @__PURE__ */ jsx(StyledCrossCircle, {}),
2501
+ icon: /* @__PURE__ */ jsx(Cross, {}),
2123
2502
  position: ["panel", "table-row"],
2124
2503
  variant: "danger",
2125
2504
  dialog: {
@@ -2147,11 +2526,6 @@ const DiscardAction = ({
2147
2526
  };
2148
2527
  };
2149
2528
  DiscardAction.type = "discard";
2150
- const StyledCrossCircle = styled(CrossCircle)`
2151
- path {
2152
- fill: currentColor;
2153
- }
2154
- `;
2155
2529
  const DEFAULT_ACTIONS = [PublishAction$1, UpdateAction, UnpublishAction$1, DiscardAction];
2156
2530
  const intervals = ["years", "months", "days", "hours", "minutes", "seconds"];
2157
2531
  const RelativeTime = React.forwardRef(
@@ -2164,7 +2538,7 @@ const RelativeTime = React.forwardRef(
2164
2538
  });
2165
2539
  const unit = intervals.find((intervalUnit) => {
2166
2540
  return interval[intervalUnit] > 0 && Object.keys(interval).includes(intervalUnit);
2167
- });
2541
+ }) ?? "seconds";
2168
2542
  const relativeTime = isPast(timestamp) ? -interval[unit] : interval[unit];
2169
2543
  const customInterval = customIntervals.find(
2170
2544
  (custom) => interval[custom.unit] < custom.threshold
@@ -2198,19 +2572,29 @@ const getDisplayName = ({
2198
2572
  return email ?? "";
2199
2573
  };
2200
2574
  const capitalise = (str) => str.charAt(0).toUpperCase() + str.slice(1);
2201
- const DocumentStatus = ({ status = "draft", ...restProps }) => {
2202
- const statusVariant = status === "draft" ? "primary" : status === "published" ? "success" : "alternative";
2203
- return /* @__PURE__ */ jsx(Status, { ...restProps, showBullet: false, size: "S", variant: statusVariant, children: /* @__PURE__ */ jsx(Typography, { tag: "span", variant: "omega", fontWeight: "bold", children: capitalise(status) }) });
2575
+ const DocumentStatus = ({ status = "draft", size = "S", ...restProps }) => {
2576
+ const statusVariant = status === "draft" ? "secondary" : status === "published" ? "success" : "alternative";
2577
+ const { formatMessage } = useIntl();
2578
+ return /* @__PURE__ */ jsx(Status, { ...restProps, size, variant: statusVariant, children: /* @__PURE__ */ jsx(Typography, { tag: "span", variant: "omega", fontWeight: "bold", children: formatMessage({
2579
+ id: `content-manager.containers.List.${status}`,
2580
+ defaultMessage: capitalise(status)
2581
+ }) }) });
2204
2582
  };
2205
2583
  const Header = ({ isCreating, status, title: documentTitle = "Untitled" }) => {
2206
2584
  const { formatMessage } = useIntl();
2207
2585
  const isCloning = useMatch(CLONE_PATH) !== null;
2586
+ const params = useParams();
2208
2587
  const title = isCreating ? formatMessage({
2209
2588
  id: "content-manager.containers.edit.title.new",
2210
2589
  defaultMessage: "Create an entry"
2211
2590
  }) : documentTitle;
2212
2591
  return /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "flex-start", paddingTop: 6, paddingBottom: 4, gap: 2, children: [
2213
- /* @__PURE__ */ jsx(BackButton, {}),
2592
+ /* @__PURE__ */ jsx(
2593
+ BackButton,
2594
+ {
2595
+ fallback: params.collectionType === SINGLE_TYPES ? void 0 : `../${COLLECTION_TYPES}/${params.slug}`
2596
+ }
2597
+ ),
2214
2598
  /* @__PURE__ */ jsxs(Flex, { width: "100%", justifyContent: "space-between", gap: "80px", alignItems: "flex-start", children: [
2215
2599
  /* @__PURE__ */ jsx(Typography, { variant: "alpha", tag: "h1", children: title }),
2216
2600
  /* @__PURE__ */ jsx(HeaderToolbar, {})
@@ -2298,12 +2682,12 @@ const Information = ({ activeTab }) => {
2298
2682
  isDisplayed: !!publishDocument?.[PUBLISHED_AT_ATTRIBUTE_NAME],
2299
2683
  label: formatMessage({
2300
2684
  id: "content-manager.containers.edit.information.last-published.label",
2301
- defaultMessage: "Last published"
2685
+ defaultMessage: "Published"
2302
2686
  }),
2303
2687
  value: formatMessage(
2304
2688
  {
2305
2689
  id: "content-manager.containers.edit.information.last-published.value",
2306
- defaultMessage: `Published {time}{isAnonymous, select, true {} other { by {author}}}`
2690
+ defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
2307
2691
  },
2308
2692
  {
2309
2693
  time: /* @__PURE__ */ jsx(RelativeTime, { timestamp: new Date(publishDocument?.[PUBLISHED_AT_ATTRIBUTE_NAME]) }),
@@ -2316,12 +2700,12 @@ const Information = ({ activeTab }) => {
2316
2700
  isDisplayed: !!createAndUpdateDocument?.[UPDATED_AT_ATTRIBUTE_NAME],
2317
2701
  label: formatMessage({
2318
2702
  id: "content-manager.containers.edit.information.last-draft.label",
2319
- defaultMessage: "Last draft"
2703
+ defaultMessage: "Updated"
2320
2704
  }),
2321
2705
  value: formatMessage(
2322
2706
  {
2323
2707
  id: "content-manager.containers.edit.information.last-draft.value",
2324
- defaultMessage: `Modified {time}{isAnonymous, select, true {} other { by {author}}}`
2708
+ defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
2325
2709
  },
2326
2710
  {
2327
2711
  time: /* @__PURE__ */ jsx(
@@ -2339,12 +2723,12 @@ const Information = ({ activeTab }) => {
2339
2723
  isDisplayed: !!createAndUpdateDocument?.[CREATED_AT_ATTRIBUTE_NAME],
2340
2724
  label: formatMessage({
2341
2725
  id: "content-manager.containers.edit.information.document.label",
2342
- defaultMessage: "Document"
2726
+ defaultMessage: "Created"
2343
2727
  }),
2344
2728
  value: formatMessage(
2345
2729
  {
2346
2730
  id: "content-manager.containers.edit.information.document.value",
2347
- defaultMessage: `Created {time}{isAnonymous, select, true {} other { by {author}}}`
2731
+ defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
2348
2732
  },
2349
2733
  {
2350
2734
  time: /* @__PURE__ */ jsx(
@@ -2382,25 +2766,77 @@ const Information = ({ activeTab }) => {
2382
2766
  );
2383
2767
  };
2384
2768
  const HeaderActions = ({ actions: actions2 }) => {
2385
- return /* @__PURE__ */ jsx(Flex, { children: actions2.map((action) => {
2386
- if ("options" in action) {
2769
+ const [dialogId, setDialogId] = React.useState(null);
2770
+ const handleClick = (action) => async (e) => {
2771
+ if (!("options" in action)) {
2772
+ const { onClick = () => false, dialog, id } = action;
2773
+ const muteDialog = await onClick(e);
2774
+ if (dialog && !muteDialog) {
2775
+ e.preventDefault();
2776
+ setDialogId(id);
2777
+ }
2778
+ }
2779
+ };
2780
+ const handleClose = () => {
2781
+ setDialogId(null);
2782
+ };
2783
+ return /* @__PURE__ */ jsx(Flex, { gap: 1, children: actions2.map((action) => {
2784
+ if (action.options) {
2387
2785
  return /* @__PURE__ */ jsx(
2388
2786
  SingleSelect,
2389
2787
  {
2390
2788
  size: "S",
2391
- disabled: action.disabled,
2392
- "aria-label": action.label,
2393
2789
  onChange: action.onSelect,
2394
- value: action.value,
2790
+ "aria-label": action.label,
2791
+ ...action,
2395
2792
  children: action.options.map(({ label, ...option }) => /* @__PURE__ */ jsx(SingleSelectOption, { ...option, children: label }, option.value))
2396
2793
  },
2397
2794
  action.id
2398
2795
  );
2399
2796
  } else {
2400
- return null;
2797
+ if (action.type === "icon") {
2798
+ return /* @__PURE__ */ jsxs(React.Fragment, { children: [
2799
+ /* @__PURE__ */ jsx(
2800
+ IconButton,
2801
+ {
2802
+ disabled: action.disabled,
2803
+ label: action.label,
2804
+ size: "S",
2805
+ onClick: handleClick(action),
2806
+ children: action.icon
2807
+ }
2808
+ ),
2809
+ action.dialog ? /* @__PURE__ */ jsx(
2810
+ HeaderActionDialog,
2811
+ {
2812
+ ...action.dialog,
2813
+ isOpen: dialogId === action.id,
2814
+ onClose: handleClose
2815
+ }
2816
+ ) : null
2817
+ ] }, action.id);
2818
+ }
2401
2819
  }
2402
2820
  }) });
2403
2821
  };
2822
+ const HeaderActionDialog = ({
2823
+ onClose,
2824
+ onCancel,
2825
+ title,
2826
+ content: Content,
2827
+ isOpen
2828
+ }) => {
2829
+ const handleClose = async () => {
2830
+ if (onCancel) {
2831
+ await onCancel();
2832
+ }
2833
+ onClose();
2834
+ };
2835
+ return /* @__PURE__ */ jsx(Dialog.Root, { open: isOpen, onOpenChange: handleClose, children: /* @__PURE__ */ jsxs(Dialog.Content, { children: [
2836
+ /* @__PURE__ */ jsx(Dialog.Header, { children: title }),
2837
+ typeof Content === "function" ? /* @__PURE__ */ jsx(Content, { onClose: handleClose }) : Content
2838
+ ] }) });
2839
+ };
2404
2840
  const ConfigureTheViewAction = ({ collectionType, model }) => {
2405
2841
  const navigate = useNavigate();
2406
2842
  const { formatMessage } = useIntl();
@@ -2441,12 +2877,16 @@ const DeleteAction$1 = ({ documentId, model, collectionType, document }) => {
2441
2877
  const { delete: deleteAction } = useDocumentActions();
2442
2878
  const { toggleNotification } = useNotification();
2443
2879
  const setSubmitting = useForm("DeleteAction", (state) => state.setSubmitting);
2880
+ const isLocalized = document?.locale != null;
2444
2881
  return {
2445
2882
  disabled: !canDelete || !document,
2446
- label: formatMessage({
2447
- id: "content-manager.actions.delete.label",
2448
- defaultMessage: "Delete document"
2449
- }),
2883
+ label: formatMessage(
2884
+ {
2885
+ id: "content-manager.actions.delete.label",
2886
+ defaultMessage: "Delete entry{isLocalized, select, true { (all locales)} other {}}"
2887
+ },
2888
+ { isLocalized }
2889
+ ),
2450
2890
  icon: /* @__PURE__ */ jsx(Trash, {}),
2451
2891
  dialog: {
2452
2892
  type: "dialog",
@@ -2475,430 +2915,128 @@ const DeleteAction$1 = ({ documentId, model, collectionType, document }) => {
2475
2915
  id: "content-manager.actions.delete.error",
2476
2916
  defaultMessage: "An error occurred while trying to delete the document."
2477
2917
  }),
2478
- type: "danger"
2479
- });
2480
- return;
2481
- }
2482
- const res = await deleteAction({
2483
- documentId,
2484
- model,
2485
- collectionType,
2486
- params: {
2487
- locale: "*"
2488
- }
2489
- });
2490
- if (!("error" in res)) {
2491
- navigate({ pathname: `../${collectionType}/${model}` }, { replace: true });
2492
- }
2493
- } finally {
2494
- if (!listViewPathMatch) {
2495
- setSubmitting(false);
2496
- }
2497
- }
2498
- }
2499
- },
2500
- variant: "danger",
2501
- position: ["header", "table-row"]
2502
- };
2503
- };
2504
- DeleteAction$1.type = "delete";
2505
- const DEFAULT_HEADER_ACTIONS = [EditTheModelAction, ConfigureTheViewAction, DeleteAction$1];
2506
- const Panels = () => {
2507
- const isCloning = useMatch(CLONE_PATH) !== null;
2508
- const [
2509
- {
2510
- query: { status }
2511
- }
2512
- ] = useQueryParams({
2513
- status: "draft"
2514
- });
2515
- const { model, id, document, meta, collectionType } = useDoc();
2516
- const plugins = useStrapiApp("Panels", (state) => state.plugins);
2517
- const props = {
2518
- activeTab: status,
2519
- model,
2520
- documentId: id,
2521
- document: isCloning ? void 0 : document,
2522
- meta: isCloning ? void 0 : meta,
2523
- collectionType
2524
- };
2525
- return /* @__PURE__ */ jsx(Flex, { direction: "column", alignItems: "stretch", gap: 2, children: /* @__PURE__ */ jsx(
2526
- DescriptionComponentRenderer,
2527
- {
2528
- props,
2529
- descriptions: plugins["content-manager"].apis.getEditViewSidePanels(),
2530
- children: (panels) => panels.map(({ content, id: id2, ...description }) => /* @__PURE__ */ jsx(Panel, { ...description, children: content }, id2))
2531
- }
2532
- ) });
2533
- };
2534
- const ActionsPanel = () => {
2535
- const { formatMessage } = useIntl();
2536
- return {
2537
- title: formatMessage({
2538
- id: "content-manager.containers.edit.panels.default.title",
2539
- defaultMessage: "Document"
2540
- }),
2541
- content: /* @__PURE__ */ jsx(ActionsPanelContent, {})
2542
- };
2543
- };
2544
- ActionsPanel.type = "actions";
2545
- const ActionsPanelContent = () => {
2546
- const isCloning = useMatch(CLONE_PATH) !== null;
2547
- const [
2548
- {
2549
- query: { status = "draft" }
2550
- }
2551
- ] = useQueryParams();
2552
- const { model, id, document, meta, collectionType } = useDoc();
2553
- const plugins = useStrapiApp("ActionsPanel", (state) => state.plugins);
2554
- const props = {
2555
- activeTab: status,
2556
- model,
2557
- documentId: id,
2558
- document: isCloning ? void 0 : document,
2559
- meta: isCloning ? void 0 : meta,
2560
- collectionType
2561
- };
2562
- return /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 2, width: "100%", children: [
2563
- /* @__PURE__ */ jsx(
2564
- DescriptionComponentRenderer,
2565
- {
2566
- props,
2567
- descriptions: plugins["content-manager"].apis.getDocumentActions(),
2568
- children: (actions2) => /* @__PURE__ */ jsx(DocumentActions, { actions: actions2 })
2569
- }
2570
- ),
2571
- /* @__PURE__ */ jsx(InjectionZone, { area: "editView.right-links", slug: model })
2572
- ] });
2573
- };
2574
- const Panel = React.forwardRef(({ children, title }, ref) => {
2575
- return /* @__PURE__ */ jsxs(
2576
- Flex,
2577
- {
2578
- ref,
2579
- tag: "aside",
2580
- "aria-labelledby": "additional-information",
2581
- background: "neutral0",
2582
- borderColor: "neutral150",
2583
- hasRadius: true,
2584
- paddingBottom: 4,
2585
- paddingLeft: 4,
2586
- paddingRight: 4,
2587
- paddingTop: 4,
2588
- shadow: "tableShadow",
2589
- gap: 3,
2590
- direction: "column",
2591
- justifyContent: "stretch",
2592
- alignItems: "flex-start",
2593
- children: [
2594
- /* @__PURE__ */ jsx(Typography, { tag: "h2", variant: "sigma", textTransform: "uppercase", children: title }),
2595
- children
2596
- ]
2597
- }
2598
- );
2599
- });
2600
- const HOOKS = {
2601
- /**
2602
- * Hook that allows to mutate the displayed headers of the list view table
2603
- * @constant
2604
- * @type {string}
2605
- */
2606
- INJECT_COLUMN_IN_TABLE: "Admin/CM/pages/ListView/inject-column-in-table",
2607
- /**
2608
- * Hook that allows to mutate the CM's collection types links pre-set filters
2609
- * @constant
2610
- * @type {string}
2611
- */
2612
- MUTATE_COLLECTION_TYPES_LINKS: "Admin/CM/pages/App/mutate-collection-types-links",
2613
- /**
2614
- * Hook that allows to mutate the CM's edit view layout
2615
- * @constant
2616
- * @type {string}
2617
- */
2618
- MUTATE_EDIT_VIEW_LAYOUT: "Admin/CM/pages/EditView/mutate-edit-view-layout",
2619
- /**
2620
- * Hook that allows to mutate the CM's single types links pre-set filters
2621
- * @constant
2622
- * @type {string}
2623
- */
2624
- MUTATE_SINGLE_TYPES_LINKS: "Admin/CM/pages/App/mutate-single-types-links"
2625
- };
2626
- const contentTypesApi = contentManagerApi.injectEndpoints({
2627
- endpoints: (builder) => ({
2628
- getContentTypeConfiguration: builder.query({
2629
- query: (uid) => ({
2630
- url: `/content-manager/content-types/${uid}/configuration`,
2631
- method: "GET"
2632
- }),
2633
- transformResponse: (response) => response.data,
2634
- providesTags: (_result, _error, uid) => [
2635
- { type: "ContentTypesConfiguration", id: uid },
2636
- { type: "ContentTypeSettings", id: "LIST" }
2637
- ]
2638
- }),
2639
- getAllContentTypeSettings: builder.query({
2640
- query: () => "/content-manager/content-types-settings",
2641
- transformResponse: (response) => response.data,
2642
- providesTags: [{ type: "ContentTypeSettings", id: "LIST" }]
2643
- }),
2644
- updateContentTypeConfiguration: builder.mutation({
2645
- query: ({ uid, ...body }) => ({
2646
- url: `/content-manager/content-types/${uid}/configuration`,
2647
- method: "PUT",
2648
- data: body
2649
- }),
2650
- transformResponse: (response) => response.data,
2651
- invalidatesTags: (_result, _error, { uid }) => [
2652
- { type: "ContentTypesConfiguration", id: uid },
2653
- { type: "ContentTypeSettings", id: "LIST" },
2654
- // Is this necessary?
2655
- { type: "InitialData" }
2656
- ]
2657
- })
2658
- })
2659
- });
2660
- const {
2661
- useGetContentTypeConfigurationQuery,
2662
- useGetAllContentTypeSettingsQuery,
2663
- useUpdateContentTypeConfigurationMutation
2664
- } = contentTypesApi;
2665
- const checkIfAttributeIsDisplayable = (attribute) => {
2666
- const { type } = attribute;
2667
- if (type === "relation") {
2668
- return !attribute.relation.toLowerCase().includes("morph");
2669
- }
2670
- return !["json", "dynamiczone", "richtext", "password", "blocks"].includes(type) && !!type;
2671
- };
2672
- const getMainField = (attribute, mainFieldName, { schemas, components }) => {
2673
- if (!mainFieldName) {
2674
- return void 0;
2675
- }
2676
- const mainFieldType = attribute.type === "component" ? components[attribute.component].attributes[mainFieldName].type : (
2677
- // @ts-expect-error – `targetModel` does exist on the attribute for a relation.
2678
- schemas.find((schema) => schema.uid === attribute.targetModel)?.attributes[mainFieldName].type
2679
- );
2680
- return {
2681
- name: mainFieldName,
2682
- type: mainFieldType ?? "string"
2683
- };
2684
- };
2685
- const DEFAULT_SETTINGS = {
2686
- bulkable: false,
2687
- filterable: false,
2688
- searchable: false,
2689
- pagination: false,
2690
- defaultSortBy: "",
2691
- defaultSortOrder: "asc",
2692
- mainField: "id",
2693
- pageSize: 10
2694
- };
2695
- const useDocumentLayout = (model) => {
2696
- const { schema, components } = useDocument({ model, collectionType: "" }, { skip: true });
2697
- const [{ query }] = useQueryParams();
2698
- const runHookWaterfall = useStrapiApp("useDocumentLayout", (state) => state.runHookWaterfall);
2699
- const { toggleNotification } = useNotification();
2700
- const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();
2701
- const { isLoading: isLoadingSchemas, schemas } = useContentTypeSchema();
2702
- const {
2703
- data,
2704
- isLoading: isLoadingConfigs,
2705
- error,
2706
- isFetching: isFetchingConfigs
2707
- } = useGetContentTypeConfigurationQuery(model);
2708
- const isLoading = isLoadingSchemas || isFetchingConfigs || isLoadingConfigs;
2709
- React.useEffect(() => {
2710
- if (error) {
2711
- toggleNotification({
2712
- type: "danger",
2713
- message: formatAPIError(error)
2714
- });
2715
- }
2716
- }, [error, formatAPIError, toggleNotification]);
2717
- const editLayout = React.useMemo(
2718
- () => data && !isLoading ? formatEditLayout(data, { schemas, schema, components }) : {
2719
- layout: [],
2720
- components: {},
2721
- metadatas: {},
2722
- options: {},
2723
- settings: DEFAULT_SETTINGS
2724
- },
2725
- [data, isLoading, schemas, schema, components]
2726
- );
2727
- const listLayout = React.useMemo(() => {
2728
- return data && !isLoading ? formatListLayout(data, { schemas, schema, components }) : {
2729
- layout: [],
2730
- metadatas: {},
2731
- options: {},
2732
- settings: DEFAULT_SETTINGS
2733
- };
2734
- }, [data, isLoading, schemas, schema, components]);
2735
- const { layout: edit } = React.useMemo(
2736
- () => runHookWaterfall(HOOKS.MUTATE_EDIT_VIEW_LAYOUT, {
2737
- layout: editLayout,
2738
- query
2739
- }),
2740
- [editLayout, query, runHookWaterfall]
2741
- );
2742
- return {
2743
- error,
2744
- isLoading,
2745
- edit,
2746
- list: listLayout
2747
- };
2748
- };
2749
- const useDocLayout = () => {
2750
- const { model } = useDoc();
2751
- return useDocumentLayout(model);
2752
- };
2753
- const formatEditLayout = (data, {
2754
- schemas,
2755
- schema,
2756
- components
2757
- }) => {
2758
- let currentPanelIndex = 0;
2759
- const panelledEditAttributes = convertEditLayoutToFieldLayouts(
2760
- data.contentType.layouts.edit,
2761
- schema?.attributes,
2762
- data.contentType.metadatas,
2763
- { configurations: data.components, schemas: components },
2764
- schemas
2765
- ).reduce((panels, row) => {
2766
- if (row.some((field) => field.type === "dynamiczone")) {
2767
- panels.push([row]);
2768
- currentPanelIndex += 2;
2769
- } else {
2770
- if (!panels[currentPanelIndex]) {
2771
- panels.push([]);
2772
- }
2773
- panels[currentPanelIndex].push(row);
2774
- }
2775
- return panels;
2776
- }, []);
2777
- const componentEditAttributes = Object.entries(data.components).reduce(
2778
- (acc, [uid, configuration]) => {
2779
- acc[uid] = {
2780
- layout: convertEditLayoutToFieldLayouts(
2781
- configuration.layouts.edit,
2782
- components[uid].attributes,
2783
- configuration.metadatas
2784
- ),
2785
- settings: {
2786
- ...configuration.settings,
2787
- icon: components[uid].info.icon,
2788
- displayName: components[uid].info.displayName
2918
+ type: "danger"
2919
+ });
2920
+ return;
2921
+ }
2922
+ const res = await deleteAction({
2923
+ documentId,
2924
+ model,
2925
+ collectionType,
2926
+ params: {
2927
+ locale: "*"
2928
+ }
2929
+ });
2930
+ if (!("error" in res)) {
2931
+ navigate({ pathname: `../${collectionType}/${model}` }, { replace: true });
2932
+ }
2933
+ } finally {
2934
+ if (!listViewPathMatch) {
2935
+ setSubmitting(false);
2936
+ }
2789
2937
  }
2790
- };
2791
- return acc;
2792
- },
2793
- {}
2794
- );
2795
- const editMetadatas = Object.entries(data.contentType.metadatas).reduce(
2796
- (acc, [attribute, metadata]) => {
2797
- return {
2798
- ...acc,
2799
- [attribute]: metadata.edit
2800
- };
2801
- },
2802
- {}
2803
- );
2804
- return {
2805
- layout: panelledEditAttributes,
2806
- components: componentEditAttributes,
2807
- metadatas: editMetadatas,
2808
- settings: {
2809
- ...data.contentType.settings,
2810
- displayName: schema?.info.displayName
2938
+ }
2811
2939
  },
2812
- options: {
2813
- ...schema?.options,
2814
- ...schema?.pluginOptions,
2815
- ...data.contentType.options
2816
- }
2940
+ variant: "danger",
2941
+ position: ["header", "table-row"]
2817
2942
  };
2818
2943
  };
2819
- const convertEditLayoutToFieldLayouts = (rows, attributes = {}, metadatas, components, schemas = []) => {
2820
- return rows.map(
2821
- (row) => row.map((field) => {
2822
- const attribute = attributes[field.name];
2823
- if (!attribute) {
2824
- return null;
2825
- }
2826
- const { edit: metadata } = metadatas[field.name];
2827
- const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
2828
- return {
2829
- attribute,
2830
- disabled: !metadata.editable,
2831
- hint: metadata.description,
2832
- label: metadata.label ?? "",
2833
- name: field.name,
2834
- // @ts-expect-error – mainField does exist on the metadata for a relation.
2835
- mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
2836
- schemas,
2837
- components: components?.schemas ?? {}
2838
- }),
2839
- placeholder: metadata.placeholder ?? "",
2840
- required: attribute.required ?? false,
2841
- size: field.size,
2842
- unique: "unique" in attribute ? attribute.unique : false,
2843
- visible: metadata.visible ?? true,
2844
- type: attribute.type
2845
- };
2846
- }).filter((field) => field !== null)
2847
- );
2944
+ DeleteAction$1.type = "delete";
2945
+ const DEFAULT_HEADER_ACTIONS = [EditTheModelAction, ConfigureTheViewAction, DeleteAction$1];
2946
+ const Panels = () => {
2947
+ const isCloning = useMatch(CLONE_PATH) !== null;
2948
+ const [
2949
+ {
2950
+ query: { status }
2951
+ }
2952
+ ] = useQueryParams({
2953
+ status: "draft"
2954
+ });
2955
+ const { model, id, document, meta, collectionType } = useDoc();
2956
+ const plugins = useStrapiApp("Panels", (state) => state.plugins);
2957
+ const props = {
2958
+ activeTab: status,
2959
+ model,
2960
+ documentId: id,
2961
+ document: isCloning ? void 0 : document,
2962
+ meta: isCloning ? void 0 : meta,
2963
+ collectionType
2964
+ };
2965
+ return /* @__PURE__ */ jsx(Flex, { direction: "column", alignItems: "stretch", gap: 2, children: /* @__PURE__ */ jsx(
2966
+ DescriptionComponentRenderer,
2967
+ {
2968
+ props,
2969
+ descriptions: plugins["content-manager"].apis.getEditViewSidePanels(),
2970
+ children: (panels) => panels.map(({ content, id: id2, ...description }) => /* @__PURE__ */ jsx(Panel, { ...description, children: content }, id2))
2971
+ }
2972
+ ) });
2848
2973
  };
2849
- const formatListLayout = (data, {
2850
- schemas,
2851
- schema,
2852
- components
2853
- }) => {
2854
- const listMetadatas = Object.entries(data.contentType.metadatas).reduce(
2855
- (acc, [attribute, metadata]) => {
2856
- return {
2857
- ...acc,
2858
- [attribute]: metadata.list
2859
- };
2860
- },
2861
- {}
2862
- );
2863
- const listAttributes = convertListLayoutToFieldLayouts(
2864
- data.contentType.layouts.list,
2865
- schema?.attributes,
2866
- listMetadatas,
2867
- { configurations: data.components, schemas: components },
2868
- schemas
2869
- );
2974
+ const ActionsPanel = () => {
2975
+ const { formatMessage } = useIntl();
2870
2976
  return {
2871
- layout: listAttributes,
2872
- settings: { ...data.contentType.settings, displayName: schema?.info.displayName },
2873
- metadatas: listMetadatas,
2874
- options: {
2875
- ...schema?.options,
2876
- ...schema?.pluginOptions,
2877
- ...data.contentType.options
2878
- }
2977
+ title: formatMessage({
2978
+ id: "content-manager.containers.edit.panels.default.title",
2979
+ defaultMessage: "Entry"
2980
+ }),
2981
+ content: /* @__PURE__ */ jsx(ActionsPanelContent, {})
2879
2982
  };
2880
2983
  };
2881
- const convertListLayoutToFieldLayouts = (columns, attributes = {}, metadatas, components, schemas = []) => {
2882
- return columns.map((name) => {
2883
- const attribute = attributes[name];
2884
- if (!attribute) {
2885
- return null;
2984
+ ActionsPanel.type = "actions";
2985
+ const ActionsPanelContent = () => {
2986
+ const isCloning = useMatch(CLONE_PATH) !== null;
2987
+ const [
2988
+ {
2989
+ query: { status = "draft" }
2886
2990
  }
2887
- const metadata = metadatas[name];
2888
- const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
2889
- return {
2890
- attribute,
2891
- label: metadata.label ?? "",
2892
- mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
2893
- schemas,
2894
- components: components?.schemas ?? {}
2895
- }),
2896
- name,
2897
- searchable: metadata.searchable ?? true,
2898
- sortable: metadata.sortable ?? true
2899
- };
2900
- }).filter((field) => field !== null);
2991
+ ] = useQueryParams();
2992
+ const { model, id, document, meta, collectionType } = useDoc();
2993
+ const plugins = useStrapiApp("ActionsPanel", (state) => state.plugins);
2994
+ const props = {
2995
+ activeTab: status,
2996
+ model,
2997
+ documentId: id,
2998
+ document: isCloning ? void 0 : document,
2999
+ meta: isCloning ? void 0 : meta,
3000
+ collectionType
3001
+ };
3002
+ return /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 2, width: "100%", children: [
3003
+ /* @__PURE__ */ jsx(
3004
+ DescriptionComponentRenderer,
3005
+ {
3006
+ props,
3007
+ descriptions: plugins["content-manager"].apis.getDocumentActions(),
3008
+ children: (actions2) => /* @__PURE__ */ jsx(DocumentActions, { actions: actions2 })
3009
+ }
3010
+ ),
3011
+ /* @__PURE__ */ jsx(InjectionZone, { area: "editView.right-links", slug: model })
3012
+ ] });
2901
3013
  };
3014
+ const Panel = React.forwardRef(({ children, title }, ref) => {
3015
+ return /* @__PURE__ */ jsxs(
3016
+ Flex,
3017
+ {
3018
+ ref,
3019
+ tag: "aside",
3020
+ "aria-labelledby": "additional-information",
3021
+ background: "neutral0",
3022
+ borderColor: "neutral150",
3023
+ hasRadius: true,
3024
+ paddingBottom: 4,
3025
+ paddingLeft: 4,
3026
+ paddingRight: 4,
3027
+ paddingTop: 4,
3028
+ shadow: "tableShadow",
3029
+ gap: 3,
3030
+ direction: "column",
3031
+ justifyContent: "stretch",
3032
+ alignItems: "flex-start",
3033
+ children: [
3034
+ /* @__PURE__ */ jsx(Typography, { tag: "h2", variant: "sigma", textTransform: "uppercase", textColor: "neutral600", children: title }),
3035
+ children
3036
+ ]
3037
+ }
3038
+ );
3039
+ });
2902
3040
  const ConfirmBulkActionDialog = ({
2903
3041
  onToggleDialog,
2904
3042
  isOpen = false,
@@ -3143,18 +3281,10 @@ const SelectedEntriesTableContent = ({
3143
3281
  search: row.locale && `?plugins[i18n][locale]=${row.locale}`
3144
3282
  },
3145
3283
  state: { from: pathname },
3146
- label: formatMessage(
3147
- { id: "app.component.HelperPluginTable.edit", defaultMessage: "Edit {target}" },
3148
- {
3149
- target: formatMessage(
3150
- {
3151
- id: "content-manager.components.ListViewHelperPluginTable.row-line",
3152
- defaultMessage: "item line {number}"
3153
- },
3154
- { number: index2 + 1 }
3155
- )
3156
- }
3157
- ),
3284
+ label: formatMessage({
3285
+ id: "content-manager.bulk-publish.edit",
3286
+ defaultMessage: "Edit"
3287
+ }),
3158
3288
  target: "_blank",
3159
3289
  marginLeft: "auto",
3160
3290
  variant: "ghost",
@@ -3798,17 +3928,27 @@ const HistoryAction = ({ model, document }) => {
3798
3928
  const { formatMessage } = useIntl();
3799
3929
  const [{ query }] = useQueryParams();
3800
3930
  const navigate = useNavigate();
3931
+ const { trackUsage } = useTracking();
3932
+ const { pathname } = useLocation();
3801
3933
  const pluginsQueryParams = stringify({ plugins: query.plugins }, { encode: false });
3802
3934
  if (!window.strapi.features.isEnabled("cms-content-history")) {
3803
3935
  return null;
3804
3936
  }
3937
+ const handleOnClick = () => {
3938
+ const destination = { pathname: "history", search: pluginsQueryParams };
3939
+ trackUsage("willNavigate", {
3940
+ from: pathname,
3941
+ to: `${pathname}/${destination.pathname}`
3942
+ });
3943
+ navigate(destination);
3944
+ };
3805
3945
  return {
3806
3946
  icon: /* @__PURE__ */ jsx(ClockCounterClockwise, {}),
3807
3947
  label: formatMessage({
3808
3948
  id: "content-manager.history.document-action",
3809
3949
  defaultMessage: "Content History"
3810
3950
  }),
3811
- onClick: () => navigate({ pathname: "history", search: pluginsQueryParams }),
3951
+ onClick: handleOnClick,
3812
3952
  disabled: (
3813
3953
  /**
3814
3954
  * The user is creating a new document.
@@ -3876,6 +4016,72 @@ const { setInitialData } = actions;
3876
4016
  const reducer = combineReducers({
3877
4017
  app: reducer$1
3878
4018
  });
4019
+ const previewApi = contentManagerApi.injectEndpoints({
4020
+ endpoints: (builder) => ({
4021
+ getPreviewUrl: builder.query({
4022
+ query({ query, params }) {
4023
+ return {
4024
+ url: `/content-manager/preview/url/${params.contentType}`,
4025
+ method: "GET",
4026
+ config: {
4027
+ params: query
4028
+ }
4029
+ };
4030
+ }
4031
+ })
4032
+ })
4033
+ });
4034
+ const { useGetPreviewUrlQuery } = previewApi;
4035
+ const PreviewSidePanel = ({ model, documentId, document }) => {
4036
+ const { formatMessage } = useIntl();
4037
+ const { trackUsage } = useTracking();
4038
+ const { pathname } = useLocation();
4039
+ const [{ query }] = useQueryParams();
4040
+ const { data, error } = useGetPreviewUrlQuery({
4041
+ params: {
4042
+ contentType: model
4043
+ },
4044
+ query: {
4045
+ documentId,
4046
+ locale: document?.locale,
4047
+ status: document?.status
4048
+ }
4049
+ });
4050
+ if (!data?.data?.url || error) {
4051
+ return null;
4052
+ }
4053
+ const trackNavigation = () => {
4054
+ const destinationPathname = pathname.replace(/\/$/, "") + "/preview";
4055
+ trackUsage("willNavigate", { from: pathname, to: destinationPathname });
4056
+ };
4057
+ return {
4058
+ title: formatMessage({ id: "content-manager.preview.panel.title", defaultMessage: "Preview" }),
4059
+ content: /* @__PURE__ */ jsx(Flex, { gap: 2, width: "100%", children: /* @__PURE__ */ jsx(
4060
+ Button,
4061
+ {
4062
+ variant: "tertiary",
4063
+ tag: Link,
4064
+ to: { pathname: "preview", search: stringify(query, { encode: false }) },
4065
+ onClick: trackNavigation,
4066
+ flex: "auto",
4067
+ children: formatMessage({
4068
+ id: "content-manager.preview.panel.button",
4069
+ defaultMessage: "Open preview"
4070
+ })
4071
+ }
4072
+ ) })
4073
+ };
4074
+ };
4075
+ const FEATURE_ID = "preview";
4076
+ const previewAdmin = {
4077
+ bootstrap(app) {
4078
+ if (!window.strapi.future.isEnabled(FEATURE_ID)) {
4079
+ return;
4080
+ }
4081
+ const contentManagerPluginApis = app.getPlugin("content-manager").apis;
4082
+ contentManagerPluginApis.addEditViewSidePanel([PreviewSidePanel]);
4083
+ }
4084
+ };
3879
4085
  const index = {
3880
4086
  register(app) {
3881
4087
  const cm = new ContentManagerPlugin();
@@ -3895,7 +4101,7 @@ const index = {
3895
4101
  app.router.addRoute({
3896
4102
  path: "content-manager/*",
3897
4103
  lazy: async () => {
3898
- const { Layout } = await import("./layout-uomiIGbG.mjs");
4104
+ const { Layout } = await import("./layout-BhIZkPuB.mjs");
3899
4105
  return {
3900
4106
  Component: Layout
3901
4107
  };
@@ -3908,11 +4114,14 @@ const index = {
3908
4114
  if (typeof historyAdmin.bootstrap === "function") {
3909
4115
  historyAdmin.bootstrap(app);
3910
4116
  }
4117
+ if (typeof previewAdmin.bootstrap === "function") {
4118
+ previewAdmin.bootstrap(app);
4119
+ }
3911
4120
  },
3912
4121
  async registerTrads({ locales }) {
3913
4122
  const importedTrads = await Promise.all(
3914
4123
  locales.map((locale) => {
3915
- 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-CbaIuYoB.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 }) => {
4124
+ 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-CfIXaZf9.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 }) => {
3916
4125
  return {
3917
4126
  data: prefixPluginTranslations(data, PLUGIN_ID),
3918
4127
  locale
@@ -3939,8 +4148,10 @@ export {
3939
4148
  HOOKS as H,
3940
4149
  InjectionZone as I,
3941
4150
  useDocument as J,
3942
- index as K,
3943
- useDocumentActions as L,
4151
+ useGetPreviewUrlQuery as K,
4152
+ index as L,
4153
+ useContentManagerContext as M,
4154
+ useDocumentActions as N,
3944
4155
  Panels as P,
3945
4156
  RelativeTime as R,
3946
4157
  SINGLE_TYPES as S,
@@ -3972,4 +4183,4 @@ export {
3972
4183
  capitalise as y,
3973
4184
  useUpdateContentTypeConfigurationMutation as z
3974
4185
  };
3975
- //# sourceMappingURL=index-BJ6uTqLL.mjs.map
4186
+ //# sourceMappingURL=index-DzTs9ga-.mjs.map