@strapi/content-manager 0.0.0-experimental.5b211b38912691ee2eab22d47b5095ea2fcfec76 → 0.0.0-experimental.5c463a4f3349c33b8034dcda66a04758d0efc542

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 (206) hide show
  1. package/LICENSE +18 -3
  2. package/dist/_chunks/{ComponentConfigurationPage-C-49MccQ.js → ComponentConfigurationPage-Cr0ttPAZ.js} +4 -4
  3. package/dist/_chunks/{ComponentConfigurationPage-C-49MccQ.js.map → ComponentConfigurationPage-Cr0ttPAZ.js.map} +1 -1
  4. package/dist/_chunks/{ComponentConfigurationPage-DmwmiFQy.mjs → ComponentConfigurationPage-UGIFDkPO.mjs} +4 -4
  5. package/dist/_chunks/{ComponentConfigurationPage-DmwmiFQy.mjs.map → ComponentConfigurationPage-UGIFDkPO.mjs.map} +1 -1
  6. package/dist/_chunks/{EditConfigurationPage-JT3E7NZy.mjs → EditConfigurationPage-7hF4_8yK.mjs} +4 -4
  7. package/dist/_chunks/{EditConfigurationPage-JT3E7NZy.mjs.map → EditConfigurationPage-7hF4_8yK.mjs.map} +1 -1
  8. package/dist/_chunks/{EditConfigurationPage-DjFJw56M.js → EditConfigurationPage-Ds3BOL2z.js} +4 -4
  9. package/dist/_chunks/{EditConfigurationPage-DjFJw56M.js.map → EditConfigurationPage-Ds3BOL2z.js.map} +1 -1
  10. package/dist/_chunks/{EditViewPage-CPj61RMh.mjs → EditViewPage-CA98g5_g.mjs} +63 -12
  11. package/dist/_chunks/EditViewPage-CA98g5_g.mjs.map +1 -0
  12. package/dist/_chunks/{EditViewPage-zT3fBr4Y.js → EditViewPage-DoQm9llG.js} +62 -11
  13. package/dist/_chunks/EditViewPage-DoQm9llG.js.map +1 -0
  14. package/dist/_chunks/{Field-dha5VnIQ.mjs → Field-B2C1tq9_.mjs} +269 -152
  15. package/dist/_chunks/Field-B2C1tq9_.mjs.map +1 -0
  16. package/dist/_chunks/{Field-Boxf9Ajp.js → Field-CQtLQzHl.js} +271 -154
  17. package/dist/_chunks/Field-CQtLQzHl.js.map +1 -0
  18. package/dist/_chunks/{Form-DHrru2AV.mjs → Form-CxQ2pPjq.mjs} +36 -17
  19. package/dist/_chunks/Form-CxQ2pPjq.mjs.map +1 -0
  20. package/dist/_chunks/{Form-y5g1SRsh.js → Form-YQaS3_NH.js} +36 -17
  21. package/dist/_chunks/Form-YQaS3_NH.js.map +1 -0
  22. package/dist/_chunks/{History-Bru_KoeP.mjs → History-DTYKr2Cg.mjs} +77 -62
  23. package/dist/_chunks/History-DTYKr2Cg.mjs.map +1 -0
  24. package/dist/_chunks/{History-CqN6K7SX.js → History-DbdpigyF.js} +76 -61
  25. package/dist/_chunks/History-DbdpigyF.js.map +1 -0
  26. package/dist/_chunks/{ListConfigurationPage-D8wGABj0.mjs → ListConfigurationPage-DQG-j52q.mjs} +21 -9
  27. package/dist/_chunks/ListConfigurationPage-DQG-j52q.mjs.map +1 -0
  28. package/dist/_chunks/{ListConfigurationPage-R_p-SbHZ.js → ListConfigurationPage-DRGhXnUA.js} +21 -9
  29. package/dist/_chunks/ListConfigurationPage-DRGhXnUA.js.map +1 -0
  30. package/dist/_chunks/{ListViewPage-pEw_zug9.js → ListViewPage-CVIEfYWN.js} +86 -46
  31. package/dist/_chunks/ListViewPage-CVIEfYWN.js.map +1 -0
  32. package/dist/_chunks/{ListViewPage-SID6TRb9.mjs → ListViewPage-DAekmnvp.mjs} +84 -44
  33. package/dist/_chunks/ListViewPage-DAekmnvp.mjs.map +1 -0
  34. package/dist/_chunks/{NoContentTypePage-CJ7UXwrQ.mjs → NoContentTypePage-5kwUPeFg.mjs} +2 -2
  35. package/dist/_chunks/{NoContentTypePage-CJ7UXwrQ.mjs.map → NoContentTypePage-5kwUPeFg.mjs.map} +1 -1
  36. package/dist/_chunks/{NoContentTypePage-C5dcQojD.js → NoContentTypePage-CTcfA2-Q.js} +2 -2
  37. package/dist/_chunks/{NoContentTypePage-C5dcQojD.js.map → NoContentTypePage-CTcfA2-Q.js.map} +1 -1
  38. package/dist/_chunks/{NoPermissionsPage-B7syEq5E.mjs → NoPermissionsPage-d-JtEVAw.mjs} +2 -2
  39. package/dist/_chunks/{NoPermissionsPage-B7syEq5E.mjs.map → NoPermissionsPage-d-JtEVAw.mjs.map} +1 -1
  40. package/dist/_chunks/{NoPermissionsPage-BtPrImPP.js → NoPermissionsPage-pVeCVj9a.js} +2 -2
  41. package/dist/_chunks/{NoPermissionsPage-BtPrImPP.js.map → NoPermissionsPage-pVeCVj9a.js.map} +1 -1
  42. package/dist/_chunks/Preview-COsm52rZ.js +307 -0
  43. package/dist/_chunks/Preview-COsm52rZ.js.map +1 -0
  44. package/dist/_chunks/Preview-gkmvcwhu.mjs +288 -0
  45. package/dist/_chunks/Preview-gkmvcwhu.mjs.map +1 -0
  46. package/dist/_chunks/{Relations-B9Crnhnn.mjs → Relations-7ItTFWp7.mjs} +73 -37
  47. package/dist/_chunks/Relations-7ItTFWp7.mjs.map +1 -0
  48. package/dist/_chunks/{Relations-DjTQ5kGB.js → Relations-Beo_uDz1.js} +72 -36
  49. package/dist/_chunks/Relations-Beo_uDz1.js.map +1 -0
  50. package/dist/_chunks/{en-fbKQxLGn.js → en-CHOp_xJv.js} +27 -16
  51. package/dist/_chunks/{en-fbKQxLGn.js.map → en-CHOp_xJv.js.map} +1 -1
  52. package/dist/_chunks/{en-Ux26r5pl.mjs → en-D_BMf0hT.mjs} +27 -16
  53. package/dist/_chunks/{en-Ux26r5pl.mjs.map → en-D_BMf0hT.mjs.map} +1 -1
  54. package/dist/_chunks/{es-EUonQTon.js → es-9K52xZIr.js} +2 -2
  55. package/dist/_chunks/{ja-CcFe8diO.js.map → es-9K52xZIr.js.map} +1 -1
  56. package/dist/_chunks/{es-CeXiYflN.mjs → es-D34tqjMw.mjs} +2 -2
  57. package/dist/_chunks/{es-CeXiYflN.mjs.map → es-D34tqjMw.mjs.map} +1 -1
  58. package/dist/_chunks/{fr-CD9VFbPM.mjs → fr--pg5jUbt.mjs} +13 -3
  59. package/dist/_chunks/{fr-CD9VFbPM.mjs.map → fr--pg5jUbt.mjs.map} +1 -1
  60. package/dist/_chunks/{fr-B7kGGg3E.js → fr-B2Kyv8Z9.js} +13 -3
  61. package/dist/_chunks/{fr-B7kGGg3E.js.map → fr-B2Kyv8Z9.js.map} +1 -1
  62. package/dist/_chunks/{index-DVPWZkbS.js → index-CJX65DLa.js} +1070 -680
  63. package/dist/_chunks/index-CJX65DLa.js.map +1 -0
  64. package/dist/_chunks/{index-DJXJw9V5.mjs → index-D3IiO0X8.mjs} +1088 -699
  65. package/dist/_chunks/index-D3IiO0X8.mjs.map +1 -0
  66. package/dist/_chunks/{ja-CcFe8diO.js → ja-7sfIbjxE.js} +2 -2
  67. package/dist/_chunks/{es-EUonQTon.js.map → ja-7sfIbjxE.js.map} +1 -1
  68. package/dist/_chunks/{ja-CtsUxOvk.mjs → ja-BHqhDq4V.mjs} +2 -2
  69. package/dist/_chunks/{ja-CtsUxOvk.mjs.map → ja-BHqhDq4V.mjs.map} +1 -1
  70. package/dist/_chunks/{layout-Dm6fbiQj.js → layout-9fI2_QJt.js} +24 -11
  71. package/dist/_chunks/layout-9fI2_QJt.js.map +1 -0
  72. package/dist/_chunks/{layout-Bau7ZfLV.mjs → layout-OhrmoJVB.mjs} +25 -12
  73. package/dist/_chunks/layout-OhrmoJVB.mjs.map +1 -0
  74. package/dist/_chunks/{objects-gigeqt7s.js → objects-BcXOv6_9.js} +2 -4
  75. package/dist/_chunks/{objects-gigeqt7s.js.map → objects-BcXOv6_9.js.map} +1 -1
  76. package/dist/_chunks/{objects-mKMAmfec.mjs → objects-D6yBsdmx.mjs} +2 -4
  77. package/dist/_chunks/{objects-mKMAmfec.mjs.map → objects-D6yBsdmx.mjs.map} +1 -1
  78. package/dist/_chunks/{relations-CKnpRgrN.js → relations-DIT8sP52.js} +6 -7
  79. package/dist/_chunks/relations-DIT8sP52.js.map +1 -0
  80. package/dist/_chunks/{relations-BH_kBSJ0.mjs → relations-sRERvWmr.mjs} +6 -7
  81. package/dist/_chunks/relations-sRERvWmr.mjs.map +1 -0
  82. package/dist/_chunks/{usePrev-B9w_-eYc.js → useDebounce-CtcjDB3L.js} +14 -1
  83. package/dist/_chunks/useDebounce-CtcjDB3L.js.map +1 -0
  84. package/dist/_chunks/useDebounce-DmuSJIF3.mjs +29 -0
  85. package/dist/_chunks/useDebounce-DmuSJIF3.mjs.map +1 -0
  86. package/dist/admin/index.js +2 -1
  87. package/dist/admin/index.js.map +1 -1
  88. package/dist/admin/index.mjs +5 -4
  89. package/dist/admin/src/exports.d.ts +1 -1
  90. package/dist/admin/src/history/index.d.ts +3 -0
  91. package/dist/admin/src/history/services/historyVersion.d.ts +1 -1
  92. package/dist/admin/src/hooks/useDocument.d.ts +32 -1
  93. package/dist/admin/src/index.d.ts +1 -0
  94. package/dist/admin/src/pages/EditView/EditViewPage.d.ts +9 -1
  95. package/dist/admin/src/pages/EditView/components/DocumentActions.d.ts +1 -0
  96. package/dist/admin/src/pages/EditView/components/DocumentStatus.d.ts +1 -1
  97. package/dist/admin/src/pages/EditView/components/FormInputs/Relations.d.ts +20 -0
  98. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/EditorLayout.d.ts +2 -2
  99. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygFooter.d.ts +2 -2
  100. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygStyles.d.ts +4 -48
  101. package/dist/admin/src/pages/EditView/components/Header.d.ts +11 -11
  102. package/dist/admin/src/preview/components/PreviewContent.d.ts +2 -0
  103. package/dist/admin/src/preview/components/PreviewHeader.d.ts +2 -0
  104. package/dist/admin/src/preview/components/PreviewSidePanel.d.ts +3 -0
  105. package/dist/admin/src/preview/constants.d.ts +1 -0
  106. package/dist/admin/src/preview/index.d.ts +4 -0
  107. package/dist/admin/src/preview/pages/Preview.d.ts +11 -0
  108. package/dist/admin/src/preview/routes.d.ts +3 -0
  109. package/dist/admin/src/preview/services/preview.d.ts +3 -0
  110. package/dist/admin/src/router.d.ts +1 -1
  111. package/dist/admin/src/services/api.d.ts +1 -1
  112. package/dist/admin/src/services/components.d.ts +2 -2
  113. package/dist/admin/src/services/contentTypes.d.ts +3 -3
  114. package/dist/admin/src/services/documents.d.ts +19 -17
  115. package/dist/admin/src/services/init.d.ts +1 -1
  116. package/dist/admin/src/services/relations.d.ts +2 -2
  117. package/dist/admin/src/services/uid.d.ts +3 -3
  118. package/dist/admin/src/utils/validation.d.ts +4 -1
  119. package/dist/server/index.js +548 -261
  120. package/dist/server/index.js.map +1 -1
  121. package/dist/server/index.mjs +549 -262
  122. package/dist/server/index.mjs.map +1 -1
  123. package/dist/server/src/bootstrap.d.ts.map +1 -1
  124. package/dist/server/src/controllers/collection-types.d.ts.map +1 -1
  125. package/dist/server/src/controllers/index.d.ts.map +1 -1
  126. package/dist/server/src/controllers/relations.d.ts.map +1 -1
  127. package/dist/server/src/controllers/uid.d.ts.map +1 -1
  128. package/dist/server/src/controllers/utils/metadata.d.ts +15 -1
  129. package/dist/server/src/controllers/utils/metadata.d.ts.map +1 -1
  130. package/dist/server/src/controllers/validation/dimensions.d.ts +4 -2
  131. package/dist/server/src/controllers/validation/dimensions.d.ts.map +1 -1
  132. package/dist/server/src/history/services/history.d.ts.map +1 -1
  133. package/dist/server/src/history/services/lifecycles.d.ts.map +1 -1
  134. package/dist/server/src/history/services/utils.d.ts +4 -4
  135. package/dist/server/src/history/services/utils.d.ts.map +1 -1
  136. package/dist/server/src/index.d.ts +4 -4
  137. package/dist/server/src/policies/hasPermissions.d.ts.map +1 -1
  138. package/dist/server/src/preview/constants.d.ts +2 -0
  139. package/dist/server/src/preview/constants.d.ts.map +1 -0
  140. package/dist/server/src/preview/controllers/index.d.ts +2 -0
  141. package/dist/server/src/preview/controllers/index.d.ts.map +1 -0
  142. package/dist/server/src/preview/controllers/preview.d.ts +13 -0
  143. package/dist/server/src/preview/controllers/preview.d.ts.map +1 -0
  144. package/dist/server/src/preview/controllers/validation/preview.d.ts +6 -0
  145. package/dist/server/src/preview/controllers/validation/preview.d.ts.map +1 -0
  146. package/dist/server/src/preview/index.d.ts +4 -0
  147. package/dist/server/src/preview/index.d.ts.map +1 -0
  148. package/dist/server/src/preview/routes/index.d.ts +8 -0
  149. package/dist/server/src/preview/routes/index.d.ts.map +1 -0
  150. package/dist/server/src/preview/routes/preview.d.ts +4 -0
  151. package/dist/server/src/preview/routes/preview.d.ts.map +1 -0
  152. package/dist/server/src/preview/services/index.d.ts +15 -0
  153. package/dist/server/src/preview/services/index.d.ts.map +1 -0
  154. package/dist/server/src/preview/services/preview-config.d.ts +30 -0
  155. package/dist/server/src/preview/services/preview-config.d.ts.map +1 -0
  156. package/dist/server/src/preview/services/preview.d.ts +12 -0
  157. package/dist/server/src/preview/services/preview.d.ts.map +1 -0
  158. package/dist/server/src/preview/utils.d.ts +18 -0
  159. package/dist/server/src/preview/utils.d.ts.map +1 -0
  160. package/dist/server/src/routes/index.d.ts.map +1 -1
  161. package/dist/server/src/services/document-manager.d.ts.map +1 -1
  162. package/dist/server/src/services/document-metadata.d.ts +8 -8
  163. package/dist/server/src/services/document-metadata.d.ts.map +1 -1
  164. package/dist/server/src/services/index.d.ts +4 -4
  165. package/dist/server/src/services/index.d.ts.map +1 -1
  166. package/dist/server/src/services/permission-checker.d.ts.map +1 -1
  167. package/dist/server/src/services/utils/configuration/index.d.ts +2 -2
  168. package/dist/server/src/services/utils/configuration/layouts.d.ts +2 -2
  169. package/dist/server/src/services/utils/populate.d.ts.map +1 -1
  170. package/dist/server/src/utils/index.d.ts +2 -0
  171. package/dist/server/src/utils/index.d.ts.map +1 -1
  172. package/dist/shared/contracts/collection-types.d.ts +3 -1
  173. package/dist/shared/contracts/collection-types.d.ts.map +1 -1
  174. package/dist/shared/contracts/index.d.ts +1 -0
  175. package/dist/shared/contracts/index.d.ts.map +1 -1
  176. package/dist/shared/contracts/preview.d.ts +27 -0
  177. package/dist/shared/contracts/preview.d.ts.map +1 -0
  178. package/dist/shared/index.js +4 -0
  179. package/dist/shared/index.js.map +1 -1
  180. package/dist/shared/index.mjs +4 -0
  181. package/dist/shared/index.mjs.map +1 -1
  182. package/package.json +13 -13
  183. package/dist/_chunks/EditViewPage-CPj61RMh.mjs.map +0 -1
  184. package/dist/_chunks/EditViewPage-zT3fBr4Y.js.map +0 -1
  185. package/dist/_chunks/Field-Boxf9Ajp.js.map +0 -1
  186. package/dist/_chunks/Field-dha5VnIQ.mjs.map +0 -1
  187. package/dist/_chunks/Form-DHrru2AV.mjs.map +0 -1
  188. package/dist/_chunks/Form-y5g1SRsh.js.map +0 -1
  189. package/dist/_chunks/History-Bru_KoeP.mjs.map +0 -1
  190. package/dist/_chunks/History-CqN6K7SX.js.map +0 -1
  191. package/dist/_chunks/ListConfigurationPage-D8wGABj0.mjs.map +0 -1
  192. package/dist/_chunks/ListConfigurationPage-R_p-SbHZ.js.map +0 -1
  193. package/dist/_chunks/ListViewPage-SID6TRb9.mjs.map +0 -1
  194. package/dist/_chunks/ListViewPage-pEw_zug9.js.map +0 -1
  195. package/dist/_chunks/Relations-B9Crnhnn.mjs.map +0 -1
  196. package/dist/_chunks/Relations-DjTQ5kGB.js.map +0 -1
  197. package/dist/_chunks/index-DJXJw9V5.mjs.map +0 -1
  198. package/dist/_chunks/index-DVPWZkbS.js.map +0 -1
  199. package/dist/_chunks/layout-Bau7ZfLV.mjs.map +0 -1
  200. package/dist/_chunks/layout-Dm6fbiQj.js.map +0 -1
  201. package/dist/_chunks/relations-BH_kBSJ0.mjs.map +0 -1
  202. package/dist/_chunks/relations-CKnpRgrN.js.map +0 -1
  203. package/dist/_chunks/usePrev-B9w_-eYc.js.map +0 -1
  204. package/dist/_chunks/usePrev-DH6iah0A.mjs +0 -16
  205. package/dist/_chunks/usePrev-DH6iah0A.mjs.map +0 -1
  206. package/strapi-server.js +0 -3
