@strapi/content-manager 0.0.0-experimental.826f263c58b6886b849d3f03b81f7a530bc51c91 → 0.0.0-experimental.8c83c87960f2f5ddf95ae2f0acf849052f4a9ab4

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 (223) hide show
  1. package/LICENSE +18 -3
  2. package/dist/_chunks/CardDragPreview-C0QyJgRA.js.map +1 -1
  3. package/dist/_chunks/CardDragPreview-DOxamsuj.mjs.map +1 -1
  4. package/dist/_chunks/{ComponentConfigurationPage-CR5XdR33.mjs → ComponentConfigurationPage-BgCLcjXO.mjs} +4 -4
  5. package/dist/_chunks/{ComponentConfigurationPage-CR5XdR33.mjs.map → ComponentConfigurationPage-BgCLcjXO.mjs.map} +1 -1
  6. package/dist/_chunks/{ComponentConfigurationPage-DJcn1DrO.js → ComponentConfigurationPage-DywpTZeV.js} +5 -6
  7. package/dist/_chunks/{ComponentConfigurationPage-DJcn1DrO.js.map → ComponentConfigurationPage-DywpTZeV.js.map} +1 -1
  8. package/dist/_chunks/{ComponentIcon-BXdiCGQp.js → ComponentIcon-CRbtQEUV.js} +2 -3
  9. package/dist/_chunks/{ComponentIcon-BXdiCGQp.js.map → ComponentIcon-CRbtQEUV.js.map} +1 -1
  10. package/dist/_chunks/ComponentIcon-u4bIXTFY.mjs.map +1 -1
  11. package/dist/_chunks/{EditConfigurationPage-DmCIb4kD.mjs → EditConfigurationPage-BNjOAHNS.mjs} +4 -4
  12. package/dist/_chunks/{EditConfigurationPage-DmCIb4kD.mjs.map → EditConfigurationPage-BNjOAHNS.mjs.map} +1 -1
  13. package/dist/_chunks/{EditConfigurationPage-tDtWj7R2.js → EditConfigurationPage-CxRlP5if.js} +5 -6
  14. package/dist/_chunks/{EditConfigurationPage-tDtWj7R2.js.map → EditConfigurationPage-CxRlP5if.js.map} +1 -1
  15. package/dist/_chunks/{EditViewPage-CoQEnFlC.js → EditViewPage-BRewdTqE.js} +101 -51
  16. package/dist/_chunks/EditViewPage-BRewdTqE.js.map +1 -0
  17. package/dist/_chunks/{EditViewPage-DvaV7U9b.mjs → EditViewPage-CD_hqc1J.mjs} +102 -51
  18. package/dist/_chunks/EditViewPage-CD_hqc1J.mjs.map +1 -0
  19. package/dist/_chunks/{Field-Cz_J9551.mjs → Field-BPkQ-3Ku.mjs} +631 -279
  20. package/dist/_chunks/Field-BPkQ-3Ku.mjs.map +1 -0
  21. package/dist/_chunks/{Field-ZdrmmQ4Y.js → Field-DwvmENVf.js} +634 -283
  22. package/dist/_chunks/Field-DwvmENVf.js.map +1 -0
  23. package/dist/_chunks/FieldTypeIcon-CMlNO8PE.mjs.map +1 -1
  24. package/dist/_chunks/FieldTypeIcon-Dnwq_IRF.js.map +1 -1
  25. package/dist/_chunks/{Form-Bpig5rch.js → Form-C_Gwv8P_.js} +55 -38
  26. package/dist/_chunks/Form-C_Gwv8P_.js.map +1 -0
  27. package/dist/_chunks/{Form-Dxmihyw8.mjs → Form-Czi0cf_2.mjs} +55 -37
  28. package/dist/_chunks/Form-Czi0cf_2.mjs.map +1 -0
  29. package/dist/_chunks/{History-BfX6XmZK.js → History-C1TKAig-.js} +175 -129
  30. package/dist/_chunks/History-C1TKAig-.js.map +1 -0
  31. package/dist/_chunks/{History-BZP8n7KT.mjs → History-CIQHyi4T.mjs} +176 -129
  32. package/dist/_chunks/History-CIQHyi4T.mjs.map +1 -0
  33. package/dist/_chunks/{ListConfigurationPage-B3CXj8PY.js → ListConfigurationPage-D-NGRLYu.js} +62 -51
  34. package/dist/_chunks/ListConfigurationPage-D-NGRLYu.js.map +1 -0
  35. package/dist/_chunks/{ListConfigurationPage-DxKuVkKz.mjs → ListConfigurationPage-DcZsfyEL.mjs} +63 -52
  36. package/dist/_chunks/ListConfigurationPage-DcZsfyEL.mjs.map +1 -0
  37. package/dist/_chunks/{ListViewPage-D5D3tVPq.mjs → ListViewPage-C10McTK1.mjs} +152 -128
  38. package/dist/_chunks/ListViewPage-C10McTK1.mjs.map +1 -0
  39. package/dist/_chunks/{ListViewPage-Bk9VO__I.js → ListViewPage-xv5IQoZp.js} +155 -132
  40. package/dist/_chunks/ListViewPage-xv5IQoZp.js.map +1 -0
  41. package/dist/_chunks/{NoContentTypePage-DnMeuQCj.mjs → NoContentTypePage-CPc0Cd3S.mjs} +2 -2
  42. package/dist/_chunks/{NoContentTypePage-DnMeuQCj.mjs.map → NoContentTypePage-CPc0Cd3S.mjs.map} +1 -1
  43. package/dist/_chunks/{NoContentTypePage-DsB2F7Z1.js → NoContentTypePage-Dzw5Yj5u.js} +2 -2
  44. package/dist/_chunks/{NoContentTypePage-DsB2F7Z1.js.map → NoContentTypePage-Dzw5Yj5u.js.map} +1 -1
  45. package/dist/_chunks/{NoPermissionsPage-BQDM64_b.js → NoPermissionsPage-DAe5CDCC.js} +2 -2
  46. package/dist/_chunks/{NoPermissionsPage-BQDM64_b.js.map → NoPermissionsPage-DAe5CDCC.js.map} +1 -1
  47. package/dist/_chunks/{NoPermissionsPage-OyoME_Tf.mjs → NoPermissionsPage-wfPBh2_0.mjs} +2 -2
  48. package/dist/_chunks/{NoPermissionsPage-OyoME_Tf.mjs.map → NoPermissionsPage-wfPBh2_0.mjs.map} +1 -1
  49. package/dist/_chunks/Preview-B7LyGT_b.js +290 -0
  50. package/dist/_chunks/Preview-B7LyGT_b.js.map +1 -0
  51. package/dist/_chunks/Preview-BVFFm7uB.mjs +272 -0
  52. package/dist/_chunks/Preview-BVFFm7uB.mjs.map +1 -0
  53. package/dist/_chunks/{Relations-B6B3A3mb.js → Relations-BmYR1AjY.js} +76 -43
  54. package/dist/_chunks/Relations-BmYR1AjY.js.map +1 -0
  55. package/dist/_chunks/{Relations-BOYZmuWy.mjs → Relations-JPhWxk-s.mjs} +76 -42
  56. package/dist/_chunks/Relations-JPhWxk-s.mjs.map +1 -0
  57. package/dist/_chunks/{en-BN1bvFK7.js → en-BK8Xyl5I.js} +35 -18
  58. package/dist/_chunks/{en-BN1bvFK7.js.map → en-BK8Xyl5I.js.map} +1 -1
  59. package/dist/_chunks/{en-Dzv55oQw.mjs → en-Dtk_ot79.mjs} +35 -18
  60. package/dist/_chunks/{en-Dzv55oQw.mjs.map → en-Dtk_ot79.mjs.map} +1 -1
  61. package/dist/_chunks/{es-EUonQTon.js → es-9K52xZIr.js} +2 -2
  62. package/dist/_chunks/{ja-CcFe8diO.js.map → es-9K52xZIr.js.map} +1 -1
  63. package/dist/_chunks/{es-CeXiYflN.mjs → es-D34tqjMw.mjs} +2 -2
  64. package/dist/_chunks/{es-CeXiYflN.mjs.map → es-D34tqjMw.mjs.map} +1 -1
  65. package/dist/_chunks/{fr-CD9VFbPM.mjs → fr--pg5jUbt.mjs} +13 -3
  66. package/dist/_chunks/{fr-CD9VFbPM.mjs.map → fr--pg5jUbt.mjs.map} +1 -1
  67. package/dist/_chunks/{fr-B7kGGg3E.js → fr-B2Kyv8Z9.js} +13 -3
  68. package/dist/_chunks/{fr-B7kGGg3E.js.map → fr-B2Kyv8Z9.js.map} +1 -1
  69. package/dist/_chunks/hooks-BAaaKPS_.js.map +1 -1
  70. package/dist/_chunks/{index-DzN3kBgx.js → index-C2Q_PLWj.js} +1165 -880
  71. package/dist/_chunks/index-C2Q_PLWj.js.map +1 -0
  72. package/dist/_chunks/{index-VHviNMeW.mjs → index-DLIkNVnQ.mjs} +1185 -900
  73. package/dist/_chunks/index-DLIkNVnQ.mjs.map +1 -0
  74. package/dist/_chunks/{ja-CcFe8diO.js → ja-7sfIbjxE.js} +2 -2
  75. package/dist/_chunks/{es-EUonQTon.js.map → ja-7sfIbjxE.js.map} +1 -1
  76. package/dist/_chunks/{ja-CtsUxOvk.mjs → ja-BHqhDq4V.mjs} +2 -2
  77. package/dist/_chunks/{ja-CtsUxOvk.mjs.map → ja-BHqhDq4V.mjs.map} +1 -1
  78. package/dist/_chunks/{layout-b91XRlD2.js → layout-7AsWJzZJ.js} +41 -24
  79. package/dist/_chunks/layout-7AsWJzZJ.js.map +1 -0
  80. package/dist/_chunks/{layout-CPn1PM6x.mjs → layout-qE8qkNH_.mjs} +42 -24
  81. package/dist/_chunks/layout-qE8qkNH_.mjs.map +1 -0
  82. package/dist/_chunks/{objects-gigeqt7s.js → objects-BcXOv6_9.js} +2 -4
  83. package/dist/_chunks/{objects-gigeqt7s.js.map → objects-BcXOv6_9.js.map} +1 -1
  84. package/dist/_chunks/{objects-mKMAmfec.mjs → objects-D6yBsdmx.mjs} +2 -4
  85. package/dist/_chunks/{objects-mKMAmfec.mjs.map → objects-D6yBsdmx.mjs.map} +1 -1
  86. package/dist/_chunks/{relations-BsqxS6tR.mjs → relations-BjHH_1Am.mjs} +6 -7
  87. package/dist/_chunks/relations-BjHH_1Am.mjs.map +1 -0
  88. package/dist/_chunks/{relations-CA7IYmcP.js → relations-EifVzf_2.js} +6 -7
  89. package/dist/_chunks/relations-EifVzf_2.js.map +1 -0
  90. package/dist/_chunks/{usePrev-B9w_-eYc.js → useDebounce-CtcjDB3L.js} +14 -1
  91. package/dist/_chunks/useDebounce-CtcjDB3L.js.map +1 -0
  92. package/dist/_chunks/useDebounce-DmuSJIF3.mjs +29 -0
  93. package/dist/_chunks/useDebounce-DmuSJIF3.mjs.map +1 -0
  94. package/dist/_chunks/{useDragAndDrop-J0TUUbR6.js → useDragAndDrop-BMtgCYzL.js} +5 -9
  95. package/dist/_chunks/{useDragAndDrop-J0TUUbR6.js.map → useDragAndDrop-BMtgCYzL.js.map} +1 -1
  96. package/dist/_chunks/{useDragAndDrop-DdHgKsqq.mjs → useDragAndDrop-DJ6jqvZN.mjs} +4 -7
  97. package/dist/_chunks/{useDragAndDrop-DdHgKsqq.mjs.map → useDragAndDrop-DJ6jqvZN.mjs.map} +1 -1
  98. package/dist/admin/index.js +2 -1
  99. package/dist/admin/index.js.map +1 -1
  100. package/dist/admin/index.mjs +8 -7
  101. package/dist/admin/src/exports.d.ts +1 -1
  102. package/dist/admin/src/history/components/VersionInputRenderer.d.ts +1 -1
  103. package/dist/admin/src/history/index.d.ts +3 -0
  104. package/dist/admin/src/history/services/historyVersion.d.ts +1 -1
  105. package/dist/admin/src/hooks/useDocument.d.ts +32 -1
  106. package/dist/admin/src/index.d.ts +1 -0
  107. package/dist/admin/src/pages/EditView/EditViewPage.d.ts +9 -1
  108. package/dist/admin/src/pages/EditView/components/DocumentActions.d.ts +8 -3
  109. package/dist/admin/src/pages/EditView/components/DocumentStatus.d.ts +2 -2
  110. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/utils/constants.d.ts +4 -0
  111. package/dist/admin/src/pages/EditView/components/FormInputs/Relations.d.ts +20 -0
  112. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/EditorLayout.d.ts +2 -2
  113. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygFooter.d.ts +2 -2
  114. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygStyles.d.ts +6 -58
  115. package/dist/admin/src/pages/EditView/components/Header.d.ts +11 -11
  116. package/dist/admin/src/pages/ListView/components/BulkActions/Actions.d.ts +3 -30
  117. package/dist/admin/src/pages/ListView/components/BulkActions/ConfirmBulkActionDialog.d.ts +2 -2
  118. package/dist/admin/src/preview/components/PreviewContent.d.ts +2 -0
  119. package/dist/admin/src/preview/components/PreviewHeader.d.ts +2 -0
  120. package/dist/admin/src/preview/components/PreviewSidePanel.d.ts +3 -0
  121. package/dist/admin/src/preview/constants.d.ts +1 -0
  122. package/dist/admin/src/preview/index.d.ts +4 -0
  123. package/dist/admin/src/preview/pages/Preview.d.ts +11 -0
  124. package/dist/admin/src/preview/routes.d.ts +3 -0
  125. package/dist/admin/src/preview/services/preview.d.ts +3 -0
  126. package/dist/admin/src/router.d.ts +1 -1
  127. package/dist/admin/src/services/api.d.ts +1 -1
  128. package/dist/admin/src/services/components.d.ts +2 -2
  129. package/dist/admin/src/services/contentTypes.d.ts +3 -3
  130. package/dist/admin/src/services/documents.d.ts +19 -20
  131. package/dist/admin/src/services/init.d.ts +1 -1
  132. package/dist/admin/src/services/relations.d.ts +2 -2
  133. package/dist/admin/src/services/uid.d.ts +3 -3
  134. package/dist/admin/src/utils/validation.d.ts +4 -1
  135. package/dist/server/index.js +616 -299
  136. package/dist/server/index.js.map +1 -1
  137. package/dist/server/index.mjs +616 -298
  138. package/dist/server/index.mjs.map +1 -1
  139. package/dist/server/src/bootstrap.d.ts.map +1 -1
  140. package/dist/server/src/controllers/collection-types.d.ts.map +1 -1
  141. package/dist/server/src/controllers/index.d.ts.map +1 -1
  142. package/dist/server/src/controllers/relations.d.ts.map +1 -1
  143. package/dist/server/src/controllers/uid.d.ts.map +1 -1
  144. package/dist/server/src/controllers/utils/metadata.d.ts +15 -1
  145. package/dist/server/src/controllers/utils/metadata.d.ts.map +1 -1
  146. package/dist/server/src/controllers/validation/dimensions.d.ts +4 -2
  147. package/dist/server/src/controllers/validation/dimensions.d.ts.map +1 -1
  148. package/dist/server/src/history/services/history.d.ts.map +1 -1
  149. package/dist/server/src/history/services/lifecycles.d.ts.map +1 -1
  150. package/dist/server/src/history/services/utils.d.ts +4 -4
  151. package/dist/server/src/history/services/utils.d.ts.map +1 -1
  152. package/dist/server/src/index.d.ts +4 -4
  153. package/dist/server/src/policies/hasPermissions.d.ts.map +1 -1
  154. package/dist/server/src/preview/constants.d.ts +2 -0
  155. package/dist/server/src/preview/constants.d.ts.map +1 -0
  156. package/dist/server/src/preview/controllers/index.d.ts +2 -0
  157. package/dist/server/src/preview/controllers/index.d.ts.map +1 -0
  158. package/dist/server/src/preview/controllers/preview.d.ts +13 -0
  159. package/dist/server/src/preview/controllers/preview.d.ts.map +1 -0
  160. package/dist/server/src/preview/controllers/validation/preview.d.ts +6 -0
  161. package/dist/server/src/preview/controllers/validation/preview.d.ts.map +1 -0
  162. package/dist/server/src/preview/index.d.ts +4 -0
  163. package/dist/server/src/preview/index.d.ts.map +1 -0
  164. package/dist/server/src/preview/routes/index.d.ts +8 -0
  165. package/dist/server/src/preview/routes/index.d.ts.map +1 -0
  166. package/dist/server/src/preview/routes/preview.d.ts +4 -0
  167. package/dist/server/src/preview/routes/preview.d.ts.map +1 -0
  168. package/dist/server/src/preview/services/index.d.ts +16 -0
  169. package/dist/server/src/preview/services/index.d.ts.map +1 -0
  170. package/dist/server/src/preview/services/preview-config.d.ts +32 -0
  171. package/dist/server/src/preview/services/preview-config.d.ts.map +1 -0
  172. package/dist/server/src/preview/services/preview.d.ts +12 -0
  173. package/dist/server/src/preview/services/preview.d.ts.map +1 -0
  174. package/dist/server/src/preview/utils.d.ts +19 -0
  175. package/dist/server/src/preview/utils.d.ts.map +1 -0
  176. package/dist/server/src/register.d.ts.map +1 -1
  177. package/dist/server/src/routes/index.d.ts.map +1 -1
  178. package/dist/server/src/services/document-manager.d.ts.map +1 -1
  179. package/dist/server/src/services/document-metadata.d.ts +8 -8
  180. package/dist/server/src/services/document-metadata.d.ts.map +1 -1
  181. package/dist/server/src/services/index.d.ts +4 -4
  182. package/dist/server/src/services/index.d.ts.map +1 -1
  183. package/dist/server/src/services/permission-checker.d.ts.map +1 -1
  184. package/dist/server/src/services/utils/configuration/index.d.ts +2 -2
  185. package/dist/server/src/services/utils/configuration/layouts.d.ts +2 -2
  186. package/dist/server/src/services/utils/populate.d.ts.map +1 -1
  187. package/dist/server/src/utils/index.d.ts +2 -0
  188. package/dist/server/src/utils/index.d.ts.map +1 -1
  189. package/dist/shared/contracts/collection-types.d.ts +3 -1
  190. package/dist/shared/contracts/collection-types.d.ts.map +1 -1
  191. package/dist/shared/contracts/index.d.ts +1 -0
  192. package/dist/shared/contracts/index.d.ts.map +1 -1
  193. package/dist/shared/contracts/preview.d.ts +27 -0
  194. package/dist/shared/contracts/preview.d.ts.map +1 -0
  195. package/dist/shared/index.js +4 -0
  196. package/dist/shared/index.js.map +1 -1
  197. package/dist/shared/index.mjs +4 -0
  198. package/dist/shared/index.mjs.map +1 -1
  199. package/package.json +15 -15
  200. package/dist/_chunks/EditViewPage-CoQEnFlC.js.map +0 -1
  201. package/dist/_chunks/EditViewPage-DvaV7U9b.mjs.map +0 -1
  202. package/dist/_chunks/Field-Cz_J9551.mjs.map +0 -1
  203. package/dist/_chunks/Field-ZdrmmQ4Y.js.map +0 -1
  204. package/dist/_chunks/Form-Bpig5rch.js.map +0 -1
  205. package/dist/_chunks/Form-Dxmihyw8.mjs.map +0 -1
  206. package/dist/_chunks/History-BZP8n7KT.mjs.map +0 -1
  207. package/dist/_chunks/History-BfX6XmZK.js.map +0 -1
  208. package/dist/_chunks/ListConfigurationPage-B3CXj8PY.js.map +0 -1
  209. package/dist/_chunks/ListConfigurationPage-DxKuVkKz.mjs.map +0 -1
  210. package/dist/_chunks/ListViewPage-Bk9VO__I.js.map +0 -1
  211. package/dist/_chunks/ListViewPage-D5D3tVPq.mjs.map +0 -1
  212. package/dist/_chunks/Relations-B6B3A3mb.js.map +0 -1
  213. package/dist/_chunks/Relations-BOYZmuWy.mjs.map +0 -1
  214. package/dist/_chunks/index-DzN3kBgx.js.map +0 -1
  215. package/dist/_chunks/index-VHviNMeW.mjs.map +0 -1
  216. package/dist/_chunks/layout-CPn1PM6x.mjs.map +0 -1
  217. package/dist/_chunks/layout-b91XRlD2.js.map +0 -1
  218. package/dist/_chunks/relations-BsqxS6tR.mjs.map +0 -1
  219. package/dist/_chunks/relations-CA7IYmcP.js.map +0 -1
  220. package/dist/_chunks/usePrev-B9w_-eYc.js.map +0 -1
  221. package/dist/_chunks/usePrev-DH6iah0A.mjs +0 -16
  222. package/dist/_chunks/usePrev-DH6iah0A.mjs.map +0 -1
  223. package/strapi-server.js +0 -3
@@ -1,25 +1,33 @@
1
- import { ClockCounterClockwise, CrossCircle, More, WarningCircle, ListPlus, Pencil, Trash, Check, CheckCircle, 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 { Menu, VisuallyHidden, Flex, Typography, Dialog, DialogBody, DialogFooter, Button, ModalLayout, ModalHeader, ModalBody, Box, Radio, Status, SingleSelect, SingleSelectOption, ModalFooter, Loader, IconButton, Tooltip, LinkButton } from "@strapi/design-system";
6
+ import { Menu, Button, VisuallyHidden, Flex, Dialog, Modal, Typography, Radio, Status, Box, SingleSelect, SingleSelectOption, IconButton, Loader, Tooltip, LinkButton } from "@strapi/design-system";
7
+ import mapValues from "lodash/fp/mapValues";
8
+ import { useIntl } from "react-intl";
9
+ import { useParams, useNavigate, Navigate, useMatch, useLocation, Link, NavLink } from "react-router-dom";
10
10
  import { styled } from "styled-components";
11
11
  import * as yup from "yup";
12
12
  import { ValidationError } from "yup";
13
+ import { stringify } from "qs";
13
14
  import pipe from "lodash/fp/pipe";
14
15
  import { intervalToDuration, isPast } from "date-fns";
15
16
  import { createSlice, combineReducers } from "@reduxjs/toolkit";
16
- const __variableDynamicImportRuntimeHelper = (glob, path) => {
17
+ const __variableDynamicImportRuntimeHelper = (glob, path, segs) => {
17
18
  const v = glob[path];
18
19
  if (v) {
19
20
  return typeof v === "function" ? v() : Promise.resolve(v);
20
21
  }
21
22
  return new Promise((_, reject) => {
22
- (typeof queueMicrotask === "function" ? queueMicrotask : setTimeout)(reject.bind(null, new Error("Unknown variable dynamic import: " + path)));
23
+ (typeof queueMicrotask === "function" ? queueMicrotask : setTimeout)(
24
+ reject.bind(
25
+ null,
26
+ new Error(
27
+ "Unknown variable dynamic import: " + path + (path.split("/").length !== segs ? ". Note that variables only represent file names one level deep." : "")
28
+ )
29
+ )
30
+ );
23
31
  });
24
32
  };
25
33
  const PLUGIN_ID = "content-manager";
@@ -49,42 +57,6 @@ const useInjectionZone = (area) => {
49
57
  const [page, position] = area.split(".");
50
58
  return contentManagerPlugin.getInjectedComponents(page, position);
51
59
  };
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
60
  const ID = "id";
89
61
  const CREATED_BY_ATTRIBUTE_NAME = "createdBy";
90
62
  const UPDATED_BY_ATTRIBUTE_NAME = "updatedBy";
@@ -136,6 +108,7 @@ const DocumentRBAC = ({ children, permissions }) => {
136
108
  if (!slug) {
137
109
  throw new Error("Cannot find the slug param in the URL");
138
110
  }
111
+ const [{ rawQuery }] = useQueryParams();
139
112
  const userPermissions = useAuth("DocumentRBAC", (state) => state.permissions);
140
113
  const contentTypePermissions = React.useMemo(() => {
141
114
  const contentTypePermissions2 = userPermissions.filter(
@@ -146,7 +119,14 @@ const DocumentRBAC = ({ children, permissions }) => {
146
119
  return { ...acc, [action]: [permission] };
147
120
  }, {});
148
121
  }, [slug, userPermissions]);
149
- const { isLoading, allowedActions } = useRBAC(contentTypePermissions, permissions ?? void 0);
122
+ const { isLoading, allowedActions } = useRBAC(
123
+ contentTypePermissions,
124
+ permissions ?? void 0,
125
+ // TODO: useRBAC context should be typed and built differently
126
+ // We are passing raw query as context to the hook so that it can
127
+ // rely on the locale provided from DocumentRBAC for its permission calculations.
128
+ rawQuery
129
+ );
150
130
  const canCreateFields = !isLoading && allowedActions.canCreate ? extractAndDedupeFields(contentTypePermissions.create) : [];
151
131
  const canReadFields = !isLoading && allowedActions.canRead ? extractAndDedupeFields(contentTypePermissions.read) : [];
152
132
  const canUpdateFields = !isLoading && allowedActions.canUpdate ? extractAndDedupeFields(contentTypePermissions.update) : [];
@@ -194,10 +174,12 @@ const contentManagerApi = adminApi.enhanceEndpoints({
194
174
  "Document",
195
175
  "InitialData",
196
176
  "HistoryVersion",
197
- "Relations"
177
+ "Relations",
178
+ "UidAvailability"
198
179
  ]
199
180
  });
200
181
  const documentApi = contentManagerApi.injectEndpoints({
182
+ overrideExisting: true,
201
183
  endpoints: (builder) => ({
202
184
  autoCloneDocument: builder.mutation({
203
185
  query: ({ model, sourceId, query }) => ({
@@ -207,7 +189,12 @@ const documentApi = contentManagerApi.injectEndpoints({
207
189
  params: query
208
190
  }
209
191
  }),
210
- invalidatesTags: (_result, _error, { model }) => [{ type: "Document", id: `${model}_LIST` }]
192
+ invalidatesTags: (_result, error, { model }) => {
193
+ if (error) {
194
+ return [];
195
+ }
196
+ return [{ type: "Document", id: `${model}_LIST` }];
197
+ }
211
198
  }),
212
199
  cloneDocument: builder.mutation({
213
200
  query: ({ model, sourceId, data, params }) => ({
@@ -218,7 +205,10 @@ const documentApi = contentManagerApi.injectEndpoints({
218
205
  params
219
206
  }
220
207
  }),
221
- invalidatesTags: (_result, _error, { model }) => [{ type: "Document", id: `${model}_LIST` }]
208
+ invalidatesTags: (_result, _error, { model }) => [
209
+ { type: "Document", id: `${model}_LIST` },
210
+ { type: "UidAvailability", id: model }
211
+ ]
222
212
  }),
223
213
  /**
224
214
  * Creates a new collection-type document. This should ONLY be used for collection-types.
@@ -235,7 +225,8 @@ const documentApi = contentManagerApi.injectEndpoints({
235
225
  }),
236
226
  invalidatesTags: (result, _error, { model }) => [
237
227
  { type: "Document", id: `${model}_LIST` },
238
- "Relations"
228
+ "Relations",
229
+ { type: "UidAvailability", id: model }
239
230
  ]
240
231
  }),
241
232
  deleteDocument: builder.mutation({
@@ -276,7 +267,8 @@ const documentApi = contentManagerApi.injectEndpoints({
276
267
  id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
277
268
  },
278
269
  { type: "Document", id: `${model}_LIST` },
279
- "Relations"
270
+ "Relations",
271
+ { type: "UidAvailability", id: model }
280
272
  ];
281
273
  }
282
274
  }),
@@ -289,11 +281,12 @@ const documentApi = contentManagerApi.injectEndpoints({
289
281
  url: `/content-manager/collection-types/${model}`,
290
282
  method: "GET",
291
283
  config: {
292
- params
284
+ params: stringify(params, { encode: true })
293
285
  }
294
286
  }),
295
287
  providesTags: (result, _error, arg) => {
296
288
  return [
289
+ { type: "Document", id: `ALL_LIST` },
297
290
  { type: "Document", id: `${arg.model}_LIST` },
298
291
  ...result?.results.map(({ documentId }) => ({
299
292
  type: "Document",
@@ -332,6 +325,11 @@ const documentApi = contentManagerApi.injectEndpoints({
332
325
  {
333
326
  type: "Document",
334
327
  id: collectionType !== SINGLE_TYPES ? `${model}_${result && "documentId" in result ? result.documentId : documentId}` : model
328
+ },
329
+ // Make it easy to invalidate all individual documents queries for a model
330
+ {
331
+ type: "Document",
332
+ id: `${model}_ALL_ITEMS`
335
333
  }
336
334
  ];
337
335
  }
@@ -395,8 +393,21 @@ const documentApi = contentManagerApi.injectEndpoints({
395
393
  type: "Document",
396
394
  id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
397
395
  },
398
- "Relations"
396
+ "Relations",
397
+ { type: "UidAvailability", id: model }
399
398
  ];
399
+ },
400
+ async onQueryStarted({ data, ...patch }, { dispatch, queryFulfilled }) {
401
+ const patchResult = dispatch(
402
+ documentApi.util.updateQueryData("getDocument", patch, (draft) => {
403
+ Object.assign(draft.data, data);
404
+ })
405
+ );
406
+ try {
407
+ await queryFulfilled;
408
+ } catch {
409
+ patchResult.undo();
410
+ }
400
411
  }
401
412
  }),
402
413
  unpublishDocument: builder.mutation({
@@ -449,8 +460,7 @@ const {
449
460
  useUnpublishManyDocumentsMutation
450
461
  } = documentApi;
451
462
  const buildValidParams = (query) => {
452
- if (!query)
453
- return query;
463
+ if (!query) return query;
454
464
  const { plugins: _, ...validQueryParams } = {
455
465
  ...query,
456
466
  ...Object.values(query?.plugins ?? {}).reduce(
@@ -458,28 +468,44 @@ const buildValidParams = (query) => {
458
468
  {}
459
469
  )
460
470
  };
461
- if ("_q" in validQueryParams) {
462
- validQueryParams._q = encodeURIComponent(validQueryParams._q);
463
- }
464
471
  return validQueryParams;
465
472
  };
466
473
  const isBaseQueryError = (error) => {
467
474
  return error.name !== void 0;
468
475
  };
469
- const createYupSchema = (attributes = {}, components = {}) => {
476
+ const arrayValidator = (attribute, options) => ({
477
+ message: translatedErrors.required,
478
+ test(value) {
479
+ if (options.status === "draft") {
480
+ return true;
481
+ }
482
+ if (!attribute.required) {
483
+ return true;
484
+ }
485
+ if (!value) {
486
+ return false;
487
+ }
488
+ if (Array.isArray(value) && value.length === 0) {
489
+ return false;
490
+ }
491
+ return true;
492
+ }
493
+ });
494
+ const createYupSchema = (attributes = {}, components = {}, options = { status: null }) => {
470
495
  const createModelSchema = (attributes2) => yup.object().shape(
471
496
  Object.entries(attributes2).reduce((acc, [name, attribute]) => {
472
497
  if (DOCUMENT_META_FIELDS.includes(name)) {
473
498
  return acc;
474
499
  }
475
500
  const validations = [
501
+ addNullableValidation,
476
502
  addRequiredValidation,
477
503
  addMinLengthValidation,
478
504
  addMaxLengthValidation,
479
505
  addMinValidation,
480
506
  addMaxValidation,
481
507
  addRegexValidation
482
- ].map((fn) => fn(attribute));
508
+ ].map((fn) => fn(attribute, options));
483
509
  const transformSchema = pipe(...validations);
484
510
  switch (attribute.type) {
485
511
  case "component": {
@@ -489,12 +515,12 @@ const createYupSchema = (attributes = {}, components = {}) => {
489
515
  ...acc,
490
516
  [name]: transformSchema(
491
517
  yup.array().of(createModelSchema(attributes3).nullable(false))
492
- )
518
+ ).test(arrayValidator(attribute, options))
493
519
  };
494
520
  } else {
495
521
  return {
496
522
  ...acc,
497
- [name]: transformSchema(createModelSchema(attributes3))
523
+ [name]: transformSchema(createModelSchema(attributes3).nullable())
498
524
  };
499
525
  }
500
526
  }
@@ -516,7 +542,7 @@ const createYupSchema = (attributes = {}, components = {}) => {
516
542
  }
517
543
  )
518
544
  )
519
- )
545
+ ).test(arrayValidator(attribute, options))
520
546
  };
521
547
  case "relation":
522
548
  return {
@@ -528,7 +554,7 @@ const createYupSchema = (attributes = {}, components = {}) => {
528
554
  } else if (Array.isArray(value)) {
529
555
  return yup.array().of(
530
556
  yup.object().shape({
531
- id: yup.string().required()
557
+ id: yup.number().required()
532
558
  })
533
559
  );
534
560
  } else if (typeof value === "object") {
@@ -580,6 +606,14 @@ const createAttributeSchema = (attribute) => {
580
606
  if (!value || typeof value === "string" && value.length === 0) {
581
607
  return true;
582
608
  }
609
+ if (typeof value === "object") {
610
+ try {
611
+ JSON.stringify(value);
612
+ return true;
613
+ } catch (err) {
614
+ return false;
615
+ }
616
+ }
583
617
  try {
584
618
  JSON.parse(value);
585
619
  return true;
@@ -598,13 +632,7 @@ const createAttributeSchema = (attribute) => {
598
632
  return yup.mixed();
599
633
  }
600
634
  };
601
- const addRequiredValidation = (attribute) => (schema) => {
602
- if (attribute.required) {
603
- return schema.required({
604
- id: translatedErrors.required.id,
605
- defaultMessage: "This field is required."
606
- });
607
- }
635
+ const nullableSchema = (schema) => {
608
636
  return schema?.nullable ? schema.nullable() : (
609
637
  // In some cases '.nullable' will not be available on the schema.
610
638
  // e.g. when the schema has been built using yup.lazy (e.g. for relations).
@@ -612,7 +640,22 @@ const addRequiredValidation = (attribute) => (schema) => {
612
640
  schema
613
641
  );
614
642
  };
615
- const addMinLengthValidation = (attribute) => (schema) => {
643
+ const addNullableValidation = () => (schema) => {
644
+ return nullableSchema(schema);
645
+ };
646
+ const addRequiredValidation = (attribute, options) => (schema) => {
647
+ if (options.status === "draft" || !attribute.required) {
648
+ return schema;
649
+ }
650
+ if (attribute.required && "required" in schema) {
651
+ return schema.required(translatedErrors.required);
652
+ }
653
+ return schema;
654
+ };
655
+ const addMinLengthValidation = (attribute, options) => (schema) => {
656
+ if (options.status === "draft") {
657
+ return schema;
658
+ }
616
659
  if ("minLength" in attribute && attribute.minLength && Number.isInteger(attribute.minLength) && "min" in schema) {
617
660
  return schema.min(attribute.minLength, {
618
661
  ...translatedErrors.minLength,
@@ -634,10 +677,13 @@ const addMaxLengthValidation = (attribute) => (schema) => {
634
677
  }
635
678
  return schema;
636
679
  };
637
- const addMinValidation = (attribute) => (schema) => {
638
- if ("min" in attribute) {
680
+ const addMinValidation = (attribute, options) => (schema) => {
681
+ if (options.status === "draft") {
682
+ return schema;
683
+ }
684
+ if ("min" in attribute && "min" in schema) {
639
685
  const min = toInteger(attribute.min);
640
- if ("min" in schema && min) {
686
+ if (min) {
641
687
  return schema.min(min, {
642
688
  ...translatedErrors.min,
643
689
  values: {
@@ -755,16 +801,115 @@ const extractContentTypeComponents = (attributes = {}, allComponents = {}) => {
755
801
  }, {});
756
802
  return componentsByKey;
757
803
  };
758
- const useDocument = (args, opts) => {
804
+ const HOOKS = {
805
+ /**
806
+ * Hook that allows to mutate the displayed headers of the list view table
807
+ * @constant
808
+ * @type {string}
809
+ */
810
+ INJECT_COLUMN_IN_TABLE: "Admin/CM/pages/ListView/inject-column-in-table",
811
+ /**
812
+ * Hook that allows to mutate the CM's collection types links pre-set filters
813
+ * @constant
814
+ * @type {string}
815
+ */
816
+ MUTATE_COLLECTION_TYPES_LINKS: "Admin/CM/pages/App/mutate-collection-types-links",
817
+ /**
818
+ * Hook that allows to mutate the CM's edit view layout
819
+ * @constant
820
+ * @type {string}
821
+ */
822
+ MUTATE_EDIT_VIEW_LAYOUT: "Admin/CM/pages/EditView/mutate-edit-view-layout",
823
+ /**
824
+ * Hook that allows to mutate the CM's single types links pre-set filters
825
+ * @constant
826
+ * @type {string}
827
+ */
828
+ MUTATE_SINGLE_TYPES_LINKS: "Admin/CM/pages/App/mutate-single-types-links"
829
+ };
830
+ const contentTypesApi = contentManagerApi.injectEndpoints({
831
+ endpoints: (builder) => ({
832
+ getContentTypeConfiguration: builder.query({
833
+ query: (uid) => ({
834
+ url: `/content-manager/content-types/${uid}/configuration`,
835
+ method: "GET"
836
+ }),
837
+ transformResponse: (response) => response.data,
838
+ providesTags: (_result, _error, uid) => [
839
+ { type: "ContentTypesConfiguration", id: uid },
840
+ { type: "ContentTypeSettings", id: "LIST" }
841
+ ]
842
+ }),
843
+ getAllContentTypeSettings: builder.query({
844
+ query: () => "/content-manager/content-types-settings",
845
+ transformResponse: (response) => response.data,
846
+ providesTags: [{ type: "ContentTypeSettings", id: "LIST" }]
847
+ }),
848
+ updateContentTypeConfiguration: builder.mutation({
849
+ query: ({ uid, ...body }) => ({
850
+ url: `/content-manager/content-types/${uid}/configuration`,
851
+ method: "PUT",
852
+ data: body
853
+ }),
854
+ transformResponse: (response) => response.data,
855
+ invalidatesTags: (_result, _error, { uid }) => [
856
+ { type: "ContentTypesConfiguration", id: uid },
857
+ { type: "ContentTypeSettings", id: "LIST" },
858
+ // Is this necessary?
859
+ { type: "InitialData" }
860
+ ]
861
+ })
862
+ })
863
+ });
864
+ const {
865
+ useGetContentTypeConfigurationQuery,
866
+ useGetAllContentTypeSettingsQuery,
867
+ useUpdateContentTypeConfigurationMutation
868
+ } = contentTypesApi;
869
+ const checkIfAttributeIsDisplayable = (attribute) => {
870
+ const { type } = attribute;
871
+ if (type === "relation") {
872
+ return !attribute.relation.toLowerCase().includes("morph");
873
+ }
874
+ return !["json", "dynamiczone", "richtext", "password", "blocks"].includes(type) && !!type;
875
+ };
876
+ const getMainField = (attribute, mainFieldName, { schemas, components }) => {
877
+ if (!mainFieldName) {
878
+ return void 0;
879
+ }
880
+ const mainFieldType = attribute.type === "component" ? components[attribute.component].attributes[mainFieldName].type : (
881
+ // @ts-expect-error – `targetModel` does exist on the attribute for a relation.
882
+ schemas.find((schema) => schema.uid === attribute.targetModel)?.attributes[mainFieldName].type
883
+ );
884
+ return {
885
+ name: mainFieldName,
886
+ type: mainFieldType ?? "string"
887
+ };
888
+ };
889
+ const DEFAULT_SETTINGS = {
890
+ bulkable: false,
891
+ filterable: false,
892
+ searchable: false,
893
+ pagination: false,
894
+ defaultSortBy: "",
895
+ defaultSortOrder: "asc",
896
+ mainField: "id",
897
+ pageSize: 10
898
+ };
899
+ const useDocumentLayout = (model) => {
900
+ const { schema, components } = useDocument({ model, collectionType: "" }, { skip: true });
901
+ const [{ query }] = useQueryParams();
902
+ const runHookWaterfall = useStrapiApp("useDocumentLayout", (state) => state.runHookWaterfall);
759
903
  const { toggleNotification } = useNotification();
760
904
  const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();
905
+ const { isLoading: isLoadingSchemas, schemas } = useContentTypeSchema();
761
906
  const {
762
- currentData: data,
763
- isLoading: isLoadingDocument,
764
- isFetching: isFetchingDocument,
765
- error
766
- } = useGetDocumentQuery(args, opts);
767
- const { components, schema, isLoading: isLoadingSchema } = useContentTypeSchema(args.model);
907
+ data,
908
+ isLoading: isLoadingConfigs,
909
+ error,
910
+ isFetching: isFetchingConfigs
911
+ } = useGetContentTypeConfigurationQuery(model);
912
+ const isLoading = isLoadingSchemas || isFetchingConfigs || isLoadingConfigs;
768
913
  React.useEffect(() => {
769
914
  if (error) {
770
915
  toggleNotification({
@@ -772,68 +917,322 @@ const useDocument = (args, opts) => {
772
917
  message: formatAPIError(error)
773
918
  });
774
919
  }
775
- }, [toggleNotification, error, formatAPIError, args.collectionType]);
776
- const validationSchema = React.useMemo(() => {
777
- if (!schema) {
778
- return null;
779
- }
780
- return createYupSchema(schema.attributes, components);
781
- }, [schema, components]);
782
- const validate = React.useCallback(
783
- (document) => {
784
- if (!validationSchema) {
785
- throw new Error(
786
- "There is no validation schema generated, this is likely due to the schema not being loaded yet."
787
- );
788
- }
789
- try {
790
- validationSchema.validateSync(document, { abortEarly: false, strict: true });
791
- return null;
792
- } catch (error2) {
793
- if (error2 instanceof ValidationError) {
794
- return getYupValidationErrors(error2);
795
- }
796
- throw error2;
797
- }
920
+ }, [error, formatAPIError, toggleNotification]);
921
+ const editLayout = React.useMemo(
922
+ () => data && !isLoading ? formatEditLayout(data, { schemas, schema, components }) : {
923
+ layout: [],
924
+ components: {},
925
+ metadatas: {},
926
+ options: {},
927
+ settings: DEFAULT_SETTINGS
798
928
  },
799
- [validationSchema]
929
+ [data, isLoading, schemas, schema, components]
930
+ );
931
+ const listLayout = React.useMemo(() => {
932
+ return data && !isLoading ? formatListLayout(data, { schemas, schema, components }) : {
933
+ layout: [],
934
+ metadatas: {},
935
+ options: {},
936
+ settings: DEFAULT_SETTINGS
937
+ };
938
+ }, [data, isLoading, schemas, schema, components]);
939
+ const { layout: edit } = React.useMemo(
940
+ () => runHookWaterfall(HOOKS.MUTATE_EDIT_VIEW_LAYOUT, {
941
+ layout: editLayout,
942
+ query
943
+ }),
944
+ [editLayout, query, runHookWaterfall]
800
945
  );
801
- const isLoading = isLoadingDocument || isFetchingDocument || isLoadingSchema;
802
946
  return {
803
- components,
804
- document: data?.data,
805
- meta: data?.meta,
947
+ error,
806
948
  isLoading,
807
- schema,
808
- validate
949
+ edit,
950
+ list: listLayout
809
951
  };
810
952
  };
811
- const useDoc = () => {
812
- const { id, slug, collectionType, origin } = useParams();
813
- const [{ query }] = useQueryParams();
814
- const params = React.useMemo(() => buildValidParams(query), [query]);
815
- if (!collectionType) {
816
- throw new Error("Could not find collectionType in url params");
817
- }
818
- if (!slug) {
953
+ const useDocLayout = () => {
954
+ const { model } = useDoc();
955
+ return useDocumentLayout(model);
956
+ };
957
+ const formatEditLayout = (data, {
958
+ schemas,
959
+ schema,
960
+ components
961
+ }) => {
962
+ let currentPanelIndex = 0;
963
+ const panelledEditAttributes = convertEditLayoutToFieldLayouts(
964
+ data.contentType.layouts.edit,
965
+ schema?.attributes,
966
+ data.contentType.metadatas,
967
+ { configurations: data.components, schemas: components },
968
+ schemas
969
+ ).reduce((panels, row) => {
970
+ if (row.some((field) => field.type === "dynamiczone")) {
971
+ panels.push([row]);
972
+ currentPanelIndex += 2;
973
+ } else {
974
+ if (!panels[currentPanelIndex]) {
975
+ panels.push([row]);
976
+ } else {
977
+ panels[currentPanelIndex].push(row);
978
+ }
979
+ }
980
+ return panels;
981
+ }, []);
982
+ const componentEditAttributes = Object.entries(data.components).reduce(
983
+ (acc, [uid, configuration]) => {
984
+ acc[uid] = {
985
+ layout: convertEditLayoutToFieldLayouts(
986
+ configuration.layouts.edit,
987
+ components[uid].attributes,
988
+ configuration.metadatas,
989
+ { configurations: data.components, schemas: components }
990
+ ),
991
+ settings: {
992
+ ...configuration.settings,
993
+ icon: components[uid].info.icon,
994
+ displayName: components[uid].info.displayName
995
+ }
996
+ };
997
+ return acc;
998
+ },
999
+ {}
1000
+ );
1001
+ const editMetadatas = Object.entries(data.contentType.metadatas).reduce(
1002
+ (acc, [attribute, metadata]) => {
1003
+ return {
1004
+ ...acc,
1005
+ [attribute]: metadata.edit
1006
+ };
1007
+ },
1008
+ {}
1009
+ );
1010
+ return {
1011
+ layout: panelledEditAttributes,
1012
+ components: componentEditAttributes,
1013
+ metadatas: editMetadatas,
1014
+ settings: {
1015
+ ...data.contentType.settings,
1016
+ displayName: schema?.info.displayName
1017
+ },
1018
+ options: {
1019
+ ...schema?.options,
1020
+ ...schema?.pluginOptions,
1021
+ ...data.contentType.options
1022
+ }
1023
+ };
1024
+ };
1025
+ const convertEditLayoutToFieldLayouts = (rows, attributes = {}, metadatas, components, schemas = []) => {
1026
+ return rows.map(
1027
+ (row) => row.map((field) => {
1028
+ const attribute = attributes[field.name];
1029
+ if (!attribute) {
1030
+ return null;
1031
+ }
1032
+ const { edit: metadata } = metadatas[field.name];
1033
+ const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
1034
+ return {
1035
+ attribute,
1036
+ disabled: !metadata.editable,
1037
+ hint: metadata.description,
1038
+ label: metadata.label ?? "",
1039
+ name: field.name,
1040
+ // @ts-expect-error – mainField does exist on the metadata for a relation.
1041
+ mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
1042
+ schemas,
1043
+ components: components?.schemas ?? {}
1044
+ }),
1045
+ placeholder: metadata.placeholder ?? "",
1046
+ required: attribute.required ?? false,
1047
+ size: field.size,
1048
+ unique: "unique" in attribute ? attribute.unique : false,
1049
+ visible: metadata.visible ?? true,
1050
+ type: attribute.type
1051
+ };
1052
+ }).filter((field) => field !== null)
1053
+ );
1054
+ };
1055
+ const formatListLayout = (data, {
1056
+ schemas,
1057
+ schema,
1058
+ components
1059
+ }) => {
1060
+ const listMetadatas = Object.entries(data.contentType.metadatas).reduce(
1061
+ (acc, [attribute, metadata]) => {
1062
+ return {
1063
+ ...acc,
1064
+ [attribute]: metadata.list
1065
+ };
1066
+ },
1067
+ {}
1068
+ );
1069
+ const listAttributes = convertListLayoutToFieldLayouts(
1070
+ data.contentType.layouts.list,
1071
+ schema?.attributes,
1072
+ listMetadatas,
1073
+ { configurations: data.components, schemas: components },
1074
+ schemas
1075
+ );
1076
+ return {
1077
+ layout: listAttributes,
1078
+ settings: { ...data.contentType.settings, displayName: schema?.info.displayName },
1079
+ metadatas: listMetadatas,
1080
+ options: {
1081
+ ...schema?.options,
1082
+ ...schema?.pluginOptions,
1083
+ ...data.contentType.options
1084
+ }
1085
+ };
1086
+ };
1087
+ const convertListLayoutToFieldLayouts = (columns, attributes = {}, metadatas, components, schemas = []) => {
1088
+ return columns.map((name) => {
1089
+ const attribute = attributes[name];
1090
+ if (!attribute) {
1091
+ return null;
1092
+ }
1093
+ const metadata = metadatas[name];
1094
+ const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
1095
+ return {
1096
+ attribute,
1097
+ label: metadata.label ?? "",
1098
+ mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
1099
+ schemas,
1100
+ components: components?.schemas ?? {}
1101
+ }),
1102
+ name,
1103
+ searchable: metadata.searchable ?? true,
1104
+ sortable: metadata.sortable ?? true
1105
+ };
1106
+ }).filter((field) => field !== null);
1107
+ };
1108
+ const useDocument = (args, opts) => {
1109
+ const { toggleNotification } = useNotification();
1110
+ const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();
1111
+ const {
1112
+ currentData: data,
1113
+ isLoading: isLoadingDocument,
1114
+ isFetching: isFetchingDocument,
1115
+ error
1116
+ } = useGetDocumentQuery(args, {
1117
+ ...opts,
1118
+ skip: !args.documentId && args.collectionType !== SINGLE_TYPES || opts?.skip
1119
+ });
1120
+ const {
1121
+ components,
1122
+ schema,
1123
+ schemas,
1124
+ isLoading: isLoadingSchema
1125
+ } = useContentTypeSchema(args.model);
1126
+ React.useEffect(() => {
1127
+ if (error) {
1128
+ toggleNotification({
1129
+ type: "danger",
1130
+ message: formatAPIError(error)
1131
+ });
1132
+ }
1133
+ }, [toggleNotification, error, formatAPIError, args.collectionType]);
1134
+ const validationSchema = React.useMemo(() => {
1135
+ if (!schema) {
1136
+ return null;
1137
+ }
1138
+ return createYupSchema(schema.attributes, components);
1139
+ }, [schema, components]);
1140
+ const validate = React.useCallback(
1141
+ (document) => {
1142
+ if (!validationSchema) {
1143
+ throw new Error(
1144
+ "There is no validation schema generated, this is likely due to the schema not being loaded yet."
1145
+ );
1146
+ }
1147
+ try {
1148
+ validationSchema.validateSync(document, { abortEarly: false, strict: true });
1149
+ return null;
1150
+ } catch (error2) {
1151
+ if (error2 instanceof ValidationError) {
1152
+ return getYupValidationErrors(error2);
1153
+ }
1154
+ throw error2;
1155
+ }
1156
+ },
1157
+ [validationSchema]
1158
+ );
1159
+ const isLoading = isLoadingDocument || isFetchingDocument || isLoadingSchema;
1160
+ const hasError = !!error;
1161
+ return {
1162
+ components,
1163
+ document: data?.data,
1164
+ meta: data?.meta,
1165
+ isLoading,
1166
+ hasError,
1167
+ schema,
1168
+ schemas,
1169
+ validate
1170
+ };
1171
+ };
1172
+ const useDoc = () => {
1173
+ const { id, slug, collectionType, origin } = useParams();
1174
+ const [{ query }] = useQueryParams();
1175
+ const params = React.useMemo(() => buildValidParams(query), [query]);
1176
+ if (!collectionType) {
1177
+ throw new Error("Could not find collectionType in url params");
1178
+ }
1179
+ if (!slug) {
819
1180
  throw new Error("Could not find model in url params");
820
1181
  }
1182
+ const document = useDocument(
1183
+ { documentId: origin || id, model: slug, collectionType, params },
1184
+ {
1185
+ skip: id === "create" || !origin && !id && collectionType !== SINGLE_TYPES
1186
+ }
1187
+ );
1188
+ const returnId = origin || id === "create" ? void 0 : id;
821
1189
  return {
822
1190
  collectionType,
823
1191
  model: slug,
824
- id: origin || id === "create" ? void 0 : id,
825
- ...useDocument(
826
- { documentId: origin || id, model: slug, collectionType, params },
827
- {
828
- skip: id === "create" || !origin && !id && collectionType !== SINGLE_TYPES
829
- }
830
- )
1192
+ id: returnId,
1193
+ ...document
1194
+ };
1195
+ };
1196
+ const useContentManagerContext = () => {
1197
+ const {
1198
+ collectionType,
1199
+ model,
1200
+ id,
1201
+ components,
1202
+ isLoading: isLoadingDoc,
1203
+ schema,
1204
+ schemas
1205
+ } = useDoc();
1206
+ const layout = useDocumentLayout(model);
1207
+ const form = useForm("useContentManagerContext", (state) => state);
1208
+ const isSingleType = collectionType === SINGLE_TYPES;
1209
+ const slug = model;
1210
+ const isCreatingEntry = id === "create";
1211
+ useContentTypeSchema();
1212
+ const isLoading = isLoadingDoc || layout.isLoading;
1213
+ const error = layout.error;
1214
+ return {
1215
+ error,
1216
+ isLoading,
1217
+ // Base metadata
1218
+ model,
1219
+ collectionType,
1220
+ id,
1221
+ slug,
1222
+ isCreatingEntry,
1223
+ isSingleType,
1224
+ hasDraftAndPublish: schema?.options?.draftAndPublish ?? false,
1225
+ // All schema infos
1226
+ components,
1227
+ contentType: schema,
1228
+ contentTypes: schemas,
1229
+ // Form state
1230
+ form,
1231
+ // layout infos
1232
+ layout
831
1233
  };
832
1234
  };
833
1235
  const prefixPluginTranslations = (trad, pluginId) => {
834
- if (!pluginId) {
835
- throw new TypeError("pluginId can't be empty");
836
- }
837
1236
  return Object.keys(trad).reduce((acc, current) => {
838
1237
  acc[`${pluginId}.${current}`] = trad[current];
839
1238
  return acc;
@@ -849,6 +1248,8 @@ const useDocumentActions = () => {
849
1248
  const { formatMessage } = useIntl();
850
1249
  const { trackUsage } = useTracking();
851
1250
  const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();
1251
+ const navigate = useNavigate();
1252
+ const setCurrentStep = useGuidedTour("useDocumentActions", (state) => state.setCurrentStep);
852
1253
  const [deleteDocument] = useDeleteDocumentMutation();
853
1254
  const _delete = React.useCallback(
854
1255
  async ({ collectionType, model, documentId, params }, trackerProperty) => {
@@ -927,12 +1328,13 @@ const useDocumentActions = () => {
927
1328
  );
928
1329
  const [discardDocument] = useDiscardDocumentMutation();
929
1330
  const discard = React.useCallback(
930
- async ({ collectionType, model, documentId }) => {
1331
+ async ({ collectionType, model, documentId, params }) => {
931
1332
  try {
932
1333
  const res = await discardDocument({
933
1334
  collectionType,
934
1335
  model,
935
- documentId
1336
+ documentId,
1337
+ params
936
1338
  });
937
1339
  if ("error" in res) {
938
1340
  toggleNotification({
@@ -1162,6 +1564,7 @@ const useDocumentActions = () => {
1162
1564
  defaultMessage: "Saved document"
1163
1565
  })
1164
1566
  });
1567
+ setCurrentStep("contentManager.success");
1165
1568
  return res.data;
1166
1569
  } catch (err) {
1167
1570
  toggleNotification({
@@ -1183,7 +1586,6 @@ const useDocumentActions = () => {
1183
1586
  sourceId
1184
1587
  });
1185
1588
  if ("error" in res) {
1186
- toggleNotification({ type: "danger", message: formatAPIError(res.error) });
1187
1589
  return { error: res.error };
1188
1590
  }
1189
1591
  toggleNotification({
@@ -1202,7 +1604,7 @@ const useDocumentActions = () => {
1202
1604
  throw err;
1203
1605
  }
1204
1606
  },
1205
- [autoCloneDocument, formatAPIError, formatMessage, toggleNotification]
1607
+ [autoCloneDocument, formatMessage, toggleNotification]
1206
1608
  );
1207
1609
  const [cloneDocument] = useCloneDocumentMutation();
1208
1610
  const clone = React.useCallback(
@@ -1228,6 +1630,7 @@ const useDocumentActions = () => {
1228
1630
  defaultMessage: "Cloned document"
1229
1631
  })
1230
1632
  });
1633
+ navigate(`../../${res.data.data.documentId}`, { relative: "path" });
1231
1634
  return res.data;
1232
1635
  } catch (err) {
1233
1636
  toggleNotification({
@@ -1238,7 +1641,7 @@ const useDocumentActions = () => {
1238
1641
  throw err;
1239
1642
  }
1240
1643
  },
1241
- [cloneDocument, trackUsage, toggleNotification, formatMessage, formatAPIError]
1644
+ [cloneDocument, trackUsage, toggleNotification, formatMessage, formatAPIError, navigate]
1242
1645
  );
1243
1646
  const [getDoc] = useLazyGetDocumentQuery();
1244
1647
  const getDocument = React.useCallback(
@@ -1263,10 +1666,10 @@ const useDocumentActions = () => {
1263
1666
  update
1264
1667
  };
1265
1668
  };
1266
- const ProtectedHistoryPage = lazy(
1267
- () => import("./History-BZP8n7KT.mjs").then((mod) => ({ default: mod.ProtectedHistoryPage }))
1669
+ const ProtectedHistoryPage = React.lazy(
1670
+ () => import("./History-CIQHyi4T.mjs").then((mod) => ({ default: mod.ProtectedHistoryPage }))
1268
1671
  );
1269
- const routes$1 = [
1672
+ const routes$2 = [
1270
1673
  {
1271
1674
  path: ":collectionType/:slug/:id/history",
1272
1675
  Component: ProtectedHistoryPage
@@ -1276,32 +1679,45 @@ const routes$1 = [
1276
1679
  Component: ProtectedHistoryPage
1277
1680
  }
1278
1681
  ];
1682
+ const ProtectedPreviewPage = React.lazy(
1683
+ () => import("./Preview-BVFFm7uB.mjs").then((mod) => ({ default: mod.ProtectedPreviewPage }))
1684
+ );
1685
+ const routes$1 = [
1686
+ {
1687
+ path: ":collectionType/:slug/:id/preview",
1688
+ Component: ProtectedPreviewPage
1689
+ },
1690
+ {
1691
+ path: ":collectionType/:slug/preview",
1692
+ Component: ProtectedPreviewPage
1693
+ }
1694
+ ];
1279
1695
  const ProtectedEditViewPage = lazy(
1280
- () => import("./EditViewPage-DvaV7U9b.mjs").then((mod) => ({ default: mod.ProtectedEditViewPage }))
1696
+ () => import("./EditViewPage-CD_hqc1J.mjs").then((mod) => ({ default: mod.ProtectedEditViewPage }))
1281
1697
  );
1282
1698
  const ProtectedListViewPage = lazy(
1283
- () => import("./ListViewPage-D5D3tVPq.mjs").then((mod) => ({ default: mod.ProtectedListViewPage }))
1699
+ () => import("./ListViewPage-C10McTK1.mjs").then((mod) => ({ default: mod.ProtectedListViewPage }))
1284
1700
  );
1285
1701
  const ProtectedListConfiguration = lazy(
1286
- () => import("./ListConfigurationPage-DxKuVkKz.mjs").then((mod) => ({
1702
+ () => import("./ListConfigurationPage-DcZsfyEL.mjs").then((mod) => ({
1287
1703
  default: mod.ProtectedListConfiguration
1288
1704
  }))
1289
1705
  );
1290
1706
  const ProtectedEditConfigurationPage = lazy(
1291
- () => import("./EditConfigurationPage-DmCIb4kD.mjs").then((mod) => ({
1707
+ () => import("./EditConfigurationPage-BNjOAHNS.mjs").then((mod) => ({
1292
1708
  default: mod.ProtectedEditConfigurationPage
1293
1709
  }))
1294
1710
  );
1295
1711
  const ProtectedComponentConfigurationPage = lazy(
1296
- () => import("./ComponentConfigurationPage-CR5XdR33.mjs").then((mod) => ({
1712
+ () => import("./ComponentConfigurationPage-BgCLcjXO.mjs").then((mod) => ({
1297
1713
  default: mod.ProtectedComponentConfigurationPage
1298
1714
  }))
1299
1715
  );
1300
1716
  const NoPermissions = lazy(
1301
- () => import("./NoPermissionsPage-OyoME_Tf.mjs").then((mod) => ({ default: mod.NoPermissions }))
1717
+ () => import("./NoPermissionsPage-wfPBh2_0.mjs").then((mod) => ({ default: mod.NoPermissions }))
1302
1718
  );
1303
1719
  const NoContentType = lazy(
1304
- () => import("./NoContentTypePage-DnMeuQCj.mjs").then((mod) => ({ default: mod.NoContentType }))
1720
+ () => import("./NoContentTypePage-CPc0Cd3S.mjs").then((mod) => ({ default: mod.NoContentType }))
1305
1721
  );
1306
1722
  const CollectionTypePages = () => {
1307
1723
  const { collectionType } = useParams();
@@ -1313,7 +1729,7 @@ const CollectionTypePages = () => {
1313
1729
  const CLONE_RELATIVE_PATH = ":collectionType/:slug/clone/:origin";
1314
1730
  const CLONE_PATH = `/content-manager/${CLONE_RELATIVE_PATH}`;
1315
1731
  const LIST_RELATIVE_PATH = ":collectionType/:slug";
1316
- const LIST_PATH = `/content-manager/${LIST_RELATIVE_PATH}`;
1732
+ const LIST_PATH = `/content-manager/collection-types/:slug`;
1317
1733
  const routes = [
1318
1734
  {
1319
1735
  path: LIST_RELATIVE_PATH,
@@ -1347,6 +1763,7 @@ const routes = [
1347
1763
  path: "no-content-types",
1348
1764
  Component: NoContentType
1349
1765
  },
1766
+ ...routes$2,
1350
1767
  ...routes$1
1351
1768
  ];
1352
1769
  const DocumentActions = ({ actions: actions2 }) => {
@@ -1415,12 +1832,14 @@ const DocumentActionButton = (action) => {
1415
1832
  /* @__PURE__ */ jsx(
1416
1833
  Button,
1417
1834
  {
1418
- flex: 1,
1835
+ flex: "auto",
1419
1836
  startIcon: action.icon,
1420
1837
  disabled: action.disabled,
1421
1838
  onClick: handleClick(action),
1422
1839
  justifyContent: "center",
1423
1840
  variant: action.variant || "default",
1841
+ paddingTop: "7px",
1842
+ paddingBottom: "7px",
1424
1843
  children: action.label
1425
1844
  }
1426
1845
  ),
@@ -1428,7 +1847,7 @@ const DocumentActionButton = (action) => {
1428
1847
  DocumentActionConfirmDialog,
1429
1848
  {
1430
1849
  ...action.dialog,
1431
- variant: action.variant,
1850
+ variant: action.dialog?.variant ?? action.variant,
1432
1851
  isOpen: dialogId === action.id,
1433
1852
  onClose: handleClose
1434
1853
  }
@@ -1443,6 +1862,11 @@ const DocumentActionButton = (action) => {
1443
1862
  ) : null
1444
1863
  ] });
1445
1864
  };
1865
+ const MenuItem = styled(Menu.Item)`
1866
+ &:hover {
1867
+ background: ${({ theme, isVariantDanger, isDisabled }) => isVariantDanger && !isDisabled ? theme.colors.danger100 : "neutral"};
1868
+ }
1869
+ `;
1446
1870
  const DocumentActionsMenu = ({
1447
1871
  actions: actions2,
1448
1872
  children,
@@ -1485,9 +1909,9 @@ const DocumentActionsMenu = ({
1485
1909
  disabled: isDisabled,
1486
1910
  size: "S",
1487
1911
  endIcon: null,
1488
- paddingTop: "7px",
1489
- paddingLeft: "9px",
1490
- paddingRight: "9px",
1912
+ paddingTop: "4px",
1913
+ paddingLeft: "7px",
1914
+ paddingRight: "7px",
1491
1915
  variant,
1492
1916
  children: [
1493
1917
  /* @__PURE__ */ jsx(More, { "aria-hidden": true, focusable: false }),
@@ -1498,36 +1922,35 @@ const DocumentActionsMenu = ({
1498
1922
  ]
1499
1923
  }
1500
1924
  ),
1501
- /* @__PURE__ */ jsxs(Menu.Content, { top: "4px", maxHeight: void 0, popoverPlacement: "bottom-end", children: [
1925
+ /* @__PURE__ */ jsxs(Menu.Content, { maxHeight: void 0, popoverPlacement: "bottom-end", children: [
1502
1926
  actions2.map((action) => {
1503
1927
  return /* @__PURE__ */ jsx(
1504
- Menu.Item,
1928
+ MenuItem,
1505
1929
  {
1506
1930
  disabled: action.disabled,
1507
1931
  onSelect: handleClick(action),
1508
1932
  display: "block",
1509
- children: /* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", gap: 4, children: [
1510
- /* @__PURE__ */ jsxs(Flex, { color: convertActionVariantToColor(action.variant), gap: 2, tag: "span", children: [
1511
- action.icon,
1512
- action.label
1513
- ] }),
1514
- action.id.startsWith("HistoryAction") && /* @__PURE__ */ jsx(
1515
- Flex,
1516
- {
1517
- alignItems: "center",
1518
- background: "alternative100",
1519
- borderStyle: "solid",
1520
- borderColor: "alternative200",
1521
- borderWidth: "1px",
1522
- height: 5,
1523
- paddingLeft: 2,
1524
- paddingRight: 2,
1525
- hasRadius: true,
1526
- color: "alternative600",
1527
- children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", fontWeight: "bold", lineHeight: 1, children: formatMessage({ id: "global.new", defaultMessage: "New" }) })
1528
- }
1529
- )
1530
- ] })
1933
+ isVariantDanger: action.variant === "danger",
1934
+ isDisabled: action.disabled,
1935
+ children: /* @__PURE__ */ jsx(Flex, { justifyContent: "space-between", gap: 4, children: /* @__PURE__ */ jsxs(
1936
+ Flex,
1937
+ {
1938
+ color: !action.disabled ? convertActionVariantToColor(action.variant) : "inherit",
1939
+ gap: 2,
1940
+ tag: "span",
1941
+ children: [
1942
+ /* @__PURE__ */ jsx(
1943
+ Flex,
1944
+ {
1945
+ tag: "span",
1946
+ color: !action.disabled ? convertActionVariantToIconColor(action.variant) : "inherit",
1947
+ children: action.icon
1948
+ }
1949
+ ),
1950
+ action.label
1951
+ ]
1952
+ }
1953
+ ) })
1531
1954
  },
1532
1955
  action.id
1533
1956
  );
@@ -1569,6 +1992,18 @@ const convertActionVariantToColor = (variant = "secondary") => {
1569
1992
  return "primary600";
1570
1993
  }
1571
1994
  };
1995
+ const convertActionVariantToIconColor = (variant = "secondary") => {
1996
+ switch (variant) {
1997
+ case "danger":
1998
+ return "danger600";
1999
+ case "secondary":
2000
+ return "neutral500";
2001
+ case "success":
2002
+ return "success600";
2003
+ default:
2004
+ return "primary600";
2005
+ }
2006
+ };
1572
2007
  const DocumentActionConfirmDialog = ({
1573
2008
  onClose,
1574
2009
  onCancel,
@@ -1591,22 +2026,20 @@ const DocumentActionConfirmDialog = ({
1591
2026
  }
1592
2027
  onClose();
1593
2028
  };
1594
- return /* @__PURE__ */ jsxs(Dialog, { isOpen, title, onClose: handleClose, children: [
1595
- /* @__PURE__ */ jsx(DialogBody, { children: content }),
1596
- /* @__PURE__ */ jsx(
1597
- DialogFooter,
1598
- {
1599
- startAction: /* @__PURE__ */ jsx(Button, { onClick: handleClose, variant: "tertiary", children: formatMessage({
1600
- id: "app.components.Button.cancel",
1601
- defaultMessage: "Cancel"
1602
- }) }),
1603
- endAction: /* @__PURE__ */ jsx(Button, { onClick: handleConfirm, variant, children: formatMessage({
1604
- id: "app.components.Button.confirm",
1605
- defaultMessage: "Confirm"
1606
- }) })
1607
- }
1608
- )
1609
- ] });
2029
+ return /* @__PURE__ */ jsx(Dialog.Root, { open: isOpen, onOpenChange: handleClose, children: /* @__PURE__ */ jsxs(Dialog.Content, { children: [
2030
+ /* @__PURE__ */ jsx(Dialog.Header, { children: title }),
2031
+ /* @__PURE__ */ jsx(Dialog.Body, { children: content }),
2032
+ /* @__PURE__ */ jsxs(Dialog.Footer, { children: [
2033
+ /* @__PURE__ */ jsx(Dialog.Cancel, { children: /* @__PURE__ */ jsx(Button, { variant: "tertiary", fullWidth: true, children: formatMessage({
2034
+ id: "app.components.Button.cancel",
2035
+ defaultMessage: "Cancel"
2036
+ }) }) }),
2037
+ /* @__PURE__ */ jsx(Button, { onClick: handleConfirm, variant, fullWidth: true, children: formatMessage({
2038
+ id: "app.components.Button.confirm",
2039
+ defaultMessage: "Confirm"
2040
+ }) })
2041
+ ] })
2042
+ ] }) });
1610
2043
  };
1611
2044
  const DocumentActionModal = ({
1612
2045
  isOpen,
@@ -1616,34 +2049,29 @@ const DocumentActionModal = ({
1616
2049
  content: Content,
1617
2050
  onModalClose
1618
2051
  }) => {
1619
- const id = React.useId();
1620
- if (!isOpen) {
1621
- return null;
1622
- }
1623
2052
  const handleClose = () => {
1624
2053
  if (onClose) {
1625
2054
  onClose();
1626
2055
  }
1627
2056
  onModalClose();
1628
2057
  };
1629
- return /* @__PURE__ */ jsxs(ModalLayout, { borderRadius: "4px", overflow: "hidden", onClose: handleClose, labelledBy: id, children: [
1630
- /* @__PURE__ */ jsx(ModalHeader, { children: /* @__PURE__ */ jsx(Typography, { fontWeight: "bold", textColor: "neutral800", tag: "h2", id, children: title }) }),
1631
- /* @__PURE__ */ jsx(ModalBody, { children: typeof Content === "function" ? /* @__PURE__ */ jsx(Content, { onClose: handleClose }) : Content }),
1632
- /* @__PURE__ */ jsx(
1633
- Box,
1634
- {
1635
- paddingTop: 4,
1636
- paddingBottom: 4,
1637
- paddingLeft: 5,
1638
- paddingRight: 5,
1639
- borderWidth: "1px 0 0 0",
1640
- borderStyle: "solid",
1641
- borderColor: "neutral150",
1642
- background: "neutral100",
1643
- children: typeof Footer === "function" ? /* @__PURE__ */ jsx(Footer, { onClose: handleClose }) : Footer
1644
- }
1645
- )
1646
- ] });
2058
+ return /* @__PURE__ */ jsx(Modal.Root, { open: isOpen, onOpenChange: handleClose, children: /* @__PURE__ */ jsxs(Modal.Content, { children: [
2059
+ /* @__PURE__ */ jsx(Modal.Header, { children: /* @__PURE__ */ jsx(Modal.Title, { children: title }) }),
2060
+ typeof Content === "function" ? /* @__PURE__ */ jsx(Content, { onClose: handleClose }) : /* @__PURE__ */ jsx(Modal.Body, { children: Content }),
2061
+ typeof Footer === "function" ? /* @__PURE__ */ jsx(Footer, { onClose: handleClose }) : Footer
2062
+ ] }) });
2063
+ };
2064
+ const transformData = (data) => {
2065
+ if (Array.isArray(data)) {
2066
+ return data.map(transformData);
2067
+ }
2068
+ if (typeof data === "object" && data !== null) {
2069
+ if ("apiData" in data) {
2070
+ return data.apiData;
2071
+ }
2072
+ return mapValues(transformData)(data);
2073
+ }
2074
+ return data;
1647
2075
  };
1648
2076
  const PublishAction$1 = ({
1649
2077
  activeTab,
@@ -1657,13 +2085,18 @@ const PublishAction$1 = ({
1657
2085
  const navigate = useNavigate();
1658
2086
  const { toggleNotification } = useNotification();
1659
2087
  const { _unstableFormatValidationErrors: formatValidationErrors } = useAPIErrorHandler();
2088
+ const isListView = useMatch(LIST_PATH) !== null;
1660
2089
  const isCloning = useMatch(CLONE_PATH) !== null;
2090
+ const { id } = useParams();
1661
2091
  const { formatMessage } = useIntl();
1662
- const { canPublish, canCreate, canUpdate } = useDocumentRBAC(
1663
- "PublishAction",
1664
- ({ canPublish: canPublish2, canCreate: canCreate2, canUpdate: canUpdate2 }) => ({ canPublish: canPublish2, canCreate: canCreate2, canUpdate: canUpdate2 })
1665
- );
2092
+ const canPublish = useDocumentRBAC("PublishAction", ({ canPublish: canPublish2 }) => canPublish2);
1666
2093
  const { publish } = useDocumentActions();
2094
+ const [
2095
+ countDraftRelations,
2096
+ { isLoading: isLoadingDraftRelations, isError: isErrorDraftRelations }
2097
+ ] = useLazyGetDraftRelationCountQuery();
2098
+ const [localCountOfDraftRelations, setLocalCountOfDraftRelations] = React.useState(0);
2099
+ const [serverCountOfDraftRelations, setServerCountOfDraftRelations] = React.useState(0);
1667
2100
  const [{ query, rawQuery }] = useQueryParams();
1668
2101
  const params = React.useMemo(() => buildValidParams(query), [query]);
1669
2102
  const modified = useForm("PublishAction", ({ modified: modified2 }) => modified2);
@@ -1672,10 +2105,107 @@ const PublishAction$1 = ({
1672
2105
  const validate = useForm("PublishAction", (state) => state.validate);
1673
2106
  const setErrors = useForm("PublishAction", (state) => state.setErrors);
1674
2107
  const formValues = useForm("PublishAction", ({ values }) => values);
2108
+ React.useEffect(() => {
2109
+ if (isErrorDraftRelations) {
2110
+ toggleNotification({
2111
+ type: "danger",
2112
+ message: formatMessage({
2113
+ id: getTranslation("error.records.fetch-draft-relatons"),
2114
+ defaultMessage: "An error occurred while fetching draft relations on this document."
2115
+ })
2116
+ });
2117
+ }
2118
+ }, [isErrorDraftRelations, toggleNotification, formatMessage]);
2119
+ React.useEffect(() => {
2120
+ const localDraftRelations = /* @__PURE__ */ new Set();
2121
+ const extractDraftRelations = (data) => {
2122
+ const relations = data.connect || [];
2123
+ relations.forEach((relation) => {
2124
+ if (relation.status === "draft") {
2125
+ localDraftRelations.add(relation.id);
2126
+ }
2127
+ });
2128
+ };
2129
+ const traverseAndExtract = (data) => {
2130
+ Object.entries(data).forEach(([key, value]) => {
2131
+ if (key === "connect" && Array.isArray(value)) {
2132
+ extractDraftRelations({ connect: value });
2133
+ } else if (typeof value === "object" && value !== null) {
2134
+ traverseAndExtract(value);
2135
+ }
2136
+ });
2137
+ };
2138
+ if (!documentId || modified) {
2139
+ traverseAndExtract(formValues);
2140
+ setLocalCountOfDraftRelations(localDraftRelations.size);
2141
+ }
2142
+ }, [documentId, modified, formValues, setLocalCountOfDraftRelations]);
2143
+ React.useEffect(() => {
2144
+ if (!document || !document.documentId || isListView) {
2145
+ return;
2146
+ }
2147
+ const fetchDraftRelationsCount = async () => {
2148
+ const { data, error } = await countDraftRelations({
2149
+ collectionType,
2150
+ model,
2151
+ documentId,
2152
+ params
2153
+ });
2154
+ if (error) {
2155
+ throw error;
2156
+ }
2157
+ if (data) {
2158
+ setServerCountOfDraftRelations(data.data);
2159
+ }
2160
+ };
2161
+ fetchDraftRelationsCount();
2162
+ }, [isListView, document, documentId, countDraftRelations, collectionType, model, params]);
1675
2163
  const isDocumentPublished = (document?.[PUBLISHED_AT_ATTRIBUTE_NAME] || meta?.availableStatus.some((doc) => doc[PUBLISHED_AT_ATTRIBUTE_NAME] !== null)) && document?.status !== "modified";
1676
2164
  if (!schema?.options?.draftAndPublish) {
1677
2165
  return null;
1678
2166
  }
2167
+ const performPublish = async () => {
2168
+ setSubmitting(true);
2169
+ try {
2170
+ const { errors } = await validate(true, {
2171
+ status: "published"
2172
+ });
2173
+ if (errors) {
2174
+ toggleNotification({
2175
+ type: "danger",
2176
+ message: formatMessage({
2177
+ id: "content-manager.validation.error",
2178
+ defaultMessage: "There are validation errors in your document. Please fix them before saving."
2179
+ })
2180
+ });
2181
+ return;
2182
+ }
2183
+ const res = await publish(
2184
+ {
2185
+ collectionType,
2186
+ model,
2187
+ documentId,
2188
+ params
2189
+ },
2190
+ transformData(formValues)
2191
+ );
2192
+ if ("data" in res && collectionType !== SINGLE_TYPES) {
2193
+ if (id === "create") {
2194
+ navigate({
2195
+ pathname: `../${collectionType}/${model}/${res.data.documentId}`,
2196
+ search: rawQuery
2197
+ });
2198
+ }
2199
+ } else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
2200
+ setErrors(formatValidationErrors(res.error));
2201
+ }
2202
+ } finally {
2203
+ setSubmitting(false);
2204
+ }
2205
+ };
2206
+ const totalDraftRelations = localCountOfDraftRelations + serverCountOfDraftRelations;
2207
+ const enableDraftRelationsCount = false;
2208
+ const hasDraftRelations = enableDraftRelationsCount;
1679
2209
  return {
1680
2210
  /**
1681
2211
  * Disabled when:
@@ -1685,49 +2215,36 @@ const PublishAction$1 = ({
1685
2215
  * - the document is already published & not modified
1686
2216
  * - the document is being created & not modified
1687
2217
  * - the user doesn't have the permission to publish
1688
- * - the user doesn't have the permission to create a new document
1689
- * - the user doesn't have the permission to update the document
1690
2218
  */
1691
- disabled: isCloning || isSubmitting || activeTab === "published" || !modified && isDocumentPublished || !modified && !document?.documentId || !canPublish || Boolean(!document?.documentId && !canCreate || document?.documentId && !canUpdate),
2219
+ disabled: isCloning || isSubmitting || isLoadingDraftRelations || activeTab === "published" || !modified && isDocumentPublished || !modified && !document?.documentId || !canPublish,
1692
2220
  label: formatMessage({
1693
2221
  id: "app.utils.publish",
1694
2222
  defaultMessage: "Publish"
1695
2223
  }),
1696
2224
  onClick: async () => {
1697
- setSubmitting(true);
1698
- try {
1699
- const { errors } = await validate();
1700
- if (errors) {
1701
- toggleNotification({
1702
- type: "danger",
1703
- message: formatMessage({
1704
- id: "content-manager.validation.error",
1705
- defaultMessage: "There are validation errors in your document. Please fix them before saving."
1706
- })
1707
- });
1708
- return;
1709
- }
1710
- const res = await publish(
1711
- {
1712
- collectionType,
1713
- model,
1714
- documentId,
1715
- params
1716
- },
1717
- formValues
1718
- );
1719
- if ("data" in res && collectionType !== SINGLE_TYPES) {
1720
- navigate({
1721
- pathname: `../${collectionType}/${model}/${res.data.documentId}`,
1722
- search: rawQuery
1723
- });
1724
- } else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
1725
- setErrors(formatValidationErrors(res.error));
2225
+ await performPublish();
2226
+ },
2227
+ dialog: hasDraftRelations ? {
2228
+ type: "dialog",
2229
+ variant: "danger",
2230
+ footer: null,
2231
+ title: formatMessage({
2232
+ id: getTranslation(`popUpwarning.warning.bulk-has-draft-relations.title`),
2233
+ defaultMessage: "Confirmation"
2234
+ }),
2235
+ content: formatMessage(
2236
+ {
2237
+ id: getTranslation(`popUpwarning.warning.bulk-has-draft-relations.message`),
2238
+ defaultMessage: "This entry is related to {count, plural, one {# draft entry} other {# draft entries}}. Publishing it could leave broken links in your app."
2239
+ },
2240
+ {
2241
+ count: totalDraftRelations
1726
2242
  }
1727
- } finally {
1728
- setSubmitting(false);
2243
+ ),
2244
+ onConfirm: async () => {
2245
+ await performPublish();
1729
2246
  }
1730
- }
2247
+ } : void 0
1731
2248
  };
1732
2249
  };
1733
2250
  PublishAction$1.type = "publish";
@@ -1743,10 +2260,6 @@ const UpdateAction = ({
1743
2260
  const cloneMatch = useMatch(CLONE_PATH);
1744
2261
  const isCloning = cloneMatch !== null;
1745
2262
  const { formatMessage } = useIntl();
1746
- const { canCreate, canUpdate } = useDocumentRBAC("UpdateAction", ({ canCreate: canCreate2, canUpdate: canUpdate2 }) => ({
1747
- canCreate: canCreate2,
1748
- canUpdate: canUpdate2
1749
- }));
1750
2263
  const { create, update, clone } = useDocumentActions();
1751
2264
  const [{ query, rawQuery }] = useQueryParams();
1752
2265
  const params = React.useMemo(() => buildValidParams(query), [query]);
@@ -1763,18 +2276,18 @@ const UpdateAction = ({
1763
2276
  * - the form is submitting
1764
2277
  * - the document is not modified & we're not cloning (you can save a clone entity straight away)
1765
2278
  * - the active tab is the published tab
1766
- * - the user doesn't have the permission to create a new document
1767
- * - the user doesn't have the permission to update the document
1768
2279
  */
1769
- disabled: isSubmitting || !modified && !isCloning || activeTab === "published" || Boolean(!documentId && !canCreate || documentId && !canUpdate),
2280
+ disabled: isSubmitting || !modified && !isCloning || activeTab === "published",
1770
2281
  label: formatMessage({
1771
- id: "content-manager.containers.Edit.save",
2282
+ id: "global.save",
1772
2283
  defaultMessage: "Save"
1773
2284
  }),
1774
2285
  onClick: async () => {
1775
2286
  setSubmitting(true);
1776
2287
  try {
1777
- const { errors } = await validate();
2288
+ const { errors } = await validate(true, {
2289
+ status: "draft"
2290
+ });
1778
2291
  if (errors) {
1779
2292
  toggleNotification({
1780
2293
  type: "danger",
@@ -1792,13 +2305,16 @@ const UpdateAction = ({
1792
2305
  documentId: cloneMatch.params.origin,
1793
2306
  params
1794
2307
  },
1795
- document
2308
+ transformData(document)
1796
2309
  );
1797
2310
  if ("data" in res) {
1798
- navigate({
1799
- pathname: `../${collectionType}/${model}/${res.data.documentId}`,
1800
- search: rawQuery
1801
- });
2311
+ navigate(
2312
+ {
2313
+ pathname: `../${res.data.documentId}`,
2314
+ search: rawQuery
2315
+ },
2316
+ { relative: "path" }
2317
+ );
1802
2318
  } else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
1803
2319
  setErrors(formatValidationErrors(res.error));
1804
2320
  }
@@ -1810,7 +2326,7 @@ const UpdateAction = ({
1810
2326
  documentId,
1811
2327
  params
1812
2328
  },
1813
- document
2329
+ transformData(document)
1814
2330
  );
1815
2331
  if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
1816
2332
  setErrors(formatValidationErrors(res.error));
@@ -1823,13 +2339,16 @@ const UpdateAction = ({
1823
2339
  model,
1824
2340
  params
1825
2341
  },
1826
- document
2342
+ transformData(document)
1827
2343
  );
1828
2344
  if ("data" in res && collectionType !== SINGLE_TYPES) {
1829
- navigate({
1830
- pathname: `../${collectionType}/${model}/${res.data.documentId}`,
1831
- search: rawQuery
1832
- });
2345
+ navigate(
2346
+ {
2347
+ pathname: `../${res.data.documentId}`,
2348
+ search: rawQuery
2349
+ },
2350
+ { replace: true, relative: "path" }
2351
+ );
1833
2352
  } else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
1834
2353
  setErrors(formatValidationErrors(res.error));
1835
2354
  }
@@ -1861,10 +2380,8 @@ const UnpublishAction$1 = ({
1861
2380
  const { toggleNotification } = useNotification();
1862
2381
  const [shouldKeepDraft, setShouldKeepDraft] = React.useState(true);
1863
2382
  const isDocumentModified = document?.status === "modified";
1864
- const handleChange = (e) => {
1865
- if ("value" in e.target) {
1866
- setShouldKeepDraft(e.target.value === UNPUBLISH_DRAFT_OPTIONS.KEEP);
1867
- }
2383
+ const handleChange = (value) => {
2384
+ setShouldKeepDraft(value === UNPUBLISH_DRAFT_OPTIONS.KEEP);
1868
2385
  };
1869
2386
  if (!schema?.options?.draftAndPublish) {
1870
2387
  return null;
@@ -1875,7 +2392,7 @@ const UnpublishAction$1 = ({
1875
2392
  id: "app.utils.unpublish",
1876
2393
  defaultMessage: "Unpublish"
1877
2394
  }),
1878
- icon: /* @__PURE__ */ jsx(StyledCrossCircle, {}),
2395
+ icon: /* @__PURE__ */ jsx(Cross, {}),
1879
2396
  onClick: async () => {
1880
2397
  if (!documentId && collectionType !== SINGLE_TYPES || isDocumentModified) {
1881
2398
  if (!documentId) {
@@ -1914,40 +2431,24 @@ const UnpublishAction$1 = ({
1914
2431
  }) })
1915
2432
  ] }),
1916
2433
  /* @__PURE__ */ jsxs(
1917
- Flex,
2434
+ Radio.Group,
1918
2435
  {
1919
- onChange: handleChange,
1920
- direction: "column",
1921
- alignItems: "flex-start",
1922
- tag: "fieldset",
1923
- borderWidth: 0,
1924
- gap: 3,
2436
+ defaultValue: UNPUBLISH_DRAFT_OPTIONS.KEEP,
2437
+ name: "discard-options",
2438
+ "aria-label": formatMessage({
2439
+ id: "content-manager.actions.unpublish.dialog.radio-label",
2440
+ defaultMessage: "Choose an option to unpublish the document."
2441
+ }),
2442
+ onValueChange: handleChange,
1925
2443
  children: [
1926
- /* @__PURE__ */ jsx(VisuallyHidden, { tag: "legend" }),
1927
- /* @__PURE__ */ jsx(
1928
- Radio,
1929
- {
1930
- checked: shouldKeepDraft,
1931
- value: UNPUBLISH_DRAFT_OPTIONS.KEEP,
1932
- name: "discard-options",
1933
- children: formatMessage({
1934
- id: "content-manager.actions.unpublish.dialog.option.keep-draft",
1935
- defaultMessage: "Keep draft"
1936
- })
1937
- }
1938
- ),
1939
- /* @__PURE__ */ jsx(
1940
- Radio,
1941
- {
1942
- checked: !shouldKeepDraft,
1943
- value: UNPUBLISH_DRAFT_OPTIONS.DISCARD,
1944
- name: "discard-options",
1945
- children: formatMessage({
1946
- id: "content-manager.actions.unpublish.dialog.option.replace-draft",
1947
- defaultMessage: "Replace draft"
1948
- })
1949
- }
1950
- )
2444
+ /* @__PURE__ */ jsx(Radio.Item, { checked: shouldKeepDraft, value: UNPUBLISH_DRAFT_OPTIONS.KEEP, children: formatMessage({
2445
+ id: "content-manager.actions.unpublish.dialog.option.keep-draft",
2446
+ defaultMessage: "Keep draft"
2447
+ }) }),
2448
+ /* @__PURE__ */ jsx(Radio.Item, { checked: !shouldKeepDraft, value: UNPUBLISH_DRAFT_OPTIONS.DISCARD, children: formatMessage({
2449
+ id: "content-manager.actions.unpublish.dialog.option.replace-draft",
2450
+ defaultMessage: "Replace draft"
2451
+ }) })
1951
2452
  ]
1952
2453
  }
1953
2454
  )
@@ -2003,7 +2504,7 @@ const DiscardAction = ({
2003
2504
  id: "content-manager.actions.discard.label",
2004
2505
  defaultMessage: "Discard changes"
2005
2506
  }),
2006
- icon: /* @__PURE__ */ jsx(StyledCrossCircle, {}),
2507
+ icon: /* @__PURE__ */ jsx(Cross, {}),
2007
2508
  position: ["panel", "table-row"],
2008
2509
  variant: "danger",
2009
2510
  dialog: {
@@ -2031,11 +2532,6 @@ const DiscardAction = ({
2031
2532
  };
2032
2533
  };
2033
2534
  DiscardAction.type = "discard";
2034
- const StyledCrossCircle = styled(CrossCircle)`
2035
- path {
2036
- fill: currentColor;
2037
- }
2038
- `;
2039
2535
  const DEFAULT_ACTIONS = [PublishAction$1, UpdateAction, UnpublishAction$1, DiscardAction];
2040
2536
  const intervals = ["years", "months", "days", "hours", "minutes", "seconds"];
2041
2537
  const RelativeTime = React.forwardRef(
@@ -2048,7 +2544,7 @@ const RelativeTime = React.forwardRef(
2048
2544
  });
2049
2545
  const unit = intervals.find((intervalUnit) => {
2050
2546
  return interval[intervalUnit] > 0 && Object.keys(interval).includes(intervalUnit);
2051
- });
2547
+ }) ?? "seconds";
2052
2548
  const relativeTime = isPast(timestamp) ? -interval[unit] : interval[unit];
2053
2549
  const customInterval = customIntervals.find(
2054
2550
  (custom) => interval[custom.unit] < custom.threshold
@@ -2082,34 +2578,34 @@ const getDisplayName = ({
2082
2578
  return email ?? "";
2083
2579
  };
2084
2580
  const capitalise = (str) => str.charAt(0).toUpperCase() + str.slice(1);
2085
- const DocumentStatus = ({ status = "draft", ...restProps }) => {
2086
- const statusVariant = status === "draft" ? "primary" : status === "published" ? "success" : "alternative";
2087
- return /* @__PURE__ */ jsx(Status, { ...restProps, showBullet: false, size: "S", variant: statusVariant, children: /* @__PURE__ */ jsx(Typography, { tag: "span", variant: "omega", fontWeight: "bold", children: capitalise(status) }) });
2581
+ const DocumentStatus = ({ status = "draft", size = "S", ...restProps }) => {
2582
+ const statusVariant = status === "draft" ? "secondary" : status === "published" ? "success" : "alternative";
2583
+ const { formatMessage } = useIntl();
2584
+ return /* @__PURE__ */ jsx(Status, { ...restProps, size, variant: statusVariant, children: /* @__PURE__ */ jsx(Typography, { tag: "span", variant: "omega", fontWeight: "bold", children: formatMessage({
2585
+ id: `content-manager.containers.List.${status}`,
2586
+ defaultMessage: capitalise(status)
2587
+ }) }) });
2088
2588
  };
2089
2589
  const Header = ({ isCreating, status, title: documentTitle = "Untitled" }) => {
2090
2590
  const { formatMessage } = useIntl();
2091
2591
  const isCloning = useMatch(CLONE_PATH) !== null;
2592
+ const params = useParams();
2092
2593
  const title = isCreating ? formatMessage({
2093
2594
  id: "content-manager.containers.edit.title.new",
2094
2595
  defaultMessage: "Create an entry"
2095
2596
  }) : documentTitle;
2096
- return /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "flex-start", paddingTop: 8, paddingBottom: 4, gap: 3, children: [
2097
- /* @__PURE__ */ jsx(BackButton, {}),
2098
- /* @__PURE__ */ jsxs(
2099
- Flex,
2597
+ return /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "flex-start", paddingTop: 6, paddingBottom: 4, gap: 2, children: [
2598
+ /* @__PURE__ */ jsx(
2599
+ BackButton,
2100
2600
  {
2101
- width: "100%",
2102
- justifyContent: "space-between",
2103
- paddingTop: 1,
2104
- gap: "80px",
2105
- alignItems: "flex-start",
2106
- children: [
2107
- /* @__PURE__ */ jsx(Typography, { variant: "alpha", tag: "h1", children: title }),
2108
- /* @__PURE__ */ jsx(HeaderToolbar, {})
2109
- ]
2601
+ fallback: params.collectionType === SINGLE_TYPES ? void 0 : `../${COLLECTION_TYPES}/${params.slug}`
2110
2602
  }
2111
2603
  ),
2112
- status ? /* @__PURE__ */ jsx(DocumentStatus, { status: isCloning ? "draft" : status }) : null
2604
+ /* @__PURE__ */ jsxs(Flex, { width: "100%", justifyContent: "space-between", gap: "80px", alignItems: "flex-start", children: [
2605
+ /* @__PURE__ */ jsx(Typography, { variant: "alpha", tag: "h1", children: title }),
2606
+ /* @__PURE__ */ jsx(HeaderToolbar, {})
2607
+ ] }),
2608
+ status ? /* @__PURE__ */ jsx(Box, { marginTop: 1, children: /* @__PURE__ */ jsx(DocumentStatus, { status: isCloning ? "draft" : status }) }) : null
2113
2609
  ] });
2114
2610
  };
2115
2611
  const HeaderToolbar = () => {
@@ -2192,12 +2688,12 @@ const Information = ({ activeTab }) => {
2192
2688
  isDisplayed: !!publishDocument?.[PUBLISHED_AT_ATTRIBUTE_NAME],
2193
2689
  label: formatMessage({
2194
2690
  id: "content-manager.containers.edit.information.last-published.label",
2195
- defaultMessage: "Last published"
2691
+ defaultMessage: "Published"
2196
2692
  }),
2197
2693
  value: formatMessage(
2198
2694
  {
2199
2695
  id: "content-manager.containers.edit.information.last-published.value",
2200
- defaultMessage: `Published {time}{isAnonymous, select, true {} other { by {author}}}`
2696
+ defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
2201
2697
  },
2202
2698
  {
2203
2699
  time: /* @__PURE__ */ jsx(RelativeTime, { timestamp: new Date(publishDocument?.[PUBLISHED_AT_ATTRIBUTE_NAME]) }),
@@ -2210,12 +2706,12 @@ const Information = ({ activeTab }) => {
2210
2706
  isDisplayed: !!createAndUpdateDocument?.[UPDATED_AT_ATTRIBUTE_NAME],
2211
2707
  label: formatMessage({
2212
2708
  id: "content-manager.containers.edit.information.last-draft.label",
2213
- defaultMessage: "Last draft"
2709
+ defaultMessage: "Updated"
2214
2710
  }),
2215
2711
  value: formatMessage(
2216
2712
  {
2217
2713
  id: "content-manager.containers.edit.information.last-draft.value",
2218
- defaultMessage: `Modified {time}{isAnonymous, select, true {} other { by {author}}}`
2714
+ defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
2219
2715
  },
2220
2716
  {
2221
2717
  time: /* @__PURE__ */ jsx(
@@ -2233,12 +2729,12 @@ const Information = ({ activeTab }) => {
2233
2729
  isDisplayed: !!createAndUpdateDocument?.[CREATED_AT_ATTRIBUTE_NAME],
2234
2730
  label: formatMessage({
2235
2731
  id: "content-manager.containers.edit.information.document.label",
2236
- defaultMessage: "Document"
2732
+ defaultMessage: "Created"
2237
2733
  }),
2238
2734
  value: formatMessage(
2239
2735
  {
2240
2736
  id: "content-manager.containers.edit.information.document.value",
2241
- defaultMessage: `Created {time}{isAnonymous, select, true {} other { by {author}}}`
2737
+ defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
2242
2738
  },
2243
2739
  {
2244
2740
  time: /* @__PURE__ */ jsx(
@@ -2276,25 +2772,77 @@ const Information = ({ activeTab }) => {
2276
2772
  );
2277
2773
  };
2278
2774
  const HeaderActions = ({ actions: actions2 }) => {
2279
- return /* @__PURE__ */ jsx(Flex, { children: actions2.map((action) => {
2280
- if ("options" in action) {
2775
+ const [dialogId, setDialogId] = React.useState(null);
2776
+ const handleClick = (action) => async (e) => {
2777
+ if (!("options" in action)) {
2778
+ const { onClick = () => false, dialog, id } = action;
2779
+ const muteDialog = await onClick(e);
2780
+ if (dialog && !muteDialog) {
2781
+ e.preventDefault();
2782
+ setDialogId(id);
2783
+ }
2784
+ }
2785
+ };
2786
+ const handleClose = () => {
2787
+ setDialogId(null);
2788
+ };
2789
+ return /* @__PURE__ */ jsx(Flex, { gap: 1, children: actions2.map((action) => {
2790
+ if (action.options) {
2281
2791
  return /* @__PURE__ */ jsx(
2282
2792
  SingleSelect,
2283
2793
  {
2284
2794
  size: "S",
2285
- disabled: action.disabled,
2286
- "aria-label": action.label,
2287
2795
  onChange: action.onSelect,
2288
- value: action.value,
2796
+ "aria-label": action.label,
2797
+ ...action,
2289
2798
  children: action.options.map(({ label, ...option }) => /* @__PURE__ */ jsx(SingleSelectOption, { ...option, children: label }, option.value))
2290
2799
  },
2291
2800
  action.id
2292
2801
  );
2293
2802
  } else {
2294
- return null;
2803
+ if (action.type === "icon") {
2804
+ return /* @__PURE__ */ jsxs(React.Fragment, { children: [
2805
+ /* @__PURE__ */ jsx(
2806
+ IconButton,
2807
+ {
2808
+ disabled: action.disabled,
2809
+ label: action.label,
2810
+ size: "S",
2811
+ onClick: handleClick(action),
2812
+ children: action.icon
2813
+ }
2814
+ ),
2815
+ action.dialog ? /* @__PURE__ */ jsx(
2816
+ HeaderActionDialog,
2817
+ {
2818
+ ...action.dialog,
2819
+ isOpen: dialogId === action.id,
2820
+ onClose: handleClose
2821
+ }
2822
+ ) : null
2823
+ ] }, action.id);
2824
+ }
2295
2825
  }
2296
2826
  }) });
2297
2827
  };
2828
+ const HeaderActionDialog = ({
2829
+ onClose,
2830
+ onCancel,
2831
+ title,
2832
+ content: Content,
2833
+ isOpen
2834
+ }) => {
2835
+ const handleClose = async () => {
2836
+ if (onCancel) {
2837
+ await onCancel();
2838
+ }
2839
+ onClose();
2840
+ };
2841
+ return /* @__PURE__ */ jsx(Dialog.Root, { open: isOpen, onOpenChange: handleClose, children: /* @__PURE__ */ jsxs(Dialog.Content, { children: [
2842
+ /* @__PURE__ */ jsx(Dialog.Header, { children: title }),
2843
+ typeof Content === "function" ? /* @__PURE__ */ jsx(Content, { onClose: handleClose }) : Content
2844
+ ] }) });
2845
+ };
2298
2846
  const ConfigureTheViewAction = ({ collectionType, model }) => {
2299
2847
  const navigate = useNavigate();
2300
2848
  const { formatMessage } = useIntl();
@@ -2335,12 +2883,16 @@ const DeleteAction$1 = ({ documentId, model, collectionType, document }) => {
2335
2883
  const { delete: deleteAction } = useDocumentActions();
2336
2884
  const { toggleNotification } = useNotification();
2337
2885
  const setSubmitting = useForm("DeleteAction", (state) => state.setSubmitting);
2886
+ const isLocalized = document?.locale != null;
2338
2887
  return {
2339
2888
  disabled: !canDelete || !document,
2340
- label: formatMessage({
2341
- id: "content-manager.actions.delete.label",
2342
- defaultMessage: "Delete document"
2343
- }),
2889
+ label: formatMessage(
2890
+ {
2891
+ id: "content-manager.actions.delete.label",
2892
+ defaultMessage: "Delete entry{isLocalized, select, true { (all locales)} other {}}"
2893
+ },
2894
+ { isLocalized }
2895
+ ),
2344
2896
  icon: /* @__PURE__ */ jsx(Trash, {}),
2345
2897
  dialog: {
2346
2898
  type: "dialog",
@@ -2430,7 +2982,7 @@ const ActionsPanel = () => {
2430
2982
  return {
2431
2983
  title: formatMessage({
2432
2984
  id: "content-manager.containers.edit.panels.default.title",
2433
- defaultMessage: "Document"
2985
+ defaultMessage: "Entry"
2434
2986
  }),
2435
2987
  content: /* @__PURE__ */ jsx(ActionsPanelContent, {})
2436
2988
  };
@@ -2483,316 +3035,14 @@ const Panel = React.forwardRef(({ children, title }, ref) => {
2483
3035
  gap: 3,
2484
3036
  direction: "column",
2485
3037
  justifyContent: "stretch",
2486
- alignItems: "flex-start",
2487
- children: [
2488
- /* @__PURE__ */ jsx(Typography, { tag: "h2", variant: "sigma", textTransform: "uppercase", children: title }),
2489
- children
2490
- ]
2491
- }
2492
- );
2493
- });
2494
- const HOOKS = {
2495
- /**
2496
- * Hook that allows to mutate the displayed headers of the list view table
2497
- * @constant
2498
- * @type {string}
2499
- */
2500
- INJECT_COLUMN_IN_TABLE: "Admin/CM/pages/ListView/inject-column-in-table",
2501
- /**
2502
- * Hook that allows to mutate the CM's collection types links pre-set filters
2503
- * @constant
2504
- * @type {string}
2505
- */
2506
- MUTATE_COLLECTION_TYPES_LINKS: "Admin/CM/pages/App/mutate-collection-types-links",
2507
- /**
2508
- * Hook that allows to mutate the CM's edit view layout
2509
- * @constant
2510
- * @type {string}
2511
- */
2512
- MUTATE_EDIT_VIEW_LAYOUT: "Admin/CM/pages/EditView/mutate-edit-view-layout",
2513
- /**
2514
- * Hook that allows to mutate the CM's single types links pre-set filters
2515
- * @constant
2516
- * @type {string}
2517
- */
2518
- MUTATE_SINGLE_TYPES_LINKS: "Admin/CM/pages/App/mutate-single-types-links"
2519
- };
2520
- const contentTypesApi = contentManagerApi.injectEndpoints({
2521
- endpoints: (builder) => ({
2522
- getContentTypeConfiguration: builder.query({
2523
- query: (uid) => ({
2524
- url: `/content-manager/content-types/${uid}/configuration`,
2525
- method: "GET"
2526
- }),
2527
- transformResponse: (response) => response.data,
2528
- providesTags: (_result, _error, uid) => [
2529
- { type: "ContentTypesConfiguration", id: uid },
2530
- { type: "ContentTypeSettings", id: "LIST" }
2531
- ]
2532
- }),
2533
- getAllContentTypeSettings: builder.query({
2534
- query: () => "/content-manager/content-types-settings",
2535
- transformResponse: (response) => response.data,
2536
- providesTags: [{ type: "ContentTypeSettings", id: "LIST" }]
2537
- }),
2538
- updateContentTypeConfiguration: builder.mutation({
2539
- query: ({ uid, ...body }) => ({
2540
- url: `/content-manager/content-types/${uid}/configuration`,
2541
- method: "PUT",
2542
- data: body
2543
- }),
2544
- transformResponse: (response) => response.data,
2545
- invalidatesTags: (_result, _error, { uid }) => [
2546
- { type: "ContentTypesConfiguration", id: uid },
2547
- { type: "ContentTypeSettings", id: "LIST" },
2548
- // Is this necessary?
2549
- { type: "InitialData" }
2550
- ]
2551
- })
2552
- })
2553
- });
2554
- const {
2555
- useGetContentTypeConfigurationQuery,
2556
- useGetAllContentTypeSettingsQuery,
2557
- useUpdateContentTypeConfigurationMutation
2558
- } = contentTypesApi;
2559
- const checkIfAttributeIsDisplayable = (attribute) => {
2560
- const { type } = attribute;
2561
- if (type === "relation") {
2562
- return !attribute.relation.toLowerCase().includes("morph");
2563
- }
2564
- return !["json", "dynamiczone", "richtext", "password", "blocks"].includes(type) && !!type;
2565
- };
2566
- const getMainField = (attribute, mainFieldName, { schemas, components }) => {
2567
- if (!mainFieldName) {
2568
- return void 0;
2569
- }
2570
- const mainFieldType = attribute.type === "component" ? components[attribute.component].attributes[mainFieldName].type : (
2571
- // @ts-expect-error – `targetModel` does exist on the attribute for a relation.
2572
- schemas.find((schema) => schema.uid === attribute.targetModel)?.attributes[mainFieldName].type
2573
- );
2574
- return {
2575
- name: mainFieldName,
2576
- type: mainFieldType ?? "string"
2577
- };
2578
- };
2579
- const DEFAULT_SETTINGS = {
2580
- bulkable: false,
2581
- filterable: false,
2582
- searchable: false,
2583
- pagination: false,
2584
- defaultSortBy: "",
2585
- defaultSortOrder: "asc",
2586
- mainField: "id",
2587
- pageSize: 10
2588
- };
2589
- const useDocumentLayout = (model) => {
2590
- const { schema, components } = useDocument({ model, collectionType: "" }, { skip: true });
2591
- const [{ query }] = useQueryParams();
2592
- const runHookWaterfall = useStrapiApp("useDocumentLayout", (state) => state.runHookWaterfall);
2593
- const { toggleNotification } = useNotification();
2594
- const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();
2595
- const { isLoading: isLoadingSchemas, schemas } = useContentTypeSchema();
2596
- const {
2597
- data,
2598
- isLoading: isLoadingConfigs,
2599
- error,
2600
- isFetching: isFetchingConfigs
2601
- } = useGetContentTypeConfigurationQuery(model);
2602
- const isLoading = isLoadingSchemas || isFetchingConfigs || isLoadingConfigs;
2603
- React.useEffect(() => {
2604
- if (error) {
2605
- toggleNotification({
2606
- type: "danger",
2607
- message: formatAPIError(error)
2608
- });
2609
- }
2610
- }, [error, formatAPIError, toggleNotification]);
2611
- const editLayout = React.useMemo(
2612
- () => data && !isLoading ? formatEditLayout(data, { schemas, schema, components }) : {
2613
- layout: [],
2614
- components: {},
2615
- metadatas: {},
2616
- options: {},
2617
- settings: DEFAULT_SETTINGS
2618
- },
2619
- [data, isLoading, schemas, schema, components]
2620
- );
2621
- const listLayout = React.useMemo(() => {
2622
- return data && !isLoading ? formatListLayout(data, { schemas, schema, components }) : {
2623
- layout: [],
2624
- metadatas: {},
2625
- options: {},
2626
- settings: DEFAULT_SETTINGS
2627
- };
2628
- }, [data, isLoading, schemas, schema, components]);
2629
- const { layout: edit } = React.useMemo(
2630
- () => runHookWaterfall(HOOKS.MUTATE_EDIT_VIEW_LAYOUT, {
2631
- layout: editLayout,
2632
- query
2633
- }),
2634
- [editLayout, query, runHookWaterfall]
2635
- );
2636
- return {
2637
- error,
2638
- isLoading,
2639
- edit,
2640
- list: listLayout
2641
- };
2642
- };
2643
- const useDocLayout = () => {
2644
- const { model } = useDoc();
2645
- return useDocumentLayout(model);
2646
- };
2647
- const formatEditLayout = (data, {
2648
- schemas,
2649
- schema,
2650
- components
2651
- }) => {
2652
- let currentPanelIndex = 0;
2653
- const panelledEditAttributes = convertEditLayoutToFieldLayouts(
2654
- data.contentType.layouts.edit,
2655
- schema?.attributes,
2656
- data.contentType.metadatas,
2657
- { configurations: data.components, schemas: components },
2658
- schemas
2659
- ).reduce((panels, row) => {
2660
- if (row.some((field) => field.type === "dynamiczone")) {
2661
- panels.push([row]);
2662
- currentPanelIndex += 2;
2663
- } else {
2664
- if (!panels[currentPanelIndex]) {
2665
- panels.push([]);
2666
- }
2667
- panels[currentPanelIndex].push(row);
2668
- }
2669
- return panels;
2670
- }, []);
2671
- const componentEditAttributes = Object.entries(data.components).reduce(
2672
- (acc, [uid, configuration]) => {
2673
- acc[uid] = {
2674
- layout: convertEditLayoutToFieldLayouts(
2675
- configuration.layouts.edit,
2676
- components[uid].attributes,
2677
- configuration.metadatas
2678
- ),
2679
- settings: {
2680
- ...configuration.settings,
2681
- icon: components[uid].info.icon,
2682
- displayName: components[uid].info.displayName
2683
- }
2684
- };
2685
- return acc;
2686
- },
2687
- {}
2688
- );
2689
- const editMetadatas = Object.entries(data.contentType.metadatas).reduce(
2690
- (acc, [attribute, metadata]) => {
2691
- return {
2692
- ...acc,
2693
- [attribute]: metadata.edit
2694
- };
2695
- },
2696
- {}
2697
- );
2698
- return {
2699
- layout: panelledEditAttributes,
2700
- components: componentEditAttributes,
2701
- metadatas: editMetadatas,
2702
- settings: {
2703
- ...data.contentType.settings,
2704
- displayName: schema?.info.displayName
2705
- },
2706
- options: {
2707
- ...schema?.options,
2708
- ...schema?.pluginOptions,
2709
- ...data.contentType.options
2710
- }
2711
- };
2712
- };
2713
- const convertEditLayoutToFieldLayouts = (rows, attributes = {}, metadatas, components, schemas = []) => {
2714
- return rows.map(
2715
- (row) => row.map((field) => {
2716
- const attribute = attributes[field.name];
2717
- if (!attribute) {
2718
- return null;
2719
- }
2720
- const { edit: metadata } = metadatas[field.name];
2721
- const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
2722
- return {
2723
- attribute,
2724
- disabled: !metadata.editable,
2725
- hint: metadata.description,
2726
- label: metadata.label ?? "",
2727
- name: field.name,
2728
- // @ts-expect-error – mainField does exist on the metadata for a relation.
2729
- mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
2730
- schemas,
2731
- components: components?.schemas ?? {}
2732
- }),
2733
- placeholder: metadata.placeholder ?? "",
2734
- required: attribute.required ?? false,
2735
- size: field.size,
2736
- unique: "unique" in attribute ? attribute.unique : false,
2737
- visible: metadata.visible ?? true,
2738
- type: attribute.type
2739
- };
2740
- }).filter((field) => field !== null)
2741
- );
2742
- };
2743
- const formatListLayout = (data, {
2744
- schemas,
2745
- schema,
2746
- components
2747
- }) => {
2748
- const listMetadatas = Object.entries(data.contentType.metadatas).reduce(
2749
- (acc, [attribute, metadata]) => {
2750
- return {
2751
- ...acc,
2752
- [attribute]: metadata.list
2753
- };
2754
- },
2755
- {}
2756
- );
2757
- const listAttributes = convertListLayoutToFieldLayouts(
2758
- data.contentType.layouts.list,
2759
- schema?.attributes,
2760
- listMetadatas,
2761
- { configurations: data.components, schemas: components },
2762
- schemas
2763
- );
2764
- return {
2765
- layout: listAttributes,
2766
- settings: { ...data.contentType.settings, displayName: schema?.info.displayName },
2767
- metadatas: listMetadatas,
2768
- options: {
2769
- ...schema?.options,
2770
- ...schema?.pluginOptions,
2771
- ...data.contentType.options
2772
- }
2773
- };
2774
- };
2775
- const convertListLayoutToFieldLayouts = (columns, attributes = {}, metadatas, components, schemas = []) => {
2776
- return columns.map((name) => {
2777
- const attribute = attributes[name];
2778
- if (!attribute) {
2779
- return null;
3038
+ alignItems: "flex-start",
3039
+ children: [
3040
+ /* @__PURE__ */ jsx(Typography, { tag: "h2", variant: "sigma", textTransform: "uppercase", textColor: "neutral600", children: title }),
3041
+ children
3042
+ ]
2780
3043
  }
2781
- const metadata = metadatas[name];
2782
- const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
2783
- return {
2784
- attribute,
2785
- label: metadata.label ?? "",
2786
- mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
2787
- schemas,
2788
- components: components?.schemas ?? {}
2789
- }),
2790
- name,
2791
- searchable: metadata.searchable ?? true,
2792
- sortable: metadata.sortable ?? true
2793
- };
2794
- }).filter((field) => field !== null);
2795
- };
3044
+ );
3045
+ });
2796
3046
  const ConfirmBulkActionDialog = ({
2797
3047
  onToggleDialog,
2798
3048
  isOpen = false,
@@ -2800,30 +3050,23 @@ const ConfirmBulkActionDialog = ({
2800
3050
  endAction
2801
3051
  }) => {
2802
3052
  const { formatMessage } = useIntl();
2803
- return /* @__PURE__ */ jsxs(
2804
- Dialog,
2805
- {
2806
- onClose: onToggleDialog,
2807
- title: formatMessage({
2808
- id: "app.components.ConfirmDialog.title",
2809
- defaultMessage: "Confirmation"
2810
- }),
2811
- isOpen,
2812
- children: [
2813
- /* @__PURE__ */ jsx(DialogBody, { icon: /* @__PURE__ */ jsx(WarningCircle, {}), children: /* @__PURE__ */ jsx(Flex, { direction: "column", alignItems: "stretch", gap: 2, children: dialogBody }) }),
2814
- /* @__PURE__ */ jsx(
2815
- DialogFooter,
2816
- {
2817
- startAction: /* @__PURE__ */ jsx(Button, { onClick: onToggleDialog, variant: "tertiary", children: formatMessage({
2818
- id: "app.components.Button.cancel",
2819
- defaultMessage: "Cancel"
2820
- }) }),
2821
- endAction
2822
- }
2823
- )
2824
- ]
2825
- }
2826
- );
3053
+ return /* @__PURE__ */ jsx(Dialog.Root, { open: isOpen, children: /* @__PURE__ */ jsxs(Dialog.Content, { children: [
3054
+ /* @__PURE__ */ jsx(Dialog.Header, { children: formatMessage({
3055
+ id: "app.components.ConfirmDialog.title",
3056
+ defaultMessage: "Confirmation"
3057
+ }) }),
3058
+ /* @__PURE__ */ jsx(Dialog.Body, { children: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
3059
+ /* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(WarningCircle, { width: "24px", height: "24px", fill: "danger600" }) }),
3060
+ dialogBody
3061
+ ] }) }),
3062
+ /* @__PURE__ */ jsxs(Dialog.Footer, { children: [
3063
+ /* @__PURE__ */ jsx(Dialog.Cancel, { children: /* @__PURE__ */ jsx(Button, { fullWidth: true, onClick: onToggleDialog, variant: "tertiary", children: formatMessage({
3064
+ id: "app.components.Button.cancel",
3065
+ defaultMessage: "Cancel"
3066
+ }) }) }),
3067
+ endAction
3068
+ ] })
3069
+ ] }) });
2827
3070
  };
2828
3071
  const BoldChunk$1 = (chunks) => /* @__PURE__ */ jsx(Typography, { fontWeight: "bold", children: chunks });
2829
3072
  const ConfirmDialogPublishAll = ({
@@ -2838,6 +3081,7 @@ const ConfirmDialogPublishAll = ({
2838
3081
  const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler(getTranslation);
2839
3082
  const { model, schema } = useDoc();
2840
3083
  const [{ query }] = useQueryParams();
3084
+ const enableDraftRelationsCount = false;
2841
3085
  const {
2842
3086
  data: countDraftRelations = 0,
2843
3087
  isLoading,
@@ -2849,7 +3093,7 @@ const ConfirmDialogPublishAll = ({
2849
3093
  locale: query?.plugins?.i18n?.locale
2850
3094
  },
2851
3095
  {
2852
- skip: selectedEntries.length === 0
3096
+ skip: !enableDraftRelationsCount
2853
3097
  }
2854
3098
  );
2855
3099
  React.useEffect(() => {
@@ -2928,16 +3172,30 @@ const formatErrorMessages = (errors, parentKey, formatMessage) => {
2928
3172
  )
2929
3173
  );
2930
3174
  } else {
2931
- messages.push(...formatErrorMessages(value, currentKey, formatMessage));
3175
+ messages.push(
3176
+ ...formatErrorMessages(
3177
+ // @ts-expect-error TODO: check why value is not compatible with FormErrors
3178
+ value,
3179
+ currentKey,
3180
+ formatMessage
3181
+ )
3182
+ );
2932
3183
  }
3184
+ } else {
3185
+ messages.push(
3186
+ formatMessage(
3187
+ {
3188
+ id: `${value}.withField`,
3189
+ defaultMessage: value
3190
+ },
3191
+ { field: currentKey }
3192
+ )
3193
+ );
2933
3194
  }
2934
3195
  });
2935
3196
  return messages;
2936
3197
  };
2937
- const EntryValidationText = ({
2938
- validationErrors,
2939
- isPublished = false
2940
- }) => {
3198
+ const EntryValidationText = ({ validationErrors, status }) => {
2941
3199
  const { formatMessage } = useIntl();
2942
3200
  if (validationErrors) {
2943
3201
  const validationErrorsMessages = formatErrorMessages(validationErrors, "", formatMessage).join(
@@ -2948,7 +3206,7 @@ const EntryValidationText = ({
2948
3206
  /* @__PURE__ */ jsx(Tooltip, { description: validationErrorsMessages, children: /* @__PURE__ */ jsx(TypographyMaxWidth, { textColor: "danger600", variant: "omega", fontWeight: "semiBold", ellipsis: true, children: validationErrorsMessages }) })
2949
3207
  ] });
2950
3208
  }
2951
- if (isPublished) {
3209
+ if (status === "published") {
2952
3210
  return /* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
2953
3211
  /* @__PURE__ */ jsx(CheckCircle, { fill: "success600" }),
2954
3212
  /* @__PURE__ */ jsx(Typography, { textColor: "success600", fontWeight: "bold", children: formatMessage({
@@ -2957,6 +3215,15 @@ const EntryValidationText = ({
2957
3215
  }) })
2958
3216
  ] });
2959
3217
  }
3218
+ if (status === "modified") {
3219
+ return /* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
3220
+ /* @__PURE__ */ jsx(ArrowsCounterClockwise, { fill: "alternative600" }),
3221
+ /* @__PURE__ */ jsx(Typography, { children: formatMessage({
3222
+ id: "content-manager.bulk-publish.modified",
3223
+ defaultMessage: "Ready to publish changes"
3224
+ }) })
3225
+ ] });
3226
+ }
2960
3227
  return /* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
2961
3228
  /* @__PURE__ */ jsx(CheckCircle, { fill: "success600" }),
2962
3229
  /* @__PURE__ */ jsx(Typography, { children: formatMessage({
@@ -3008,10 +3275,10 @@ const SelectedEntriesTableContent = ({
3008
3275
  EntryValidationText,
3009
3276
  {
3010
3277
  validationErrors: validationErrors[row.documentId],
3011
- isPublished: row.status === "published"
3278
+ status: row.status
3012
3279
  }
3013
3280
  ) }),
3014
- /* @__PURE__ */ jsx(Table.Cell, { children: /* @__PURE__ */ jsx(
3281
+ /* @__PURE__ */ jsx(Table.Cell, { children: /* @__PURE__ */ jsx(Flex, { children: /* @__PURE__ */ jsx(
3015
3282
  IconButton,
3016
3283
  {
3017
3284
  tag: Link,
@@ -3020,23 +3287,16 @@ const SelectedEntriesTableContent = ({
3020
3287
  search: row.locale && `?plugins[i18n][locale]=${row.locale}`
3021
3288
  },
3022
3289
  state: { from: pathname },
3023
- label: formatMessage(
3024
- { id: "app.component.HelperPluginTable.edit", defaultMessage: "Edit {target}" },
3025
- {
3026
- target: formatMessage(
3027
- {
3028
- id: "content-manager.components.ListViewHelperPluginTable.row-line",
3029
- defaultMessage: "item line {number}"
3030
- },
3031
- { number: index2 + 1 }
3032
- )
3033
- }
3034
- ),
3290
+ label: formatMessage({
3291
+ id: "content-manager.bulk-publish.edit",
3292
+ defaultMessage: "Edit"
3293
+ }),
3035
3294
  target: "_blank",
3036
3295
  marginLeft: "auto",
3037
- children: /* @__PURE__ */ jsx(Pencil, {})
3296
+ variant: "ghost",
3297
+ children: /* @__PURE__ */ jsx(Pencil, { width: "1.6rem", height: "1.6rem" })
3038
3298
  }
3039
- ) })
3299
+ ) }) })
3040
3300
  ] }, row.id)) })
3041
3301
  ] });
3042
3302
  };
@@ -3073,7 +3333,13 @@ const SelectedEntriesModalContent = ({
3073
3333
  );
3074
3334
  const { rows, validationErrors } = React.useMemo(() => {
3075
3335
  if (data.length > 0 && schema) {
3076
- const validate = createYupSchema(schema.attributes, components);
3336
+ const validate = createYupSchema(
3337
+ schema.attributes,
3338
+ components,
3339
+ // Since this is the "Publish" action, the validation
3340
+ // schema must enforce the rules for published entities
3341
+ { status: "published" }
3342
+ );
3077
3343
  const validationErrors2 = {};
3078
3344
  const rows2 = data.map((entry) => {
3079
3345
  try {
@@ -3149,7 +3415,7 @@ const SelectedEntriesModalContent = ({
3149
3415
  );
3150
3416
  };
3151
3417
  return /* @__PURE__ */ jsxs(Fragment, { children: [
3152
- /* @__PURE__ */ jsxs(ModalBody, { children: [
3418
+ /* @__PURE__ */ jsxs(Modal.Body, { children: [
3153
3419
  /* @__PURE__ */ jsx(Typography, { children: getFormattedCountMessage() }),
3154
3420
  /* @__PURE__ */ jsx(Box, { marginTop: 5, children: /* @__PURE__ */ jsx(
3155
3421
  SelectedEntriesTableContent,
@@ -3161,27 +3427,24 @@ const SelectedEntriesModalContent = ({
3161
3427
  }
3162
3428
  ) })
3163
3429
  ] }),
3164
- /* @__PURE__ */ jsx(
3165
- ModalFooter,
3166
- {
3167
- startActions: /* @__PURE__ */ jsx(Button, { onClick: toggleModal, variant: "tertiary", children: formatMessage({
3168
- id: "app.components.Button.cancel",
3169
- defaultMessage: "Cancel"
3170
- }) }),
3171
- endActions: /* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
3172
- /* @__PURE__ */ jsx(Button, { onClick: refetch, variant: "tertiary", loading: isFetching, children: formatMessage({ id: "app.utils.refresh", defaultMessage: "Refresh" }) }),
3173
- /* @__PURE__ */ jsx(
3174
- Button,
3175
- {
3176
- onClick: toggleDialog,
3177
- disabled: selectedEntries.length === 0 || selectedEntries.length === selectedEntriesWithErrorsCount || selectedEntriesPublished === selectedEntries.length || isLoading,
3178
- loading: isSubmittingForm,
3179
- children: formatMessage({ id: "app.utils.publish", defaultMessage: "Publish" })
3180
- }
3181
- )
3182
- ] })
3183
- }
3184
- ),
3430
+ /* @__PURE__ */ jsxs(Modal.Footer, { children: [
3431
+ /* @__PURE__ */ jsx(Button, { onClick: toggleModal, variant: "tertiary", children: formatMessage({
3432
+ id: "app.components.Button.cancel",
3433
+ defaultMessage: "Cancel"
3434
+ }) }),
3435
+ /* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
3436
+ /* @__PURE__ */ jsx(Button, { onClick: refetch, variant: "tertiary", loading: isFetching, children: formatMessage({ id: "app.utils.refresh", defaultMessage: "Refresh" }) }),
3437
+ /* @__PURE__ */ jsx(
3438
+ Button,
3439
+ {
3440
+ onClick: toggleDialog,
3441
+ disabled: selectedEntries.length === 0 || selectedEntries.length === selectedEntriesWithErrorsCount || selectedEntriesPublished === selectedEntries.length || isLoading,
3442
+ loading: isSubmittingForm,
3443
+ children: formatMessage({ id: "app.utils.publish", defaultMessage: "Publish" })
3444
+ }
3445
+ )
3446
+ ] })
3447
+ ] }),
3185
3448
  /* @__PURE__ */ jsx(
3186
3449
  ConfirmDialogPublishAll,
3187
3450
  {
@@ -3201,8 +3464,7 @@ const PublishAction = ({ documents, model }) => {
3201
3464
  const refetchList = () => {
3202
3465
  contentManagerApi.util.invalidateTags([{ type: "Document", id: `${model}_LIST` }]);
3203
3466
  };
3204
- if (!showPublishButton)
3205
- return null;
3467
+ if (!showPublishButton) return null;
3206
3468
  return {
3207
3469
  actionType: "publish",
3208
3470
  variant: "tertiary",
@@ -3246,143 +3508,10 @@ const BulkActionsRenderer = () => {
3246
3508
  documents: selectedRows
3247
3509
  },
3248
3510
  descriptions: plugins["content-manager"].apis.getBulkActions(),
3249
- children: (actions2) => actions2.map((action) => /* @__PURE__ */ jsx(BulkActionAction, { ...action }, action.id))
3511
+ children: (actions2) => actions2.map((action) => /* @__PURE__ */ jsx(DocumentActionButton, { ...action }, action.id))
3250
3512
  }
3251
3513
  ) });
3252
3514
  };
3253
- const BulkActionAction = (action) => {
3254
- const [dialogId, setDialogId] = React.useState(null);
3255
- const { toggleNotification } = useNotification();
3256
- const handleClick = (action2) => (e) => {
3257
- const { onClick, dialog, id } = action2;
3258
- if (onClick) {
3259
- onClick(e);
3260
- }
3261
- if (dialog) {
3262
- switch (dialog.type) {
3263
- case "notification":
3264
- toggleNotification({
3265
- title: dialog.title,
3266
- message: dialog.content,
3267
- type: dialog.status,
3268
- timeout: dialog.timeout,
3269
- onClose: dialog.onClose
3270
- });
3271
- break;
3272
- case "dialog":
3273
- case "modal": {
3274
- e.preventDefault();
3275
- setDialogId(id);
3276
- }
3277
- }
3278
- }
3279
- };
3280
- const handleClose = () => {
3281
- setDialogId(null);
3282
- if (action.dialog?.type === "modal" && action.dialog?.onClose) {
3283
- action.dialog.onClose();
3284
- }
3285
- };
3286
- return /* @__PURE__ */ jsxs(Fragment, { children: [
3287
- /* @__PURE__ */ jsx(
3288
- Button,
3289
- {
3290
- disabled: action.disabled,
3291
- startIcon: action.icon,
3292
- variant: action.variant,
3293
- onClick: handleClick(action),
3294
- children: action.label
3295
- }
3296
- ),
3297
- action.dialog?.type === "dialog" ? /* @__PURE__ */ jsx(
3298
- BulkActionConfirmDialog,
3299
- {
3300
- ...action.dialog,
3301
- variant: action.variant,
3302
- isOpen: dialogId === action.id,
3303
- onClose: handleClose
3304
- }
3305
- ) : null,
3306
- action.dialog?.type === "modal" ? /* @__PURE__ */ jsx(
3307
- BulkActionModal,
3308
- {
3309
- ...action.dialog,
3310
- onModalClose: handleClose,
3311
- isOpen: dialogId === action.id
3312
- }
3313
- ) : null
3314
- ] });
3315
- };
3316
- const BulkActionConfirmDialog = ({
3317
- onClose,
3318
- onCancel,
3319
- onConfirm,
3320
- title,
3321
- content,
3322
- confirmButton,
3323
- isOpen,
3324
- variant = "secondary"
3325
- }) => {
3326
- const { formatMessage } = useIntl();
3327
- const handleClose = async () => {
3328
- if (onCancel) {
3329
- await onCancel();
3330
- }
3331
- onClose();
3332
- };
3333
- const handleConfirm = async () => {
3334
- if (onConfirm) {
3335
- await onConfirm();
3336
- }
3337
- onClose();
3338
- };
3339
- return /* @__PURE__ */ jsxs(Dialog, { isOpen, title, onClose: handleClose, children: [
3340
- /* @__PURE__ */ jsx(DialogBody, { icon: /* @__PURE__ */ jsx(WarningCircle, {}), children: content }),
3341
- /* @__PURE__ */ jsx(
3342
- DialogFooter,
3343
- {
3344
- startAction: /* @__PURE__ */ jsx(Button, { onClick: handleClose, variant: "tertiary", children: formatMessage({
3345
- id: "app.components.Button.cancel",
3346
- defaultMessage: "Cancel"
3347
- }) }),
3348
- endAction: /* @__PURE__ */ jsx(
3349
- Button,
3350
- {
3351
- onClick: handleConfirm,
3352
- variant: variant === "danger-light" ? variant : "secondary",
3353
- startIcon: variant === "danger-light" ? /* @__PURE__ */ jsx(Trash, {}) : /* @__PURE__ */ jsx(Check, {}),
3354
- children: confirmButton ? confirmButton : formatMessage({
3355
- id: "app.components.Button.confirm",
3356
- defaultMessage: "Confirm"
3357
- })
3358
- }
3359
- )
3360
- }
3361
- )
3362
- ] });
3363
- };
3364
- const BulkActionModal = ({
3365
- isOpen,
3366
- title,
3367
- onClose,
3368
- content: Content,
3369
- onModalClose
3370
- }) => {
3371
- const id = React.useId();
3372
- if (!isOpen) {
3373
- return null;
3374
- }
3375
- const handleClose = () => {
3376
- if (onClose) {
3377
- onClose();
3378
- }
3379
- onModalClose();
3380
- };
3381
- return /* @__PURE__ */ jsxs(ModalLayout, { borderRadius: "4px", overflow: "hidden", onClose: handleClose, labelledBy: id, children: [
3382
- /* @__PURE__ */ jsx(ModalHeader, { children: /* @__PURE__ */ jsx(Typography, { fontWeight: "bold", textColor: "neutral800", tag: "h2", id, children: title }) }),
3383
- /* @__PURE__ */ jsx(Content, { onClose: handleClose })
3384
- ] });
3385
- };
3386
3515
  const DeleteAction = ({ documents, model }) => {
3387
3516
  const { formatMessage } = useIntl();
3388
3517
  const { schema: contentType } = useDoc();
@@ -3403,8 +3532,7 @@ const DeleteAction = ({ documents, model }) => {
3403
3532
  selectRow([]);
3404
3533
  }
3405
3534
  };
3406
- if (!hasDeletePermission)
3407
- return null;
3535
+ if (!hasDeletePermission) return null;
3408
3536
  return {
3409
3537
  variant: "danger-light",
3410
3538
  label: formatMessage({ id: "global.delete", defaultMessage: "Delete" }),
@@ -3415,6 +3543,7 @@ const DeleteAction = ({ documents, model }) => {
3415
3543
  defaultMessage: "Confirmation"
3416
3544
  }),
3417
3545
  content: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
3546
+ /* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(WarningCircle, { width: "24px", height: "24px", fill: "danger600" }) }),
3418
3547
  /* @__PURE__ */ jsx(Typography, { id: "confirm-description", textAlign: "center", children: formatMessage({
3419
3548
  id: "popUpWarning.bodyMessage.contentType.delete.all",
3420
3549
  defaultMessage: "Are you sure you want to delete these entries?"
@@ -3451,9 +3580,8 @@ const UnpublishAction = ({ documents, model }) => {
3451
3580
  selectRow([]);
3452
3581
  }
3453
3582
  };
3454
- const showUnpublishButton = hasDraftAndPublishEnabled && hasPublishPermission && documents.some((entry) => entry.status === "published");
3455
- if (!showUnpublishButton)
3456
- return null;
3583
+ const showUnpublishButton = hasDraftAndPublishEnabled && hasPublishPermission && documents.some((entry) => entry.status === "published" || entry.status === "modified");
3584
+ if (!showUnpublishButton) return null;
3457
3585
  return {
3458
3586
  variant: "tertiary",
3459
3587
  label: formatMessage({ id: "app.utils.unpublish", defaultMessage: "Unpublish" }),
@@ -3464,6 +3592,7 @@ const UnpublishAction = ({ documents, model }) => {
3464
3592
  defaultMessage: "Confirmation"
3465
3593
  }),
3466
3594
  content: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
3595
+ /* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(WarningCircle, { width: "24px", height: "24px", fill: "danger600" }) }),
3467
3596
  /* @__PURE__ */ jsx(Typography, { id: "confirm-description", textAlign: "center", children: formatMessage({
3468
3597
  id: "popUpWarning.bodyMessage.contentType.unpublish.all",
3469
3598
  defaultMessage: "Are you sure you want to unpublish these entries?"
@@ -3557,7 +3686,7 @@ const TableActions = ({ document }) => {
3557
3686
  DescriptionComponentRenderer,
3558
3687
  {
3559
3688
  props,
3560
- descriptions: plugins["content-manager"].apis.getDocumentActions(),
3689
+ descriptions: plugins["content-manager"].apis.getDocumentActions().filter((action) => action.name !== "PublishAction"),
3561
3690
  children: (actions2) => {
3562
3691
  const tableRowActions = actions2.filter((action) => {
3563
3692
  const positions = Array.isArray(action.position) ? action.position : [action.position];
@@ -3668,7 +3797,7 @@ const CloneAction = ({ model, documentId }) => {
3668
3797
  }),
3669
3798
  content: /* @__PURE__ */ jsx(AutoCloneFailureModalBody, { prohibitedFields }),
3670
3799
  footer: ({ onClose }) => {
3671
- return /* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", children: [
3800
+ return /* @__PURE__ */ jsxs(Modal.Footer, { children: [
3672
3801
  /* @__PURE__ */ jsx(Button, { onClick: onClose, variant: "tertiary", children: formatMessage({
3673
3802
  id: "cancel",
3674
3803
  defaultMessage: "Cancel"
@@ -3709,8 +3838,7 @@ class ContentManagerPlugin {
3709
3838
  documentActions = [
3710
3839
  ...DEFAULT_ACTIONS,
3711
3840
  ...DEFAULT_TABLE_ROW_ACTIONS,
3712
- ...DEFAULT_HEADER_ACTIONS,
3713
- HistoryAction
3841
+ ...DEFAULT_HEADER_ACTIONS
3714
3842
  ];
3715
3843
  editViewSidePanels = [ActionsPanel];
3716
3844
  headerActions = [];
@@ -3789,16 +3917,70 @@ class ContentManagerPlugin {
3789
3917
  const getPrintableType = (value) => {
3790
3918
  const nativeType = typeof value;
3791
3919
  if (nativeType === "object") {
3792
- if (value === null)
3793
- return "null";
3794
- if (Array.isArray(value))
3795
- return "array";
3920
+ if (value === null) return "null";
3921
+ if (Array.isArray(value)) return "array";
3796
3922
  if (value instanceof Object && value.constructor.name !== "Object") {
3797
3923
  return value.constructor.name;
3798
3924
  }
3799
3925
  }
3800
3926
  return nativeType;
3801
3927
  };
3928
+ const HistoryAction = ({ model, document }) => {
3929
+ const { formatMessage } = useIntl();
3930
+ const [{ query }] = useQueryParams();
3931
+ const navigate = useNavigate();
3932
+ const { trackUsage } = useTracking();
3933
+ const { pathname } = useLocation();
3934
+ const pluginsQueryParams = stringify({ plugins: query.plugins }, { encode: false });
3935
+ if (!window.strapi.features.isEnabled("cms-content-history")) {
3936
+ return null;
3937
+ }
3938
+ const handleOnClick = () => {
3939
+ const destination = { pathname: "history", search: pluginsQueryParams };
3940
+ trackUsage("willNavigate", {
3941
+ from: pathname,
3942
+ to: `${pathname}/${destination.pathname}`
3943
+ });
3944
+ navigate(destination);
3945
+ };
3946
+ return {
3947
+ icon: /* @__PURE__ */ jsx(ClockCounterClockwise, {}),
3948
+ label: formatMessage({
3949
+ id: "content-manager.history.document-action",
3950
+ defaultMessage: "Content History"
3951
+ }),
3952
+ onClick: handleOnClick,
3953
+ disabled: (
3954
+ /**
3955
+ * The user is creating a new document.
3956
+ * It hasn't been saved yet, so there's no history to go to
3957
+ */
3958
+ !document || /**
3959
+ * The document has been created but the current dimension has never been saved.
3960
+ * For example, the user is creating a new locale in an existing document,
3961
+ * so there's no history for the document in that locale
3962
+ */
3963
+ !document.id || /**
3964
+ * History is only available for content types created by the user.
3965
+ * These have the `api::` prefix, as opposed to the ones created by Strapi or plugins,
3966
+ * which start with `admin::` or `plugin::`
3967
+ */
3968
+ !model.startsWith("api::")
3969
+ ),
3970
+ position: "header"
3971
+ };
3972
+ };
3973
+ HistoryAction.type = "history";
3974
+ const historyAdmin = {
3975
+ bootstrap(app) {
3976
+ const { addDocumentAction } = app.getPlugin("content-manager").apis;
3977
+ addDocumentAction((actions2) => {
3978
+ const indexOfDeleteAction = actions2.findIndex((action) => action.type === "delete");
3979
+ actions2.splice(indexOfDeleteAction, 0, HistoryAction);
3980
+ return actions2;
3981
+ });
3982
+ }
3983
+ };
3802
3984
  const initialState = {
3803
3985
  collectionTypeLinks: [],
3804
3986
  components: [],
@@ -3835,6 +4017,90 @@ const { setInitialData } = actions;
3835
4017
  const reducer = combineReducers({
3836
4018
  app: reducer$1
3837
4019
  });
4020
+ const previewApi = contentManagerApi.injectEndpoints({
4021
+ endpoints: (builder) => ({
4022
+ getPreviewUrl: builder.query({
4023
+ query({ query, params }) {
4024
+ return {
4025
+ url: `/content-manager/preview/url/${params.contentType}`,
4026
+ method: "GET",
4027
+ config: {
4028
+ params: query
4029
+ }
4030
+ };
4031
+ }
4032
+ })
4033
+ })
4034
+ });
4035
+ const { useGetPreviewUrlQuery } = previewApi;
4036
+ const ConditionalTooltip = ({ isShown, label, children }) => {
4037
+ if (isShown) {
4038
+ return /* @__PURE__ */ jsx(Tooltip, { label, children });
4039
+ }
4040
+ return children;
4041
+ };
4042
+ const PreviewSidePanel = ({ model, documentId, document }) => {
4043
+ const { formatMessage } = useIntl();
4044
+ const { trackUsage } = useTracking();
4045
+ const { pathname } = useLocation();
4046
+ const [{ query }] = useQueryParams();
4047
+ const isModified = useForm("PreviewSidePanel", (state) => state.modified);
4048
+ const { data, error } = useGetPreviewUrlQuery({
4049
+ params: {
4050
+ contentType: model
4051
+ },
4052
+ query: {
4053
+ documentId,
4054
+ locale: document?.locale,
4055
+ status: document?.status
4056
+ }
4057
+ });
4058
+ if (!data?.data?.url || error) {
4059
+ return null;
4060
+ }
4061
+ const trackNavigation = () => {
4062
+ const destinationPathname = pathname.replace(/\/$/, "") + "/preview";
4063
+ trackUsage("willNavigate", { from: pathname, to: destinationPathname });
4064
+ };
4065
+ return {
4066
+ title: formatMessage({ id: "content-manager.preview.panel.title", defaultMessage: "Preview" }),
4067
+ content: /* @__PURE__ */ jsx(Flex, { gap: 2, width: "100%", children: /* @__PURE__ */ jsx(
4068
+ ConditionalTooltip,
4069
+ {
4070
+ label: formatMessage({
4071
+ id: "content-manager.preview.panel.button-disabled-tooltip",
4072
+ defaultMessage: "Please save to open the preview"
4073
+ }),
4074
+ isShown: isModified,
4075
+ children: /* @__PURE__ */ jsx(
4076
+ Button,
4077
+ {
4078
+ variant: "tertiary",
4079
+ tag: Link,
4080
+ to: { pathname: "preview", search: stringify(query, { encode: false }) },
4081
+ onClick: trackNavigation,
4082
+ flex: "auto",
4083
+ disabled: isModified,
4084
+ children: formatMessage({
4085
+ id: "content-manager.preview.panel.button",
4086
+ defaultMessage: "Open preview"
4087
+ })
4088
+ }
4089
+ )
4090
+ }
4091
+ ) })
4092
+ };
4093
+ };
4094
+ const FEATURE_ID = "preview";
4095
+ const previewAdmin = {
4096
+ bootstrap(app) {
4097
+ if (!window.strapi.future.isEnabled(FEATURE_ID)) {
4098
+ return;
4099
+ }
4100
+ const contentManagerPluginApis = app.getPlugin("content-manager").apis;
4101
+ contentManagerPluginApis.addEditViewSidePanel([PreviewSidePanel]);
4102
+ }
4103
+ };
3838
4104
  const index = {
3839
4105
  register(app) {
3840
4106
  const cm = new ContentManagerPlugin();
@@ -3849,15 +4115,32 @@ const index = {
3849
4115
  defaultMessage: "Content Manager"
3850
4116
  },
3851
4117
  permissions: [],
3852
- Component: () => import("./layout-CPn1PM6x.mjs").then((mod) => ({ default: mod.Layout })),
3853
4118
  position: 1
3854
4119
  });
4120
+ app.router.addRoute({
4121
+ path: "content-manager/*",
4122
+ lazy: async () => {
4123
+ const { Layout } = await import("./layout-qE8qkNH_.mjs");
4124
+ return {
4125
+ Component: Layout
4126
+ };
4127
+ },
4128
+ children: routes
4129
+ });
3855
4130
  app.registerPlugin(cm.config);
3856
4131
  },
4132
+ bootstrap(app) {
4133
+ if (typeof historyAdmin.bootstrap === "function") {
4134
+ historyAdmin.bootstrap(app);
4135
+ }
4136
+ if (typeof previewAdmin.bootstrap === "function") {
4137
+ previewAdmin.bootstrap(app);
4138
+ }
4139
+ },
3857
4140
  async registerTrads({ locales }) {
3858
4141
  const importedTrads = await Promise.all(
3859
4142
  locales.map((locale) => {
3860
- 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-Dzv55oQw.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 }) => {
4143
+ 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-Dtk_ot79.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`, 3).then(({ default: data }) => {
3861
4144
  return {
3862
4145
  data: prefixPluginTranslations(data, PLUGIN_ID),
3863
4146
  locale
@@ -3884,37 +4167,39 @@ export {
3884
4167
  HOOKS as H,
3885
4168
  InjectionZone as I,
3886
4169
  useDocument as J,
3887
- index as K,
3888
- useDocumentActions as L,
4170
+ useGetPreviewUrlQuery as K,
4171
+ index as L,
4172
+ useContentManagerContext as M,
4173
+ useDocumentActions as N,
3889
4174
  Panels as P,
3890
4175
  RelativeTime as R,
3891
4176
  SINGLE_TYPES as S,
3892
4177
  TableActions as T,
3893
- useGetAllContentTypeSettingsQuery as a,
3894
- useDoc as b,
3895
- buildValidParams as c,
3896
- contentManagerApi as d,
3897
- useDocumentRBAC as e,
3898
- useDocumentLayout as f,
4178
+ useGetInitialDataQuery as a,
4179
+ useGetAllContentTypeSettingsQuery as b,
4180
+ useDoc as c,
4181
+ buildValidParams as d,
4182
+ contentManagerApi as e,
4183
+ useDocumentRBAC as f,
3899
4184
  getTranslation as g,
3900
- createYupSchema as h,
3901
- Header as i,
3902
- PERMISSIONS as j,
3903
- DocumentRBAC as k,
3904
- DOCUMENT_META_FIELDS as l,
3905
- useDocLayout as m,
3906
- useContentTypeSchema as n,
3907
- useGetContentTypeConfigurationQuery as o,
3908
- CREATOR_FIELDS as p,
3909
- getMainField as q,
3910
- routes as r,
4185
+ useDocumentLayout as h,
4186
+ createYupSchema as i,
4187
+ Header as j,
4188
+ PERMISSIONS as k,
4189
+ DocumentRBAC as l,
4190
+ DOCUMENT_META_FIELDS as m,
4191
+ CLONE_PATH as n,
4192
+ useDocLayout as o,
4193
+ useGetContentTypeConfigurationQuery as p,
4194
+ CREATOR_FIELDS as q,
4195
+ getMainField as r,
3911
4196
  setInitialData as s,
3912
4197
  getDisplayName as t,
3913
- useGetInitialDataQuery as u,
4198
+ useContentTypeSchema as u,
3914
4199
  checkIfAttributeIsDisplayable as v,
3915
4200
  useGetAllDocumentsQuery as w,
3916
4201
  convertListLayoutToFieldLayouts as x,
3917
4202
  capitalise as y,
3918
4203
  useUpdateContentTypeConfigurationMutation as z
3919
4204
  };
3920
- //# sourceMappingURL=index-VHviNMeW.mjs.map
4205
+ //# sourceMappingURL=index-DLIkNVnQ.mjs.map