@@ -1,17 +1,18 @@
1
- import { ClockCounterClockwise, CrossCircle, More, WarningCircle, ListPlus, Pencil, Trash, Check, CheckCircle, ArrowsCounterClockwise, ChevronRight, Duplicate, 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, useQueryParams, createContext, useAuth, useRBAC, Page, adminApi, translatedErrors, useNotification, useAPIErrorHandler, getYupValidationErrors, useTracking, useForm, BackButton, DescriptionComponentRenderer, useTable, Table } from "@strapi/admin/strapi-admin";
4
- import { stringify } from "qs";
5
- import { useIntl } from "react-intl";
6
- import { useNavigate, useParams, Navigate, useMatch, useLocation, Link, NavLink } from "react-router-dom";
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";
7
4
  import * as React from "react";
8
5
  import { lazy } from "react";
9
- import { Button, Menu, VisuallyHidden, Flex, Box, Typography, Dialog, Modal, Radio, Status, SingleSelect, SingleSelectOption, Loader, IconButton, Tooltip, LinkButton } from "@strapi/design-system";
10
- import { styled } from "styled-components";
6
+ import { Button, Menu, 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";
8
+ import { useIntl } from "react-intl";
9
+ import { useParams, useNavigate, Navigate, useMatch, useLocation, Link, NavLink } from "react-router-dom";
11
10
  import * as yup from "yup";
12
11
  import { ValidationError } from "yup";
13
12
  import pipe from "lodash/fp/pipe";
14
13
  import { intervalToDuration, isPast } from "date-fns";
14
+ import { styled } from "styled-components";
15
+ import { stringify } from "qs";
15
16
  import { createSlice, combineReducers } from "@reduxjs/toolkit";
16
17
  const __variableDynamicImportRuntimeHelper = (glob, path) => {
17
18
  const v = glob[path];
@@ -49,42 +50,6 @@ const useInjectionZone = (area) => {
49
50
  const [page, position] = area.split(".");
50
51
  return contentManagerPlugin.getInjectedComponents(page, position);
51
52
  };
52
- const HistoryAction = ({ model, document }) => {
53
- const { formatMessage } = useIntl();
54
- const [{ query }] = useQueryParams();
55
- const navigate = useNavigate();
56
- const pluginsQueryParams = stringify({ plugins: query.plugins }, { encode: false });
57
- if (!window.strapi.features.isEnabled("cms-content-history")) {
58
- return null;
59
- }
60
- return {
61
- icon: /* @__PURE__ */ jsx(ClockCounterClockwise, {}),
62
- label: formatMessage({
63
- id: "content-manager.history.document-action",
64
- defaultMessage: "Content History"
65
- }),
66
- onClick: () => navigate({ pathname: "history", search: pluginsQueryParams }),
67
- disabled: (
68
- /**
69
- * The user is creating a new document.
70
- * It hasn't been saved yet, so there's no history to go to
71
- */
72
- !document || /**
73
- * The document has been created but the current dimension has never been saved.
74
- * For example, the user is creating a new locale in an existing document,
75
- * so there's no history for the document in that locale
76
- */
77
- !document.id || /**
78
- * History is only available for content types created by the user.
79
- * These have the `api::` prefix, as opposed to the ones created by Strapi or plugins,
80
- * which start with `admin::` or `plugin::`
81
- */
82
- !model.startsWith("api::")
83
- ),
84
- position: "header"
85
- };
86
- };
87
- HistoryAction.type = "history";
88
53
  const ID = "id";
89
54
  const CREATED_BY_ATTRIBUTE_NAME = "createdBy";
90
55
  const UPDATED_BY_ATTRIBUTE_NAME = "updatedBy";
@@ -136,6 +101,7 @@ const DocumentRBAC = ({ children, permissions }) => {
136
101
  if (!slug) {
137
102
  throw new Error("Cannot find the slug param in the URL");
138
103
  }
104
+ const [{ rawQuery }] = useQueryParams();
139
105
  const userPermissions = useAuth("DocumentRBAC", (state) => state.permissions);
140
106
  const contentTypePermissions = React.useMemo(() => {
141
107
  const contentTypePermissions2 = userPermissions.filter(
@@ -146,7 +112,14 @@ const DocumentRBAC = ({ children, permissions }) => {
146
112
  return { ...acc, [action]: [permission] };
147
113
  }, {});
148
114
  }, [slug, userPermissions]);
149
- 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
+ );
150
123
  const canCreateFields = !isLoading && allowedActions.canCreate ? extractAndDedupeFields(contentTypePermissions.create) : [];
151
124
  const canReadFields = !isLoading && allowedActions.canRead ? extractAndDedupeFields(contentTypePermissions.read) : [];
152
125
  const canUpdateFields = !isLoading && allowedActions.canUpdate ? extractAndDedupeFields(contentTypePermissions.update) : [];
@@ -194,7 +167,8 @@ const contentManagerApi = adminApi.enhanceEndpoints({
194
167
  "Document",
195
168
  "InitialData",
196
169
  "HistoryVersion",
197
- "Relations"
170
+ "Relations",
171
+ "UidAvailability"
198
172
  ]
199
173
  });
200
174
  const documentApi = contentManagerApi.injectEndpoints({
@@ -208,7 +182,12 @@ const documentApi = contentManagerApi.injectEndpoints({
208
182
  params: query
209
183
  }
210
184
  }),
211
- invalidatesTags: (_result, _error, { model }) => [{ type: "Document", id: `${model}_LIST` }]
185
+ invalidatesTags: (_result, error, { model }) => {
186
+ if (error) {
187
+ return [];
188
+ }
189
+ return [{ type: "Document", id: `${model}_LIST` }];
190
+ }
212
191
  }),
213
192
  cloneDocument: builder.mutation({
214
193
  query: ({ model, sourceId, data, params }) => ({
@@ -219,7 +198,10 @@ const documentApi = contentManagerApi.injectEndpoints({
219
198
  params
220
199
  }
221
200
  }),
222
- invalidatesTags: (_result, _error, { model }) => [{ type: "Document", id: `${model}_LIST` }]
201
+ invalidatesTags: (_result, _error, { model }) => [
202
+ { type: "Document", id: `${model}_LIST` },
203
+ { type: "UidAvailability", id: model }
204
+ ]
223
205
  }),
224
206
  /**
225
207
  * Creates a new collection-type document. This should ONLY be used for collection-types.
@@ -236,7 +218,8 @@ const documentApi = contentManagerApi.injectEndpoints({
236
218
  }),
237
219
  invalidatesTags: (result, _error, { model }) => [
238
220
  { type: "Document", id: `${model}_LIST` },
239
- "Relations"
221
+ "Relations",
222
+ { type: "UidAvailability", id: model }
240
223
  ]
241
224
  }),
242
225
  deleteDocument: builder.mutation({
@@ -277,7 +260,8 @@ const documentApi = contentManagerApi.injectEndpoints({
277
260
  id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
278
261
  },
279
262
  { type: "Document", id: `${model}_LIST` },
280
- "Relations"
263
+ "Relations",
264
+ { type: "UidAvailability", id: model }
281
265
  ];
282
266
  }
283
267
  }),
@@ -295,6 +279,7 @@ const documentApi = contentManagerApi.injectEndpoints({
295
279
  }),
296
280
  providesTags: (result, _error, arg) => {
297
281
  return [
282
+ { type: "Document", id: `ALL_LIST` },
298
283
  { type: "Document", id: `${arg.model}_LIST` },
299
284
  ...result?.results.map(({ documentId }) => ({
300
285
  type: "Document",
@@ -333,6 +318,11 @@ const documentApi = contentManagerApi.injectEndpoints({
333
318
  {
334
319
  type: "Document",
335
320
  id: collectionType !== SINGLE_TYPES ? `${model}_${result && "documentId" in result ? result.documentId : documentId}` : model
321
+ },
322
+ // Make it easy to invalidate all individual documents queries for a model
323
+ {
324
+ type: "Document",
325
+ id: `${model}_ALL_ITEMS`
336
326
  }
337
327
  ];
338
328
  }
@@ -396,8 +386,21 @@ const documentApi = contentManagerApi.injectEndpoints({
396
386
  type: "Document",
397
387
  id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
398
388
  },
399
- "Relations"
389
+ "Relations",
390
+ { type: "UidAvailability", id: model }
400
391
  ];
392
+ },
393
+ async onQueryStarted({ data, ...patch }, { dispatch, queryFulfilled }) {
394
+ const patchResult = dispatch(
395
+ documentApi.util.updateQueryData("getDocument", patch, (draft) => {
396
+ Object.assign(draft.data, data);
397
+ })
398
+ );
399
+ try {
400
+ await queryFulfilled;
401
+ } catch {
402
+ patchResult.undo();
403
+ }
401
404
  }
402
405
  }),
403
406
  unpublishDocument: builder.mutation({
@@ -467,20 +470,39 @@ const buildValidParams = (query) => {
467
470
  const isBaseQueryError = (error) => {
468
471
  return error.name !== void 0;
469
472
  };
470
- const createYupSchema = (attributes = {}, components = {}) => {
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
+ });
491
+ const createYupSchema = (attributes = {}, components = {}, options = { status: null }) => {
471
492
  const createModelSchema = (attributes2) => yup.object().shape(
472
493
  Object.entries(attributes2).reduce((acc, [name, attribute]) => {
473
494
  if (DOCUMENT_META_FIELDS.includes(name)) {
474
495
  return acc;
475
496
  }
476
497
  const validations = [
498
+ addNullableValidation,
477
499
  addRequiredValidation,
478
500
  addMinLengthValidation,
479
501
  addMaxLengthValidation,
480
502
  addMinValidation,
481
503
  addMaxValidation,
482
504
  addRegexValidation
483
- ].map((fn) => fn(attribute));
505
+ ].map((fn) => fn(attribute, options));
484
506
  const transformSchema = pipe(...validations);
485
507
  switch (attribute.type) {
486
508
  case "component": {
@@ -490,12 +512,12 @@ const createYupSchema = (attributes = {}, components = {}) => {
490
512
  ...acc,
491
513
  [name]: transformSchema(
492
514
  yup.array().of(createModelSchema(attributes3).nullable(false))
493
- )
515
+ ).test(arrayValidator(attribute, options))
494
516
  };
495
517
  } else {
496
518
  return {
497
519
  ...acc,
498
- [name]: transformSchema(createModelSchema(attributes3))
520
+ [name]: transformSchema(createModelSchema(attributes3).nullable())
499
521
  };
500
522
  }
501
523
  }
@@ -517,7 +539,7 @@ const createYupSchema = (attributes = {}, components = {}) => {
517
539
  }
518
540
  )
519
541
  )
520
- )
542
+ ).test(arrayValidator(attribute, options))
521
543
  };
522
544
  case "relation":
523
545
  return {
@@ -529,7 +551,7 @@ const createYupSchema = (attributes = {}, components = {}) => {
529
551
  } else if (Array.isArray(value)) {
530
552
  return yup.array().of(
531
553
  yup.object().shape({
532
- id: yup.string().required()
554
+ id: yup.number().required()
533
555
  })
534
556
  );
535
557
  } else if (typeof value === "object") {
@@ -581,6 +603,14 @@ const createAttributeSchema = (attribute) => {
581
603
  if (!value || typeof value === "string" && value.length === 0) {
582
604
  return true;
583
605
  }
606
+ if (typeof value === "object") {
607
+ try {
608
+ JSON.stringify(value);
609
+ return true;
610
+ } catch (err) {
611
+ return false;
612
+ }
613
+ }
584
614
  try {
585
615
  JSON.parse(value);
586
616
  return true;
@@ -599,13 +629,7 @@ const createAttributeSchema = (attribute) => {
599
629
  return yup.mixed();
600
630
  }
601
631
  };
602
- const addRequiredValidation = (attribute) => (schema) => {
603
- if (attribute.required) {
604
- return schema.required({
605
- id: translatedErrors.required.id,
606
- defaultMessage: "This field is required."
607
- });
608
- }
632
+ const nullableSchema = (schema) => {
609
633
  return schema?.nullable ? schema.nullable() : (
610
634
  // In some cases '.nullable' will not be available on the schema.
611
635
  // e.g. when the schema has been built using yup.lazy (e.g. for relations).
@@ -613,7 +637,22 @@ const addRequiredValidation = (attribute) => (schema) => {
613
637
  schema
614
638
  );
615
639
  };
616
- const addMinLengthValidation = (attribute) => (schema) => {
640
+ const addNullableValidation = () => (schema) => {
641
+ return nullableSchema(schema);
642
+ };
643
+ const addRequiredValidation = (attribute, options) => (schema) => {
644
+ if (options.status === "draft" || !attribute.required) {
645
+ return schema;
646
+ }
647
+ if (attribute.required && "required" in schema) {
648
+ return schema.required(translatedErrors.required);
649
+ }
650
+ return schema;
651
+ };
652
+ const addMinLengthValidation = (attribute, options) => (schema) => {
653
+ if (options.status === "draft") {
654
+ return schema;
655
+ }
617
656
  if ("minLength" in attribute && attribute.minLength && Number.isInteger(attribute.minLength) && "min" in schema) {
618
657
  return schema.min(attribute.minLength, {
619
658
  ...translatedErrors.minLength,
@@ -635,10 +674,13 @@ const addMaxLengthValidation = (attribute) => (schema) => {
635
674
  }
636
675
  return schema;
637
676
  };
638
- const addMinValidation = (attribute) => (schema) => {
639
- if ("min" in attribute) {
677
+ const addMinValidation = (attribute, options) => (schema) => {
678
+ if (options.status === "draft") {
679
+ return schema;
680
+ }
681
+ if ("min" in attribute && "min" in schema) {
640
682
  const min = toInteger(attribute.min);
641
- if ("min" in schema && min) {
683
+ if (min) {
642
684
  return schema.min(min, {
643
685
  ...translatedErrors.min,
644
686
  values: {
@@ -756,16 +798,115 @@ const extractContentTypeComponents = (attributes = {}, allComponents = {}) => {
756
798
  }, {});
757
799
  return componentsByKey;
758
800
  };
759
- 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);
760
900
  const { toggleNotification } = useNotification();
761
901
  const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();
902
+ const { isLoading: isLoadingSchemas, schemas } = useContentTypeSchema();
762
903
  const {
763
- currentData: data,
764
- isLoading: isLoadingDocument,
765
- isFetching: isFetchingDocument,
766
- error
767
- } = useGetDocumentQuery(args, opts);
768
- 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;
769
910
  React.useEffect(() => {
770
911
  if (error) {
771
912
  toggleNotification({
@@ -773,68 +914,322 @@ const useDocument = (args, opts) => {
773
914
  message: formatAPIError(error)
774
915
  });
775
916
  }
776
- }, [toggleNotification, error, formatAPIError, args.collectionType]);
777
- const validationSchema = React.useMemo(() => {
778
- if (!schema) {
779
- return null;
780
- }
781
- return createYupSchema(schema.attributes, components);
782
- }, [schema, components]);
783
- const validate = React.useCallback(
784
- (document) => {
785
- if (!validationSchema) {
786
- throw new Error(
787
- "There is no validation schema generated, this is likely due to the schema not being loaded yet."
788
- );
789
- }
790
- try {
791
- validationSchema.validateSync(document, { abortEarly: false, strict: true });
792
- return null;
793
- } catch (error2) {
794
- if (error2 instanceof ValidationError) {
795
- return getYupValidationErrors(error2);
796
- }
797
- throw error2;
798
- }
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
799
925
  },
800
- [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]
801
942
  );
802
- const isLoading = isLoadingDocument || isFetchingDocument || isLoadingSchema;
803
943
  return {
804
- components,
805
- document: data?.data,
806
- meta: data?.meta,
944
+ error,
807
945
  isLoading,
808
- schema,
809
- validate
946
+ edit,
947
+ list: listLayout
810
948
  };
811
949
  };
812
- const useDoc = () => {
813
- const { id, slug, collectionType, origin } = useParams();
814
- const [{ query }] = useQueryParams();
815
- const params = React.useMemo(() => buildValidParams(query), [query]);
816
- if (!collectionType) {
817
- throw new Error("Could not find collectionType in url params");
818
- }
819
- if (!slug) {
820
- throw new Error("Could not find model in url params");
821
- }
950
+ const useDocLayout = () => {
951
+ const { model } = useDoc();
952
+ return useDocumentLayout(model);
953
+ };
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);
975
+ }
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
992
+ }
993
+ };
994
+ return acc;
995
+ },
996
+ {}
997
+ );
998
+ const editMetadatas = Object.entries(data.contentType.metadatas).reduce(
999
+ (acc, [attribute, metadata]) => {
1000
+ return {
1001
+ ...acc,
1002
+ [attribute]: metadata.edit
1003
+ };
1004
+ },
1005
+ {}
1006
+ );
1007
+ return {
1008
+ layout: panelledEditAttributes,
1009
+ components: componentEditAttributes,
1010
+ metadatas: editMetadatas,
1011
+ settings: {
1012
+ ...data.contentType.settings,
1013
+ displayName: schema?.info.displayName
1014
+ },
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;
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
+ };
1063
+ },
1064
+ {}
1065
+ );
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
+ }
1144
+ try {
1145
+ validationSchema.validateSync(document, { abortEarly: false, strict: true });
1146
+ return null;
1147
+ } catch (error2) {
1148
+ if (error2 instanceof ValidationError) {
1149
+ return getYupValidationErrors(error2);
1150
+ }
1151
+ throw error2;
1152
+ }
1153
+ },
1154
+ [validationSchema]
1155
+ );
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;
822
1186
  return {
823
1187
  collectionType,
824
1188
  model: slug,
825
- id: origin || id === "create" ? void 0 : id,
826
- ...useDocument(
827
- { documentId: origin || id, model: slug, collectionType, params },
828
- {
829
- skip: id === "create" || !origin && !id && collectionType !== SINGLE_TYPES
830
- }
831
- )
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
832
1230
  };
833
1231
  };
834
1232
  const prefixPluginTranslations = (trad, pluginId) => {
835
- if (!pluginId) {
836
- throw new TypeError("pluginId can't be empty");
837
- }
838
1233
  return Object.keys(trad).reduce((acc, current) => {
839
1234
  acc[`${pluginId}.${current}`] = trad[current];
840
1235
  return acc;
@@ -850,6 +1245,8 @@ const useDocumentActions = () => {
850
1245
  const { formatMessage } = useIntl();
851
1246
  const { trackUsage } = useTracking();
852
1247
  const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();
1248
+ const navigate = useNavigate();
1249
+ const setCurrentStep = useGuidedTour("useDocumentActions", (state) => state.setCurrentStep);
853
1250
  const [deleteDocument] = useDeleteDocumentMutation();
854
1251
  const _delete = React.useCallback(
855
1252
  async ({ collectionType, model, documentId, params }, trackerProperty) => {
@@ -1164,6 +1561,7 @@ const useDocumentActions = () => {
1164
1561
  defaultMessage: "Saved document"
1165
1562
  })
1166
1563
  });
1564
+ setCurrentStep("contentManager.success");
1167
1565
  return res.data;
1168
1566
  } catch (err) {
1169
1567
  toggleNotification({
@@ -1185,7 +1583,6 @@ const useDocumentActions = () => {
1185
1583
  sourceId
1186
1584
  });
1187
1585
  if ("error" in res) {
1188
- toggleNotification({ type: "danger", message: formatAPIError(res.error) });
1189
1586
  return { error: res.error };
1190
1587
  }
1191
1588
  toggleNotification({
@@ -1204,7 +1601,7 @@ const useDocumentActions = () => {
1204
1601
  throw err;
1205
1602
  }
1206
1603
  },
1207
- [autoCloneDocument, formatAPIError, formatMessage, toggleNotification]
1604
+ [autoCloneDocument, formatMessage, toggleNotification]
1208
1605
  );
1209
1606
  const [cloneDocument] = useCloneDocumentMutation();
1210
1607
  const clone = React.useCallback(
@@ -1230,6 +1627,7 @@ const useDocumentActions = () => {
1230
1627
  defaultMessage: "Cloned document"
1231
1628
  })
1232
1629
  });
1630
+ navigate(`../../${res.data.data.documentId}`, { relative: "path" });
1233
1631
  return res.data;
1234
1632
  } catch (err) {
1235
1633
  toggleNotification({
@@ -1240,7 +1638,7 @@ const useDocumentActions = () => {
1240
1638
  throw err;
1241
1639
  }
1242
1640
  },
1243
- [cloneDocument, trackUsage, toggleNotification, formatMessage, formatAPIError]
1641
+ [cloneDocument, trackUsage, toggleNotification, formatMessage, formatAPIError, navigate]
1244
1642
  );
1245
1643
  const [getDoc] = useLazyGetDocumentQuery();
1246
1644
  const getDocument = React.useCallback(
@@ -1265,10 +1663,10 @@ const useDocumentActions = () => {
1265
1663
  update
1266
1664
  };
1267
1665
  };
1268
- const ProtectedHistoryPage = lazy(
1269
- () => import("./History-Bru_KoeP.mjs").then((mod) => ({ default: mod.ProtectedHistoryPage }))
1666
+ const ProtectedHistoryPage = React.lazy(
1667
+ () => import("./History-DTYKr2Cg.mjs").then((mod) => ({ default: mod.ProtectedHistoryPage }))
1270
1668
  );
1271
- const routes$1 = [
1669
+ const routes$2 = [
1272
1670
  {
1273
1671
  path: ":collectionType/:slug/:id/history",
1274
1672
  Component: ProtectedHistoryPage
@@ -1278,32 +1676,45 @@ const routes$1 = [
1278
1676
  Component: ProtectedHistoryPage
1279
1677
  }
1280
1678
  ];
1679
+ const ProtectedPreviewPage = React.lazy(
1680
+ () => import("./Preview-gkmvcwhu.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
+ ];
1281
1692
  const ProtectedEditViewPage = lazy(
1282
- () => import("./EditViewPage-CPj61RMh.mjs").then((mod) => ({ default: mod.ProtectedEditViewPage }))
1693
+ () => import("./EditViewPage-CA98g5_g.mjs").then((mod) => ({ default: mod.ProtectedEditViewPage }))
1283
1694
  );
1284
1695
  const ProtectedListViewPage = lazy(
1285
- () => import("./ListViewPage-SID6TRb9.mjs").then((mod) => ({ default: mod.ProtectedListViewPage }))
1696
+ () => import("./ListViewPage-DAekmnvp.mjs").then((mod) => ({ default: mod.ProtectedListViewPage }))
1286
1697
  );
1287
1698
  const ProtectedListConfiguration = lazy(
1288
- () => import("./ListConfigurationPage-D8wGABj0.mjs").then((mod) => ({
1699
+ () => import("./ListConfigurationPage-DQG-j52q.mjs").then((mod) => ({
1289
1700
  default: mod.ProtectedListConfiguration
1290
1701
  }))
1291
1702
  );
1292
1703
  const ProtectedEditConfigurationPage = lazy(
1293
- () => import("./EditConfigurationPage-JT3E7NZy.mjs").then((mod) => ({
1704
+ () => import("./EditConfigurationPage-7hF4_8yK.mjs").then((mod) => ({
1294
1705
  default: mod.ProtectedEditConfigurationPage
1295
1706
  }))
1296
1707
  );
1297
1708
  const ProtectedComponentConfigurationPage = lazy(
1298
- () => import("./ComponentConfigurationPage-DmwmiFQy.mjs").then((mod) => ({
1709
+ () => import("./ComponentConfigurationPage-UGIFDkPO.mjs").then((mod) => ({
1299
1710
  default: mod.ProtectedComponentConfigurationPage
1300
1711
  }))
1301
1712
  );
1302
1713
  const NoPermissions = lazy(
1303
- () => import("./NoPermissionsPage-B7syEq5E.mjs").then((mod) => ({ default: mod.NoPermissions }))
1714
+ () => import("./NoPermissionsPage-d-JtEVAw.mjs").then((mod) => ({ default: mod.NoPermissions }))
1304
1715
  );
1305
1716
  const NoContentType = lazy(
1306
- () => import("./NoContentTypePage-CJ7UXwrQ.mjs").then((mod) => ({ default: mod.NoContentType }))
1717
+ () => import("./NoContentTypePage-5kwUPeFg.mjs").then((mod) => ({ default: mod.NoContentType }))
1307
1718
  );
1308
1719
  const CollectionTypePages = () => {
1309
1720
  const { collectionType } = useParams();
@@ -1315,7 +1726,7 @@ const CollectionTypePages = () => {
1315
1726
  const CLONE_RELATIVE_PATH = ":collectionType/:slug/clone/:origin";
1316
1727
  const CLONE_PATH = `/content-manager/${CLONE_RELATIVE_PATH}`;
1317
1728
  const LIST_RELATIVE_PATH = ":collectionType/:slug";
1318
- const LIST_PATH = `/content-manager/${LIST_RELATIVE_PATH}`;
1729
+ const LIST_PATH = `/content-manager/collection-types/:slug`;
1319
1730
  const routes = [
1320
1731
  {
1321
1732
  path: LIST_RELATIVE_PATH,
@@ -1349,6 +1760,7 @@ const routes = [
1349
1760
  path: "no-content-types",
1350
1761
  Component: NoContentType
1351
1762
  },
1763
+ ...routes$2,
1352
1764
  ...routes$1
1353
1765
  ];
1354
1766
  const DocumentActions = ({ actions: actions2 }) => {
@@ -1417,12 +1829,14 @@ const DocumentActionButton = (action) => {
1417
1829
  /* @__PURE__ */ jsx(
1418
1830
  Button,
1419
1831
  {
1420
- flex: 1,
1832
+ flex: "auto",
1421
1833
  startIcon: action.icon,
1422
1834
  disabled: action.disabled,
1423
1835
  onClick: handleClick(action),
1424
1836
  justifyContent: "center",
1425
1837
  variant: action.variant || "default",
1838
+ paddingTop: "7px",
1839
+ paddingBottom: "7px",
1426
1840
  children: action.label
1427
1841
  }
1428
1842
  ),
@@ -1430,7 +1844,7 @@ const DocumentActionButton = (action) => {
1430
1844
  DocumentActionConfirmDialog,
1431
1845
  {
1432
1846
  ...action.dialog,
1433
- variant: action.variant,
1847
+ variant: action.dialog?.variant ?? action.variant,
1434
1848
  isOpen: dialogId === action.id,
1435
1849
  onClose: handleClose
1436
1850
  }
@@ -1487,9 +1901,9 @@ const DocumentActionsMenu = ({
1487
1901
  disabled: isDisabled,
1488
1902
  size: "S",
1489
1903
  endIcon: null,
1490
- paddingTop: "7px",
1491
- paddingLeft: "9px",
1492
- paddingRight: "9px",
1904
+ paddingTop: "4px",
1905
+ paddingLeft: "7px",
1906
+ paddingRight: "7px",
1493
1907
  variant,
1494
1908
  children: [
1495
1909
  /* @__PURE__ */ jsx(More, { "aria-hidden": true, focusable: false }),
@@ -1500,7 +1914,7 @@ const DocumentActionsMenu = ({
1500
1914
  ]
1501
1915
  }
1502
1916
  ),
1503
- /* @__PURE__ */ jsxs(Menu.Content, { top: "4px", maxHeight: void 0, popoverPlacement: "bottom-end", children: [
1917
+ /* @__PURE__ */ jsxs(Menu.Content, { maxHeight: void 0, popoverPlacement: "bottom-end", children: [
1504
1918
  actions2.map((action) => {
1505
1919
  return /* @__PURE__ */ jsx(
1506
1920
  Menu.Item,
@@ -1508,28 +1922,25 @@ const DocumentActionsMenu = ({
1508
1922
  disabled: action.disabled,
1509
1923
  onSelect: handleClick(action),
1510
1924
  display: "block",
1511
- children: /* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", gap: 4, children: [
1512
- /* @__PURE__ */ jsxs(Flex, { color: convertActionVariantToColor(action.variant), gap: 2, tag: "span", children: [
1513
- /* @__PURE__ */ jsx(Box, { tag: "span", color: convertActionVariantToIconColor(action.variant), children: action.icon }),
1514
- action.label
1515
- ] }),
1516
- action.id.startsWith("HistoryAction") && /* @__PURE__ */ jsx(
1517
- Flex,
1518
- {
1519
- alignItems: "center",
1520
- background: "alternative100",
1521
- borderStyle: "solid",
1522
- borderColor: "alternative200",
1523
- borderWidth: "1px",
1524
- height: 5,
1525
- paddingLeft: 2,
1526
- paddingRight: 2,
1527
- hasRadius: true,
1528
- color: "alternative600",
1529
- children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", fontWeight: "bold", lineHeight: 1, children: formatMessage({ id: "global.new", defaultMessage: "New" }) })
1530
- }
1531
- )
1532
- ] })
1925
+ children: /* @__PURE__ */ jsx(Flex, { justifyContent: "space-between", gap: 4, children: /* @__PURE__ */ jsxs(
1926
+ Flex,
1927
+ {
1928
+ color: !action.disabled ? convertActionVariantToColor(action.variant) : "inherit",
1929
+ gap: 2,
1930
+ tag: "span",
1931
+ children: [
1932
+ /* @__PURE__ */ jsx(
1933
+ Flex,
1934
+ {
1935
+ tag: "span",
1936
+ color: !action.disabled ? convertActionVariantToIconColor(action.variant) : "inherit",
1937
+ children: action.icon
1938
+ }
1939
+ ),
1940
+ action.label
1941
+ ]
1942
+ }
1943
+ ) })
1533
1944
  },
1534
1945
  action.id
1535
1946
  );
@@ -1609,11 +2020,11 @@ const DocumentActionConfirmDialog = ({
1609
2020
  /* @__PURE__ */ jsx(Dialog.Header, { children: title }),
1610
2021
  /* @__PURE__ */ jsx(Dialog.Body, { children: content }),
1611
2022
  /* @__PURE__ */ jsxs(Dialog.Footer, { children: [
1612
- /* @__PURE__ */ jsx(Dialog.Cancel, { children: /* @__PURE__ */ jsx(Button, { variant: "tertiary", children: formatMessage({
2023
+ /* @__PURE__ */ jsx(Dialog.Cancel, { children: /* @__PURE__ */ jsx(Button, { variant: "tertiary", fullWidth: true, children: formatMessage({
1613
2024
  id: "app.components.Button.cancel",
1614
2025
  defaultMessage: "Cancel"
1615
2026
  }) }) }),
1616
- /* @__PURE__ */ jsx(Button, { onClick: handleConfirm, variant, children: formatMessage({
2027
+ /* @__PURE__ */ jsx(Button, { onClick: handleConfirm, variant, fullWidth: true, children: formatMessage({
1617
2028
  id: "app.components.Button.confirm",
1618
2029
  defaultMessage: "Confirm"
1619
2030
  }) })
@@ -1640,7 +2051,19 @@ const DocumentActionModal = ({
1640
2051
  typeof Footer === "function" ? /* @__PURE__ */ jsx(Footer, { onClose: handleClose }) : Footer
1641
2052
  ] }) });
1642
2053
  };
1643
- const PublishAction$1 = ({
2054
+ const transformData = (data) => {
2055
+ if (Array.isArray(data)) {
2056
+ return data.map(transformData);
2057
+ }
2058
+ if (typeof data === "object" && data !== null) {
2059
+ if ("apiData" in data) {
2060
+ return data.apiData;
2061
+ }
2062
+ return mapValues(transformData)(data);
2063
+ }
2064
+ return data;
2065
+ };
2066
+ const PublishAction$1 = ({
1644
2067
  activeTab,
1645
2068
  documentId,
1646
2069
  model,
@@ -1652,13 +2075,17 @@ const PublishAction$1 = ({
1652
2075
  const navigate = useNavigate();
1653
2076
  const { toggleNotification } = useNotification();
1654
2077
  const { _unstableFormatValidationErrors: formatValidationErrors } = useAPIErrorHandler();
2078
+ const isListView = useMatch(LIST_PATH) !== null;
1655
2079
  const isCloning = useMatch(CLONE_PATH) !== null;
1656
2080
  const { formatMessage } = useIntl();
1657
- const { canPublish, canCreate, canUpdate } = useDocumentRBAC(
1658
- "PublishAction",
1659
- ({ canPublish: canPublish2, canCreate: canCreate2, canUpdate: canUpdate2 }) => ({ canPublish: canPublish2, canCreate: canCreate2, canUpdate: canUpdate2 })
1660
- );
2081
+ const canPublish = useDocumentRBAC("PublishAction", ({ canPublish: canPublish2 }) => canPublish2);
1661
2082
  const { publish } = useDocumentActions();
2083
+ const [
2084
+ countDraftRelations,
2085
+ { isLoading: isLoadingDraftRelations, isError: isErrorDraftRelations }
2086
+ ] = useLazyGetDraftRelationCountQuery();
2087
+ const [localCountOfDraftRelations, setLocalCountOfDraftRelations] = React.useState(0);
2088
+ const [serverCountOfDraftRelations, setServerCountOfDraftRelations] = React.useState(0);
1662
2089
  const [{ query, rawQuery }] = useQueryParams();
1663
2090
  const params = React.useMemo(() => buildValidParams(query), [query]);
1664
2091
  const modified = useForm("PublishAction", ({ modified: modified2 }) => modified2);
@@ -1667,10 +2094,105 @@ const PublishAction$1 = ({
1667
2094
  const validate = useForm("PublishAction", (state) => state.validate);
1668
2095
  const setErrors = useForm("PublishAction", (state) => state.setErrors);
1669
2096
  const formValues = useForm("PublishAction", ({ values }) => values);
2097
+ React.useEffect(() => {
2098
+ if (isErrorDraftRelations) {
2099
+ toggleNotification({
2100
+ type: "danger",
2101
+ message: formatMessage({
2102
+ id: getTranslation("error.records.fetch-draft-relatons"),
2103
+ defaultMessage: "An error occurred while fetching draft relations on this document."
2104
+ })
2105
+ });
2106
+ }
2107
+ }, [isErrorDraftRelations, toggleNotification, formatMessage]);
2108
+ React.useEffect(() => {
2109
+ const localDraftRelations = /* @__PURE__ */ new Set();
2110
+ const extractDraftRelations = (data) => {
2111
+ const relations = data.connect || [];
2112
+ relations.forEach((relation) => {
2113
+ if (relation.status === "draft") {
2114
+ localDraftRelations.add(relation.id);
2115
+ }
2116
+ });
2117
+ };
2118
+ const traverseAndExtract = (data) => {
2119
+ Object.entries(data).forEach(([key, value]) => {
2120
+ if (key === "connect" && Array.isArray(value)) {
2121
+ extractDraftRelations({ connect: value });
2122
+ } else if (typeof value === "object" && value !== null) {
2123
+ traverseAndExtract(value);
2124
+ }
2125
+ });
2126
+ };
2127
+ if (!documentId || modified) {
2128
+ traverseAndExtract(formValues);
2129
+ setLocalCountOfDraftRelations(localDraftRelations.size);
2130
+ }
2131
+ }, [documentId, modified, formValues, setLocalCountOfDraftRelations]);
2132
+ React.useEffect(() => {
2133
+ if (!document || !document.documentId || isListView) {
2134
+ return;
2135
+ }
2136
+ const fetchDraftRelationsCount = async () => {
2137
+ const { data, error } = await countDraftRelations({
2138
+ collectionType,
2139
+ model,
2140
+ documentId,
2141
+ params
2142
+ });
2143
+ if (error) {
2144
+ throw error;
2145
+ }
2146
+ if (data) {
2147
+ setServerCountOfDraftRelations(data.data);
2148
+ }
2149
+ };
2150
+ fetchDraftRelationsCount();
2151
+ }, [isListView, document, documentId, countDraftRelations, collectionType, model, params]);
1670
2152
  const isDocumentPublished = (document?.[PUBLISHED_AT_ATTRIBUTE_NAME] || meta?.availableStatus.some((doc) => doc[PUBLISHED_AT_ATTRIBUTE_NAME] !== null)) && document?.status !== "modified";
1671
2153
  if (!schema?.options?.draftAndPublish) {
1672
2154
  return null;
1673
2155
  }
2156
+ const performPublish = async () => {
2157
+ setSubmitting(true);
2158
+ try {
2159
+ const { errors } = await validate(true, {
2160
+ status: "published"
2161
+ });
2162
+ if (errors) {
2163
+ toggleNotification({
2164
+ type: "danger",
2165
+ message: formatMessage({
2166
+ id: "content-manager.validation.error",
2167
+ defaultMessage: "There are validation errors in your document. Please fix them before saving."
2168
+ })
2169
+ });
2170
+ return;
2171
+ }
2172
+ const res = await publish(
2173
+ {
2174
+ collectionType,
2175
+ model,
2176
+ documentId,
2177
+ params
2178
+ },
2179
+ transformData(formValues)
2180
+ );
2181
+ if ("data" in res && collectionType !== SINGLE_TYPES) {
2182
+ navigate({
2183
+ pathname: `../${collectionType}/${model}/${res.data.documentId}`,
2184
+ search: rawQuery
2185
+ });
2186
+ } else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
2187
+ setErrors(formatValidationErrors(res.error));
2188
+ }
2189
+ } finally {
2190
+ setSubmitting(false);
2191
+ }
2192
+ };
2193
+ const totalDraftRelations = localCountOfDraftRelations + serverCountOfDraftRelations;
2194
+ const enableDraftRelationsCount = false;
2195
+ const hasDraftRelations = enableDraftRelationsCount;
1674
2196
  return {
1675
2197
  /**
1676
2198
  * Disabled when:
@@ -1680,49 +2202,36 @@ const PublishAction$1 = ({
1680
2202
  * - the document is already published & not modified
1681
2203
  * - the document is being created & not modified
1682
2204
  * - the user doesn't have the permission to publish
1683
- * - the user doesn't have the permission to create a new document
1684
- * - the user doesn't have the permission to update the document
1685
2205
  */
1686
- disabled: isCloning || isSubmitting || activeTab === "published" || !modified && isDocumentPublished || !modified && !document?.documentId || !canPublish || Boolean(!document?.documentId && !canCreate || document?.documentId && !canUpdate),
2206
+ disabled: isCloning || isSubmitting || isLoadingDraftRelations || activeTab === "published" || !modified && isDocumentPublished || !modified && !document?.documentId || !canPublish,
1687
2207
  label: formatMessage({
1688
2208
  id: "app.utils.publish",
1689
2209
  defaultMessage: "Publish"
1690
2210
  }),
1691
2211
  onClick: async () => {
1692
- setSubmitting(true);
1693
- try {
1694
- const { errors } = await validate();
1695
- if (errors) {
1696
- toggleNotification({
1697
- type: "danger",
1698
- message: formatMessage({
1699
- id: "content-manager.validation.error",
1700
- defaultMessage: "There are validation errors in your document. Please fix them before saving."
1701
- })
1702
- });
1703
- return;
1704
- }
1705
- const res = await publish(
1706
- {
1707
- collectionType,
1708
- model,
1709
- documentId,
1710
- params
1711
- },
1712
- formValues
1713
- );
1714
- if ("data" in res && collectionType !== SINGLE_TYPES) {
1715
- navigate({
1716
- pathname: `../${collectionType}/${model}/${res.data.documentId}`,
1717
- search: rawQuery
1718
- });
1719
- } else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
1720
- setErrors(formatValidationErrors(res.error));
2212
+ await performPublish();
2213
+ },
2214
+ dialog: hasDraftRelations ? {
2215
+ type: "dialog",
2216
+ variant: "danger",
2217
+ footer: null,
2218
+ title: formatMessage({
2219
+ id: getTranslation(`popUpwarning.warning.bulk-has-draft-relations.title`),
2220
+ defaultMessage: "Confirmation"
2221
+ }),
2222
+ content: formatMessage(
2223
+ {
2224
+ id: getTranslation(`popUpwarning.warning.bulk-has-draft-relations.message`),
2225
+ defaultMessage: "This entry is related to {count, plural, one {# draft entry} other {# draft entries}}. Publishing it could leave broken links in your app."
2226
+ },
2227
+ {
2228
+ count: totalDraftRelations
1721
2229
  }
1722
- } finally {
1723
- setSubmitting(false);
2230
+ ),
2231
+ onConfirm: async () => {
2232
+ await performPublish();
1724
2233
  }
1725
- }
2234
+ } : void 0
1726
2235
  };
1727
2236
  };
1728
2237
  PublishAction$1.type = "publish";
@@ -1738,10 +2247,6 @@ const UpdateAction = ({
1738
2247
  const cloneMatch = useMatch(CLONE_PATH);
1739
2248
  const isCloning = cloneMatch !== null;
1740
2249
  const { formatMessage } = useIntl();
1741
- const { canCreate, canUpdate } = useDocumentRBAC("UpdateAction", ({ canCreate: canCreate2, canUpdate: canUpdate2 }) => ({
1742
- canCreate: canCreate2,
1743
- canUpdate: canUpdate2
1744
- }));
1745
2250
  const { create, update, clone } = useDocumentActions();
1746
2251
  const [{ query, rawQuery }] = useQueryParams();
1747
2252
  const params = React.useMemo(() => buildValidParams(query), [query]);
@@ -1758,10 +2263,8 @@ const UpdateAction = ({
1758
2263
  * - the form is submitting
1759
2264
  * - the document is not modified & we're not cloning (you can save a clone entity straight away)
1760
2265
  * - the active tab is the published tab
1761
- * - the user doesn't have the permission to create a new document
1762
- * - the user doesn't have the permission to update the document
1763
2266
  */
1764
- disabled: isSubmitting || !modified && !isCloning || activeTab === "published" || Boolean(!documentId && !canCreate || documentId && !canUpdate),
2267
+ disabled: isSubmitting || !modified && !isCloning || activeTab === "published",
1765
2268
  label: formatMessage({
1766
2269
  id: "content-manager.containers.Edit.save",
1767
2270
  defaultMessage: "Save"
@@ -1769,7 +2272,9 @@ const UpdateAction = ({
1769
2272
  onClick: async () => {
1770
2273
  setSubmitting(true);
1771
2274
  try {
1772
- const { errors } = await validate();
2275
+ const { errors } = await validate(true, {
2276
+ status: "draft"
2277
+ });
1773
2278
  if (errors) {
1774
2279
  toggleNotification({
1775
2280
  type: "danger",
@@ -1787,13 +2292,16 @@ const UpdateAction = ({
1787
2292
  documentId: cloneMatch.params.origin,
1788
2293
  params
1789
2294
  },
1790
- document
2295
+ transformData(document)
1791
2296
  );
1792
2297
  if ("data" in res) {
1793
- navigate({
1794
- pathname: `../${collectionType}/${model}/${res.data.documentId}`,
1795
- search: rawQuery
1796
- });
2298
+ navigate(
2299
+ {
2300
+ pathname: `../${res.data.documentId}`,
2301
+ search: rawQuery
2302
+ },
2303
+ { relative: "path" }
2304
+ );
1797
2305
  } else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
1798
2306
  setErrors(formatValidationErrors(res.error));
1799
2307
  }
@@ -1805,7 +2313,7 @@ const UpdateAction = ({
1805
2313
  documentId,
1806
2314
  params
1807
2315
  },
1808
- document
2316
+ transformData(document)
1809
2317
  );
1810
2318
  if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
1811
2319
  setErrors(formatValidationErrors(res.error));
@@ -1818,13 +2326,16 @@ const UpdateAction = ({
1818
2326
  model,
1819
2327
  params
1820
2328
  },
1821
- document
2329
+ transformData(document)
1822
2330
  );
1823
2331
  if ("data" in res && collectionType !== SINGLE_TYPES) {
1824
- navigate({
1825
- pathname: `../${collectionType}/${model}/${res.data.documentId}`,
1826
- search: rawQuery
1827
- });
2332
+ navigate(
2333
+ {
2334
+ pathname: `../${res.data.documentId}`,
2335
+ search: rawQuery
2336
+ },
2337
+ { replace: true, relative: "path" }
2338
+ );
1828
2339
  } else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
1829
2340
  setErrors(formatValidationErrors(res.error));
1830
2341
  }
@@ -1868,7 +2379,7 @@ const UnpublishAction$1 = ({
1868
2379
  id: "app.utils.unpublish",
1869
2380
  defaultMessage: "Unpublish"
1870
2381
  }),
1871
- icon: /* @__PURE__ */ jsx(StyledCrossCircle, {}),
2382
+ icon: /* @__PURE__ */ jsx(Cross, {}),
1872
2383
  onClick: async () => {
1873
2384
  if (!documentId && collectionType !== SINGLE_TYPES || isDocumentModified) {
1874
2385
  if (!documentId) {
@@ -1980,7 +2491,7 @@ const DiscardAction = ({
1980
2491
  id: "content-manager.actions.discard.label",
1981
2492
  defaultMessage: "Discard changes"
1982
2493
  }),
1983
- icon: /* @__PURE__ */ jsx(StyledCrossCircle, {}),
2494
+ icon: /* @__PURE__ */ jsx(Cross, {}),
1984
2495
  position: ["panel", "table-row"],
1985
2496
  variant: "danger",
1986
2497
  dialog: {
@@ -2008,11 +2519,6 @@ const DiscardAction = ({
2008
2519
  };
2009
2520
  };
2010
2521
  DiscardAction.type = "discard";
2011
- const StyledCrossCircle = styled(CrossCircle)`
2012
- path {
2013
- fill: currentColor;
2014
- }
2015
- `;
2016
2522
  const DEFAULT_ACTIONS = [PublishAction$1, UpdateAction, UnpublishAction$1, DiscardAction];
2017
2523
  const intervals = ["years", "months", "days", "hours", "minutes", "seconds"];
2018
2524
  const RelativeTime = React.forwardRef(
@@ -2060,8 +2566,12 @@ const getDisplayName = ({
2060
2566
  };
2061
2567
  const capitalise = (str) => str.charAt(0).toUpperCase() + str.slice(1);
2062
2568
  const DocumentStatus = ({ status = "draft", ...restProps }) => {
2063
- const statusVariant = status === "draft" ? "primary" : status === "published" ? "success" : "alternative";
2064
- return /* @__PURE__ */ jsx(Status, { ...restProps, showBullet: false, size: "S", variant: statusVariant, children: /* @__PURE__ */ jsx(Typography, { tag: "span", variant: "omega", fontWeight: "bold", children: capitalise(status) }) });
2569
+ const statusVariant = status === "draft" ? "secondary" : status === "published" ? "success" : "alternative";
2570
+ const { formatMessage } = useIntl();
2571
+ return /* @__PURE__ */ jsx(Status, { ...restProps, size: "S", variant: statusVariant, children: /* @__PURE__ */ jsx(Typography, { tag: "span", variant: "omega", fontWeight: "bold", children: formatMessage({
2572
+ id: `content-manager.containers.List.${status}`,
2573
+ defaultMessage: capitalise(status)
2574
+ }) }) });
2065
2575
  };
2066
2576
  const Header = ({ isCreating, status, title: documentTitle = "Untitled" }) => {
2067
2577
  const { formatMessage } = useIntl();
@@ -2070,23 +2580,13 @@ const Header = ({ isCreating, status, title: documentTitle = "Untitled" }) => {
2070
2580
  id: "content-manager.containers.edit.title.new",
2071
2581
  defaultMessage: "Create an entry"
2072
2582
  }) : documentTitle;
2073
- return /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "flex-start", paddingTop: 8, paddingBottom: 4, gap: 3, children: [
2583
+ return /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "flex-start", paddingTop: 6, paddingBottom: 4, gap: 2, children: [
2074
2584
  /* @__PURE__ */ jsx(BackButton, {}),
2075
- /* @__PURE__ */ jsxs(
2076
- Flex,
2077
- {
2078
- width: "100%",
2079
- justifyContent: "space-between",
2080
- paddingTop: 1,
2081
- gap: "80px",
2082
- alignItems: "flex-start",
2083
- children: [
2084
- /* @__PURE__ */ jsx(Typography, { variant: "alpha", tag: "h1", children: title }),
2085
- /* @__PURE__ */ jsx(HeaderToolbar, {})
2086
- ]
2087
- }
2088
- ),
2089
- status ? /* @__PURE__ */ jsx(DocumentStatus, { status: isCloning ? "draft" : status }) : null
2585
+ /* @__PURE__ */ jsxs(Flex, { width: "100%", justifyContent: "space-between", gap: "80px", alignItems: "flex-start", children: [
2586
+ /* @__PURE__ */ jsx(Typography, { variant: "alpha", tag: "h1", children: title }),
2587
+ /* @__PURE__ */ jsx(HeaderToolbar, {})
2588
+ ] }),
2589
+ status ? /* @__PURE__ */ jsx(Box, { marginTop: 1, children: /* @__PURE__ */ jsx(DocumentStatus, { status: isCloning ? "draft" : status }) }) : null
2090
2590
  ] });
2091
2591
  };
2092
2592
  const HeaderToolbar = () => {
@@ -2169,12 +2669,12 @@ const Information = ({ activeTab }) => {
2169
2669
  isDisplayed: !!publishDocument?.[PUBLISHED_AT_ATTRIBUTE_NAME],
2170
2670
  label: formatMessage({
2171
2671
  id: "content-manager.containers.edit.information.last-published.label",
2172
- defaultMessage: "Last published"
2672
+ defaultMessage: "Published"
2173
2673
  }),
2174
2674
  value: formatMessage(
2175
2675
  {
2176
2676
  id: "content-manager.containers.edit.information.last-published.value",
2177
- defaultMessage: `Published {time}{isAnonymous, select, true {} other { by {author}}}`
2677
+ defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
2178
2678
  },
2179
2679
  {
2180
2680
  time: /* @__PURE__ */ jsx(RelativeTime, { timestamp: new Date(publishDocument?.[PUBLISHED_AT_ATTRIBUTE_NAME]) }),
@@ -2187,12 +2687,12 @@ const Information = ({ activeTab }) => {
2187
2687
  isDisplayed: !!createAndUpdateDocument?.[UPDATED_AT_ATTRIBUTE_NAME],
2188
2688
  label: formatMessage({
2189
2689
  id: "content-manager.containers.edit.information.last-draft.label",
2190
- defaultMessage: "Last draft"
2690
+ defaultMessage: "Updated"
2191
2691
  }),
2192
2692
  value: formatMessage(
2193
2693
  {
2194
2694
  id: "content-manager.containers.edit.information.last-draft.value",
2195
- defaultMessage: `Modified {time}{isAnonymous, select, true {} other { by {author}}}`
2695
+ defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
2196
2696
  },
2197
2697
  {
2198
2698
  time: /* @__PURE__ */ jsx(
@@ -2210,12 +2710,12 @@ const Information = ({ activeTab }) => {
2210
2710
  isDisplayed: !!createAndUpdateDocument?.[CREATED_AT_ATTRIBUTE_NAME],
2211
2711
  label: formatMessage({
2212
2712
  id: "content-manager.containers.edit.information.document.label",
2213
- defaultMessage: "Document"
2713
+ defaultMessage: "Created"
2214
2714
  }),
2215
2715
  value: formatMessage(
2216
2716
  {
2217
2717
  id: "content-manager.containers.edit.information.document.value",
2218
- defaultMessage: `Created {time}{isAnonymous, select, true {} other { by {author}}}`
2718
+ defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
2219
2719
  },
2220
2720
  {
2221
2721
  time: /* @__PURE__ */ jsx(
@@ -2253,25 +2753,77 @@ const Information = ({ activeTab }) => {
2253
2753
  );
2254
2754
  };
2255
2755
  const HeaderActions = ({ actions: actions2 }) => {
2256
- return /* @__PURE__ */ jsx(Flex, { children: actions2.map((action) => {
2257
- if ("options" in action) {
2756
+ const [dialogId, setDialogId] = React.useState(null);
2757
+ const handleClick = (action) => async (e) => {
2758
+ if (!("options" in action)) {
2759
+ const { onClick = () => false, dialog, id } = action;
2760
+ const muteDialog = await onClick(e);
2761
+ if (dialog && !muteDialog) {
2762
+ e.preventDefault();
2763
+ setDialogId(id);
2764
+ }
2765
+ }
2766
+ };
2767
+ const handleClose = () => {
2768
+ setDialogId(null);
2769
+ };
2770
+ return /* @__PURE__ */ jsx(Flex, { gap: 1, children: actions2.map((action) => {
2771
+ if (action.options) {
2258
2772
  return /* @__PURE__ */ jsx(
2259
2773
  SingleSelect,
2260
2774
  {
2261
2775
  size: "S",
2262
- disabled: action.disabled,
2263
- "aria-label": action.label,
2264
2776
  onChange: action.onSelect,
2265
- value: action.value,
2777
+ "aria-label": action.label,
2778
+ ...action,
2266
2779
  children: action.options.map(({ label, ...option }) => /* @__PURE__ */ jsx(SingleSelectOption, { ...option, children: label }, option.value))
2267
2780
  },
2268
2781
  action.id
2269
2782
  );
2270
2783
  } else {
2271
- return null;
2784
+ if (action.type === "icon") {
2785
+ return /* @__PURE__ */ jsxs(React.Fragment, { children: [
2786
+ /* @__PURE__ */ jsx(
2787
+ IconButton,
2788
+ {
2789
+ disabled: action.disabled,
2790
+ label: action.label,
2791
+ size: "S",
2792
+ onClick: handleClick(action),
2793
+ children: action.icon
2794
+ }
2795
+ ),
2796
+ action.dialog ? /* @__PURE__ */ jsx(
2797
+ HeaderActionDialog,
2798
+ {
2799
+ ...action.dialog,
2800
+ isOpen: dialogId === action.id,
2801
+ onClose: handleClose
2802
+ }
2803
+ ) : null
2804
+ ] }, action.id);
2805
+ }
2272
2806
  }
2273
2807
  }) });
2274
2808
  };
2809
+ const HeaderActionDialog = ({
2810
+ onClose,
2811
+ onCancel,
2812
+ title,
2813
+ content: Content,
2814
+ isOpen
2815
+ }) => {
2816
+ const handleClose = async () => {
2817
+ if (onCancel) {
2818
+ await onCancel();
2819
+ }
2820
+ onClose();
2821
+ };
2822
+ return /* @__PURE__ */ jsx(Dialog.Root, { open: isOpen, onOpenChange: handleClose, children: /* @__PURE__ */ jsxs(Dialog.Content, { children: [
2823
+ /* @__PURE__ */ jsx(Dialog.Header, { children: title }),
2824
+ typeof Content === "function" ? /* @__PURE__ */ jsx(Content, { onClose: handleClose }) : Content
2825
+ ] }) });
2826
+ };
2275
2827
  const ConfigureTheViewAction = ({ collectionType, model }) => {
2276
2828
  const navigate = useNavigate();
2277
2829
  const { formatMessage } = useIntl();
@@ -2312,12 +2864,16 @@ const DeleteAction$1 = ({ documentId, model, collectionType, document }) => {
2312
2864
  const { delete: deleteAction } = useDocumentActions();
2313
2865
  const { toggleNotification } = useNotification();
2314
2866
  const setSubmitting = useForm("DeleteAction", (state) => state.setSubmitting);
2867
+ const isLocalized = document?.locale != null;
2315
2868
  return {
2316
2869
  disabled: !canDelete || !document,
2317
- label: formatMessage({
2318
- id: "content-manager.actions.delete.label",
2319
- defaultMessage: "Delete document"
2320
- }),
2870
+ label: formatMessage(
2871
+ {
2872
+ id: "content-manager.actions.delete.label",
2873
+ defaultMessage: "Delete entry{isLocalized, select, true { (all locales)} other {}}"
2874
+ },
2875
+ { isLocalized }
2876
+ ),
2321
2877
  icon: /* @__PURE__ */ jsx(Trash, {}),
2322
2878
  dialog: {
2323
2879
  type: "dialog",
@@ -2360,416 +2916,114 @@ const DeleteAction$1 = ({ documentId, model, collectionType, document }) => {
2360
2916
  });
2361
2917
  if (!("error" in res)) {
2362
2918
  navigate({ pathname: `../${collectionType}/${model}` }, { replace: true });
2363
- }
2364
- } finally {
2365
- if (!listViewPathMatch) {
2366
- setSubmitting(false);
2367
- }
2368
- }
2369
- }
2370
- },
2371
- variant: "danger",
2372
- position: ["header", "table-row"]
2373
- };
2374
- };
2375
- DeleteAction$1.type = "delete";
2376
- const DEFAULT_HEADER_ACTIONS = [EditTheModelAction, ConfigureTheViewAction, DeleteAction$1];
2377
- const Panels = () => {
2378
- const isCloning = useMatch(CLONE_PATH) !== null;
2379
- const [
2380
- {
2381
- query: { status }
2382
- }
2383
- ] = useQueryParams({
2384
- status: "draft"
2385
- });
2386
- const { model, id, document, meta, collectionType } = useDoc();
2387
- const plugins = useStrapiApp("Panels", (state) => state.plugins);
2388
- const props = {
2389
- activeTab: status,
2390
- model,
2391
- documentId: id,
2392
- document: isCloning ? void 0 : document,
2393
- meta: isCloning ? void 0 : meta,
2394
- collectionType
2395
- };
2396
- return /* @__PURE__ */ jsx(Flex, { direction: "column", alignItems: "stretch", gap: 2, children: /* @__PURE__ */ jsx(
2397
- DescriptionComponentRenderer,
2398
- {
2399
- props,
2400
- descriptions: plugins["content-manager"].apis.getEditViewSidePanels(),
2401
- children: (panels) => panels.map(({ content, id: id2, ...description }) => /* @__PURE__ */ jsx(Panel, { ...description, children: content }, id2))
2402
- }
2403
- ) });
2404
- };
2405
- const ActionsPanel = () => {
2406
- const { formatMessage } = useIntl();
2407
- return {
2408
- title: formatMessage({
2409
- id: "content-manager.containers.edit.panels.default.title",
2410
- defaultMessage: "Document"
2411
- }),
2412
- content: /* @__PURE__ */ jsx(ActionsPanelContent, {})
2413
- };
2414
- };
2415
- ActionsPanel.type = "actions";
2416
- const ActionsPanelContent = () => {
2417
- const isCloning = useMatch(CLONE_PATH) !== null;
2418
- const [
2419
- {
2420
- query: { status = "draft" }
2421
- }
2422
- ] = useQueryParams();
2423
- const { model, id, document, meta, collectionType } = useDoc();
2424
- const plugins = useStrapiApp("ActionsPanel", (state) => state.plugins);
2425
- const props = {
2426
- activeTab: status,
2427
- model,
2428
- documentId: id,
2429
- document: isCloning ? void 0 : document,
2430
- meta: isCloning ? void 0 : meta,
2431
- collectionType
2432
- };
2433
- return /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 2, width: "100%", children: [
2434
- /* @__PURE__ */ jsx(
2435
- DescriptionComponentRenderer,
2436
- {
2437
- props,
2438
- descriptions: plugins["content-manager"].apis.getDocumentActions(),
2439
- children: (actions2) => /* @__PURE__ */ jsx(DocumentActions, { actions: actions2 })
2440
- }
2441
- ),
2442
- /* @__PURE__ */ jsx(InjectionZone, { area: "editView.right-links", slug: model })
2443
- ] });
2444
- };
2445
- const Panel = React.forwardRef(({ children, title }, ref) => {
2446
- return /* @__PURE__ */ jsxs(
2447
- Flex,
2448
- {
2449
- ref,
2450
- tag: "aside",
2451
- "aria-labelledby": "additional-information",
2452
- background: "neutral0",
2453
- borderColor: "neutral150",
2454
- hasRadius: true,
2455
- paddingBottom: 4,
2456
- paddingLeft: 4,
2457
- paddingRight: 4,
2458
- paddingTop: 4,
2459
- shadow: "tableShadow",
2460
- gap: 3,
2461
- direction: "column",
2462
- justifyContent: "stretch",
2463
- alignItems: "flex-start",
2464
- children: [
2465
- /* @__PURE__ */ jsx(Typography, { tag: "h2", variant: "sigma", textTransform: "uppercase", children: title }),
2466
- children
2467
- ]
2468
- }
2469
- );
2470
- });
2471
- const HOOKS = {
2472
- /**
2473
- * Hook that allows to mutate the displayed headers of the list view table
2474
- * @constant
2475
- * @type {string}
2476
- */
2477
- INJECT_COLUMN_IN_TABLE: "Admin/CM/pages/ListView/inject-column-in-table",
2478
- /**
2479
- * Hook that allows to mutate the CM's collection types links pre-set filters
2480
- * @constant
2481
- * @type {string}
2482
- */
2483
- MUTATE_COLLECTION_TYPES_LINKS: "Admin/CM/pages/App/mutate-collection-types-links",
2484
- /**
2485
- * Hook that allows to mutate the CM's edit view layout
2486
- * @constant
2487
- * @type {string}
2488
- */
2489
- MUTATE_EDIT_VIEW_LAYOUT: "Admin/CM/pages/EditView/mutate-edit-view-layout",
2490
- /**
2491
- * Hook that allows to mutate the CM's single types links pre-set filters
2492
- * @constant
2493
- * @type {string}
2494
- */
2495
- MUTATE_SINGLE_TYPES_LINKS: "Admin/CM/pages/App/mutate-single-types-links"
2496
- };
2497
- const contentTypesApi = contentManagerApi.injectEndpoints({
2498
- endpoints: (builder) => ({
2499
- getContentTypeConfiguration: builder.query({
2500
- query: (uid) => ({
2501
- url: `/content-manager/content-types/${uid}/configuration`,
2502
- method: "GET"
2503
- }),
2504
- transformResponse: (response) => response.data,
2505
- providesTags: (_result, _error, uid) => [
2506
- { type: "ContentTypesConfiguration", id: uid },
2507
- { type: "ContentTypeSettings", id: "LIST" }
2508
- ]
2509
- }),
2510
- getAllContentTypeSettings: builder.query({
2511
- query: () => "/content-manager/content-types-settings",
2512
- transformResponse: (response) => response.data,
2513
- providesTags: [{ type: "ContentTypeSettings", id: "LIST" }]
2514
- }),
2515
- updateContentTypeConfiguration: builder.mutation({
2516
- query: ({ uid, ...body }) => ({
2517
- url: `/content-manager/content-types/${uid}/configuration`,
2518
- method: "PUT",
2519
- data: body
2520
- }),
2521
- transformResponse: (response) => response.data,
2522
- invalidatesTags: (_result, _error, { uid }) => [
2523
- { type: "ContentTypesConfiguration", id: uid },
2524
- { type: "ContentTypeSettings", id: "LIST" },
2525
- // Is this necessary?
2526
- { type: "InitialData" }
2527
- ]
2528
- })
2529
- })
2530
- });
2531
- const {
2532
- useGetContentTypeConfigurationQuery,
2533
- useGetAllContentTypeSettingsQuery,
2534
- useUpdateContentTypeConfigurationMutation
2535
- } = contentTypesApi;
2536
- const checkIfAttributeIsDisplayable = (attribute) => {
2537
- const { type } = attribute;
2538
- if (type === "relation") {
2539
- return !attribute.relation.toLowerCase().includes("morph");
2540
- }
2541
- return !["json", "dynamiczone", "richtext", "password", "blocks"].includes(type) && !!type;
2542
- };
2543
- const getMainField = (attribute, mainFieldName, { schemas, components }) => {
2544
- if (!mainFieldName) {
2545
- return void 0;
2546
- }
2547
- const mainFieldType = attribute.type === "component" ? components[attribute.component].attributes[mainFieldName].type : (
2548
- // @ts-expect-error – `targetModel` does exist on the attribute for a relation.
2549
- schemas.find((schema) => schema.uid === attribute.targetModel)?.attributes[mainFieldName].type
2550
- );
2551
- return {
2552
- name: mainFieldName,
2553
- type: mainFieldType ?? "string"
2554
- };
2555
- };
2556
- const DEFAULT_SETTINGS = {
2557
- bulkable: false,
2558
- filterable: false,
2559
- searchable: false,
2560
- pagination: false,
2561
- defaultSortBy: "",
2562
- defaultSortOrder: "asc",
2563
- mainField: "id",
2564
- pageSize: 10
2565
- };
2566
- const useDocumentLayout = (model) => {
2567
- const { schema, components } = useDocument({ model, collectionType: "" }, { skip: true });
2568
- const [{ query }] = useQueryParams();
2569
- const runHookWaterfall = useStrapiApp("useDocumentLayout", (state) => state.runHookWaterfall);
2570
- const { toggleNotification } = useNotification();
2571
- const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();
2572
- const { isLoading: isLoadingSchemas, schemas } = useContentTypeSchema();
2573
- const {
2574
- data,
2575
- isLoading: isLoadingConfigs,
2576
- error,
2577
- isFetching: isFetchingConfigs
2578
- } = useGetContentTypeConfigurationQuery(model);
2579
- const isLoading = isLoadingSchemas || isFetchingConfigs || isLoadingConfigs;
2580
- React.useEffect(() => {
2581
- if (error) {
2582
- toggleNotification({
2583
- type: "danger",
2584
- message: formatAPIError(error)
2585
- });
2586
- }
2587
- }, [error, formatAPIError, toggleNotification]);
2588
- const editLayout = React.useMemo(
2589
- () => data && !isLoading ? formatEditLayout(data, { schemas, schema, components }) : {
2590
- layout: [],
2591
- components: {},
2592
- metadatas: {},
2593
- options: {},
2594
- settings: DEFAULT_SETTINGS
2595
- },
2596
- [data, isLoading, schemas, schema, components]
2597
- );
2598
- const listLayout = React.useMemo(() => {
2599
- return data && !isLoading ? formatListLayout(data, { schemas, schema, components }) : {
2600
- layout: [],
2601
- metadatas: {},
2602
- options: {},
2603
- settings: DEFAULT_SETTINGS
2604
- };
2605
- }, [data, isLoading, schemas, schema, components]);
2606
- const { layout: edit } = React.useMemo(
2607
- () => runHookWaterfall(HOOKS.MUTATE_EDIT_VIEW_LAYOUT, {
2608
- layout: editLayout,
2609
- query
2610
- }),
2611
- [editLayout, query, runHookWaterfall]
2612
- );
2613
- return {
2614
- error,
2615
- isLoading,
2616
- edit,
2617
- list: listLayout
2618
- };
2619
- };
2620
- const useDocLayout = () => {
2621
- const { model } = useDoc();
2622
- return useDocumentLayout(model);
2623
- };
2624
- const formatEditLayout = (data, {
2625
- schemas,
2626
- schema,
2627
- components
2628
- }) => {
2629
- let currentPanelIndex = 0;
2630
- const panelledEditAttributes = convertEditLayoutToFieldLayouts(
2631
- data.contentType.layouts.edit,
2632
- schema?.attributes,
2633
- data.contentType.metadatas,
2634
- { configurations: data.components, schemas: components },
2635
- schemas
2636
- ).reduce((panels, row) => {
2637
- if (row.some((field) => field.type === "dynamiczone")) {
2638
- panels.push([row]);
2639
- currentPanelIndex += 2;
2640
- } else {
2641
- if (!panels[currentPanelIndex]) {
2642
- panels.push([]);
2643
- }
2644
- panels[currentPanelIndex].push(row);
2645
- }
2646
- return panels;
2647
- }, []);
2648
- const componentEditAttributes = Object.entries(data.components).reduce(
2649
- (acc, [uid, configuration]) => {
2650
- acc[uid] = {
2651
- layout: convertEditLayoutToFieldLayouts(
2652
- configuration.layouts.edit,
2653
- components[uid].attributes,
2654
- configuration.metadatas
2655
- ),
2656
- settings: {
2657
- ...configuration.settings,
2658
- icon: components[uid].info.icon,
2659
- displayName: components[uid].info.displayName
2660
- }
2661
- };
2662
- return acc;
2663
- },
2664
- {}
2665
- );
2666
- const editMetadatas = Object.entries(data.contentType.metadatas).reduce(
2667
- (acc, [attribute, metadata]) => {
2668
- return {
2669
- ...acc,
2670
- [attribute]: metadata.edit
2671
- };
2672
- },
2673
- {}
2674
- );
2675
- return {
2676
- layout: panelledEditAttributes,
2677
- components: componentEditAttributes,
2678
- metadatas: editMetadatas,
2679
- settings: {
2680
- ...data.contentType.settings,
2681
- displayName: schema?.info.displayName
2919
+ }
2920
+ } finally {
2921
+ if (!listViewPathMatch) {
2922
+ setSubmitting(false);
2923
+ }
2924
+ }
2925
+ }
2682
2926
  },
2683
- options: {
2684
- ...schema?.options,
2685
- ...schema?.pluginOptions,
2686
- ...data.contentType.options
2687
- }
2927
+ variant: "danger",
2928
+ position: ["header", "table-row"]
2688
2929
  };
2689
2930
  };
2690
- const convertEditLayoutToFieldLayouts = (rows, attributes = {}, metadatas, components, schemas = []) => {
2691
- return rows.map(
2692
- (row) => row.map((field) => {
2693
- const attribute = attributes[field.name];
2694
- if (!attribute) {
2695
- return null;
2696
- }
2697
- const { edit: metadata } = metadatas[field.name];
2698
- const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
2699
- return {
2700
- attribute,
2701
- disabled: !metadata.editable,
2702
- hint: metadata.description,
2703
- label: metadata.label ?? "",
2704
- name: field.name,
2705
- // @ts-expect-error – mainField does exist on the metadata for a relation.
2706
- mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
2707
- schemas,
2708
- components: components?.schemas ?? {}
2709
- }),
2710
- placeholder: metadata.placeholder ?? "",
2711
- required: attribute.required ?? false,
2712
- size: field.size,
2713
- unique: "unique" in attribute ? attribute.unique : false,
2714
- visible: metadata.visible ?? true,
2715
- type: attribute.type
2716
- };
2717
- }).filter((field) => field !== null)
2718
- );
2931
+ DeleteAction$1.type = "delete";
2932
+ const DEFAULT_HEADER_ACTIONS = [EditTheModelAction, ConfigureTheViewAction, DeleteAction$1];
2933
+ const Panels = () => {
2934
+ const isCloning = useMatch(CLONE_PATH) !== null;
2935
+ const [
2936
+ {
2937
+ query: { status }
2938
+ }
2939
+ ] = useQueryParams({
2940
+ status: "draft"
2941
+ });
2942
+ const { model, id, document, meta, collectionType } = useDoc();
2943
+ const plugins = useStrapiApp("Panels", (state) => state.plugins);
2944
+ const props = {
2945
+ activeTab: status,
2946
+ model,
2947
+ documentId: id,
2948
+ document: isCloning ? void 0 : document,
2949
+ meta: isCloning ? void 0 : meta,
2950
+ collectionType
2951
+ };
2952
+ return /* @__PURE__ */ jsx(Flex, { direction: "column", alignItems: "stretch", gap: 2, children: /* @__PURE__ */ jsx(
2953
+ DescriptionComponentRenderer,
2954
+ {
2955
+ props,
2956
+ descriptions: plugins["content-manager"].apis.getEditViewSidePanels(),
2957
+ children: (panels) => panels.map(({ content, id: id2, ...description }) => /* @__PURE__ */ jsx(Panel, { ...description, children: content }, id2))
2958
+ }
2959
+ ) });
2719
2960
  };
2720
- const formatListLayout = (data, {
2721
- schemas,
2722
- schema,
2723
- components
2724
- }) => {
2725
- const listMetadatas = Object.entries(data.contentType.metadatas).reduce(
2726
- (acc, [attribute, metadata]) => {
2727
- return {
2728
- ...acc,
2729
- [attribute]: metadata.list
2730
- };
2731
- },
2732
- {}
2733
- );
2734
- const listAttributes = convertListLayoutToFieldLayouts(
2735
- data.contentType.layouts.list,
2736
- schema?.attributes,
2737
- listMetadatas,
2738
- { configurations: data.components, schemas: components },
2739
- schemas
2740
- );
2961
+ const ActionsPanel = () => {
2962
+ const { formatMessage } = useIntl();
2741
2963
  return {
2742
- layout: listAttributes,
2743
- settings: { ...data.contentType.settings, displayName: schema?.info.displayName },
2744
- metadatas: listMetadatas,
2745
- options: {
2746
- ...schema?.options,
2747
- ...schema?.pluginOptions,
2748
- ...data.contentType.options
2749
- }
2964
+ title: formatMessage({
2965
+ id: "content-manager.containers.edit.panels.default.title",
2966
+ defaultMessage: "Entry"
2967
+ }),
2968
+ content: /* @__PURE__ */ jsx(ActionsPanelContent, {})
2750
2969
  };
2751
2970
  };
2752
- const convertListLayoutToFieldLayouts = (columns, attributes = {}, metadatas, components, schemas = []) => {
2753
- return columns.map((name) => {
2754
- const attribute = attributes[name];
2755
- if (!attribute) {
2756
- return null;
2971
+ ActionsPanel.type = "actions";
2972
+ const ActionsPanelContent = () => {
2973
+ const isCloning = useMatch(CLONE_PATH) !== null;
2974
+ const [
2975
+ {
2976
+ query: { status = "draft" }
2757
2977
  }
2758
- const metadata = metadatas[name];
2759
- const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
2760
- return {
2761
- attribute,
2762
- label: metadata.label ?? "",
2763
- mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
2764
- schemas,
2765
- components: components?.schemas ?? {}
2766
- }),
2767
- name,
2768
- searchable: metadata.searchable ?? true,
2769
- sortable: metadata.sortable ?? true
2770
- };
2771
- }).filter((field) => field !== null);
2978
+ ] = useQueryParams();
2979
+ const { model, id, document, meta, collectionType } = useDoc();
2980
+ const plugins = useStrapiApp("ActionsPanel", (state) => state.plugins);
2981
+ const props = {
2982
+ activeTab: status,
2983
+ model,
2984
+ documentId: id,
2985
+ document: isCloning ? void 0 : document,
2986
+ meta: isCloning ? void 0 : meta,
2987
+ collectionType
2988
+ };
2989
+ return /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 2, width: "100%", children: [
2990
+ /* @__PURE__ */ jsx(
2991
+ DescriptionComponentRenderer,
2992
+ {
2993
+ props,
2994
+ descriptions: plugins["content-manager"].apis.getDocumentActions(),
2995
+ children: (actions2) => /* @__PURE__ */ jsx(DocumentActions, { actions: actions2 })
2996
+ }
2997
+ ),
2998
+ /* @__PURE__ */ jsx(InjectionZone, { area: "editView.right-links", slug: model })
2999
+ ] });
2772
3000
  };
3001
+ const Panel = React.forwardRef(({ children, title }, ref) => {
3002
+ return /* @__PURE__ */ jsxs(
3003
+ Flex,
3004
+ {
3005
+ ref,
3006
+ tag: "aside",
3007
+ "aria-labelledby": "additional-information",
3008
+ background: "neutral0",
3009
+ borderColor: "neutral150",
3010
+ hasRadius: true,
3011
+ paddingBottom: 4,
3012
+ paddingLeft: 4,
3013
+ paddingRight: 4,
3014
+ paddingTop: 4,
3015
+ shadow: "tableShadow",
3016
+ gap: 3,
3017
+ direction: "column",
3018
+ justifyContent: "stretch",
3019
+ alignItems: "flex-start",
3020
+ children: [
3021
+ /* @__PURE__ */ jsx(Typography, { tag: "h2", variant: "sigma", textTransform: "uppercase", textColor: "neutral600", children: title }),
3022
+ children
3023
+ ]
3024
+ }
3025
+ );
3026
+ });
2773
3027
  const ConfirmBulkActionDialog = ({
2774
3028
  onToggleDialog,
2775
3029
  isOpen = false,
@@ -2777,7 +3031,7 @@ const ConfirmBulkActionDialog = ({
2777
3031
  endAction
2778
3032
  }) => {
2779
3033
  const { formatMessage } = useIntl();
2780
- return /* @__PURE__ */ jsx(Dialog.Root, { onOpenChange: onToggleDialog, open: isOpen, children: /* @__PURE__ */ jsxs(Dialog.Content, { children: [
3034
+ return /* @__PURE__ */ jsx(Dialog.Root, { open: isOpen, children: /* @__PURE__ */ jsxs(Dialog.Content, { children: [
2781
3035
  /* @__PURE__ */ jsx(Dialog.Header, { children: formatMessage({
2782
3036
  id: "app.components.ConfirmDialog.title",
2783
3037
  defaultMessage: "Confirmation"
@@ -2808,6 +3062,7 @@ const ConfirmDialogPublishAll = ({
2808
3062
  const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler(getTranslation);
2809
3063
  const { model, schema } = useDoc();
2810
3064
  const [{ query }] = useQueryParams();
3065
+ const enableDraftRelationsCount = false;
2811
3066
  const {
2812
3067
  data: countDraftRelations = 0,
2813
3068
  isLoading,
@@ -2819,7 +3074,7 @@ const ConfirmDialogPublishAll = ({
2819
3074
  locale: query?.plugins?.i18n?.locale
2820
3075
  },
2821
3076
  {
2822
- skip: selectedEntries.length === 0
3077
+ skip: !enableDraftRelationsCount
2823
3078
  }
2824
3079
  );
2825
3080
  React.useEffect(() => {
@@ -2898,7 +3153,14 @@ const formatErrorMessages = (errors, parentKey, formatMessage) => {
2898
3153
  )
2899
3154
  );
2900
3155
  } else {
2901
- messages.push(...formatErrorMessages(value, currentKey, formatMessage));
3156
+ messages.push(
3157
+ ...formatErrorMessages(
3158
+ // @ts-expect-error TODO: check why value is not compatible with FormErrors
3159
+ value,
3160
+ currentKey,
3161
+ formatMessage
3162
+ )
3163
+ );
2902
3164
  }
2903
3165
  } else {
2904
3166
  messages.push(
@@ -2997,7 +3259,7 @@ const SelectedEntriesTableContent = ({
2997
3259
  status: row.status
2998
3260
  }
2999
3261
  ) }),
3000
- /* @__PURE__ */ jsx(Table.Cell, { children: /* @__PURE__ */ jsx(
3262
+ /* @__PURE__ */ jsx(Table.Cell, { children: /* @__PURE__ */ jsx(Flex, { children: /* @__PURE__ */ jsx(
3001
3263
  IconButton,
3002
3264
  {
3003
3265
  tag: Link,
@@ -3020,9 +3282,10 @@ const SelectedEntriesTableContent = ({
3020
3282
  ),
3021
3283
  target: "_blank",
3022
3284
  marginLeft: "auto",
3023
- children: /* @__PURE__ */ jsx(Pencil, {})
3285
+ variant: "ghost",
3286
+ children: /* @__PURE__ */ jsx(Pencil, { width: "1.6rem", height: "1.6rem" })
3024
3287
  }
3025
- ) })
3288
+ ) }) })
3026
3289
  ] }, row.id)) })
3027
3290
  ] });
3028
3291
  };
@@ -3059,7 +3322,13 @@ const SelectedEntriesModalContent = ({
3059
3322
  );
3060
3323
  const { rows, validationErrors } = React.useMemo(() => {
3061
3324
  if (data.length > 0 && schema) {
3062
- const validate = createYupSchema(schema.attributes, components);
3325
+ const validate = createYupSchema(
3326
+ schema.attributes,
3327
+ components,
3328
+ // Since this is the "Publish" action, the validation
3329
+ // schema must enforce the rules for published entities
3330
+ { status: "published" }
3331
+ );
3063
3332
  const validationErrors2 = {};
3064
3333
  const rows2 = data.map((entry) => {
3065
3334
  try {
@@ -3409,7 +3678,7 @@ const TableActions = ({ document }) => {
3409
3678
  DescriptionComponentRenderer,
3410
3679
  {
3411
3680
  props,
3412
- descriptions: plugins["content-manager"].apis.getDocumentActions(),
3681
+ descriptions: plugins["content-manager"].apis.getDocumentActions().filter((action) => action.name !== "PublishAction"),
3413
3682
  children: (actions2) => {
3414
3683
  const tableRowActions = actions2.filter((action) => {
3415
3684
  const positions = Array.isArray(action.position) ? action.position : [action.position];
@@ -3520,7 +3789,7 @@ const CloneAction = ({ model, documentId }) => {
3520
3789
  }),
3521
3790
  content: /* @__PURE__ */ jsx(AutoCloneFailureModalBody, { prohibitedFields }),
3522
3791
  footer: ({ onClose }) => {
3523
- return /* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", children: [
3792
+ return /* @__PURE__ */ jsxs(Modal.Footer, { children: [
3524
3793
  /* @__PURE__ */ jsx(Button, { onClick: onClose, variant: "tertiary", children: formatMessage({
3525
3794
  id: "cancel",
3526
3795
  defaultMessage: "Cancel"
@@ -3561,8 +3830,7 @@ class ContentManagerPlugin {
3561
3830
  documentActions = [
3562
3831
  ...DEFAULT_ACTIONS,
3563
3832
  ...DEFAULT_TABLE_ROW_ACTIONS,
3564
- ...DEFAULT_HEADER_ACTIONS,
3565
- HistoryAction
3833
+ ...DEFAULT_HEADER_ACTIONS
3566
3834
  ];
3567
3835
  editViewSidePanels = [ActionsPanel];
3568
3836
  headerActions = [];
@@ -3651,6 +3919,52 @@ const getPrintableType = (value) => {
3651
3919
  }
3652
3920
  return nativeType;
3653
3921
  };
3922
+ const HistoryAction = ({ model, document }) => {
3923
+ const { formatMessage } = useIntl();
3924
+ const [{ query }] = useQueryParams();
3925
+ const navigate = useNavigate();
3926
+ const pluginsQueryParams = stringify({ plugins: query.plugins }, { encode: false });
3927
+ if (!window.strapi.features.isEnabled("cms-content-history")) {
3928
+ return null;
3929
+ }
3930
+ return {
3931
+ icon: /* @__PURE__ */ jsx(ClockCounterClockwise, {}),
3932
+ label: formatMessage({
3933
+ id: "content-manager.history.document-action",
3934
+ defaultMessage: "Content History"
3935
+ }),
3936
+ onClick: () => navigate({ pathname: "history", search: pluginsQueryParams }),
3937
+ disabled: (
3938
+ /**
3939
+ * The user is creating a new document.
3940
+ * It hasn't been saved yet, so there's no history to go to
3941
+ */
3942
+ !document || /**
3943
+ * The document has been created but the current dimension has never been saved.
3944
+ * For example, the user is creating a new locale in an existing document,
3945
+ * so there's no history for the document in that locale
3946
+ */
3947
+ !document.id || /**
3948
+ * History is only available for content types created by the user.
3949
+ * These have the `api::` prefix, as opposed to the ones created by Strapi or plugins,
3950
+ * which start with `admin::` or `plugin::`
3951
+ */
3952
+ !model.startsWith("api::")
3953
+ ),
3954
+ position: "header"
3955
+ };
3956
+ };
3957
+ HistoryAction.type = "history";
3958
+ const historyAdmin = {
3959
+ bootstrap(app) {
3960
+ const { addDocumentAction } = app.getPlugin("content-manager").apis;
3961
+ addDocumentAction((actions2) => {
3962
+ const indexOfDeleteAction = actions2.findIndex((action) => action.type === "delete");
3963
+ actions2.splice(indexOfDeleteAction, 0, HistoryAction);
3964
+ return actions2;
3965
+ });
3966
+ }
3967
+ };
3654
3968
  const initialState = {
3655
3969
  collectionTypeLinks: [],
3656
3970
  components: [],
@@ -3687,6 +4001,70 @@ const { setInitialData } = actions;
3687
4001
  const reducer = combineReducers({
3688
4002
  app: reducer$1
3689
4003
  });
4004
+ const previewApi = contentManagerApi.injectEndpoints({
4005
+ endpoints: (builder) => ({
4006
+ getPreviewUrl: builder.query({
4007
+ query({ query, params }) {
4008
+ return {
4009
+ url: `/content-manager/preview/url/${params.contentType}`,
4010
+ method: "GET",
4011
+ config: {
4012
+ params: query
4013
+ }
4014
+ };
4015
+ }
4016
+ })
4017
+ })
4018
+ });
4019
+ const { useGetPreviewUrlQuery } = previewApi;
4020
+ const PreviewSidePanel = ({ model, documentId, document }) => {
4021
+ const { formatMessage } = useIntl();
4022
+ const { trackUsage } = useTracking();
4023
+ const [{ query }] = useQueryParams();
4024
+ const { data, error } = useGetPreviewUrlQuery({
4025
+ params: {
4026
+ contentType: model
4027
+ },
4028
+ query: {
4029
+ documentId,
4030
+ locale: document?.locale,
4031
+ status: document?.status
4032
+ }
4033
+ });
4034
+ if (!data?.data?.url || error) {
4035
+ return null;
4036
+ }
4037
+ const handleClick = () => {
4038
+ trackUsage("willOpenPreview");
4039
+ };
4040
+ return {
4041
+ title: formatMessage({ id: "content-manager.preview.panel.title", defaultMessage: "Preview" }),
4042
+ content: /* @__PURE__ */ jsx(Flex, { gap: 2, width: "100%", children: /* @__PURE__ */ jsx(
4043
+ Button,
4044
+ {
4045
+ variant: "tertiary",
4046
+ tag: Link,
4047
+ to: { pathname: "preview", search: stringify(query, { encode: false }) },
4048
+ onClick: handleClick,
4049
+ flex: "auto",
4050
+ children: formatMessage({
4051
+ id: "content-manager.preview.panel.button",
4052
+ defaultMessage: "Open preview"
4053
+ })
4054
+ }
4055
+ ) })
4056
+ };
4057
+ };
4058
+ const FEATURE_ID = "preview";
4059
+ const previewAdmin = {
4060
+ bootstrap(app) {
4061
+ if (!window.strapi.future.isEnabled(FEATURE_ID)) {
4062
+ return;
4063
+ }
4064
+ const contentManagerPluginApis = app.getPlugin("content-manager").apis;
4065
+ contentManagerPluginApis.addEditViewSidePanel([PreviewSidePanel]);
4066
+ }
4067
+ };
3690
4068
  const index = {
3691
4069
  register(app) {
3692
4070
  const cm = new ContentManagerPlugin();
@@ -3706,7 +4084,7 @@ const index = {
3706
4084
  app.router.addRoute({
3707
4085
  path: "content-manager/*",
3708
4086
  lazy: async () => {
3709
- const { Layout } = await import("./layout-Bau7ZfLV.mjs");
4087
+ const { Layout } = await import("./layout-OhrmoJVB.mjs");
3710
4088
  return {
3711
4089
  Component: Layout
3712
4090
  };
@@ -3715,10 +4093,18 @@ const index = {
3715
4093
  });
3716
4094
  app.registerPlugin(cm.config);
3717
4095
  },
4096
+ bootstrap(app) {
4097
+ if (typeof historyAdmin.bootstrap === "function") {
4098
+ historyAdmin.bootstrap(app);
4099
+ }
4100
+ if (typeof previewAdmin.bootstrap === "function") {
4101
+ previewAdmin.bootstrap(app);
4102
+ }
4103
+ },
3718
4104
  async registerTrads({ locales }) {
3719
4105
  const importedTrads = await Promise.all(
3720
4106
  locales.map((locale) => {
3721
- 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-Ux26r5pl.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 }) => {
4107
+ 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-D_BMf0hT.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 }) => {
3722
4108
  return {
3723
4109
  data: prefixPluginTranslations(data, PLUGIN_ID),
3724
4110
  locale
@@ -3739,13 +4125,16 @@ export {
3739
4125
  BulkActionsRenderer as B,
3740
4126
  COLLECTION_TYPES as C,
3741
4127
  DocumentStatus as D,
3742
- DEFAULT_SETTINGS as E,
3743
- convertEditLayoutToFieldLayouts as F,
3744
- useDocument as G,
4128
+ extractContentTypeComponents as E,
4129
+ DEFAULT_SETTINGS as F,
4130
+ convertEditLayoutToFieldLayouts as G,
3745
4131
  HOOKS as H,
3746
4132
  InjectionZone as I,
3747
- index as J,
3748
- useDocumentActions as K,
4133
+ useDocument as J,
4134
+ useGetPreviewUrlQuery as K,
4135
+ index as L,
4136
+ useContentManagerContext as M,
4137
+ useDocumentActions as N,
3749
4138
  Panels as P,
3750
4139
  RelativeTime as R,
3751
4140
  SINGLE_TYPES as S,
@@ -3763,18 +4152,18 @@ export {
3763
4152
  PERMISSIONS as k,
3764
4153
  DocumentRBAC as l,
3765
4154
  DOCUMENT_META_FIELDS as m,
3766
- useDocLayout as n,
3767
- useGetContentTypeConfigurationQuery as o,
3768
- CREATOR_FIELDS as p,
3769
- getMainField as q,
3770
- getDisplayName as r,
4155
+ CLONE_PATH as n,
4156
+ useDocLayout as o,
4157
+ useGetContentTypeConfigurationQuery as p,
4158
+ CREATOR_FIELDS as q,
4159
+ getMainField as r,
3771
4160
  setInitialData as s,
3772
- checkIfAttributeIsDisplayable as t,
4161
+ getDisplayName as t,
3773
4162
  useContentTypeSchema as u,
3774
- useGetAllDocumentsQuery as v,
3775
- convertListLayoutToFieldLayouts as w,
3776
- capitalise as x,
3777
- useUpdateContentTypeConfigurationMutation as y,
3778
- extractContentTypeComponents as z
4163
+ checkIfAttributeIsDisplayable as v,
4164
+ useGetAllDocumentsQuery as w,
4165
+ convertListLayoutToFieldLayouts as x,
4166
+ capitalise as y,
4167
+ useUpdateContentTypeConfigurationMutation as z
3779
4168
  };
3780
- //# sourceMappingURL=index-DJXJw9V5.mjs.map
4169
+ //# sourceMappingURL=index-D3IiO0X8.mjs.map