@strapi/content-manager 0.0.0-experimental.4ddd402c7194d1a969a797313bf007c93148d59a → 0.0.0-experimental.51e87e311df34df634a6bce7b841df8be31f1efb

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 (226) 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-Cxz51Sve.mjs → ComponentConfigurationPage-D4H-v0et.mjs} +4 -4
  5. package/dist/_chunks/{ComponentConfigurationPage-Cxz51Sve.mjs.map → ComponentConfigurationPage-D4H-v0et.mjs.map} +1 -1
  6. package/dist/_chunks/{ComponentConfigurationPage-BZIaEffq.js → ComponentConfigurationPage-DdkVGfXC.js} +5 -6
  7. package/dist/_chunks/{ComponentConfigurationPage-BZIaEffq.js.map → ComponentConfigurationPage-DdkVGfXC.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-CZLbgfIp.mjs → EditConfigurationPage-D1nvB7Br.mjs} +4 -4
  12. package/dist/_chunks/{EditConfigurationPage-CZLbgfIp.mjs.map → EditConfigurationPage-D1nvB7Br.mjs.map} +1 -1
  13. package/dist/_chunks/{EditConfigurationPage-CM62NN0L.js → EditConfigurationPage-LYEvR4fW.js} +5 -6
  14. package/dist/_chunks/{EditConfigurationPage-CM62NN0L.js.map → EditConfigurationPage-LYEvR4fW.js.map} +1 -1
  15. package/dist/_chunks/EditViewPage-Bcnff6Vd.mjs +191 -0
  16. package/dist/_chunks/EditViewPage-Bcnff6Vd.mjs.map +1 -0
  17. package/dist/_chunks/{EditViewPage-CU7724gt.js → EditViewPage-DqelJ9UK.js} +71 -84
  18. package/dist/_chunks/EditViewPage-DqelJ9UK.js.map +1 -0
  19. package/dist/_chunks/FieldTypeIcon-CMlNO8PE.mjs.map +1 -1
  20. package/dist/_chunks/FieldTypeIcon-Dnwq_IRF.js.map +1 -1
  21. package/dist/_chunks/{Form-BOR8NOe1.js → Form-CnHfBeiB.js} +55 -38
  22. package/dist/_chunks/Form-CnHfBeiB.js.map +1 -0
  23. package/dist/_chunks/{Form-COLpvlnv.mjs → Form-CzPCJi3B.mjs} +55 -37
  24. package/dist/_chunks/Form-CzPCJi3B.mjs.map +1 -0
  25. package/dist/_chunks/{History-Bu53Yfw-.mjs → History-CcmSn3Mj.mjs} +201 -130
  26. package/dist/_chunks/History-CcmSn3Mj.mjs.map +1 -0
  27. package/dist/_chunks/{History-CW2akQ6h.js → History-zArjENzj.js} +208 -138
  28. package/dist/_chunks/History-zArjENzj.js.map +1 -0
  29. package/dist/_chunks/{Field-Dh1yZyqy.js → Input-CDHKQd7o.js} +1748 -1373
  30. package/dist/_chunks/Input-CDHKQd7o.js.map +1 -0
  31. package/dist/_chunks/{Field-QtUSh5mU.mjs → Input-aV8SSoTa.mjs} +1757 -1382
  32. package/dist/_chunks/Input-aV8SSoTa.mjs.map +1 -0
  33. package/dist/_chunks/{ListConfigurationPage-TqrmwjPN.mjs → ListConfigurationPage-BPvzENJJ.mjs} +63 -52
  34. package/dist/_chunks/ListConfigurationPage-BPvzENJJ.mjs.map +1 -0
  35. package/dist/_chunks/{ListConfigurationPage-jzdhEk_u.js → ListConfigurationPage-ByZAO_9H.js} +62 -51
  36. package/dist/_chunks/ListConfigurationPage-ByZAO_9H.js.map +1 -0
  37. package/dist/_chunks/{ListViewPage-B3bMOrMv.js → ListViewPage-BVKBeQAA.js} +154 -128
  38. package/dist/_chunks/ListViewPage-BVKBeQAA.js.map +1 -0
  39. package/dist/_chunks/{ListViewPage-BO_mOXIl.mjs → ListViewPage-HljQVnFH.mjs} +155 -128
  40. package/dist/_chunks/ListViewPage-HljQVnFH.mjs.map +1 -0
  41. package/dist/_chunks/{NoContentTypePage-D77xsNHj.js → NoContentTypePage-BV5zfDxr.js} +2 -2
  42. package/dist/_chunks/{NoContentTypePage-D77xsNHj.js.map → NoContentTypePage-BV5zfDxr.js.map} +1 -1
  43. package/dist/_chunks/{NoContentTypePage-DqB0QV0k.mjs → NoContentTypePage-BfHaSM-K.mjs} +2 -2
  44. package/dist/_chunks/{NoContentTypePage-DqB0QV0k.mjs.map → NoContentTypePage-BfHaSM-K.mjs.map} +1 -1
  45. package/dist/_chunks/{NoPermissionsPage-DTXi042N.mjs → NoPermissionsPage-D6ze2nQL.mjs} +2 -2
  46. package/dist/_chunks/{NoPermissionsPage-DTXi042N.mjs.map → NoPermissionsPage-D6ze2nQL.mjs.map} +1 -1
  47. package/dist/_chunks/{NoPermissionsPage-C6qTGogm.js → NoPermissionsPage-vdNpc6jb.js} +2 -2
  48. package/dist/_chunks/{NoPermissionsPage-C6qTGogm.js.map → NoPermissionsPage-vdNpc6jb.js.map} +1 -1
  49. package/dist/_chunks/Preview-DEHdENT1.js +305 -0
  50. package/dist/_chunks/Preview-DEHdENT1.js.map +1 -0
  51. package/dist/_chunks/Preview-vfWOtPG5.mjs +287 -0
  52. package/dist/_chunks/Preview-vfWOtPG5.mjs.map +1 -0
  53. package/dist/_chunks/{Relations-CJ4qdkRo.mjs → Relations-B7_hbF0w.mjs} +79 -44
  54. package/dist/_chunks/Relations-B7_hbF0w.mjs.map +1 -0
  55. package/dist/_chunks/{Relations-B6fb2POW.js → Relations-DcoOBejP.js} +79 -45
  56. package/dist/_chunks/Relations-DcoOBejP.js.map +1 -0
  57. package/dist/_chunks/{en-DZXjRiWA.js → en-BR48D_RH.js} +41 -18
  58. package/dist/_chunks/{en-DZXjRiWA.js.map → en-BR48D_RH.js.map} +1 -1
  59. package/dist/_chunks/{en-9GwRW_ku.mjs → en-D65uIF6Y.mjs} +41 -18
  60. package/dist/_chunks/{en-9GwRW_ku.mjs.map → en-D65uIF6Y.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-B7kGGg3E.js → fr-C43IbhA_.js} +16 -3
  66. package/dist/_chunks/{fr-B7kGGg3E.js.map → fr-C43IbhA_.js.map} +1 -1
  67. package/dist/_chunks/{fr-CD9VFbPM.mjs → fr-DBseuRuB.mjs} +16 -3
  68. package/dist/_chunks/{fr-CD9VFbPM.mjs.map → fr-DBseuRuB.mjs.map} +1 -1
  69. package/dist/_chunks/hooks-BAaaKPS_.js.map +1 -1
  70. package/dist/_chunks/{index-DcUu-_72.js → index-CxLSGwnk.js} +1504 -960
  71. package/dist/_chunks/index-CxLSGwnk.js.map +1 -0
  72. package/dist/_chunks/{index-Dahjdw4h.mjs → index-EH8ZtHd5.mjs} +1524 -980
  73. package/dist/_chunks/index-EH8ZtHd5.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-omucV6TV.mjs → layout-CxDMdJ13.mjs} +28 -15
  79. package/dist/_chunks/layout-CxDMdJ13.mjs.map +1 -0
  80. package/dist/_chunks/{layout-jcY4dyUG.js → layout-DSeUTfMv.js} +27 -15
  81. package/dist/_chunks/layout-DSeUTfMv.js.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-CN0-aw6p.mjs → relations-B8_Uu38Q.mjs} +21 -8
  87. package/dist/_chunks/relations-B8_Uu38Q.mjs.map +1 -0
  88. package/dist/_chunks/{relations-DGzD7ORa.js → relations-S5nNKdN3.js} +20 -7
  89. package/dist/_chunks/relations-S5nNKdN3.js.map +1 -0
  90. package/dist/_chunks/{useDragAndDrop-J0TUUbR6.js → useDragAndDrop-BMtgCYzL.js} +5 -9
  91. package/dist/_chunks/{useDragAndDrop-J0TUUbR6.js.map → useDragAndDrop-BMtgCYzL.js.map} +1 -1
  92. package/dist/_chunks/{useDragAndDrop-DdHgKsqq.mjs → useDragAndDrop-DJ6jqvZN.mjs} +4 -7
  93. package/dist/_chunks/{useDragAndDrop-DdHgKsqq.mjs.map → useDragAndDrop-DJ6jqvZN.mjs.map} +1 -1
  94. package/dist/_chunks/usePrev-B9w_-eYc.js.map +1 -1
  95. package/dist/_chunks/usePrev-DH6iah0A.mjs.map +1 -1
  96. package/dist/admin/index.js +3 -1
  97. package/dist/admin/index.js.map +1 -1
  98. package/dist/admin/index.mjs +6 -4
  99. package/dist/admin/src/content-manager.d.ts +3 -2
  100. package/dist/admin/src/exports.d.ts +2 -1
  101. package/dist/admin/src/history/components/VersionInputRenderer.d.ts +1 -1
  102. package/dist/admin/src/history/index.d.ts +3 -0
  103. package/dist/admin/src/history/services/historyVersion.d.ts +1 -1
  104. package/dist/admin/src/hooks/useDocument.d.ts +49 -1
  105. package/dist/admin/src/index.d.ts +1 -0
  106. package/dist/admin/src/pages/EditView/EditViewPage.d.ts +9 -1
  107. package/dist/admin/src/pages/EditView/components/DocumentActions.d.ts +9 -4
  108. package/dist/admin/src/pages/EditView/components/DocumentStatus.d.ts +3 -3
  109. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/Code.d.ts +7 -0
  110. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/utils/prismLanguages.d.ts +49 -0
  111. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/utils/constants.d.ts +5 -0
  112. package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.d.ts +4 -1
  113. package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/Field.d.ts +4 -1
  114. package/dist/admin/src/pages/EditView/components/FormInputs/Relations.d.ts +20 -0
  115. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/EditorLayout.d.ts +2 -2
  116. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygFooter.d.ts +2 -2
  117. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygStyles.d.ts +6 -58
  118. package/dist/admin/src/pages/EditView/components/FormLayout.d.ts +27 -0
  119. package/dist/admin/src/pages/EditView/components/Header.d.ts +11 -11
  120. package/dist/admin/src/pages/EditView/utils/data.d.ts +1 -0
  121. package/dist/admin/src/pages/ListView/components/BulkActions/Actions.d.ts +3 -30
  122. package/dist/admin/src/pages/ListView/components/BulkActions/ConfirmBulkActionDialog.d.ts +2 -2
  123. package/dist/admin/src/preview/components/PreviewContent.d.ts +2 -0
  124. package/dist/admin/src/preview/components/PreviewHeader.d.ts +2 -0
  125. package/dist/admin/src/preview/components/PreviewSidePanel.d.ts +3 -0
  126. package/dist/admin/src/preview/index.d.ts +4 -0
  127. package/dist/admin/src/preview/pages/Preview.d.ts +11 -0
  128. package/dist/admin/src/preview/routes.d.ts +3 -0
  129. package/dist/admin/src/preview/services/preview.d.ts +3 -0
  130. package/dist/admin/src/router.d.ts +1 -1
  131. package/dist/admin/src/services/api.d.ts +1 -1
  132. package/dist/admin/src/services/components.d.ts +2 -2
  133. package/dist/admin/src/services/contentTypes.d.ts +3 -3
  134. package/dist/admin/src/services/documents.d.ts +19 -20
  135. package/dist/admin/src/services/init.d.ts +1 -1
  136. package/dist/admin/src/services/relations.d.ts +2 -2
  137. package/dist/admin/src/services/uid.d.ts +3 -3
  138. package/dist/admin/src/utils/validation.d.ts +4 -1
  139. package/dist/server/index.js +765 -434
  140. package/dist/server/index.js.map +1 -1
  141. package/dist/server/index.mjs +766 -434
  142. package/dist/server/index.mjs.map +1 -1
  143. package/dist/server/src/bootstrap.d.ts.map +1 -1
  144. package/dist/server/src/controllers/collection-types.d.ts.map +1 -1
  145. package/dist/server/src/controllers/index.d.ts.map +1 -1
  146. package/dist/server/src/controllers/relations.d.ts.map +1 -1
  147. package/dist/server/src/controllers/uid.d.ts.map +1 -1
  148. package/dist/server/src/controllers/utils/metadata.d.ts +16 -1
  149. package/dist/server/src/controllers/utils/metadata.d.ts.map +1 -1
  150. package/dist/server/src/controllers/validation/dimensions.d.ts +4 -2
  151. package/dist/server/src/controllers/validation/dimensions.d.ts.map +1 -1
  152. package/dist/server/src/history/controllers/history-version.d.ts +1 -1
  153. package/dist/server/src/history/controllers/history-version.d.ts.map +1 -1
  154. package/dist/server/src/history/services/history.d.ts +3 -3
  155. package/dist/server/src/history/services/history.d.ts.map +1 -1
  156. package/dist/server/src/history/services/lifecycles.d.ts.map +1 -1
  157. package/dist/server/src/history/services/utils.d.ts +8 -12
  158. package/dist/server/src/history/services/utils.d.ts.map +1 -1
  159. package/dist/server/src/index.d.ts +7 -6
  160. package/dist/server/src/index.d.ts.map +1 -1
  161. package/dist/server/src/policies/hasPermissions.d.ts.map +1 -1
  162. package/dist/server/src/preview/controllers/index.d.ts +2 -0
  163. package/dist/server/src/preview/controllers/index.d.ts.map +1 -0
  164. package/dist/server/src/preview/controllers/preview.d.ts +13 -0
  165. package/dist/server/src/preview/controllers/preview.d.ts.map +1 -0
  166. package/dist/server/src/preview/controllers/validation/preview.d.ts +6 -0
  167. package/dist/server/src/preview/controllers/validation/preview.d.ts.map +1 -0
  168. package/dist/server/src/preview/index.d.ts +4 -0
  169. package/dist/server/src/preview/index.d.ts.map +1 -0
  170. package/dist/server/src/preview/routes/index.d.ts +8 -0
  171. package/dist/server/src/preview/routes/index.d.ts.map +1 -0
  172. package/dist/server/src/preview/routes/preview.d.ts +4 -0
  173. package/dist/server/src/preview/routes/preview.d.ts.map +1 -0
  174. package/dist/server/src/preview/services/index.d.ts +16 -0
  175. package/dist/server/src/preview/services/index.d.ts.map +1 -0
  176. package/dist/server/src/preview/services/preview-config.d.ts +32 -0
  177. package/dist/server/src/preview/services/preview-config.d.ts.map +1 -0
  178. package/dist/server/src/preview/services/preview.d.ts +12 -0
  179. package/dist/server/src/preview/services/preview.d.ts.map +1 -0
  180. package/dist/server/src/preview/utils.d.ts +19 -0
  181. package/dist/server/src/preview/utils.d.ts.map +1 -0
  182. package/dist/server/src/register.d.ts.map +1 -1
  183. package/dist/server/src/routes/index.d.ts.map +1 -1
  184. package/dist/server/src/services/document-manager.d.ts.map +1 -1
  185. package/dist/server/src/services/document-metadata.d.ts +12 -10
  186. package/dist/server/src/services/document-metadata.d.ts.map +1 -1
  187. package/dist/server/src/services/index.d.ts +7 -6
  188. package/dist/server/src/services/index.d.ts.map +1 -1
  189. package/dist/server/src/services/permission-checker.d.ts.map +1 -1
  190. package/dist/server/src/services/utils/populate.d.ts +2 -2
  191. package/dist/server/src/services/utils/populate.d.ts.map +1 -1
  192. package/dist/server/src/utils/index.d.ts +2 -0
  193. package/dist/server/src/utils/index.d.ts.map +1 -1
  194. package/dist/shared/contracts/collection-types.d.ts +3 -1
  195. package/dist/shared/contracts/collection-types.d.ts.map +1 -1
  196. package/dist/shared/contracts/index.d.ts +1 -0
  197. package/dist/shared/contracts/index.d.ts.map +1 -1
  198. package/dist/shared/contracts/preview.d.ts +27 -0
  199. package/dist/shared/contracts/preview.d.ts.map +1 -0
  200. package/dist/shared/index.js +4 -0
  201. package/dist/shared/index.js.map +1 -1
  202. package/dist/shared/index.mjs +4 -0
  203. package/dist/shared/index.mjs.map +1 -1
  204. package/package.json +17 -16
  205. package/dist/_chunks/EditViewPage-CU7724gt.js.map +0 -1
  206. package/dist/_chunks/EditViewPage-CzuJgWWp.mjs +0 -203
  207. package/dist/_chunks/EditViewPage-CzuJgWWp.mjs.map +0 -1
  208. package/dist/_chunks/Field-Dh1yZyqy.js.map +0 -1
  209. package/dist/_chunks/Field-QtUSh5mU.mjs.map +0 -1
  210. package/dist/_chunks/Form-BOR8NOe1.js.map +0 -1
  211. package/dist/_chunks/Form-COLpvlnv.mjs.map +0 -1
  212. package/dist/_chunks/History-Bu53Yfw-.mjs.map +0 -1
  213. package/dist/_chunks/History-CW2akQ6h.js.map +0 -1
  214. package/dist/_chunks/ListConfigurationPage-TqrmwjPN.mjs.map +0 -1
  215. package/dist/_chunks/ListConfigurationPage-jzdhEk_u.js.map +0 -1
  216. package/dist/_chunks/ListViewPage-B3bMOrMv.js.map +0 -1
  217. package/dist/_chunks/ListViewPage-BO_mOXIl.mjs.map +0 -1
  218. package/dist/_chunks/Relations-B6fb2POW.js.map +0 -1
  219. package/dist/_chunks/Relations-CJ4qdkRo.mjs.map +0 -1
  220. package/dist/_chunks/index-Dahjdw4h.mjs.map +0 -1
  221. package/dist/_chunks/index-DcUu-_72.js.map +0 -1
  222. package/dist/_chunks/layout-jcY4dyUG.js.map +0 -1
  223. package/dist/_chunks/layout-omucV6TV.mjs.map +0 -1
  224. package/dist/_chunks/relations-CN0-aw6p.mjs.map +0 -1
  225. package/dist/_chunks/relations-DGzD7ORa.js.map +0 -1
  226. package/strapi-server.js +0 -3
@@ -1,25 +1,34 @@
1
- import { ClockCounterClockwise, CrossCircle, More, WarningCircle, ListPlus, Pencil, Trash, Check, CheckCircle, ArrowsCounterClockwise, ChevronRight, Duplicate, Feather } from "@strapi/icons";
1
+ import { More, Cross, WarningCircle, ListPlus, Pencil, Trash, Check, CheckCircle, ArrowsCounterClockwise, CrossCircle, 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, RawTable, Loader, Tbody, Tr, Td, 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 { generateNKeysBetween } from "fractional-indexing";
13
14
  import pipe from "lodash/fp/pipe";
15
+ import { stringify } from "qs";
14
16
  import { intervalToDuration, isPast } from "date-fns";
15
17
  import { createSlice, combineReducers } from "@reduxjs/toolkit";
16
- const __variableDynamicImportRuntimeHelper = (glob, path) => {
18
+ const __variableDynamicImportRuntimeHelper = (glob, path, segs) => {
17
19
  const v = glob[path];
18
20
  if (v) {
19
21
  return typeof v === "function" ? v() : Promise.resolve(v);
20
22
  }
21
23
  return new Promise((_, reject) => {
22
- (typeof queueMicrotask === "function" ? queueMicrotask : setTimeout)(reject.bind(null, new Error("Unknown variable dynamic import: " + path)));
24
+ (typeof queueMicrotask === "function" ? queueMicrotask : setTimeout)(
25
+ reject.bind(
26
+ null,
27
+ new Error(
28
+ "Unknown variable dynamic import: " + path + (path.split("/").length !== segs ? ". Note that variables only represent file names one level deep." : "")
29
+ )
30
+ )
31
+ );
23
32
  });
24
33
  };
25
34
  const PLUGIN_ID = "content-manager";
@@ -49,42 +58,6 @@ const useInjectionZone = (area) => {
49
58
  const [page, position] = area.split(".");
50
59
  return contentManagerPlugin.getInjectedComponents(page, position);
51
60
  };
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
61
  const ID = "id";
89
62
  const CREATED_BY_ATTRIBUTE_NAME = "createdBy";
90
63
  const UPDATED_BY_ATTRIBUTE_NAME = "updatedBy";
@@ -136,6 +109,7 @@ const DocumentRBAC = ({ children, permissions }) => {
136
109
  if (!slug) {
137
110
  throw new Error("Cannot find the slug param in the URL");
138
111
  }
112
+ const [{ rawQuery }] = useQueryParams();
139
113
  const userPermissions = useAuth("DocumentRBAC", (state) => state.permissions);
140
114
  const contentTypePermissions = React.useMemo(() => {
141
115
  const contentTypePermissions2 = userPermissions.filter(
@@ -146,7 +120,14 @@ const DocumentRBAC = ({ children, permissions }) => {
146
120
  return { ...acc, [action]: [permission] };
147
121
  }, {});
148
122
  }, [slug, userPermissions]);
149
- const { isLoading, allowedActions } = useRBAC(contentTypePermissions, permissions ?? void 0);
123
+ const { isLoading, allowedActions } = useRBAC(
124
+ contentTypePermissions,
125
+ permissions ?? void 0,
126
+ // TODO: useRBAC context should be typed and built differently
127
+ // We are passing raw query as context to the hook so that it can
128
+ // rely on the locale provided from DocumentRBAC for its permission calculations.
129
+ rawQuery
130
+ );
150
131
  const canCreateFields = !isLoading && allowedActions.canCreate ? extractAndDedupeFields(contentTypePermissions.create) : [];
151
132
  const canReadFields = !isLoading && allowedActions.canRead ? extractAndDedupeFields(contentTypePermissions.read) : [];
152
133
  const canUpdateFields = !isLoading && allowedActions.canUpdate ? extractAndDedupeFields(contentTypePermissions.update) : [];
@@ -186,6 +167,113 @@ const extractAndDedupeFields = (permissions = []) => permissions.flatMap((permis
186
167
  (field, index2, arr) => arr.indexOf(field) === index2 && typeof field === "string"
187
168
  );
188
169
  const removeNumericalStrings = (arr) => arr.filter((item) => isNaN(Number(item)));
170
+ const BLOCK_LIST_ATTRIBUTE_KEYS = ["__component", "__temp_key__"];
171
+ const traverseData = (predicate, transform) => (schema, components = {}) => (data = {}) => {
172
+ const traverse = (datum, attributes) => {
173
+ return Object.entries(datum).reduce((acc, [key, value]) => {
174
+ const attribute = attributes[key];
175
+ if (BLOCK_LIST_ATTRIBUTE_KEYS.includes(key) || value === null || value === void 0) {
176
+ acc[key] = value;
177
+ return acc;
178
+ }
179
+ if (attribute.type === "component") {
180
+ if (attribute.repeatable) {
181
+ const componentValue = predicate(attribute, value) ? transform(value, attribute) : value;
182
+ acc[key] = componentValue.map(
183
+ (componentData) => traverse(componentData, components[attribute.component]?.attributes ?? {})
184
+ );
185
+ } else {
186
+ const componentValue = predicate(attribute, value) ? transform(value, attribute) : value;
187
+ acc[key] = traverse(componentValue, components[attribute.component]?.attributes ?? {});
188
+ }
189
+ } else if (attribute.type === "dynamiczone") {
190
+ const dynamicZoneValue = predicate(attribute, value) ? transform(value, attribute) : value;
191
+ acc[key] = dynamicZoneValue.map(
192
+ (componentData) => traverse(componentData, components[componentData.__component]?.attributes ?? {})
193
+ );
194
+ } else if (predicate(attribute, value)) {
195
+ acc[key] = transform(value, attribute);
196
+ } else {
197
+ acc[key] = value;
198
+ }
199
+ return acc;
200
+ }, {});
201
+ };
202
+ return traverse(data, schema.attributes);
203
+ };
204
+ const removeProhibitedFields = (prohibitedFields) => traverseData(
205
+ (attribute) => prohibitedFields.includes(attribute.type),
206
+ () => ""
207
+ );
208
+ const prepareRelations = traverseData(
209
+ (attribute) => attribute.type === "relation",
210
+ () => ({
211
+ connect: [],
212
+ disconnect: []
213
+ })
214
+ );
215
+ const prepareTempKeys = traverseData(
216
+ (attribute) => attribute.type === "component" && attribute.repeatable || attribute.type === "dynamiczone",
217
+ (data) => {
218
+ if (Array.isArray(data) && data.length > 0) {
219
+ const keys = generateNKeysBetween(void 0, void 0, data.length);
220
+ return data.map((datum, index2) => ({
221
+ ...datum,
222
+ __temp_key__: keys[index2]
223
+ }));
224
+ }
225
+ return data;
226
+ }
227
+ );
228
+ const removeFieldsThatDontExistOnSchema = (schema) => (data) => {
229
+ const schemaKeys = Object.keys(schema.attributes);
230
+ const dataKeys = Object.keys(data);
231
+ const keysToRemove = dataKeys.filter((key) => !schemaKeys.includes(key));
232
+ const revisedData = [...keysToRemove, ...DOCUMENT_META_FIELDS].reduce((acc, key) => {
233
+ delete acc[key];
234
+ return acc;
235
+ }, structuredClone(data));
236
+ return revisedData;
237
+ };
238
+ const removeNullValues = (data) => {
239
+ return Object.entries(data).reduce((acc, [key, value]) => {
240
+ if (value === null) {
241
+ return acc;
242
+ }
243
+ acc[key] = value;
244
+ return acc;
245
+ }, {});
246
+ };
247
+ const transformDocument = (schema, components = {}) => (document) => {
248
+ const transformations = pipe(
249
+ removeFieldsThatDontExistOnSchema(schema),
250
+ removeProhibitedFields(["password"])(schema, components),
251
+ removeNullValues,
252
+ prepareRelations(schema, components),
253
+ prepareTempKeys(schema, components)
254
+ );
255
+ return transformations(document);
256
+ };
257
+ const createDefaultForm = (contentType, components = {}) => {
258
+ const traverseSchema = (attributes) => {
259
+ return Object.entries(attributes).reduce((acc, [key, attribute]) => {
260
+ if ("default" in attribute) {
261
+ acc[key] = attribute.default;
262
+ } else if (attribute.type === "component" && attribute.required) {
263
+ const defaultComponentForm = traverseSchema(components[attribute.component].attributes);
264
+ if (attribute.repeatable) {
265
+ acc[key] = attribute.min ? [...Array(attribute.min).fill(defaultComponentForm)] : [];
266
+ } else {
267
+ acc[key] = defaultComponentForm;
268
+ }
269
+ } else if (attribute.type === "dynamiczone" && attribute.required) {
270
+ acc[key] = [];
271
+ }
272
+ return acc;
273
+ }, {});
274
+ };
275
+ return traverseSchema(contentType.attributes);
276
+ };
189
277
  const contentManagerApi = adminApi.enhanceEndpoints({
190
278
  addTagTypes: [
191
279
  "ComponentConfiguration",
@@ -194,10 +282,13 @@ const contentManagerApi = adminApi.enhanceEndpoints({
194
282
  "Document",
195
283
  "InitialData",
196
284
  "HistoryVersion",
197
- "Relations"
285
+ "Relations",
286
+ "UidAvailability",
287
+ "RecentDocumentList"
198
288
  ]
199
289
  });
200
290
  const documentApi = contentManagerApi.injectEndpoints({
291
+ overrideExisting: true,
201
292
  endpoints: (builder) => ({
202
293
  autoCloneDocument: builder.mutation({
203
294
  query: ({ model, sourceId, query }) => ({
@@ -207,7 +298,12 @@ const documentApi = contentManagerApi.injectEndpoints({
207
298
  params: query
208
299
  }
209
300
  }),
210
- invalidatesTags: (_result, _error, { model }) => [{ type: "Document", id: `${model}_LIST` }]
301
+ invalidatesTags: (_result, error, { model }) => {
302
+ if (error) {
303
+ return [];
304
+ }
305
+ return [{ type: "Document", id: `${model}_LIST` }, "RecentDocumentList"];
306
+ }
211
307
  }),
212
308
  cloneDocument: builder.mutation({
213
309
  query: ({ model, sourceId, data, params }) => ({
@@ -218,7 +314,11 @@ const documentApi = contentManagerApi.injectEndpoints({
218
314
  params
219
315
  }
220
316
  }),
221
- invalidatesTags: (_result, _error, { model }) => [{ type: "Document", id: `${model}_LIST` }]
317
+ invalidatesTags: (_result, _error, { model }) => [
318
+ { type: "Document", id: `${model}_LIST` },
319
+ { type: "UidAvailability", id: model },
320
+ "RecentDocumentList"
321
+ ]
222
322
  }),
223
323
  /**
224
324
  * Creates a new collection-type document. This should ONLY be used for collection-types.
@@ -235,8 +335,22 @@ const documentApi = contentManagerApi.injectEndpoints({
235
335
  }),
236
336
  invalidatesTags: (result, _error, { model }) => [
237
337
  { type: "Document", id: `${model}_LIST` },
238
- "Relations"
239
- ]
338
+ "Relations",
339
+ { type: "UidAvailability", id: model },
340
+ "RecentDocumentList"
341
+ ],
342
+ transformResponse: (response, meta, arg) => {
343
+ if (!("data" in response) && arg.model === "plugin::users-permissions.user") {
344
+ return {
345
+ data: response,
346
+ meta: {
347
+ availableStatus: [],
348
+ availableLocales: []
349
+ }
350
+ };
351
+ }
352
+ return response;
353
+ }
240
354
  }),
241
355
  deleteDocument: builder.mutation({
242
356
  query: ({ collectionType, model, documentId, params }) => ({
@@ -247,7 +361,8 @@ const documentApi = contentManagerApi.injectEndpoints({
247
361
  }
248
362
  }),
249
363
  invalidatesTags: (_result, _error, { collectionType, model }) => [
250
- { type: "Document", id: collectionType !== SINGLE_TYPES ? `${model}_LIST` : model }
364
+ { type: "Document", id: collectionType !== SINGLE_TYPES ? `${model}_LIST` : model },
365
+ "RecentDocumentList"
251
366
  ]
252
367
  }),
253
368
  deleteManyDocuments: builder.mutation({
@@ -259,7 +374,10 @@ const documentApi = contentManagerApi.injectEndpoints({
259
374
  params
260
375
  }
261
376
  }),
262
- invalidatesTags: (_res, _error, { model }) => [{ type: "Document", id: `${model}_LIST` }]
377
+ invalidatesTags: (_res, _error, { model }) => [
378
+ { type: "Document", id: `${model}_LIST` },
379
+ "RecentDocumentList"
380
+ ]
263
381
  }),
264
382
  discardDocument: builder.mutation({
265
383
  query: ({ collectionType, model, documentId, params }) => ({
@@ -276,7 +394,9 @@ const documentApi = contentManagerApi.injectEndpoints({
276
394
  id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
277
395
  },
278
396
  { type: "Document", id: `${model}_LIST` },
279
- "Relations"
397
+ "Relations",
398
+ { type: "UidAvailability", id: model },
399
+ "RecentDocumentList"
280
400
  ];
281
401
  }
282
402
  }),
@@ -289,11 +409,12 @@ const documentApi = contentManagerApi.injectEndpoints({
289
409
  url: `/content-manager/collection-types/${model}`,
290
410
  method: "GET",
291
411
  config: {
292
- params
412
+ params: stringify(params, { encode: true })
293
413
  }
294
414
  }),
295
415
  providesTags: (result, _error, arg) => {
296
416
  return [
417
+ { type: "Document", id: `ALL_LIST` },
297
418
  { type: "Document", id: `${arg.model}_LIST` },
298
419
  ...result?.results.map(({ documentId }) => ({
299
420
  type: "Document",
@@ -332,6 +453,11 @@ const documentApi = contentManagerApi.injectEndpoints({
332
453
  {
333
454
  type: "Document",
334
455
  id: collectionType !== SINGLE_TYPES ? `${model}_${result && "documentId" in result ? result.documentId : documentId}` : model
456
+ },
457
+ // Make it easy to invalidate all individual documents queries for a model
458
+ {
459
+ type: "Document",
460
+ id: `${model}_ALL_ITEMS`
335
461
  }
336
462
  ];
337
463
  }
@@ -365,7 +491,8 @@ const documentApi = contentManagerApi.injectEndpoints({
365
491
  id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
366
492
  },
367
493
  { type: "Document", id: `${model}_LIST` },
368
- "Relations"
494
+ "Relations",
495
+ "RecentDocumentList"
369
496
  ];
370
497
  }
371
498
  }),
@@ -395,8 +522,23 @@ const documentApi = contentManagerApi.injectEndpoints({
395
522
  type: "Document",
396
523
  id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
397
524
  },
398
- "Relations"
525
+ "Relations",
526
+ { type: "UidAvailability", id: model },
527
+ "RecentDocumentList",
528
+ "RecentDocumentList"
399
529
  ];
530
+ },
531
+ async onQueryStarted({ data, ...patch }, { dispatch, queryFulfilled }) {
532
+ const patchResult = dispatch(
533
+ documentApi.util.updateQueryData("getDocument", patch, (draft) => {
534
+ Object.assign(draft.data, data);
535
+ })
536
+ );
537
+ try {
538
+ await queryFulfilled;
539
+ } catch {
540
+ patchResult.undo();
541
+ }
400
542
  }
401
543
  }),
402
544
  unpublishDocument: builder.mutation({
@@ -413,7 +555,8 @@ const documentApi = contentManagerApi.injectEndpoints({
413
555
  {
414
556
  type: "Document",
415
557
  id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
416
- }
558
+ },
559
+ "RecentDocumentList"
417
560
  ];
418
561
  }
419
562
  }),
@@ -426,7 +569,10 @@ const documentApi = contentManagerApi.injectEndpoints({
426
569
  params
427
570
  }
428
571
  }),
429
- invalidatesTags: (_res, _error, { model, documentIds }) => documentIds.map((id) => ({ type: "Document", id: `${model}_${id}` }))
572
+ invalidatesTags: (_res, _error, { model, documentIds }) => [
573
+ ...documentIds.map((id) => ({ type: "Document", id: `${model}_${id}` })),
574
+ "RecentDocumentList"
575
+ ]
430
576
  })
431
577
  })
432
578
  });
@@ -449,8 +595,7 @@ const {
449
595
  useUnpublishManyDocumentsMutation
450
596
  } = documentApi;
451
597
  const buildValidParams = (query) => {
452
- if (!query)
453
- return query;
598
+ if (!query) return query;
454
599
  const { plugins: _, ...validQueryParams } = {
455
600
  ...query,
456
601
  ...Object.values(query?.plugins ?? {}).reduce(
@@ -458,28 +603,44 @@ const buildValidParams = (query) => {
458
603
  {}
459
604
  )
460
605
  };
461
- if ("_q" in validQueryParams) {
462
- validQueryParams._q = encodeURIComponent(validQueryParams._q);
463
- }
464
606
  return validQueryParams;
465
607
  };
466
608
  const isBaseQueryError = (error) => {
467
609
  return error.name !== void 0;
468
610
  };
469
- const createYupSchema = (attributes = {}, components = {}) => {
611
+ const arrayValidator = (attribute, options) => ({
612
+ message: translatedErrors.required,
613
+ test(value) {
614
+ if (options.status === "draft") {
615
+ return true;
616
+ }
617
+ if (!attribute.required) {
618
+ return true;
619
+ }
620
+ if (!value) {
621
+ return false;
622
+ }
623
+ if (Array.isArray(value) && value.length === 0) {
624
+ return false;
625
+ }
626
+ return true;
627
+ }
628
+ });
629
+ const createYupSchema = (attributes = {}, components = {}, options = { status: null }) => {
470
630
  const createModelSchema = (attributes2) => yup.object().shape(
471
631
  Object.entries(attributes2).reduce((acc, [name, attribute]) => {
472
632
  if (DOCUMENT_META_FIELDS.includes(name)) {
473
633
  return acc;
474
634
  }
475
635
  const validations = [
636
+ addNullableValidation,
476
637
  addRequiredValidation,
477
638
  addMinLengthValidation,
478
639
  addMaxLengthValidation,
479
640
  addMinValidation,
480
641
  addMaxValidation,
481
642
  addRegexValidation
482
- ].map((fn) => fn(attribute));
643
+ ].map((fn) => fn(attribute, options));
483
644
  const transformSchema = pipe(...validations);
484
645
  switch (attribute.type) {
485
646
  case "component": {
@@ -489,12 +650,12 @@ const createYupSchema = (attributes = {}, components = {}) => {
489
650
  ...acc,
490
651
  [name]: transformSchema(
491
652
  yup.array().of(createModelSchema(attributes3).nullable(false))
492
- )
653
+ ).test(arrayValidator(attribute, options))
493
654
  };
494
655
  } else {
495
656
  return {
496
657
  ...acc,
497
- [name]: transformSchema(createModelSchema(attributes3))
658
+ [name]: transformSchema(createModelSchema(attributes3).nullable())
498
659
  };
499
660
  }
500
661
  }
@@ -516,7 +677,7 @@ const createYupSchema = (attributes = {}, components = {}) => {
516
677
  }
517
678
  )
518
679
  )
519
- )
680
+ ).test(arrayValidator(attribute, options))
520
681
  };
521
682
  case "relation":
522
683
  return {
@@ -528,7 +689,7 @@ const createYupSchema = (attributes = {}, components = {}) => {
528
689
  } else if (Array.isArray(value)) {
529
690
  return yup.array().of(
530
691
  yup.object().shape({
531
- id: yup.string().required()
692
+ id: yup.number().required()
532
693
  })
533
694
  );
534
695
  } else if (typeof value === "object") {
@@ -580,6 +741,14 @@ const createAttributeSchema = (attribute) => {
580
741
  if (!value || typeof value === "string" && value.length === 0) {
581
742
  return true;
582
743
  }
744
+ if (typeof value === "object") {
745
+ try {
746
+ JSON.stringify(value);
747
+ return true;
748
+ } catch (err) {
749
+ return false;
750
+ }
751
+ }
583
752
  try {
584
753
  JSON.parse(value);
585
754
  return true;
@@ -598,13 +767,7 @@ const createAttributeSchema = (attribute) => {
598
767
  return yup.mixed();
599
768
  }
600
769
  };
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
- }
770
+ const nullableSchema = (schema) => {
608
771
  return schema?.nullable ? schema.nullable() : (
609
772
  // In some cases '.nullable' will not be available on the schema.
610
773
  // e.g. when the schema has been built using yup.lazy (e.g. for relations).
@@ -612,7 +775,22 @@ const addRequiredValidation = (attribute) => (schema) => {
612
775
  schema
613
776
  );
614
777
  };
615
- const addMinLengthValidation = (attribute) => (schema) => {
778
+ const addNullableValidation = () => (schema) => {
779
+ return nullableSchema(schema);
780
+ };
781
+ const addRequiredValidation = (attribute, options) => (schema) => {
782
+ if (options.status === "draft" || !attribute.required) {
783
+ return schema;
784
+ }
785
+ if (attribute.required && "required" in schema) {
786
+ return schema.required(translatedErrors.required);
787
+ }
788
+ return schema;
789
+ };
790
+ const addMinLengthValidation = (attribute, options) => (schema) => {
791
+ if (options.status === "draft") {
792
+ return schema;
793
+ }
616
794
  if ("minLength" in attribute && attribute.minLength && Number.isInteger(attribute.minLength) && "min" in schema) {
617
795
  return schema.min(attribute.minLength, {
618
796
  ...translatedErrors.minLength,
@@ -634,10 +812,13 @@ const addMaxLengthValidation = (attribute) => (schema) => {
634
812
  }
635
813
  return schema;
636
814
  };
637
- const addMinValidation = (attribute) => (schema) => {
638
- if ("min" in attribute) {
815
+ const addMinValidation = (attribute, options) => (schema) => {
816
+ if (options.status === "draft") {
817
+ return schema;
818
+ }
819
+ if ("min" in attribute && "min" in schema) {
639
820
  const min = toInteger(attribute.min);
640
- if ("min" in schema && min) {
821
+ if (min) {
641
822
  return schema.min(min, {
642
823
  ...translatedErrors.min,
643
824
  values: {
@@ -755,16 +936,115 @@ const extractContentTypeComponents = (attributes = {}, allComponents = {}) => {
755
936
  }, {});
756
937
  return componentsByKey;
757
938
  };
758
- const useDocument = (args, opts) => {
939
+ const HOOKS = {
940
+ /**
941
+ * Hook that allows to mutate the displayed headers of the list view table
942
+ * @constant
943
+ * @type {string}
944
+ */
945
+ INJECT_COLUMN_IN_TABLE: "Admin/CM/pages/ListView/inject-column-in-table",
946
+ /**
947
+ * Hook that allows to mutate the CM's collection types links pre-set filters
948
+ * @constant
949
+ * @type {string}
950
+ */
951
+ MUTATE_COLLECTION_TYPES_LINKS: "Admin/CM/pages/App/mutate-collection-types-links",
952
+ /**
953
+ * Hook that allows to mutate the CM's edit view layout
954
+ * @constant
955
+ * @type {string}
956
+ */
957
+ MUTATE_EDIT_VIEW_LAYOUT: "Admin/CM/pages/EditView/mutate-edit-view-layout",
958
+ /**
959
+ * Hook that allows to mutate the CM's single types links pre-set filters
960
+ * @constant
961
+ * @type {string}
962
+ */
963
+ MUTATE_SINGLE_TYPES_LINKS: "Admin/CM/pages/App/mutate-single-types-links"
964
+ };
965
+ const contentTypesApi = contentManagerApi.injectEndpoints({
966
+ endpoints: (builder) => ({
967
+ getContentTypeConfiguration: builder.query({
968
+ query: (uid) => ({
969
+ url: `/content-manager/content-types/${uid}/configuration`,
970
+ method: "GET"
971
+ }),
972
+ transformResponse: (response) => response.data,
973
+ providesTags: (_result, _error, uid) => [
974
+ { type: "ContentTypesConfiguration", id: uid },
975
+ { type: "ContentTypeSettings", id: "LIST" }
976
+ ]
977
+ }),
978
+ getAllContentTypeSettings: builder.query({
979
+ query: () => "/content-manager/content-types-settings",
980
+ transformResponse: (response) => response.data,
981
+ providesTags: [{ type: "ContentTypeSettings", id: "LIST" }]
982
+ }),
983
+ updateContentTypeConfiguration: builder.mutation({
984
+ query: ({ uid, ...body }) => ({
985
+ url: `/content-manager/content-types/${uid}/configuration`,
986
+ method: "PUT",
987
+ data: body
988
+ }),
989
+ transformResponse: (response) => response.data,
990
+ invalidatesTags: (_result, _error, { uid }) => [
991
+ { type: "ContentTypesConfiguration", id: uid },
992
+ { type: "ContentTypeSettings", id: "LIST" },
993
+ // Is this necessary?
994
+ { type: "InitialData" }
995
+ ]
996
+ })
997
+ })
998
+ });
999
+ const {
1000
+ useGetContentTypeConfigurationQuery,
1001
+ useGetAllContentTypeSettingsQuery,
1002
+ useUpdateContentTypeConfigurationMutation
1003
+ } = contentTypesApi;
1004
+ const checkIfAttributeIsDisplayable = (attribute) => {
1005
+ const { type } = attribute;
1006
+ if (type === "relation") {
1007
+ return !attribute.relation.toLowerCase().includes("morph");
1008
+ }
1009
+ return !["json", "dynamiczone", "richtext", "password", "blocks"].includes(type) && !!type;
1010
+ };
1011
+ const getMainField = (attribute, mainFieldName, { schemas, components }) => {
1012
+ if (!mainFieldName) {
1013
+ return void 0;
1014
+ }
1015
+ const mainFieldType = attribute.type === "component" ? components[attribute.component].attributes[mainFieldName].type : (
1016
+ // @ts-expect-error – `targetModel` does exist on the attribute for a relation.
1017
+ schemas.find((schema) => schema.uid === attribute.targetModel)?.attributes[mainFieldName].type
1018
+ );
1019
+ return {
1020
+ name: mainFieldName,
1021
+ type: mainFieldType ?? "string"
1022
+ };
1023
+ };
1024
+ const DEFAULT_SETTINGS = {
1025
+ bulkable: false,
1026
+ filterable: false,
1027
+ searchable: false,
1028
+ pagination: false,
1029
+ defaultSortBy: "",
1030
+ defaultSortOrder: "asc",
1031
+ mainField: "id",
1032
+ pageSize: 10
1033
+ };
1034
+ const useDocumentLayout = (model) => {
1035
+ const { schema, components } = useDocument({ model, collectionType: "" }, { skip: true });
1036
+ const [{ query }] = useQueryParams();
1037
+ const runHookWaterfall = useStrapiApp("useDocumentLayout", (state) => state.runHookWaterfall);
759
1038
  const { toggleNotification } = useNotification();
760
1039
  const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();
1040
+ const { isLoading: isLoadingSchemas, schemas } = useContentTypeSchema();
761
1041
  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);
1042
+ data,
1043
+ isLoading: isLoadingConfigs,
1044
+ error,
1045
+ isFetching: isFetchingConfigs
1046
+ } = useGetContentTypeConfigurationQuery(model);
1047
+ const isLoading = isLoadingSchemas || isFetchingConfigs || isLoadingConfigs;
768
1048
  React.useEffect(() => {
769
1049
  if (error) {
770
1050
  toggleNotification({
@@ -772,40 +1052,284 @@ const useDocument = (args, opts) => {
772
1052
  message: formatAPIError(error)
773
1053
  });
774
1054
  }
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
- }
1055
+ }, [error, formatAPIError, toggleNotification]);
1056
+ const editLayout = React.useMemo(
1057
+ () => data && !isLoading ? formatEditLayout(data, { schemas, schema, components }) : {
1058
+ layout: [],
1059
+ components: {},
1060
+ metadatas: {},
1061
+ options: {},
1062
+ settings: DEFAULT_SETTINGS
1063
+ },
1064
+ [data, isLoading, schemas, schema, components]
1065
+ );
1066
+ const listLayout = React.useMemo(() => {
1067
+ return data && !isLoading ? formatListLayout(data, { schemas, schema, components }) : {
1068
+ layout: [],
1069
+ metadatas: {},
1070
+ options: {},
1071
+ settings: DEFAULT_SETTINGS
1072
+ };
1073
+ }, [data, isLoading, schemas, schema, components]);
1074
+ const { layout: edit } = React.useMemo(
1075
+ () => runHookWaterfall(HOOKS.MUTATE_EDIT_VIEW_LAYOUT, {
1076
+ layout: editLayout,
1077
+ query
1078
+ }),
1079
+ [editLayout, query, runHookWaterfall]
1080
+ );
1081
+ return {
1082
+ error,
1083
+ isLoading,
1084
+ edit,
1085
+ list: listLayout
1086
+ };
1087
+ };
1088
+ const useDocLayout = () => {
1089
+ const { model } = useDoc();
1090
+ return useDocumentLayout(model);
1091
+ };
1092
+ const formatEditLayout = (data, {
1093
+ schemas,
1094
+ schema,
1095
+ components
1096
+ }) => {
1097
+ let currentPanelIndex = 0;
1098
+ const panelledEditAttributes = convertEditLayoutToFieldLayouts(
1099
+ data.contentType.layouts.edit,
1100
+ schema?.attributes,
1101
+ data.contentType.metadatas,
1102
+ { configurations: data.components, schemas: components },
1103
+ schemas
1104
+ ).reduce((panels, row) => {
1105
+ if (row.some((field) => field.type === "dynamiczone")) {
1106
+ panels.push([row]);
1107
+ currentPanelIndex += 2;
1108
+ } else {
1109
+ if (!panels[currentPanelIndex]) {
1110
+ panels.push([row]);
1111
+ } else {
1112
+ panels[currentPanelIndex].push(row);
1113
+ }
1114
+ }
1115
+ return panels;
1116
+ }, []);
1117
+ const componentEditAttributes = Object.entries(data.components).reduce(
1118
+ (acc, [uid, configuration]) => {
1119
+ acc[uid] = {
1120
+ layout: convertEditLayoutToFieldLayouts(
1121
+ configuration.layouts.edit,
1122
+ components[uid].attributes,
1123
+ configuration.metadatas,
1124
+ { configurations: data.components, schemas: components }
1125
+ ),
1126
+ settings: {
1127
+ ...configuration.settings,
1128
+ icon: components[uid].info.icon,
1129
+ displayName: components[uid].info.displayName
1130
+ }
1131
+ };
1132
+ return acc;
1133
+ },
1134
+ {}
1135
+ );
1136
+ const editMetadatas = Object.entries(data.contentType.metadatas).reduce(
1137
+ (acc, [attribute, metadata]) => {
1138
+ return {
1139
+ ...acc,
1140
+ [attribute]: metadata.edit
1141
+ };
1142
+ },
1143
+ {}
1144
+ );
1145
+ return {
1146
+ layout: panelledEditAttributes,
1147
+ components: componentEditAttributes,
1148
+ metadatas: editMetadatas,
1149
+ settings: {
1150
+ ...data.contentType.settings,
1151
+ displayName: schema?.info.displayName
1152
+ },
1153
+ options: {
1154
+ ...schema?.options,
1155
+ ...schema?.pluginOptions,
1156
+ ...data.contentType.options
1157
+ }
1158
+ };
1159
+ };
1160
+ const convertEditLayoutToFieldLayouts = (rows, attributes = {}, metadatas, components, schemas = []) => {
1161
+ return rows.map(
1162
+ (row) => row.map((field) => {
1163
+ const attribute = attributes[field.name];
1164
+ if (!attribute) {
1165
+ return null;
1166
+ }
1167
+ const { edit: metadata } = metadatas[field.name];
1168
+ const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
1169
+ return {
1170
+ attribute,
1171
+ disabled: !metadata.editable,
1172
+ hint: metadata.description,
1173
+ label: metadata.label ?? "",
1174
+ name: field.name,
1175
+ // @ts-expect-error – mainField does exist on the metadata for a relation.
1176
+ mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
1177
+ schemas,
1178
+ components: components?.schemas ?? {}
1179
+ }),
1180
+ placeholder: metadata.placeholder ?? "",
1181
+ required: attribute.required ?? false,
1182
+ size: field.size,
1183
+ unique: "unique" in attribute ? attribute.unique : false,
1184
+ visible: metadata.visible ?? true,
1185
+ type: attribute.type
1186
+ };
1187
+ }).filter((field) => field !== null)
1188
+ );
1189
+ };
1190
+ const formatListLayout = (data, {
1191
+ schemas,
1192
+ schema,
1193
+ components
1194
+ }) => {
1195
+ const listMetadatas = Object.entries(data.contentType.metadatas).reduce(
1196
+ (acc, [attribute, metadata]) => {
1197
+ return {
1198
+ ...acc,
1199
+ [attribute]: metadata.list
1200
+ };
1201
+ },
1202
+ {}
1203
+ );
1204
+ const listAttributes = convertListLayoutToFieldLayouts(
1205
+ data.contentType.layouts.list,
1206
+ schema?.attributes,
1207
+ listMetadatas,
1208
+ { configurations: data.components, schemas: components },
1209
+ schemas
1210
+ );
1211
+ return {
1212
+ layout: listAttributes,
1213
+ settings: { ...data.contentType.settings, displayName: schema?.info.displayName },
1214
+ metadatas: listMetadatas,
1215
+ options: {
1216
+ ...schema?.options,
1217
+ ...schema?.pluginOptions,
1218
+ ...data.contentType.options
1219
+ }
1220
+ };
1221
+ };
1222
+ const convertListLayoutToFieldLayouts = (columns, attributes = {}, metadatas, components, schemas = []) => {
1223
+ return columns.map((name) => {
1224
+ const attribute = attributes[name];
1225
+ if (!attribute) {
1226
+ return null;
1227
+ }
1228
+ const metadata = metadatas[name];
1229
+ const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
1230
+ return {
1231
+ attribute,
1232
+ label: metadata.label ?? "",
1233
+ mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
1234
+ schemas,
1235
+ components: components?.schemas ?? {}
1236
+ }),
1237
+ name,
1238
+ searchable: metadata.searchable ?? true,
1239
+ sortable: metadata.sortable ?? true
1240
+ };
1241
+ }).filter((field) => field !== null);
1242
+ };
1243
+ const useDocument = (args, opts) => {
1244
+ const { toggleNotification } = useNotification();
1245
+ const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();
1246
+ const { formatMessage } = useIntl();
1247
+ const {
1248
+ currentData: data,
1249
+ isLoading: isLoadingDocument,
1250
+ isFetching: isFetchingDocument,
1251
+ error
1252
+ } = useGetDocumentQuery(args, {
1253
+ ...opts,
1254
+ skip: !args.documentId && args.collectionType !== SINGLE_TYPES || opts?.skip
1255
+ });
1256
+ const document = data?.data;
1257
+ const meta = data?.meta;
1258
+ const {
1259
+ components,
1260
+ schema,
1261
+ schemas,
1262
+ isLoading: isLoadingSchema
1263
+ } = useContentTypeSchema(args.model);
1264
+ const isSingleType = schema?.kind === "singleType";
1265
+ const getTitle = (mainField) => {
1266
+ if (mainField !== "id" && document?.[mainField]) {
1267
+ return document[mainField];
1268
+ }
1269
+ if (isSingleType && schema?.info.displayName) {
1270
+ return schema.info.displayName;
1271
+ }
1272
+ return formatMessage({
1273
+ id: "content-manager.containers.untitled",
1274
+ defaultMessage: "Untitled"
1275
+ });
1276
+ };
1277
+ React.useEffect(() => {
1278
+ if (error) {
1279
+ toggleNotification({
1280
+ type: "danger",
1281
+ message: formatAPIError(error)
1282
+ });
1283
+ }
1284
+ }, [toggleNotification, error, formatAPIError, args.collectionType]);
1285
+ const validationSchema = React.useMemo(() => {
1286
+ if (!schema) {
1287
+ return null;
1288
+ }
1289
+ return createYupSchema(schema.attributes, components);
1290
+ }, [schema, components]);
1291
+ const validate = React.useCallback(
1292
+ (document2) => {
1293
+ if (!validationSchema) {
1294
+ throw new Error(
1295
+ "There is no validation schema generated, this is likely due to the schema not being loaded yet."
1296
+ );
1297
+ }
1298
+ try {
1299
+ validationSchema.validateSync(document2, { abortEarly: false, strict: true });
1300
+ return null;
1301
+ } catch (error2) {
1302
+ if (error2 instanceof ValidationError) {
1303
+ return getYupValidationErrors(error2);
1304
+ }
796
1305
  throw error2;
797
1306
  }
798
1307
  },
799
1308
  [validationSchema]
800
1309
  );
1310
+ const getInitialFormValues = React.useCallback(
1311
+ (isCreatingDocument = false) => {
1312
+ if (!document && !isCreatingDocument && !isSingleType || !schema) {
1313
+ return void 0;
1314
+ }
1315
+ const form = document?.id ? document : createDefaultForm(schema, components);
1316
+ return transformDocument(schema, components)(form);
1317
+ },
1318
+ [document, isSingleType, schema, components]
1319
+ );
801
1320
  const isLoading = isLoadingDocument || isFetchingDocument || isLoadingSchema;
1321
+ const hasError = !!error;
802
1322
  return {
803
1323
  components,
804
- document: data?.data,
805
- meta: data?.meta,
1324
+ document,
1325
+ meta,
806
1326
  isLoading,
1327
+ hasError,
807
1328
  schema,
808
- validate
1329
+ schemas,
1330
+ validate,
1331
+ getTitle,
1332
+ getInitialFormValues
809
1333
  };
810
1334
  };
811
1335
  const useDoc = () => {
@@ -818,22 +1342,60 @@ const useDoc = () => {
818
1342
  if (!slug) {
819
1343
  throw new Error("Could not find model in url params");
820
1344
  }
1345
+ const document = useDocument(
1346
+ { documentId: origin || id, model: slug, collectionType, params },
1347
+ {
1348
+ skip: id === "create" || !origin && !id && collectionType !== SINGLE_TYPES
1349
+ }
1350
+ );
1351
+ const returnId = origin || id === "create" ? void 0 : id;
821
1352
  return {
822
1353
  collectionType,
823
1354
  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
- )
1355
+ id: returnId,
1356
+ ...document
1357
+ };
1358
+ };
1359
+ const useContentManagerContext = () => {
1360
+ const {
1361
+ collectionType,
1362
+ model,
1363
+ id,
1364
+ components,
1365
+ isLoading: isLoadingDoc,
1366
+ schema,
1367
+ schemas
1368
+ } = useDoc();
1369
+ const layout = useDocumentLayout(model);
1370
+ const form = useForm("useContentManagerContext", (state) => state);
1371
+ const isSingleType = collectionType === SINGLE_TYPES;
1372
+ const slug = model;
1373
+ const isCreatingEntry = id === "create";
1374
+ useContentTypeSchema();
1375
+ const isLoading = isLoadingDoc || layout.isLoading;
1376
+ const error = layout.error;
1377
+ return {
1378
+ error,
1379
+ isLoading,
1380
+ // Base metadata
1381
+ model,
1382
+ collectionType,
1383
+ id,
1384
+ slug,
1385
+ isCreatingEntry,
1386
+ isSingleType,
1387
+ hasDraftAndPublish: schema?.options?.draftAndPublish ?? false,
1388
+ // All schema infos
1389
+ components,
1390
+ contentType: schema,
1391
+ contentTypes: schemas,
1392
+ // Form state
1393
+ form,
1394
+ // layout infos
1395
+ layout
831
1396
  };
832
1397
  };
833
1398
  const prefixPluginTranslations = (trad, pluginId) => {
834
- if (!pluginId) {
835
- throw new TypeError("pluginId can't be empty");
836
- }
837
1399
  return Object.keys(trad).reduce((acc, current) => {
838
1400
  acc[`${pluginId}.${current}`] = trad[current];
839
1401
  return acc;
@@ -849,6 +1411,8 @@ const useDocumentActions = () => {
849
1411
  const { formatMessage } = useIntl();
850
1412
  const { trackUsage } = useTracking();
851
1413
  const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();
1414
+ const navigate = useNavigate();
1415
+ const setCurrentStep = useGuidedTour("useDocumentActions", (state) => state.setCurrentStep);
852
1416
  const [deleteDocument] = useDeleteDocumentMutation();
853
1417
  const _delete = React.useCallback(
854
1418
  async ({ collectionType, model, documentId, params }, trackerProperty) => {
@@ -1163,6 +1727,7 @@ const useDocumentActions = () => {
1163
1727
  defaultMessage: "Saved document"
1164
1728
  })
1165
1729
  });
1730
+ setCurrentStep("contentManager.success");
1166
1731
  return res.data;
1167
1732
  } catch (err) {
1168
1733
  toggleNotification({
@@ -1184,7 +1749,6 @@ const useDocumentActions = () => {
1184
1749
  sourceId
1185
1750
  });
1186
1751
  if ("error" in res) {
1187
- toggleNotification({ type: "danger", message: formatAPIError(res.error) });
1188
1752
  return { error: res.error };
1189
1753
  }
1190
1754
  toggleNotification({
@@ -1203,7 +1767,7 @@ const useDocumentActions = () => {
1203
1767
  throw err;
1204
1768
  }
1205
1769
  },
1206
- [autoCloneDocument, formatAPIError, formatMessage, toggleNotification]
1770
+ [autoCloneDocument, formatMessage, toggleNotification]
1207
1771
  );
1208
1772
  const [cloneDocument] = useCloneDocumentMutation();
1209
1773
  const clone = React.useCallback(
@@ -1229,6 +1793,7 @@ const useDocumentActions = () => {
1229
1793
  defaultMessage: "Cloned document"
1230
1794
  })
1231
1795
  });
1796
+ navigate(`../../${res.data.data.documentId}`, { relative: "path" });
1232
1797
  return res.data;
1233
1798
  } catch (err) {
1234
1799
  toggleNotification({
@@ -1239,7 +1804,7 @@ const useDocumentActions = () => {
1239
1804
  throw err;
1240
1805
  }
1241
1806
  },
1242
- [cloneDocument, trackUsage, toggleNotification, formatMessage, formatAPIError]
1807
+ [cloneDocument, trackUsage, toggleNotification, formatMessage, formatAPIError, navigate]
1243
1808
  );
1244
1809
  const [getDoc] = useLazyGetDocumentQuery();
1245
1810
  const getDocument = React.useCallback(
@@ -1264,10 +1829,10 @@ const useDocumentActions = () => {
1264
1829
  update
1265
1830
  };
1266
1831
  };
1267
- const ProtectedHistoryPage = lazy(
1268
- () => import("./History-Bu53Yfw-.mjs").then((mod) => ({ default: mod.ProtectedHistoryPage }))
1832
+ const ProtectedHistoryPage = React.lazy(
1833
+ () => import("./History-CcmSn3Mj.mjs").then((mod) => ({ default: mod.ProtectedHistoryPage }))
1269
1834
  );
1270
- const routes$1 = [
1835
+ const routes$2 = [
1271
1836
  {
1272
1837
  path: ":collectionType/:slug/:id/history",
1273
1838
  Component: ProtectedHistoryPage
@@ -1277,32 +1842,45 @@ const routes$1 = [
1277
1842
  Component: ProtectedHistoryPage
1278
1843
  }
1279
1844
  ];
1280
- const ProtectedEditViewPage = lazy(
1281
- () => import("./EditViewPage-CzuJgWWp.mjs").then((mod) => ({ default: mod.ProtectedEditViewPage }))
1845
+ const ProtectedPreviewPage = React.lazy(
1846
+ () => import("./Preview-vfWOtPG5.mjs").then((mod) => ({ default: mod.ProtectedPreviewPage }))
1847
+ );
1848
+ const routes$1 = [
1849
+ {
1850
+ path: ":collectionType/:slug/:id/preview",
1851
+ Component: ProtectedPreviewPage
1852
+ },
1853
+ {
1854
+ path: ":collectionType/:slug/preview",
1855
+ Component: ProtectedPreviewPage
1856
+ }
1857
+ ];
1858
+ const ProtectedEditViewPage = lazy(
1859
+ () => import("./EditViewPage-Bcnff6Vd.mjs").then((mod) => ({ default: mod.ProtectedEditViewPage }))
1282
1860
  );
1283
1861
  const ProtectedListViewPage = lazy(
1284
- () => import("./ListViewPage-BO_mOXIl.mjs").then((mod) => ({ default: mod.ProtectedListViewPage }))
1862
+ () => import("./ListViewPage-HljQVnFH.mjs").then((mod) => ({ default: mod.ProtectedListViewPage }))
1285
1863
  );
1286
1864
  const ProtectedListConfiguration = lazy(
1287
- () => import("./ListConfigurationPage-TqrmwjPN.mjs").then((mod) => ({
1865
+ () => import("./ListConfigurationPage-BPvzENJJ.mjs").then((mod) => ({
1288
1866
  default: mod.ProtectedListConfiguration
1289
1867
  }))
1290
1868
  );
1291
1869
  const ProtectedEditConfigurationPage = lazy(
1292
- () => import("./EditConfigurationPage-CZLbgfIp.mjs").then((mod) => ({
1870
+ () => import("./EditConfigurationPage-D1nvB7Br.mjs").then((mod) => ({
1293
1871
  default: mod.ProtectedEditConfigurationPage
1294
1872
  }))
1295
1873
  );
1296
1874
  const ProtectedComponentConfigurationPage = lazy(
1297
- () => import("./ComponentConfigurationPage-Cxz51Sve.mjs").then((mod) => ({
1875
+ () => import("./ComponentConfigurationPage-D4H-v0et.mjs").then((mod) => ({
1298
1876
  default: mod.ProtectedComponentConfigurationPage
1299
1877
  }))
1300
1878
  );
1301
1879
  const NoPermissions = lazy(
1302
- () => import("./NoPermissionsPage-DTXi042N.mjs").then((mod) => ({ default: mod.NoPermissions }))
1880
+ () => import("./NoPermissionsPage-D6ze2nQL.mjs").then((mod) => ({ default: mod.NoPermissions }))
1303
1881
  );
1304
1882
  const NoContentType = lazy(
1305
- () => import("./NoContentTypePage-DqB0QV0k.mjs").then((mod) => ({ default: mod.NoContentType }))
1883
+ () => import("./NoContentTypePage-BfHaSM-K.mjs").then((mod) => ({ default: mod.NoContentType }))
1306
1884
  );
1307
1885
  const CollectionTypePages = () => {
1308
1886
  const { collectionType } = useParams();
@@ -1314,7 +1892,7 @@ const CollectionTypePages = () => {
1314
1892
  const CLONE_RELATIVE_PATH = ":collectionType/:slug/clone/:origin";
1315
1893
  const CLONE_PATH = `/content-manager/${CLONE_RELATIVE_PATH}`;
1316
1894
  const LIST_RELATIVE_PATH = ":collectionType/:slug";
1317
- const LIST_PATH = `/content-manager/${LIST_RELATIVE_PATH}`;
1895
+ const LIST_PATH = `/content-manager/collection-types/:slug`;
1318
1896
  const routes = [
1319
1897
  {
1320
1898
  path: LIST_RELATIVE_PATH,
@@ -1348,6 +1926,7 @@ const routes = [
1348
1926
  path: "no-content-types",
1349
1927
  Component: NoContentType
1350
1928
  },
1929
+ ...routes$2,
1351
1930
  ...routes$1
1352
1931
  ];
1353
1932
  const DocumentActions = ({ actions: actions2 }) => {
@@ -1416,12 +1995,14 @@ const DocumentActionButton = (action) => {
1416
1995
  /* @__PURE__ */ jsx(
1417
1996
  Button,
1418
1997
  {
1419
- flex: 1,
1998
+ flex: "auto",
1420
1999
  startIcon: action.icon,
1421
2000
  disabled: action.disabled,
1422
2001
  onClick: handleClick(action),
1423
2002
  justifyContent: "center",
1424
2003
  variant: action.variant || "default",
2004
+ paddingTop: "7px",
2005
+ paddingBottom: "7px",
1425
2006
  children: action.label
1426
2007
  }
1427
2008
  ),
@@ -1429,7 +2010,7 @@ const DocumentActionButton = (action) => {
1429
2010
  DocumentActionConfirmDialog,
1430
2011
  {
1431
2012
  ...action.dialog,
1432
- variant: action.variant,
2013
+ variant: action.dialog?.variant ?? action.variant,
1433
2014
  isOpen: dialogId === action.id,
1434
2015
  onClose: handleClose
1435
2016
  }
@@ -1444,6 +2025,11 @@ const DocumentActionButton = (action) => {
1444
2025
  ) : null
1445
2026
  ] });
1446
2027
  };
2028
+ const MenuItem = styled(Menu.Item)`
2029
+ &:hover {
2030
+ background: ${({ theme, isVariantDanger, isDisabled }) => isVariantDanger && !isDisabled ? theme.colors.danger100 : "neutral"};
2031
+ }
2032
+ `;
1447
2033
  const DocumentActionsMenu = ({
1448
2034
  actions: actions2,
1449
2035
  children,
@@ -1486,9 +2072,9 @@ const DocumentActionsMenu = ({
1486
2072
  disabled: isDisabled,
1487
2073
  size: "S",
1488
2074
  endIcon: null,
1489
- paddingTop: "7px",
1490
- paddingLeft: "9px",
1491
- paddingRight: "9px",
2075
+ paddingTop: "4px",
2076
+ paddingLeft: "7px",
2077
+ paddingRight: "7px",
1492
2078
  variant,
1493
2079
  children: [
1494
2080
  /* @__PURE__ */ jsx(More, { "aria-hidden": true, focusable: false }),
@@ -1499,36 +2085,35 @@ const DocumentActionsMenu = ({
1499
2085
  ]
1500
2086
  }
1501
2087
  ),
1502
- /* @__PURE__ */ jsxs(Menu.Content, { top: "4px", maxHeight: void 0, popoverPlacement: "bottom-end", children: [
2088
+ /* @__PURE__ */ jsxs(Menu.Content, { maxHeight: void 0, popoverPlacement: "bottom-end", children: [
1503
2089
  actions2.map((action) => {
1504
2090
  return /* @__PURE__ */ jsx(
1505
- Menu.Item,
2091
+ MenuItem,
1506
2092
  {
1507
2093
  disabled: action.disabled,
1508
2094
  onSelect: handleClick(action),
1509
2095
  display: "block",
1510
- children: /* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", gap: 4, children: [
1511
- /* @__PURE__ */ jsxs(Flex, { color: convertActionVariantToColor(action.variant), gap: 2, tag: "span", children: [
1512
- action.icon,
1513
- action.label
1514
- ] }),
1515
- action.id.startsWith("HistoryAction") && /* @__PURE__ */ jsx(
1516
- Flex,
1517
- {
1518
- alignItems: "center",
1519
- background: "alternative100",
1520
- borderStyle: "solid",
1521
- borderColor: "alternative200",
1522
- borderWidth: "1px",
1523
- height: 5,
1524
- paddingLeft: 2,
1525
- paddingRight: 2,
1526
- hasRadius: true,
1527
- color: "alternative600",
1528
- children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", fontWeight: "bold", lineHeight: 1, children: formatMessage({ id: "global.new", defaultMessage: "New" }) })
1529
- }
1530
- )
1531
- ] })
2096
+ isVariantDanger: action.variant === "danger",
2097
+ isDisabled: action.disabled,
2098
+ children: /* @__PURE__ */ jsx(Flex, { justifyContent: "space-between", gap: 4, children: /* @__PURE__ */ jsxs(
2099
+ Flex,
2100
+ {
2101
+ color: !action.disabled ? convertActionVariantToColor(action.variant) : "inherit",
2102
+ gap: 2,
2103
+ tag: "span",
2104
+ children: [
2105
+ /* @__PURE__ */ jsx(
2106
+ Flex,
2107
+ {
2108
+ tag: "span",
2109
+ color: !action.disabled ? convertActionVariantToIconColor(action.variant) : "inherit",
2110
+ children: action.icon
2111
+ }
2112
+ ),
2113
+ action.label
2114
+ ]
2115
+ }
2116
+ ) })
1532
2117
  },
1533
2118
  action.id
1534
2119
  );
@@ -1570,6 +2155,18 @@ const convertActionVariantToColor = (variant = "secondary") => {
1570
2155
  return "primary600";
1571
2156
  }
1572
2157
  };
2158
+ const convertActionVariantToIconColor = (variant = "secondary") => {
2159
+ switch (variant) {
2160
+ case "danger":
2161
+ return "danger600";
2162
+ case "secondary":
2163
+ return "neutral500";
2164
+ case "success":
2165
+ return "success600";
2166
+ default:
2167
+ return "primary600";
2168
+ }
2169
+ };
1573
2170
  const DocumentActionConfirmDialog = ({
1574
2171
  onClose,
1575
2172
  onCancel,
@@ -1592,22 +2189,20 @@ const DocumentActionConfirmDialog = ({
1592
2189
  }
1593
2190
  onClose();
1594
2191
  };
1595
- return /* @__PURE__ */ jsxs(Dialog, { isOpen, title, onClose: handleClose, children: [
1596
- /* @__PURE__ */ jsx(DialogBody, { children: content }),
1597
- /* @__PURE__ */ jsx(
1598
- DialogFooter,
1599
- {
1600
- startAction: /* @__PURE__ */ jsx(Button, { onClick: handleClose, variant: "tertiary", children: formatMessage({
1601
- id: "app.components.Button.cancel",
1602
- defaultMessage: "Cancel"
1603
- }) }),
1604
- endAction: /* @__PURE__ */ jsx(Button, { onClick: handleConfirm, variant, children: formatMessage({
1605
- id: "app.components.Button.confirm",
1606
- defaultMessage: "Confirm"
1607
- }) })
1608
- }
1609
- )
1610
- ] });
2192
+ return /* @__PURE__ */ jsx(Dialog.Root, { open: isOpen, onOpenChange: handleClose, children: /* @__PURE__ */ jsxs(Dialog.Content, { children: [
2193
+ /* @__PURE__ */ jsx(Dialog.Header, { children: title }),
2194
+ /* @__PURE__ */ jsx(Dialog.Body, { children: content }),
2195
+ /* @__PURE__ */ jsxs(Dialog.Footer, { children: [
2196
+ /* @__PURE__ */ jsx(Dialog.Cancel, { children: /* @__PURE__ */ jsx(Button, { variant: "tertiary", fullWidth: true, children: formatMessage({
2197
+ id: "app.components.Button.cancel",
2198
+ defaultMessage: "Cancel"
2199
+ }) }) }),
2200
+ /* @__PURE__ */ jsx(Button, { onClick: handleConfirm, variant, fullWidth: true, children: formatMessage({
2201
+ id: "app.components.Button.confirm",
2202
+ defaultMessage: "Confirm"
2203
+ }) })
2204
+ ] })
2205
+ ] }) });
1611
2206
  };
1612
2207
  const DocumentActionModal = ({
1613
2208
  isOpen,
@@ -1617,34 +2212,29 @@ const DocumentActionModal = ({
1617
2212
  content: Content,
1618
2213
  onModalClose
1619
2214
  }) => {
1620
- const id = React.useId();
1621
- if (!isOpen) {
1622
- return null;
1623
- }
1624
2215
  const handleClose = () => {
1625
2216
  if (onClose) {
1626
2217
  onClose();
1627
2218
  }
1628
2219
  onModalClose();
1629
2220
  };
1630
- return /* @__PURE__ */ jsxs(ModalLayout, { borderRadius: "4px", overflow: "hidden", onClose: handleClose, labelledBy: id, children: [
1631
- /* @__PURE__ */ jsx(ModalHeader, { children: /* @__PURE__ */ jsx(Typography, { fontWeight: "bold", textColor: "neutral800", tag: "h2", id, children: title }) }),
1632
- /* @__PURE__ */ jsx(ModalBody, { children: typeof Content === "function" ? /* @__PURE__ */ jsx(Content, { onClose: handleClose }) : Content }),
1633
- /* @__PURE__ */ jsx(
1634
- Box,
1635
- {
1636
- paddingTop: 4,
1637
- paddingBottom: 4,
1638
- paddingLeft: 5,
1639
- paddingRight: 5,
1640
- borderWidth: "1px 0 0 0",
1641
- borderStyle: "solid",
1642
- borderColor: "neutral150",
1643
- background: "neutral100",
1644
- children: typeof Footer === "function" ? /* @__PURE__ */ jsx(Footer, { onClose: handleClose }) : Footer
1645
- }
1646
- )
1647
- ] });
2221
+ return /* @__PURE__ */ jsx(Modal.Root, { open: isOpen, onOpenChange: handleClose, children: /* @__PURE__ */ jsxs(Modal.Content, { children: [
2222
+ /* @__PURE__ */ jsx(Modal.Header, { children: /* @__PURE__ */ jsx(Modal.Title, { children: title }) }),
2223
+ typeof Content === "function" ? /* @__PURE__ */ jsx(Content, { onClose: handleClose }) : /* @__PURE__ */ jsx(Modal.Body, { children: Content }),
2224
+ typeof Footer === "function" ? /* @__PURE__ */ jsx(Footer, { onClose: handleClose }) : Footer
2225
+ ] }) });
2226
+ };
2227
+ const transformData = (data) => {
2228
+ if (Array.isArray(data)) {
2229
+ return data.map(transformData);
2230
+ }
2231
+ if (typeof data === "object" && data !== null) {
2232
+ if ("apiData" in data) {
2233
+ return data.apiData;
2234
+ }
2235
+ return mapValues(transformData)(data);
2236
+ }
2237
+ return data;
1648
2238
  };
1649
2239
  const PublishAction$1 = ({
1650
2240
  activeTab,
@@ -1658,13 +2248,18 @@ const PublishAction$1 = ({
1658
2248
  const navigate = useNavigate();
1659
2249
  const { toggleNotification } = useNotification();
1660
2250
  const { _unstableFormatValidationErrors: formatValidationErrors } = useAPIErrorHandler();
2251
+ const isListView = useMatch(LIST_PATH) !== null;
1661
2252
  const isCloning = useMatch(CLONE_PATH) !== null;
2253
+ const { id } = useParams();
1662
2254
  const { formatMessage } = useIntl();
1663
- const { canPublish, canCreate, canUpdate } = useDocumentRBAC(
1664
- "PublishAction",
1665
- ({ canPublish: canPublish2, canCreate: canCreate2, canUpdate: canUpdate2 }) => ({ canPublish: canPublish2, canCreate: canCreate2, canUpdate: canUpdate2 })
1666
- );
2255
+ const canPublish = useDocumentRBAC("PublishAction", ({ canPublish: canPublish2 }) => canPublish2);
1667
2256
  const { publish } = useDocumentActions();
2257
+ const [
2258
+ countDraftRelations,
2259
+ { isLoading: isLoadingDraftRelations, isError: isErrorDraftRelations }
2260
+ ] = useLazyGetDraftRelationCountQuery();
2261
+ const [localCountOfDraftRelations, setLocalCountOfDraftRelations] = React.useState(0);
2262
+ const [serverCountOfDraftRelations, setServerCountOfDraftRelations] = React.useState(0);
1668
2263
  const [{ query, rawQuery }] = useQueryParams();
1669
2264
  const params = React.useMemo(() => buildValidParams(query), [query]);
1670
2265
  const modified = useForm("PublishAction", ({ modified: modified2 }) => modified2);
@@ -1673,10 +2268,107 @@ const PublishAction$1 = ({
1673
2268
  const validate = useForm("PublishAction", (state) => state.validate);
1674
2269
  const setErrors = useForm("PublishAction", (state) => state.setErrors);
1675
2270
  const formValues = useForm("PublishAction", ({ values }) => values);
2271
+ React.useEffect(() => {
2272
+ if (isErrorDraftRelations) {
2273
+ toggleNotification({
2274
+ type: "danger",
2275
+ message: formatMessage({
2276
+ id: getTranslation("error.records.fetch-draft-relatons"),
2277
+ defaultMessage: "An error occurred while fetching draft relations on this document."
2278
+ })
2279
+ });
2280
+ }
2281
+ }, [isErrorDraftRelations, toggleNotification, formatMessage]);
2282
+ React.useEffect(() => {
2283
+ const localDraftRelations = /* @__PURE__ */ new Set();
2284
+ const extractDraftRelations = (data) => {
2285
+ const relations = data.connect || [];
2286
+ relations.forEach((relation) => {
2287
+ if (relation.status === "draft") {
2288
+ localDraftRelations.add(relation.id);
2289
+ }
2290
+ });
2291
+ };
2292
+ const traverseAndExtract = (data) => {
2293
+ Object.entries(data).forEach(([key, value]) => {
2294
+ if (key === "connect" && Array.isArray(value)) {
2295
+ extractDraftRelations({ connect: value });
2296
+ } else if (typeof value === "object" && value !== null) {
2297
+ traverseAndExtract(value);
2298
+ }
2299
+ });
2300
+ };
2301
+ if (!documentId || modified) {
2302
+ traverseAndExtract(formValues);
2303
+ setLocalCountOfDraftRelations(localDraftRelations.size);
2304
+ }
2305
+ }, [documentId, modified, formValues, setLocalCountOfDraftRelations]);
2306
+ React.useEffect(() => {
2307
+ if (!document || !document.documentId || isListView) {
2308
+ return;
2309
+ }
2310
+ const fetchDraftRelationsCount = async () => {
2311
+ const { data, error } = await countDraftRelations({
2312
+ collectionType,
2313
+ model,
2314
+ documentId,
2315
+ params
2316
+ });
2317
+ if (error) {
2318
+ throw error;
2319
+ }
2320
+ if (data) {
2321
+ setServerCountOfDraftRelations(data.data);
2322
+ }
2323
+ };
2324
+ fetchDraftRelationsCount();
2325
+ }, [isListView, document, documentId, countDraftRelations, collectionType, model, params]);
1676
2326
  const isDocumentPublished = (document?.[PUBLISHED_AT_ATTRIBUTE_NAME] || meta?.availableStatus.some((doc) => doc[PUBLISHED_AT_ATTRIBUTE_NAME] !== null)) && document?.status !== "modified";
1677
2327
  if (!schema?.options?.draftAndPublish) {
1678
2328
  return null;
1679
2329
  }
2330
+ const performPublish = async () => {
2331
+ setSubmitting(true);
2332
+ try {
2333
+ const { errors } = await validate(true, {
2334
+ status: "published"
2335
+ });
2336
+ if (errors) {
2337
+ toggleNotification({
2338
+ type: "danger",
2339
+ message: formatMessage({
2340
+ id: "content-manager.validation.error",
2341
+ defaultMessage: "There are validation errors in your document. Please fix them before saving."
2342
+ })
2343
+ });
2344
+ return;
2345
+ }
2346
+ const res = await publish(
2347
+ {
2348
+ collectionType,
2349
+ model,
2350
+ documentId,
2351
+ params
2352
+ },
2353
+ transformData(formValues)
2354
+ );
2355
+ if ("data" in res && collectionType !== SINGLE_TYPES) {
2356
+ if (id === "create") {
2357
+ navigate({
2358
+ pathname: `../${collectionType}/${model}/${res.data.documentId}`,
2359
+ search: rawQuery
2360
+ });
2361
+ }
2362
+ } else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
2363
+ setErrors(formatValidationErrors(res.error));
2364
+ }
2365
+ } finally {
2366
+ setSubmitting(false);
2367
+ }
2368
+ };
2369
+ const totalDraftRelations = localCountOfDraftRelations + serverCountOfDraftRelations;
2370
+ const enableDraftRelationsCount = false;
2371
+ const hasDraftRelations = enableDraftRelationsCount;
1680
2372
  return {
1681
2373
  /**
1682
2374
  * Disabled when:
@@ -1686,52 +2378,40 @@ const PublishAction$1 = ({
1686
2378
  * - the document is already published & not modified
1687
2379
  * - the document is being created & not modified
1688
2380
  * - the user doesn't have the permission to publish
1689
- * - the user doesn't have the permission to create a new document
1690
- * - the user doesn't have the permission to update the document
1691
2381
  */
1692
- disabled: isCloning || isSubmitting || activeTab === "published" || !modified && isDocumentPublished || !modified && !document?.documentId || !canPublish || Boolean(!document?.documentId && !canCreate || document?.documentId && !canUpdate),
2382
+ disabled: isCloning || isSubmitting || isLoadingDraftRelations || activeTab === "published" || !modified && isDocumentPublished || !modified && !document?.documentId || !canPublish,
1693
2383
  label: formatMessage({
1694
2384
  id: "app.utils.publish",
1695
2385
  defaultMessage: "Publish"
1696
2386
  }),
1697
2387
  onClick: async () => {
1698
- setSubmitting(true);
1699
- try {
1700
- const { errors } = await validate();
1701
- if (errors) {
1702
- toggleNotification({
1703
- type: "danger",
1704
- message: formatMessage({
1705
- id: "content-manager.validation.error",
1706
- defaultMessage: "There are validation errors in your document. Please fix them before saving."
1707
- })
1708
- });
1709
- return;
1710
- }
1711
- const res = await publish(
1712
- {
1713
- collectionType,
1714
- model,
1715
- documentId,
1716
- params
1717
- },
1718
- formValues
1719
- );
1720
- if ("data" in res && collectionType !== SINGLE_TYPES) {
1721
- navigate({
1722
- pathname: `../${collectionType}/${model}/${res.data.documentId}`,
1723
- search: rawQuery
1724
- });
1725
- } else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
1726
- setErrors(formatValidationErrors(res.error));
2388
+ await performPublish();
2389
+ },
2390
+ dialog: hasDraftRelations ? {
2391
+ type: "dialog",
2392
+ variant: "danger",
2393
+ footer: null,
2394
+ title: formatMessage({
2395
+ id: getTranslation(`popUpwarning.warning.bulk-has-draft-relations.title`),
2396
+ defaultMessage: "Confirmation"
2397
+ }),
2398
+ content: formatMessage(
2399
+ {
2400
+ id: getTranslation(`popUpwarning.warning.bulk-has-draft-relations.message`),
2401
+ defaultMessage: "This entry is related to {count, plural, one {# draft entry} other {# draft entries}}. Publishing it could leave broken links in your app."
2402
+ },
2403
+ {
2404
+ count: totalDraftRelations
1727
2405
  }
1728
- } finally {
1729
- setSubmitting(false);
2406
+ ),
2407
+ onConfirm: async () => {
2408
+ await performPublish();
1730
2409
  }
1731
- }
2410
+ } : void 0
1732
2411
  };
1733
2412
  };
1734
2413
  PublishAction$1.type = "publish";
2414
+ PublishAction$1.position = "panel";
1735
2415
  const UpdateAction = ({
1736
2416
  activeTab,
1737
2417
  documentId,
@@ -1744,10 +2424,6 @@ const UpdateAction = ({
1744
2424
  const cloneMatch = useMatch(CLONE_PATH);
1745
2425
  const isCloning = cloneMatch !== null;
1746
2426
  const { formatMessage } = useIntl();
1747
- const { canCreate, canUpdate } = useDocumentRBAC("UpdateAction", ({ canCreate: canCreate2, canUpdate: canUpdate2 }) => ({
1748
- canCreate: canCreate2,
1749
- canUpdate: canUpdate2
1750
- }));
1751
2427
  const { create, update, clone } = useDocumentActions();
1752
2428
  const [{ query, rawQuery }] = useQueryParams();
1753
2429
  const params = React.useMemo(() => buildValidParams(query), [query]);
@@ -1758,90 +2434,134 @@ const UpdateAction = ({
1758
2434
  const validate = useForm("UpdateAction", (state) => state.validate);
1759
2435
  const setErrors = useForm("UpdateAction", (state) => state.setErrors);
1760
2436
  const resetForm = useForm("PublishAction", ({ resetForm: resetForm2 }) => resetForm2);
1761
- return {
1762
- /**
1763
- * Disabled when:
1764
- * - the form is submitting
1765
- * - the document is not modified & we're not cloning (you can save a clone entity straight away)
1766
- * - the active tab is the published tab
1767
- * - the user doesn't have the permission to create a new document
1768
- * - the user doesn't have the permission to update the document
1769
- */
1770
- disabled: isSubmitting || !modified && !isCloning || activeTab === "published" || Boolean(!documentId && !canCreate || documentId && !canUpdate),
1771
- label: formatMessage({
1772
- id: "content-manager.containers.Edit.save",
1773
- defaultMessage: "Save"
1774
- }),
1775
- onClick: async () => {
1776
- setSubmitting(true);
1777
- try {
1778
- const { errors } = await validate();
1779
- if (errors) {
1780
- toggleNotification({
1781
- type: "danger",
1782
- message: formatMessage({
1783
- id: "content-manager.validation.error",
1784
- defaultMessage: "There are validation errors in your document. Please fix them before saving."
1785
- })
1786
- });
1787
- return;
1788
- }
1789
- if (isCloning) {
1790
- const res = await clone(
2437
+ const handleUpdate = React.useCallback(async () => {
2438
+ setSubmitting(true);
2439
+ try {
2440
+ if (!modified) {
2441
+ return;
2442
+ }
2443
+ const { errors } = await validate(true, {
2444
+ status: "draft"
2445
+ });
2446
+ if (errors) {
2447
+ toggleNotification({
2448
+ type: "danger",
2449
+ message: formatMessage({
2450
+ id: "content-manager.validation.error",
2451
+ defaultMessage: "There are validation errors in your document. Please fix them before saving."
2452
+ })
2453
+ });
2454
+ return;
2455
+ }
2456
+ if (isCloning) {
2457
+ const res = await clone(
2458
+ {
2459
+ model,
2460
+ documentId: cloneMatch.params.origin,
2461
+ params
2462
+ },
2463
+ transformData(document)
2464
+ );
2465
+ if ("data" in res) {
2466
+ navigate(
1791
2467
  {
1792
- model,
1793
- documentId: cloneMatch.params.origin,
1794
- params
1795
- },
1796
- document
1797
- );
1798
- if ("data" in res) {
1799
- navigate({
1800
- pathname: `../${collectionType}/${model}/${res.data.documentId}`,
2468
+ pathname: `../${res.data.documentId}`,
1801
2469
  search: rawQuery
1802
- });
1803
- } else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
1804
- setErrors(formatValidationErrors(res.error));
1805
- }
1806
- } else if (documentId || collectionType === SINGLE_TYPES) {
1807
- const res = await update(
1808
- {
1809
- collectionType,
1810
- model,
1811
- documentId,
1812
- params
1813
2470
  },
1814
- document
2471
+ { relative: "path" }
1815
2472
  );
1816
- if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
1817
- setErrors(formatValidationErrors(res.error));
1818
- } else {
1819
- resetForm();
1820
- }
2473
+ } else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
2474
+ setErrors(formatValidationErrors(res.error));
2475
+ }
2476
+ } else if (documentId || collectionType === SINGLE_TYPES) {
2477
+ const res = await update(
2478
+ {
2479
+ collectionType,
2480
+ model,
2481
+ documentId,
2482
+ params
2483
+ },
2484
+ transformData(document)
2485
+ );
2486
+ if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
2487
+ setErrors(formatValidationErrors(res.error));
1821
2488
  } else {
1822
- const res = await create(
2489
+ resetForm();
2490
+ }
2491
+ } else {
2492
+ const res = await create(
2493
+ {
2494
+ model,
2495
+ params
2496
+ },
2497
+ transformData(document)
2498
+ );
2499
+ if ("data" in res && collectionType !== SINGLE_TYPES) {
2500
+ navigate(
1823
2501
  {
1824
- model,
1825
- params
2502
+ pathname: `../${res.data.documentId}`,
2503
+ search: rawQuery
1826
2504
  },
1827
- document
2505
+ { replace: true, relative: "path" }
1828
2506
  );
1829
- if ("data" in res && collectionType !== SINGLE_TYPES) {
1830
- navigate({
1831
- pathname: `../${collectionType}/${model}/${res.data.documentId}`,
1832
- search: rawQuery
1833
- });
1834
- } else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
1835
- setErrors(formatValidationErrors(res.error));
1836
- }
2507
+ } else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
2508
+ setErrors(formatValidationErrors(res.error));
1837
2509
  }
1838
- } finally {
1839
- setSubmitting(false);
1840
2510
  }
2511
+ } finally {
2512
+ setSubmitting(false);
1841
2513
  }
2514
+ }, [
2515
+ clone,
2516
+ cloneMatch?.params.origin,
2517
+ collectionType,
2518
+ create,
2519
+ document,
2520
+ documentId,
2521
+ formatMessage,
2522
+ formatValidationErrors,
2523
+ isCloning,
2524
+ model,
2525
+ modified,
2526
+ navigate,
2527
+ params,
2528
+ rawQuery,
2529
+ resetForm,
2530
+ setErrors,
2531
+ setSubmitting,
2532
+ toggleNotification,
2533
+ update,
2534
+ validate
2535
+ ]);
2536
+ React.useEffect(() => {
2537
+ const handleKeyDown = (e) => {
2538
+ if (e.key === "Enter" && (e.metaKey || e.ctrlKey)) {
2539
+ e.preventDefault();
2540
+ handleUpdate();
2541
+ }
2542
+ };
2543
+ window.addEventListener("keydown", handleKeyDown);
2544
+ return () => {
2545
+ window.removeEventListener("keydown", handleKeyDown);
2546
+ };
2547
+ }, [handleUpdate]);
2548
+ return {
2549
+ /**
2550
+ * Disabled when:
2551
+ * - the form is submitting
2552
+ * - the document is not modified & we're not cloning (you can save a clone entity straight away)
2553
+ * - the active tab is the published tab
2554
+ */
2555
+ disabled: isSubmitting || !modified && !isCloning || activeTab === "published",
2556
+ label: formatMessage({
2557
+ id: "global.save",
2558
+ defaultMessage: "Save"
2559
+ }),
2560
+ onClick: handleUpdate
1842
2561
  };
1843
2562
  };
1844
2563
  UpdateAction.type = "update";
2564
+ UpdateAction.position = "panel";
1845
2565
  const UNPUBLISH_DRAFT_OPTIONS = {
1846
2566
  KEEP: "keep",
1847
2567
  DISCARD: "discard"
@@ -1862,10 +2582,8 @@ const UnpublishAction$1 = ({
1862
2582
  const { toggleNotification } = useNotification();
1863
2583
  const [shouldKeepDraft, setShouldKeepDraft] = React.useState(true);
1864
2584
  const isDocumentModified = document?.status === "modified";
1865
- const handleChange = (e) => {
1866
- if ("value" in e.target) {
1867
- setShouldKeepDraft(e.target.value === UNPUBLISH_DRAFT_OPTIONS.KEEP);
1868
- }
2585
+ const handleChange = (value) => {
2586
+ setShouldKeepDraft(value === UNPUBLISH_DRAFT_OPTIONS.KEEP);
1869
2587
  };
1870
2588
  if (!schema?.options?.draftAndPublish) {
1871
2589
  return null;
@@ -1876,7 +2594,7 @@ const UnpublishAction$1 = ({
1876
2594
  id: "app.utils.unpublish",
1877
2595
  defaultMessage: "Unpublish"
1878
2596
  }),
1879
- icon: /* @__PURE__ */ jsx(StyledCrossCircle, {}),
2597
+ icon: /* @__PURE__ */ jsx(Cross, {}),
1880
2598
  onClick: async () => {
1881
2599
  if (!documentId && collectionType !== SINGLE_TYPES || isDocumentModified) {
1882
2600
  if (!documentId) {
@@ -1915,40 +2633,24 @@ const UnpublishAction$1 = ({
1915
2633
  }) })
1916
2634
  ] }),
1917
2635
  /* @__PURE__ */ jsxs(
1918
- Flex,
2636
+ Radio.Group,
1919
2637
  {
1920
- onChange: handleChange,
1921
- direction: "column",
1922
- alignItems: "flex-start",
1923
- tag: "fieldset",
1924
- borderWidth: 0,
1925
- gap: 3,
2638
+ defaultValue: UNPUBLISH_DRAFT_OPTIONS.KEEP,
2639
+ name: "discard-options",
2640
+ "aria-label": formatMessage({
2641
+ id: "content-manager.actions.unpublish.dialog.radio-label",
2642
+ defaultMessage: "Choose an option to unpublish the document."
2643
+ }),
2644
+ onValueChange: handleChange,
1926
2645
  children: [
1927
- /* @__PURE__ */ jsx(VisuallyHidden, { tag: "legend" }),
1928
- /* @__PURE__ */ jsx(
1929
- Radio,
1930
- {
1931
- checked: shouldKeepDraft,
1932
- value: UNPUBLISH_DRAFT_OPTIONS.KEEP,
1933
- name: "discard-options",
1934
- children: formatMessage({
1935
- id: "content-manager.actions.unpublish.dialog.option.keep-draft",
1936
- defaultMessage: "Keep draft"
1937
- })
1938
- }
1939
- ),
1940
- /* @__PURE__ */ jsx(
1941
- Radio,
1942
- {
1943
- checked: !shouldKeepDraft,
1944
- value: UNPUBLISH_DRAFT_OPTIONS.DISCARD,
1945
- name: "discard-options",
1946
- children: formatMessage({
1947
- id: "content-manager.actions.unpublish.dialog.option.replace-draft",
1948
- defaultMessage: "Replace draft"
1949
- })
1950
- }
1951
- )
2646
+ /* @__PURE__ */ jsx(Radio.Item, { checked: shouldKeepDraft, value: UNPUBLISH_DRAFT_OPTIONS.KEEP, children: formatMessage({
2647
+ id: "content-manager.actions.unpublish.dialog.option.keep-draft",
2648
+ defaultMessage: "Keep draft"
2649
+ }) }),
2650
+ /* @__PURE__ */ jsx(Radio.Item, { checked: !shouldKeepDraft, value: UNPUBLISH_DRAFT_OPTIONS.DISCARD, children: formatMessage({
2651
+ id: "content-manager.actions.unpublish.dialog.option.replace-draft",
2652
+ defaultMessage: "Replace draft"
2653
+ }) })
1952
2654
  ]
1953
2655
  }
1954
2656
  )
@@ -1982,6 +2684,7 @@ const UnpublishAction$1 = ({
1982
2684
  };
1983
2685
  };
1984
2686
  UnpublishAction$1.type = "unpublish";
2687
+ UnpublishAction$1.position = "panel";
1985
2688
  const DiscardAction = ({
1986
2689
  activeTab,
1987
2690
  documentId,
@@ -2004,7 +2707,7 @@ const DiscardAction = ({
2004
2707
  id: "content-manager.actions.discard.label",
2005
2708
  defaultMessage: "Discard changes"
2006
2709
  }),
2007
- icon: /* @__PURE__ */ jsx(StyledCrossCircle, {}),
2710
+ icon: /* @__PURE__ */ jsx(Cross, {}),
2008
2711
  position: ["panel", "table-row"],
2009
2712
  variant: "danger",
2010
2713
  dialog: {
@@ -2032,11 +2735,7 @@ const DiscardAction = ({
2032
2735
  };
2033
2736
  };
2034
2737
  DiscardAction.type = "discard";
2035
- const StyledCrossCircle = styled(CrossCircle)`
2036
- path {
2037
- fill: currentColor;
2038
- }
2039
- `;
2738
+ DiscardAction.position = "panel";
2040
2739
  const DEFAULT_ACTIONS = [PublishAction$1, UpdateAction, UnpublishAction$1, DiscardAction];
2041
2740
  const intervals = ["years", "months", "days", "hours", "minutes", "seconds"];
2042
2741
  const RelativeTime = React.forwardRef(
@@ -2049,7 +2748,7 @@ const RelativeTime = React.forwardRef(
2049
2748
  });
2050
2749
  const unit = intervals.find((intervalUnit) => {
2051
2750
  return interval[intervalUnit] > 0 && Object.keys(interval).includes(intervalUnit);
2052
- });
2751
+ }) ?? "seconds";
2053
2752
  const relativeTime = isPast(timestamp) ? -interval[unit] : interval[unit];
2054
2753
  const customInterval = customIntervals.find(
2055
2754
  (custom) => interval[custom.unit] < custom.threshold
@@ -2083,34 +2782,34 @@ const getDisplayName = ({
2083
2782
  return email ?? "";
2084
2783
  };
2085
2784
  const capitalise = (str) => str.charAt(0).toUpperCase() + str.slice(1);
2086
- const DocumentStatus = ({ status = "draft", ...restProps }) => {
2087
- const statusVariant = status === "draft" ? "primary" : status === "published" ? "success" : "alternative";
2088
- return /* @__PURE__ */ jsx(Status, { ...restProps, showBullet: false, size: "S", variant: statusVariant, children: /* @__PURE__ */ jsx(Typography, { tag: "span", variant: "omega", fontWeight: "bold", children: capitalise(status) }) });
2785
+ const DocumentStatus = ({ status = "draft", size = "S", ...restProps }) => {
2786
+ const statusVariant = status === "draft" ? "secondary" : status === "published" ? "success" : "alternative";
2787
+ const { formatMessage } = useIntl();
2788
+ return /* @__PURE__ */ jsx(Status, { ...restProps, size, variant: statusVariant, children: /* @__PURE__ */ jsx(Typography, { tag: "span", variant: "omega", fontWeight: "bold", children: formatMessage({
2789
+ id: `content-manager.containers.List.${status}`,
2790
+ defaultMessage: capitalise(status)
2791
+ }) }) });
2089
2792
  };
2090
2793
  const Header = ({ isCreating, status, title: documentTitle = "Untitled" }) => {
2091
2794
  const { formatMessage } = useIntl();
2092
2795
  const isCloning = useMatch(CLONE_PATH) !== null;
2796
+ const params = useParams();
2093
2797
  const title = isCreating ? formatMessage({
2094
2798
  id: "content-manager.containers.edit.title.new",
2095
2799
  defaultMessage: "Create an entry"
2096
2800
  }) : documentTitle;
2097
- return /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "flex-start", paddingTop: 8, paddingBottom: 4, gap: 3, children: [
2098
- /* @__PURE__ */ jsx(BackButton, {}),
2099
- /* @__PURE__ */ jsxs(
2100
- Flex,
2801
+ return /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "flex-start", paddingTop: 6, paddingBottom: 4, gap: 2, children: [
2802
+ /* @__PURE__ */ jsx(
2803
+ BackButton,
2101
2804
  {
2102
- width: "100%",
2103
- justifyContent: "space-between",
2104
- paddingTop: 1,
2105
- gap: "80px",
2106
- alignItems: "flex-start",
2107
- children: [
2108
- /* @__PURE__ */ jsx(Typography, { variant: "alpha", tag: "h1", children: title }),
2109
- /* @__PURE__ */ jsx(HeaderToolbar, {})
2110
- ]
2805
+ fallback: params.collectionType === SINGLE_TYPES ? void 0 : `../${COLLECTION_TYPES}/${params.slug}`
2111
2806
  }
2112
2807
  ),
2113
- status ? /* @__PURE__ */ jsx(DocumentStatus, { status: isCloning ? "draft" : status }) : null
2808
+ /* @__PURE__ */ jsxs(Flex, { width: "100%", justifyContent: "space-between", gap: "80px", alignItems: "flex-start", children: [
2809
+ /* @__PURE__ */ jsx(Typography, { variant: "alpha", tag: "h1", children: title }),
2810
+ /* @__PURE__ */ jsx(HeaderToolbar, {})
2811
+ ] }),
2812
+ status ? /* @__PURE__ */ jsx(Box, { marginTop: 1, children: /* @__PURE__ */ jsx(DocumentStatus, { status: isCloning ? "draft" : status }) }) : null
2114
2813
  ] });
2115
2814
  };
2116
2815
  const HeaderToolbar = () => {
@@ -2156,7 +2855,7 @@ const HeaderToolbar = () => {
2156
2855
  meta: isCloning ? void 0 : meta,
2157
2856
  collectionType
2158
2857
  },
2159
- descriptions: plugins["content-manager"].apis.getDocumentActions(),
2858
+ descriptions: plugins["content-manager"].apis.getDocumentActions("header"),
2160
2859
  children: (actions2) => {
2161
2860
  const headerActions = actions2.filter((action) => {
2162
2861
  const positions = Array.isArray(action.position) ? action.position : [action.position];
@@ -2193,12 +2892,12 @@ const Information = ({ activeTab }) => {
2193
2892
  isDisplayed: !!publishDocument?.[PUBLISHED_AT_ATTRIBUTE_NAME],
2194
2893
  label: formatMessage({
2195
2894
  id: "content-manager.containers.edit.information.last-published.label",
2196
- defaultMessage: "Last published"
2895
+ defaultMessage: "Published"
2197
2896
  }),
2198
2897
  value: formatMessage(
2199
2898
  {
2200
2899
  id: "content-manager.containers.edit.information.last-published.value",
2201
- defaultMessage: `Published {time}{isAnonymous, select, true {} other { by {author}}}`
2900
+ defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
2202
2901
  },
2203
2902
  {
2204
2903
  time: /* @__PURE__ */ jsx(RelativeTime, { timestamp: new Date(publishDocument?.[PUBLISHED_AT_ATTRIBUTE_NAME]) }),
@@ -2211,12 +2910,12 @@ const Information = ({ activeTab }) => {
2211
2910
  isDisplayed: !!createAndUpdateDocument?.[UPDATED_AT_ATTRIBUTE_NAME],
2212
2911
  label: formatMessage({
2213
2912
  id: "content-manager.containers.edit.information.last-draft.label",
2214
- defaultMessage: "Last draft"
2913
+ defaultMessage: "Updated"
2215
2914
  }),
2216
2915
  value: formatMessage(
2217
2916
  {
2218
2917
  id: "content-manager.containers.edit.information.last-draft.value",
2219
- defaultMessage: `Modified {time}{isAnonymous, select, true {} other { by {author}}}`
2918
+ defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
2220
2919
  },
2221
2920
  {
2222
2921
  time: /* @__PURE__ */ jsx(
@@ -2234,12 +2933,12 @@ const Information = ({ activeTab }) => {
2234
2933
  isDisplayed: !!createAndUpdateDocument?.[CREATED_AT_ATTRIBUTE_NAME],
2235
2934
  label: formatMessage({
2236
2935
  id: "content-manager.containers.edit.information.document.label",
2237
- defaultMessage: "Document"
2936
+ defaultMessage: "Created"
2238
2937
  }),
2239
2938
  value: formatMessage(
2240
2939
  {
2241
2940
  id: "content-manager.containers.edit.information.document.value",
2242
- defaultMessage: `Created {time}{isAnonymous, select, true {} other { by {author}}}`
2941
+ defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
2243
2942
  },
2244
2943
  {
2245
2944
  time: /* @__PURE__ */ jsx(
@@ -2277,41 +2976,94 @@ const Information = ({ activeTab }) => {
2277
2976
  );
2278
2977
  };
2279
2978
  const HeaderActions = ({ actions: actions2 }) => {
2280
- return /* @__PURE__ */ jsx(Flex, { children: actions2.map((action) => {
2281
- if ("options" in action) {
2979
+ const [dialogId, setDialogId] = React.useState(null);
2980
+ const handleClick = (action) => async (e) => {
2981
+ if (!("options" in action)) {
2982
+ const { onClick = () => false, dialog, id } = action;
2983
+ const muteDialog = await onClick(e);
2984
+ if (dialog && !muteDialog) {
2985
+ e.preventDefault();
2986
+ setDialogId(id);
2987
+ }
2988
+ }
2989
+ };
2990
+ const handleClose = () => {
2991
+ setDialogId(null);
2992
+ };
2993
+ return /* @__PURE__ */ jsx(Flex, { gap: 1, children: actions2.map((action) => {
2994
+ if (action.options) {
2282
2995
  return /* @__PURE__ */ jsx(
2283
2996
  SingleSelect,
2284
2997
  {
2285
2998
  size: "S",
2286
- disabled: action.disabled,
2287
- "aria-label": action.label,
2288
2999
  onChange: action.onSelect,
2289
- value: action.value,
3000
+ "aria-label": action.label,
3001
+ ...action,
2290
3002
  children: action.options.map(({ label, ...option }) => /* @__PURE__ */ jsx(SingleSelectOption, { ...option, children: label }, option.value))
2291
3003
  },
2292
3004
  action.id
2293
3005
  );
2294
3006
  } else {
2295
- return null;
3007
+ if (action.type === "icon") {
3008
+ return /* @__PURE__ */ jsxs(React.Fragment, { children: [
3009
+ /* @__PURE__ */ jsx(
3010
+ IconButton,
3011
+ {
3012
+ disabled: action.disabled,
3013
+ label: action.label,
3014
+ size: "S",
3015
+ onClick: handleClick(action),
3016
+ children: action.icon
3017
+ }
3018
+ ),
3019
+ action.dialog ? /* @__PURE__ */ jsx(
3020
+ HeaderActionDialog,
3021
+ {
3022
+ ...action.dialog,
3023
+ isOpen: dialogId === action.id,
3024
+ onClose: handleClose
3025
+ }
3026
+ ) : null
3027
+ ] }, action.id);
3028
+ }
2296
3029
  }
2297
3030
  }) });
2298
3031
  };
2299
- const ConfigureTheViewAction = ({ collectionType, model }) => {
2300
- const navigate = useNavigate();
2301
- const { formatMessage } = useIntl();
2302
- return {
2303
- label: formatMessage({
2304
- id: "app.links.configure-view",
2305
- defaultMessage: "Configure the view"
2306
- }),
2307
- icon: /* @__PURE__ */ jsx(ListPlus, {}),
2308
- onClick: () => {
3032
+ const HeaderActionDialog = ({
3033
+ onClose,
3034
+ onCancel,
3035
+ title,
3036
+ content: Content,
3037
+ isOpen
3038
+ }) => {
3039
+ const handleClose = async () => {
3040
+ if (onCancel) {
3041
+ await onCancel();
3042
+ }
3043
+ onClose();
3044
+ };
3045
+ return /* @__PURE__ */ jsx(Dialog.Root, { open: isOpen, onOpenChange: handleClose, children: /* @__PURE__ */ jsxs(Dialog.Content, { children: [
3046
+ /* @__PURE__ */ jsx(Dialog.Header, { children: title }),
3047
+ typeof Content === "function" ? /* @__PURE__ */ jsx(Content, { onClose: handleClose }) : Content
3048
+ ] }) });
3049
+ };
3050
+ const ConfigureTheViewAction = ({ collectionType, model }) => {
3051
+ const navigate = useNavigate();
3052
+ const { formatMessage } = useIntl();
3053
+ return {
3054
+ label: formatMessage({
3055
+ id: "app.links.configure-view",
3056
+ defaultMessage: "Configure the view"
3057
+ }),
3058
+ icon: /* @__PURE__ */ jsx(ListPlus, {}),
3059
+ onClick: () => {
2309
3060
  navigate(`../${collectionType}/${model}/configurations/edit`);
2310
3061
  },
2311
3062
  position: "header"
2312
3063
  };
2313
3064
  };
2314
3065
  ConfigureTheViewAction.type = "configure-the-view";
3066
+ ConfigureTheViewAction.position = "header";
2315
3067
  const EditTheModelAction = ({ model }) => {
2316
3068
  const navigate = useNavigate();
2317
3069
  const { formatMessage } = useIntl();
@@ -2328,6 +3080,7 @@ const EditTheModelAction = ({ model }) => {
2328
3080
  };
2329
3081
  };
2330
3082
  EditTheModelAction.type = "edit-the-model";
3083
+ EditTheModelAction.position = "header";
2331
3084
  const DeleteAction$1 = ({ documentId, model, collectionType, document }) => {
2332
3085
  const navigate = useNavigate();
2333
3086
  const { formatMessage } = useIntl();
@@ -2336,12 +3089,16 @@ const DeleteAction$1 = ({ documentId, model, collectionType, document }) => {
2336
3089
  const { delete: deleteAction } = useDocumentActions();
2337
3090
  const { toggleNotification } = useNotification();
2338
3091
  const setSubmitting = useForm("DeleteAction", (state) => state.setSubmitting);
3092
+ const isLocalized = document?.locale != null;
2339
3093
  return {
2340
3094
  disabled: !canDelete || !document,
2341
- label: formatMessage({
2342
- id: "content-manager.actions.delete.label",
2343
- defaultMessage: "Delete document"
2344
- }),
3095
+ label: formatMessage(
3096
+ {
3097
+ id: "content-manager.actions.delete.label",
3098
+ defaultMessage: "Delete entry{isLocalized, select, true { (all locales)} other {}}"
3099
+ },
3100
+ { isLocalized }
3101
+ ),
2345
3102
  icon: /* @__PURE__ */ jsx(Trash, {}),
2346
3103
  dialog: {
2347
3104
  type: "dialog",
@@ -2397,6 +3154,7 @@ const DeleteAction$1 = ({ documentId, model, collectionType, document }) => {
2397
3154
  };
2398
3155
  };
2399
3156
  DeleteAction$1.type = "delete";
3157
+ DeleteAction$1.position = ["header", "table-row"];
2400
3158
  const DEFAULT_HEADER_ACTIONS = [EditTheModelAction, ConfigureTheViewAction, DeleteAction$1];
2401
3159
  const Panels = () => {
2402
3160
  const isCloning = useMatch(CLONE_PATH) !== null;
@@ -2431,7 +3189,7 @@ const ActionsPanel = () => {
2431
3189
  return {
2432
3190
  title: formatMessage({
2433
3191
  id: "content-manager.containers.edit.panels.default.title",
2434
- defaultMessage: "Document"
3192
+ defaultMessage: "Entry"
2435
3193
  }),
2436
3194
  content: /* @__PURE__ */ jsx(ActionsPanelContent, {})
2437
3195
  };
@@ -2459,7 +3217,7 @@ const ActionsPanelContent = () => {
2459
3217
  DescriptionComponentRenderer,
2460
3218
  {
2461
3219
  props,
2462
- descriptions: plugins["content-manager"].apis.getDocumentActions(),
3220
+ descriptions: plugins["content-manager"].apis.getDocumentActions("panel"),
2463
3221
  children: (actions2) => /* @__PURE__ */ jsx(DocumentActions, { actions: actions2 })
2464
3222
  }
2465
3223
  ),
@@ -2486,314 +3244,12 @@ const Panel = React.forwardRef(({ children, title }, ref) => {
2486
3244
  justifyContent: "stretch",
2487
3245
  alignItems: "flex-start",
2488
3246
  children: [
2489
- /* @__PURE__ */ jsx(Typography, { tag: "h2", variant: "sigma", textTransform: "uppercase", children: title }),
3247
+ /* @__PURE__ */ jsx(Typography, { tag: "h2", variant: "sigma", textTransform: "uppercase", textColor: "neutral600", children: title }),
2490
3248
  children
2491
3249
  ]
2492
3250
  }
2493
3251
  );
2494
3252
  });
2495
- const HOOKS = {
2496
- /**
2497
- * Hook that allows to mutate the displayed headers of the list view table
2498
- * @constant
2499
- * @type {string}
2500
- */
2501
- INJECT_COLUMN_IN_TABLE: "Admin/CM/pages/ListView/inject-column-in-table",
2502
- /**
2503
- * Hook that allows to mutate the CM's collection types links pre-set filters
2504
- * @constant
2505
- * @type {string}
2506
- */
2507
- MUTATE_COLLECTION_TYPES_LINKS: "Admin/CM/pages/App/mutate-collection-types-links",
2508
- /**
2509
- * Hook that allows to mutate the CM's edit view layout
2510
- * @constant
2511
- * @type {string}
2512
- */
2513
- MUTATE_EDIT_VIEW_LAYOUT: "Admin/CM/pages/EditView/mutate-edit-view-layout",
2514
- /**
2515
- * Hook that allows to mutate the CM's single types links pre-set filters
2516
- * @constant
2517
- * @type {string}
2518
- */
2519
- MUTATE_SINGLE_TYPES_LINKS: "Admin/CM/pages/App/mutate-single-types-links"
2520
- };
2521
- const contentTypesApi = contentManagerApi.injectEndpoints({
2522
- endpoints: (builder) => ({
2523
- getContentTypeConfiguration: builder.query({
2524
- query: (uid) => ({
2525
- url: `/content-manager/content-types/${uid}/configuration`,
2526
- method: "GET"
2527
- }),
2528
- transformResponse: (response) => response.data,
2529
- providesTags: (_result, _error, uid) => [
2530
- { type: "ContentTypesConfiguration", id: uid },
2531
- { type: "ContentTypeSettings", id: "LIST" }
2532
- ]
2533
- }),
2534
- getAllContentTypeSettings: builder.query({
2535
- query: () => "/content-manager/content-types-settings",
2536
- transformResponse: (response) => response.data,
2537
- providesTags: [{ type: "ContentTypeSettings", id: "LIST" }]
2538
- }),
2539
- updateContentTypeConfiguration: builder.mutation({
2540
- query: ({ uid, ...body }) => ({
2541
- url: `/content-manager/content-types/${uid}/configuration`,
2542
- method: "PUT",
2543
- data: body
2544
- }),
2545
- transformResponse: (response) => response.data,
2546
- invalidatesTags: (_result, _error, { uid }) => [
2547
- { type: "ContentTypesConfiguration", id: uid },
2548
- { type: "ContentTypeSettings", id: "LIST" },
2549
- // Is this necessary?
2550
- { type: "InitialData" }
2551
- ]
2552
- })
2553
- })
2554
- });
2555
- const {
2556
- useGetContentTypeConfigurationQuery,
2557
- useGetAllContentTypeSettingsQuery,
2558
- useUpdateContentTypeConfigurationMutation
2559
- } = contentTypesApi;
2560
- const checkIfAttributeIsDisplayable = (attribute) => {
2561
- const { type } = attribute;
2562
- if (type === "relation") {
2563
- return !attribute.relation.toLowerCase().includes("morph");
2564
- }
2565
- return !["json", "dynamiczone", "richtext", "password", "blocks"].includes(type) && !!type;
2566
- };
2567
- const getMainField = (attribute, mainFieldName, { schemas, components }) => {
2568
- if (!mainFieldName) {
2569
- return void 0;
2570
- }
2571
- const mainFieldType = attribute.type === "component" ? components[attribute.component].attributes[mainFieldName].type : (
2572
- // @ts-expect-error – `targetModel` does exist on the attribute for a relation.
2573
- schemas.find((schema) => schema.uid === attribute.targetModel)?.attributes[mainFieldName].type
2574
- );
2575
- return {
2576
- name: mainFieldName,
2577
- type: mainFieldType ?? "string"
2578
- };
2579
- };
2580
- const DEFAULT_SETTINGS = {
2581
- bulkable: false,
2582
- filterable: false,
2583
- searchable: false,
2584
- pagination: false,
2585
- defaultSortBy: "",
2586
- defaultSortOrder: "asc",
2587
- mainField: "id",
2588
- pageSize: 10
2589
- };
2590
- const useDocumentLayout = (model) => {
2591
- const { schema, components } = useDocument({ model, collectionType: "" }, { skip: true });
2592
- const [{ query }] = useQueryParams();
2593
- const runHookWaterfall = useStrapiApp("useDocumentLayout", (state) => state.runHookWaterfall);
2594
- const { toggleNotification } = useNotification();
2595
- const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();
2596
- const { isLoading: isLoadingSchemas, schemas } = useContentTypeSchema();
2597
- const {
2598
- data,
2599
- isLoading: isLoadingConfigs,
2600
- error,
2601
- isFetching: isFetchingConfigs
2602
- } = useGetContentTypeConfigurationQuery(model);
2603
- const isLoading = isLoadingSchemas || isFetchingConfigs || isLoadingConfigs;
2604
- React.useEffect(() => {
2605
- if (error) {
2606
- toggleNotification({
2607
- type: "danger",
2608
- message: formatAPIError(error)
2609
- });
2610
- }
2611
- }, [error, formatAPIError, toggleNotification]);
2612
- const editLayout = React.useMemo(
2613
- () => data && !isLoading ? formatEditLayout(data, { schemas, schema, components }) : {
2614
- layout: [],
2615
- components: {},
2616
- metadatas: {},
2617
- options: {},
2618
- settings: DEFAULT_SETTINGS
2619
- },
2620
- [data, isLoading, schemas, schema, components]
2621
- );
2622
- const listLayout = React.useMemo(() => {
2623
- return data && !isLoading ? formatListLayout(data, { schemas, schema, components }) : {
2624
- layout: [],
2625
- metadatas: {},
2626
- options: {},
2627
- settings: DEFAULT_SETTINGS
2628
- };
2629
- }, [data, isLoading, schemas, schema, components]);
2630
- const { layout: edit } = React.useMemo(
2631
- () => runHookWaterfall(HOOKS.MUTATE_EDIT_VIEW_LAYOUT, {
2632
- layout: editLayout,
2633
- query
2634
- }),
2635
- [editLayout, query, runHookWaterfall]
2636
- );
2637
- return {
2638
- error,
2639
- isLoading,
2640
- edit,
2641
- list: listLayout
2642
- };
2643
- };
2644
- const useDocLayout = () => {
2645
- const { model } = useDoc();
2646
- return useDocumentLayout(model);
2647
- };
2648
- const formatEditLayout = (data, {
2649
- schemas,
2650
- schema,
2651
- components
2652
- }) => {
2653
- let currentPanelIndex = 0;
2654
- const panelledEditAttributes = convertEditLayoutToFieldLayouts(
2655
- data.contentType.layouts.edit,
2656
- schema?.attributes,
2657
- data.contentType.metadatas,
2658
- { configurations: data.components, schemas: components },
2659
- schemas
2660
- ).reduce((panels, row) => {
2661
- if (row.some((field) => field.type === "dynamiczone")) {
2662
- panels.push([row]);
2663
- currentPanelIndex += 2;
2664
- } else {
2665
- if (!panels[currentPanelIndex]) {
2666
- panels.push([]);
2667
- }
2668
- panels[currentPanelIndex].push(row);
2669
- }
2670
- return panels;
2671
- }, []);
2672
- const componentEditAttributes = Object.entries(data.components).reduce(
2673
- (acc, [uid, configuration]) => {
2674
- acc[uid] = {
2675
- layout: convertEditLayoutToFieldLayouts(
2676
- configuration.layouts.edit,
2677
- components[uid].attributes,
2678
- configuration.metadatas
2679
- ),
2680
- settings: {
2681
- ...configuration.settings,
2682
- icon: components[uid].info.icon,
2683
- displayName: components[uid].info.displayName
2684
- }
2685
- };
2686
- return acc;
2687
- },
2688
- {}
2689
- );
2690
- const editMetadatas = Object.entries(data.contentType.metadatas).reduce(
2691
- (acc, [attribute, metadata]) => {
2692
- return {
2693
- ...acc,
2694
- [attribute]: metadata.edit
2695
- };
2696
- },
2697
- {}
2698
- );
2699
- return {
2700
- layout: panelledEditAttributes,
2701
- components: componentEditAttributes,
2702
- metadatas: editMetadatas,
2703
- settings: {
2704
- ...data.contentType.settings,
2705
- displayName: schema?.info.displayName
2706
- },
2707
- options: {
2708
- ...schema?.options,
2709
- ...schema?.pluginOptions,
2710
- ...data.contentType.options
2711
- }
2712
- };
2713
- };
2714
- const convertEditLayoutToFieldLayouts = (rows, attributes = {}, metadatas, components, schemas = []) => {
2715
- return rows.map(
2716
- (row) => row.map((field) => {
2717
- const attribute = attributes[field.name];
2718
- if (!attribute) {
2719
- return null;
2720
- }
2721
- const { edit: metadata } = metadatas[field.name];
2722
- const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
2723
- return {
2724
- attribute,
2725
- disabled: !metadata.editable,
2726
- hint: metadata.description,
2727
- label: metadata.label ?? "",
2728
- name: field.name,
2729
- // @ts-expect-error – mainField does exist on the metadata for a relation.
2730
- mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
2731
- schemas,
2732
- components: components?.schemas ?? {}
2733
- }),
2734
- placeholder: metadata.placeholder ?? "",
2735
- required: attribute.required ?? false,
2736
- size: field.size,
2737
- unique: "unique" in attribute ? attribute.unique : false,
2738
- visible: metadata.visible ?? true,
2739
- type: attribute.type
2740
- };
2741
- }).filter((field) => field !== null)
2742
- );
2743
- };
2744
- const formatListLayout = (data, {
2745
- schemas,
2746
- schema,
2747
- components
2748
- }) => {
2749
- const listMetadatas = Object.entries(data.contentType.metadatas).reduce(
2750
- (acc, [attribute, metadata]) => {
2751
- return {
2752
- ...acc,
2753
- [attribute]: metadata.list
2754
- };
2755
- },
2756
- {}
2757
- );
2758
- const listAttributes = convertListLayoutToFieldLayouts(
2759
- data.contentType.layouts.list,
2760
- schema?.attributes,
2761
- listMetadatas,
2762
- { configurations: data.components, schemas: components },
2763
- schemas
2764
- );
2765
- return {
2766
- layout: listAttributes,
2767
- settings: { ...data.contentType.settings, displayName: schema?.info.displayName },
2768
- metadatas: listMetadatas,
2769
- options: {
2770
- ...schema?.options,
2771
- ...schema?.pluginOptions,
2772
- ...data.contentType.options
2773
- }
2774
- };
2775
- };
2776
- const convertListLayoutToFieldLayouts = (columns, attributes = {}, metadatas, components, schemas = []) => {
2777
- return columns.map((name) => {
2778
- const attribute = attributes[name];
2779
- if (!attribute) {
2780
- return null;
2781
- }
2782
- const metadata = metadatas[name];
2783
- const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
2784
- return {
2785
- attribute,
2786
- label: metadata.label ?? "",
2787
- mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
2788
- schemas,
2789
- components: components?.schemas ?? {}
2790
- }),
2791
- name,
2792
- searchable: metadata.searchable ?? true,
2793
- sortable: metadata.sortable ?? true
2794
- };
2795
- }).filter((field) => field !== null);
2796
- };
2797
3253
  const ConfirmBulkActionDialog = ({
2798
3254
  onToggleDialog,
2799
3255
  isOpen = false,
@@ -2801,32 +3257,25 @@ const ConfirmBulkActionDialog = ({
2801
3257
  endAction
2802
3258
  }) => {
2803
3259
  const { formatMessage } = useIntl();
2804
- return /* @__PURE__ */ jsxs(
2805
- Dialog,
2806
- {
2807
- onClose: onToggleDialog,
2808
- title: formatMessage({
2809
- id: "app.components.ConfirmDialog.title",
2810
- defaultMessage: "Confirmation"
2811
- }),
2812
- isOpen,
2813
- children: [
2814
- /* @__PURE__ */ jsx(DialogBody, { icon: /* @__PURE__ */ jsx(WarningCircle, {}), children: /* @__PURE__ */ jsx(Flex, { direction: "column", alignItems: "stretch", gap: 2, children: dialogBody }) }),
2815
- /* @__PURE__ */ jsx(
2816
- DialogFooter,
2817
- {
2818
- startAction: /* @__PURE__ */ jsx(Button, { onClick: onToggleDialog, variant: "tertiary", children: formatMessage({
2819
- id: "app.components.Button.cancel",
2820
- defaultMessage: "Cancel"
2821
- }) }),
2822
- endAction
2823
- }
2824
- )
2825
- ]
2826
- }
2827
- );
3260
+ return /* @__PURE__ */ jsx(Dialog.Root, { open: isOpen, children: /* @__PURE__ */ jsxs(Dialog.Content, { children: [
3261
+ /* @__PURE__ */ jsx(Dialog.Header, { children: formatMessage({
3262
+ id: "app.components.ConfirmDialog.title",
3263
+ defaultMessage: "Confirmation"
3264
+ }) }),
3265
+ /* @__PURE__ */ jsx(Dialog.Body, { children: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
3266
+ /* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(WarningCircle, { width: "24px", height: "24px", fill: "danger600" }) }),
3267
+ dialogBody
3268
+ ] }) }),
3269
+ /* @__PURE__ */ jsxs(Dialog.Footer, { children: [
3270
+ /* @__PURE__ */ jsx(Dialog.Cancel, { children: /* @__PURE__ */ jsx(Button, { fullWidth: true, onClick: onToggleDialog, variant: "tertiary", children: formatMessage({
3271
+ id: "app.components.Button.cancel",
3272
+ defaultMessage: "Cancel"
3273
+ }) }) }),
3274
+ endAction
3275
+ ] })
3276
+ ] }) });
2828
3277
  };
2829
- const BoldChunk$1 = (chunks) => /* @__PURE__ */ jsx(Typography, { fontWeight: "bold", children: chunks });
3278
+ const BoldChunk = (chunks) => /* @__PURE__ */ jsx(Typography, { fontWeight: "bold", children: chunks });
2830
3279
  const ConfirmDialogPublishAll = ({
2831
3280
  isOpen,
2832
3281
  onToggleDialog,
@@ -2839,6 +3288,7 @@ const ConfirmDialogPublishAll = ({
2839
3288
  const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler(getTranslation);
2840
3289
  const { model, schema } = useDoc();
2841
3290
  const [{ query }] = useQueryParams();
3291
+ const enableDraftRelationsCount = false;
2842
3292
  const {
2843
3293
  data: countDraftRelations = 0,
2844
3294
  isLoading,
@@ -2850,7 +3300,7 @@ const ConfirmDialogPublishAll = ({
2850
3300
  locale: query?.plugins?.i18n?.locale
2851
3301
  },
2852
3302
  {
2853
- skip: selectedEntries.length === 0
3303
+ skip: !enableDraftRelationsCount
2854
3304
  }
2855
3305
  );
2856
3306
  React.useEffect(() => {
@@ -2874,7 +3324,7 @@ const ConfirmDialogPublishAll = ({
2874
3324
  defaultMessage: "<b>{count} {count, plural, one { relation } other { relations } } out of {entities} { entities, plural, one { entry } other { entries } } {count, plural, one { is } other { are } }</b> not published yet and might lead to unexpected behavior. "
2875
3325
  },
2876
3326
  {
2877
- b: BoldChunk$1,
3327
+ b: BoldChunk,
2878
3328
  count: countDraftRelations,
2879
3329
  entities: selectedEntries.length
2880
3330
  }
@@ -2913,6 +3363,16 @@ const ConfirmDialogPublishAll = ({
2913
3363
  const TypographyMaxWidth = styled(Typography)`
2914
3364
  max-width: 300px;
2915
3365
  `;
3366
+ const TableComponent = styled(RawTable)`
3367
+ width: 100%;
3368
+ table-layout: fixed;
3369
+ td:first-child {
3370
+ border-right: 1px solid ${({ theme }) => theme.colors.neutral150};
3371
+ }
3372
+ td:first-of-type {
3373
+ padding: ${({ theme }) => theme.spaces[4]};
3374
+ }
3375
+ `;
2916
3376
  const formatErrorMessages = (errors, parentKey, formatMessage) => {
2917
3377
  const messages = [];
2918
3378
  Object.entries(errors).forEach(([key, value]) => {
@@ -2929,7 +3389,14 @@ const formatErrorMessages = (errors, parentKey, formatMessage) => {
2929
3389
  )
2930
3390
  );
2931
3391
  } else {
2932
- messages.push(...formatErrorMessages(value, currentKey, formatMessage));
3392
+ messages.push(
3393
+ ...formatErrorMessages(
3394
+ // @ts-expect-error TODO: check why value is not compatible with FormErrors
3395
+ value,
3396
+ currentKey,
3397
+ formatMessage
3398
+ )
3399
+ );
2933
3400
  }
2934
3401
  } else {
2935
3402
  messages.push(
@@ -3010,7 +3477,7 @@ const SelectedEntriesTableContent = ({
3010
3477
  )
3011
3478
  ] }),
3012
3479
  /* @__PURE__ */ jsx(Table.Loading, {}),
3013
- /* @__PURE__ */ jsx(Table.Body, { children: rowsToDisplay.map((row, index2) => /* @__PURE__ */ jsxs(Table.Row, { children: [
3480
+ /* @__PURE__ */ jsx(Table.Body, { children: rowsToDisplay.map((row) => /* @__PURE__ */ jsxs(Table.Row, { children: [
3014
3481
  /* @__PURE__ */ jsx(Table.CheckboxCell, { id: row.id }),
3015
3482
  /* @__PURE__ */ jsx(Table.Cell, { children: /* @__PURE__ */ jsx(Typography, { children: row.id }) }),
3016
3483
  shouldDisplayMainField && /* @__PURE__ */ jsx(Table.Cell, { children: /* @__PURE__ */ jsx(Typography, { children: row[mainField] }) }),
@@ -3028,7 +3495,7 @@ const SelectedEntriesTableContent = ({
3028
3495
  status: row.status
3029
3496
  }
3030
3497
  ) }),
3031
- /* @__PURE__ */ jsx(Table.Cell, { children: /* @__PURE__ */ jsx(
3498
+ /* @__PURE__ */ jsx(Table.Cell, { children: /* @__PURE__ */ jsx(Flex, { children: /* @__PURE__ */ jsx(
3032
3499
  IconButton,
3033
3500
  {
3034
3501
  tag: Link,
@@ -3037,27 +3504,86 @@ const SelectedEntriesTableContent = ({
3037
3504
  search: row.locale && `?plugins[i18n][locale]=${row.locale}`
3038
3505
  },
3039
3506
  state: { from: pathname },
3040
- label: formatMessage(
3041
- { id: "app.component.HelperPluginTable.edit", defaultMessage: "Edit {target}" },
3042
- {
3043
- target: formatMessage(
3044
- {
3045
- id: "content-manager.components.ListViewHelperPluginTable.row-line",
3046
- defaultMessage: "item line {number}"
3047
- },
3048
- { number: index2 + 1 }
3049
- )
3050
- }
3051
- ),
3507
+ label: formatMessage({
3508
+ id: "content-manager.bulk-publish.edit",
3509
+ defaultMessage: "Edit"
3510
+ }),
3052
3511
  target: "_blank",
3053
3512
  marginLeft: "auto",
3054
- children: /* @__PURE__ */ jsx(Pencil, {})
3513
+ variant: "ghost",
3514
+ children: /* @__PURE__ */ jsx(Pencil, { width: "1.6rem", height: "1.6rem" })
3055
3515
  }
3056
- ) })
3516
+ ) }) })
3057
3517
  ] }, row.id)) })
3058
3518
  ] });
3059
3519
  };
3060
- const BoldChunk = (chunks) => /* @__PURE__ */ jsx(Typography, { fontWeight: "bold", children: chunks });
3520
+ const PublicationStatusSummary = ({ count, icon, message }) => {
3521
+ return /* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", flex: 1, gap: 3, children: [
3522
+ /* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
3523
+ icon,
3524
+ /* @__PURE__ */ jsx(Typography, { children: message })
3525
+ ] }),
3526
+ /* @__PURE__ */ jsx(Typography, { fontWeight: "bold", children: count })
3527
+ ] });
3528
+ };
3529
+ const PublicationStatusGrid = ({
3530
+ entriesReadyToPublishCount,
3531
+ entriesPublishedCount,
3532
+ entriesModifiedCount,
3533
+ entriesWithErrorsCount
3534
+ }) => {
3535
+ const { formatMessage } = useIntl();
3536
+ return /* @__PURE__ */ jsx(Box, { hasRadius: true, borderColor: "neutral150", children: /* @__PURE__ */ jsx(TableComponent, { colCount: 2, rowCount: 2, children: /* @__PURE__ */ jsxs(Tbody, { children: [
3537
+ /* @__PURE__ */ jsxs(Tr, { children: [
3538
+ /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(
3539
+ PublicationStatusSummary,
3540
+ {
3541
+ count: entriesReadyToPublishCount,
3542
+ icon: /* @__PURE__ */ jsx(CheckCircle, { fill: "success600" }),
3543
+ message: formatMessage({
3544
+ id: "app.utils.ready-to-publish",
3545
+ defaultMessage: "Ready to publish"
3546
+ })
3547
+ }
3548
+ ) }),
3549
+ /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(
3550
+ PublicationStatusSummary,
3551
+ {
3552
+ count: entriesPublishedCount,
3553
+ icon: /* @__PURE__ */ jsx(CheckCircle, { fill: "success600" }),
3554
+ message: formatMessage({
3555
+ id: "app.utils.already-published",
3556
+ defaultMessage: "Already published"
3557
+ })
3558
+ }
3559
+ ) })
3560
+ ] }),
3561
+ /* @__PURE__ */ jsxs(Tr, { children: [
3562
+ /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(
3563
+ PublicationStatusSummary,
3564
+ {
3565
+ count: entriesModifiedCount,
3566
+ icon: /* @__PURE__ */ jsx(ArrowsCounterClockwise, { fill: "alternative600" }),
3567
+ message: formatMessage({
3568
+ id: "content-manager.bulk-publish.modified",
3569
+ defaultMessage: "Ready to publish changes"
3570
+ })
3571
+ }
3572
+ ) }),
3573
+ /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(
3574
+ PublicationStatusSummary,
3575
+ {
3576
+ count: entriesWithErrorsCount,
3577
+ icon: /* @__PURE__ */ jsx(CrossCircle, { fill: "danger600" }),
3578
+ message: formatMessage({
3579
+ id: "content-manager.bulk-publish.waiting-for-action",
3580
+ defaultMessage: "Waiting for action"
3581
+ })
3582
+ }
3583
+ ) })
3584
+ ] })
3585
+ ] }) }) });
3586
+ };
3061
3587
  const SelectedEntriesModalContent = ({
3062
3588
  listViewSelectedEntries,
3063
3589
  toggleModal,
@@ -3090,7 +3616,13 @@ const SelectedEntriesModalContent = ({
3090
3616
  );
3091
3617
  const { rows, validationErrors } = React.useMemo(() => {
3092
3618
  if (data.length > 0 && schema) {
3093
- const validate = createYupSchema(schema.attributes, components);
3619
+ const validate = createYupSchema(
3620
+ schema.attributes,
3621
+ components,
3622
+ // Since this is the "Publish" action, the validation
3623
+ // schema must enforce the rules for published entities
3624
+ { status: "published" }
3625
+ );
3094
3626
  const validationErrors2 = {};
3095
3627
  const rows2 = data.map((entry) => {
3096
3628
  try {
@@ -3110,7 +3642,6 @@ const SelectedEntriesModalContent = ({
3110
3642
  validationErrors: {}
3111
3643
  };
3112
3644
  }, [components, data, schema]);
3113
- const [publishedCount, setPublishedCount] = React.useState(0);
3114
3645
  const [isDialogOpen, setIsDialogOpen] = React.useState(false);
3115
3646
  const { publishMany: bulkPublishAction } = useDocumentActions();
3116
3647
  const [, { isLoading: isSubmittingForm }] = usePublishManyDocumentsMutation();
@@ -3122,53 +3653,36 @@ const SelectedEntriesModalContent = ({
3122
3653
  const selectedEntriesWithErrorsCount = selectedEntries.filter(
3123
3654
  ({ documentId }) => validationErrors[documentId]
3124
3655
  ).length;
3125
- const selectedEntriesPublished = selectedEntries.filter(
3656
+ const selectedEntriesPublishedCount = selectedEntries.filter(
3126
3657
  ({ status }) => status === "published"
3127
3658
  ).length;
3128
- const selectedEntriesWithNoErrorsCount = selectedEntries.length - selectedEntriesWithErrorsCount - selectedEntriesPublished;
3659
+ const selectedEntriesModifiedCount = selectedEntries.filter(
3660
+ ({ status, documentId }) => status === "modified" && !validationErrors[documentId]
3661
+ ).length;
3662
+ const selectedEntriesWithNoErrorsCount = selectedEntries.length - selectedEntriesWithErrorsCount - selectedEntriesPublishedCount;
3129
3663
  const toggleDialog = () => setIsDialogOpen((prev) => !prev);
3130
3664
  const handleConfirmBulkPublish = async () => {
3131
3665
  toggleDialog();
3132
3666
  const res = await bulkPublishAction({ model, documentIds: entriesToPublish, params });
3133
3667
  if (!("error" in res)) {
3134
- setPublishedCount(res.count);
3135
3668
  const unpublishedEntries = rows.filter((row) => {
3136
3669
  return !entriesToPublish.includes(row.documentId);
3137
3670
  });
3138
3671
  setListViewSelectedDocuments(unpublishedEntries);
3139
3672
  }
3140
3673
  };
3141
- const getFormattedCountMessage = () => {
3142
- if (publishedCount) {
3143
- return formatMessage(
3144
- {
3145
- id: getTranslation("containers.list.selectedEntriesModal.publishedCount"),
3146
- defaultMessage: "<b>{publishedCount}</b> {publishedCount, plural, =0 {entries} one {entry} other {entries}} published. <b>{withErrorsCount}</b> {withErrorsCount, plural, =0 {entries} one {entry} other {entries}} waiting for action."
3147
- },
3674
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
3675
+ /* @__PURE__ */ jsxs(Modal.Body, { children: [
3676
+ /* @__PURE__ */ jsx(
3677
+ PublicationStatusGrid,
3148
3678
  {
3149
- publishedCount,
3150
- withErrorsCount: selectedEntriesWithErrorsCount,
3151
- b: BoldChunk
3679
+ entriesReadyToPublishCount: selectedEntriesWithNoErrorsCount - selectedEntriesModifiedCount,
3680
+ entriesPublishedCount: selectedEntriesPublishedCount,
3681
+ entriesModifiedCount: selectedEntriesModifiedCount,
3682
+ entriesWithErrorsCount: selectedEntriesWithErrorsCount
3152
3683
  }
3153
- );
3154
- }
3155
- return formatMessage(
3156
- {
3157
- id: getTranslation("containers.list.selectedEntriesModal.selectedCount"),
3158
- defaultMessage: "<b>{alreadyPublishedCount}</b> {alreadyPublishedCount, plural, =0 {entries} one {entry} other {entries}} already published. <b>{readyToPublishCount}</b> {readyToPublishCount, plural, =0 {entries} one {entry} other {entries}} ready to publish. <b>{withErrorsCount}</b> {withErrorsCount, plural, =0 {entries} one {entry} other {entries}} waiting for action."
3159
- },
3160
- {
3161
- readyToPublishCount: selectedEntriesWithNoErrorsCount,
3162
- withErrorsCount: selectedEntriesWithErrorsCount,
3163
- alreadyPublishedCount: selectedEntriesPublished,
3164
- b: BoldChunk
3165
- }
3166
- );
3167
- };
3168
- return /* @__PURE__ */ jsxs(Fragment, { children: [
3169
- /* @__PURE__ */ jsxs(ModalBody, { children: [
3170
- /* @__PURE__ */ jsx(Typography, { children: getFormattedCountMessage() }),
3171
- /* @__PURE__ */ jsx(Box, { marginTop: 5, children: /* @__PURE__ */ jsx(
3684
+ ),
3685
+ /* @__PURE__ */ jsx(Box, { marginTop: 7, children: /* @__PURE__ */ jsx(
3172
3686
  SelectedEntriesTableContent,
3173
3687
  {
3174
3688
  isPublishing: isSubmittingForm,
@@ -3178,27 +3692,24 @@ const SelectedEntriesModalContent = ({
3178
3692
  }
3179
3693
  ) })
3180
3694
  ] }),
3181
- /* @__PURE__ */ jsx(
3182
- ModalFooter,
3183
- {
3184
- startActions: /* @__PURE__ */ jsx(Button, { onClick: toggleModal, variant: "tertiary", children: formatMessage({
3185
- id: "app.components.Button.cancel",
3186
- defaultMessage: "Cancel"
3187
- }) }),
3188
- endActions: /* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
3189
- /* @__PURE__ */ jsx(Button, { onClick: refetch, variant: "tertiary", loading: isFetching, children: formatMessage({ id: "app.utils.refresh", defaultMessage: "Refresh" }) }),
3190
- /* @__PURE__ */ jsx(
3191
- Button,
3192
- {
3193
- onClick: toggleDialog,
3194
- disabled: selectedEntries.length === 0 || selectedEntries.length === selectedEntriesWithErrorsCount || selectedEntriesPublished === selectedEntries.length || isLoading,
3195
- loading: isSubmittingForm,
3196
- children: formatMessage({ id: "app.utils.publish", defaultMessage: "Publish" })
3197
- }
3198
- )
3199
- ] })
3200
- }
3201
- ),
3695
+ /* @__PURE__ */ jsxs(Modal.Footer, { children: [
3696
+ /* @__PURE__ */ jsx(Button, { onClick: toggleModal, variant: "tertiary", children: formatMessage({
3697
+ id: "app.components.Button.cancel",
3698
+ defaultMessage: "Cancel"
3699
+ }) }),
3700
+ /* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
3701
+ /* @__PURE__ */ jsx(Button, { onClick: refetch, variant: "tertiary", loading: isFetching, children: formatMessage({ id: "app.utils.refresh", defaultMessage: "Refresh" }) }),
3702
+ /* @__PURE__ */ jsx(
3703
+ Button,
3704
+ {
3705
+ onClick: toggleDialog,
3706
+ disabled: selectedEntries.length === 0 || selectedEntries.length === selectedEntriesWithErrorsCount || selectedEntriesPublishedCount === selectedEntries.length || isLoading,
3707
+ loading: isSubmittingForm,
3708
+ children: formatMessage({ id: "app.utils.publish", defaultMessage: "Publish" })
3709
+ }
3710
+ )
3711
+ ] })
3712
+ ] }),
3202
3713
  /* @__PURE__ */ jsx(
3203
3714
  ConfirmDialogPublishAll,
3204
3715
  {
@@ -3218,8 +3729,7 @@ const PublishAction = ({ documents, model }) => {
3218
3729
  const refetchList = () => {
3219
3730
  contentManagerApi.util.invalidateTags([{ type: "Document", id: `${model}_LIST` }]);
3220
3731
  };
3221
- if (!showPublishButton)
3222
- return null;
3732
+ if (!showPublishButton) return null;
3223
3733
  return {
3224
3734
  actionType: "publish",
3225
3735
  variant: "tertiary",
@@ -3263,143 +3773,10 @@ const BulkActionsRenderer = () => {
3263
3773
  documents: selectedRows
3264
3774
  },
3265
3775
  descriptions: plugins["content-manager"].apis.getBulkActions(),
3266
- children: (actions2) => actions2.map((action) => /* @__PURE__ */ jsx(BulkActionAction, { ...action }, action.id))
3776
+ children: (actions2) => actions2.map((action) => /* @__PURE__ */ jsx(DocumentActionButton, { ...action }, action.id))
3267
3777
  }
3268
3778
  ) });
3269
3779
  };
3270
- const BulkActionAction = (action) => {
3271
- const [dialogId, setDialogId] = React.useState(null);
3272
- const { toggleNotification } = useNotification();
3273
- const handleClick = (action2) => (e) => {
3274
- const { onClick, dialog, id } = action2;
3275
- if (onClick) {
3276
- onClick(e);
3277
- }
3278
- if (dialog) {
3279
- switch (dialog.type) {
3280
- case "notification":
3281
- toggleNotification({
3282
- title: dialog.title,
3283
- message: dialog.content,
3284
- type: dialog.status,
3285
- timeout: dialog.timeout,
3286
- onClose: dialog.onClose
3287
- });
3288
- break;
3289
- case "dialog":
3290
- case "modal": {
3291
- e.preventDefault();
3292
- setDialogId(id);
3293
- }
3294
- }
3295
- }
3296
- };
3297
- const handleClose = () => {
3298
- setDialogId(null);
3299
- if (action.dialog?.type === "modal" && action.dialog?.onClose) {
3300
- action.dialog.onClose();
3301
- }
3302
- };
3303
- return /* @__PURE__ */ jsxs(Fragment, { children: [
3304
- /* @__PURE__ */ jsx(
3305
- Button,
3306
- {
3307
- disabled: action.disabled,
3308
- startIcon: action.icon,
3309
- variant: action.variant,
3310
- onClick: handleClick(action),
3311
- children: action.label
3312
- }
3313
- ),
3314
- action.dialog?.type === "dialog" ? /* @__PURE__ */ jsx(
3315
- BulkActionConfirmDialog,
3316
- {
3317
- ...action.dialog,
3318
- variant: action.variant,
3319
- isOpen: dialogId === action.id,
3320
- onClose: handleClose
3321
- }
3322
- ) : null,
3323
- action.dialog?.type === "modal" ? /* @__PURE__ */ jsx(
3324
- BulkActionModal,
3325
- {
3326
- ...action.dialog,
3327
- onModalClose: handleClose,
3328
- isOpen: dialogId === action.id
3329
- }
3330
- ) : null
3331
- ] });
3332
- };
3333
- const BulkActionConfirmDialog = ({
3334
- onClose,
3335
- onCancel,
3336
- onConfirm,
3337
- title,
3338
- content,
3339
- confirmButton,
3340
- isOpen,
3341
- variant = "secondary"
3342
- }) => {
3343
- const { formatMessage } = useIntl();
3344
- const handleClose = async () => {
3345
- if (onCancel) {
3346
- await onCancel();
3347
- }
3348
- onClose();
3349
- };
3350
- const handleConfirm = async () => {
3351
- if (onConfirm) {
3352
- await onConfirm();
3353
- }
3354
- onClose();
3355
- };
3356
- return /* @__PURE__ */ jsxs(Dialog, { isOpen, title, onClose: handleClose, children: [
3357
- /* @__PURE__ */ jsx(DialogBody, { icon: /* @__PURE__ */ jsx(WarningCircle, {}), children: content }),
3358
- /* @__PURE__ */ jsx(
3359
- DialogFooter,
3360
- {
3361
- startAction: /* @__PURE__ */ jsx(Button, { onClick: handleClose, variant: "tertiary", children: formatMessage({
3362
- id: "app.components.Button.cancel",
3363
- defaultMessage: "Cancel"
3364
- }) }),
3365
- endAction: /* @__PURE__ */ jsx(
3366
- Button,
3367
- {
3368
- onClick: handleConfirm,
3369
- variant: variant === "danger-light" ? variant : "secondary",
3370
- startIcon: variant === "danger-light" ? /* @__PURE__ */ jsx(Trash, {}) : /* @__PURE__ */ jsx(Check, {}),
3371
- children: confirmButton ? confirmButton : formatMessage({
3372
- id: "app.components.Button.confirm",
3373
- defaultMessage: "Confirm"
3374
- })
3375
- }
3376
- )
3377
- }
3378
- )
3379
- ] });
3380
- };
3381
- const BulkActionModal = ({
3382
- isOpen,
3383
- title,
3384
- onClose,
3385
- content: Content,
3386
- onModalClose
3387
- }) => {
3388
- const id = React.useId();
3389
- if (!isOpen) {
3390
- return null;
3391
- }
3392
- const handleClose = () => {
3393
- if (onClose) {
3394
- onClose();
3395
- }
3396
- onModalClose();
3397
- };
3398
- return /* @__PURE__ */ jsxs(ModalLayout, { borderRadius: "4px", overflow: "hidden", onClose: handleClose, labelledBy: id, children: [
3399
- /* @__PURE__ */ jsx(ModalHeader, { children: /* @__PURE__ */ jsx(Typography, { fontWeight: "bold", textColor: "neutral800", tag: "h2", id, children: title }) }),
3400
- /* @__PURE__ */ jsx(Content, { onClose: handleClose })
3401
- ] });
3402
- };
3403
3780
  const DeleteAction = ({ documents, model }) => {
3404
3781
  const { formatMessage } = useIntl();
3405
3782
  const { schema: contentType } = useDoc();
@@ -3420,8 +3797,7 @@ const DeleteAction = ({ documents, model }) => {
3420
3797
  selectRow([]);
3421
3798
  }
3422
3799
  };
3423
- if (!hasDeletePermission)
3424
- return null;
3800
+ if (!hasDeletePermission) return null;
3425
3801
  return {
3426
3802
  variant: "danger-light",
3427
3803
  label: formatMessage({ id: "global.delete", defaultMessage: "Delete" }),
@@ -3432,6 +3808,7 @@ const DeleteAction = ({ documents, model }) => {
3432
3808
  defaultMessage: "Confirmation"
3433
3809
  }),
3434
3810
  content: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
3811
+ /* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(WarningCircle, { width: "24px", height: "24px", fill: "danger600" }) }),
3435
3812
  /* @__PURE__ */ jsx(Typography, { id: "confirm-description", textAlign: "center", children: formatMessage({
3436
3813
  id: "popUpWarning.bodyMessage.contentType.delete.all",
3437
3814
  defaultMessage: "Are you sure you want to delete these entries?"
@@ -3469,8 +3846,7 @@ const UnpublishAction = ({ documents, model }) => {
3469
3846
  }
3470
3847
  };
3471
3848
  const showUnpublishButton = hasDraftAndPublishEnabled && hasPublishPermission && documents.some((entry) => entry.status === "published" || entry.status === "modified");
3472
- if (!showUnpublishButton)
3473
- return null;
3849
+ if (!showUnpublishButton) return null;
3474
3850
  return {
3475
3851
  variant: "tertiary",
3476
3852
  label: formatMessage({ id: "app.utils.unpublish", defaultMessage: "Unpublish" }),
@@ -3481,6 +3857,7 @@ const UnpublishAction = ({ documents, model }) => {
3481
3857
  defaultMessage: "Confirmation"
3482
3858
  }),
3483
3859
  content: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
3860
+ /* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(WarningCircle, { width: "24px", height: "24px", fill: "danger600" }) }),
3484
3861
  /* @__PURE__ */ jsx(Typography, { id: "confirm-description", textAlign: "center", children: formatMessage({
3485
3862
  id: "popUpWarning.bodyMessage.contentType.unpublish.all",
3486
3863
  defaultMessage: "Are you sure you want to unpublish these entries?"
@@ -3574,7 +3951,7 @@ const TableActions = ({ document }) => {
3574
3951
  DescriptionComponentRenderer,
3575
3952
  {
3576
3953
  props,
3577
- descriptions: plugins["content-manager"].apis.getDocumentActions(),
3954
+ descriptions: plugins["content-manager"].apis.getDocumentActions("table-row").filter((action) => action.name !== "PublishAction"),
3578
3955
  children: (actions2) => {
3579
3956
  const tableRowActions = actions2.filter((action) => {
3580
3957
  const positions = Array.isArray(action.position) ? action.position : [action.position];
@@ -3633,6 +4010,7 @@ const EditAction = ({ documentId }) => {
3633
4010
  };
3634
4011
  };
3635
4012
  EditAction.type = "edit";
4013
+ EditAction.position = "table-row";
3636
4014
  const StyledPencil = styled(Pencil)`
3637
4015
  path {
3638
4016
  fill: currentColor;
@@ -3685,7 +4063,7 @@ const CloneAction = ({ model, documentId }) => {
3685
4063
  }),
3686
4064
  content: /* @__PURE__ */ jsx(AutoCloneFailureModalBody, { prohibitedFields }),
3687
4065
  footer: ({ onClose }) => {
3688
- return /* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", children: [
4066
+ return /* @__PURE__ */ jsxs(Modal.Footer, { children: [
3689
4067
  /* @__PURE__ */ jsx(Button, { onClick: onClose, variant: "tertiary", children: formatMessage({
3690
4068
  id: "cancel",
3691
4069
  defaultMessage: "Cancel"
@@ -3709,6 +4087,7 @@ const CloneAction = ({ model, documentId }) => {
3709
4087
  };
3710
4088
  };
3711
4089
  CloneAction.type = "clone";
4090
+ CloneAction.position = "table-row";
3712
4091
  const StyledDuplicate = styled(Duplicate)`
3713
4092
  path {
3714
4093
  fill: currentColor;
@@ -3726,8 +4105,7 @@ class ContentManagerPlugin {
3726
4105
  documentActions = [
3727
4106
  ...DEFAULT_ACTIONS,
3728
4107
  ...DEFAULT_TABLE_ROW_ACTIONS,
3729
- ...DEFAULT_HEADER_ACTIONS,
3730
- HistoryAction
4108
+ ...DEFAULT_HEADER_ACTIONS
3731
4109
  ];
3732
4110
  editViewSidePanels = [ActionsPanel];
3733
4111
  headerActions = [];
@@ -3796,7 +4174,14 @@ class ContentManagerPlugin {
3796
4174
  addDocumentHeaderAction: this.addDocumentHeaderAction.bind(this),
3797
4175
  addEditViewSidePanel: this.addEditViewSidePanel.bind(this),
3798
4176
  getBulkActions: () => this.bulkActions,
3799
- getDocumentActions: () => this.documentActions,
4177
+ getDocumentActions: (position) => {
4178
+ if (position) {
4179
+ return this.documentActions.filter(
4180
+ (action) => action.position == void 0 || [action.position].flat().includes(position)
4181
+ );
4182
+ }
4183
+ return this.documentActions;
4184
+ },
3800
4185
  getEditViewSidePanels: () => this.editViewSidePanels,
3801
4186
  getHeaderActions: () => this.headerActions
3802
4187
  }
@@ -3806,16 +4191,71 @@ class ContentManagerPlugin {
3806
4191
  const getPrintableType = (value) => {
3807
4192
  const nativeType = typeof value;
3808
4193
  if (nativeType === "object") {
3809
- if (value === null)
3810
- return "null";
3811
- if (Array.isArray(value))
3812
- return "array";
4194
+ if (value === null) return "null";
4195
+ if (Array.isArray(value)) return "array";
3813
4196
  if (value instanceof Object && value.constructor.name !== "Object") {
3814
4197
  return value.constructor.name;
3815
4198
  }
3816
4199
  }
3817
4200
  return nativeType;
3818
4201
  };
4202
+ const HistoryAction = ({ model, document }) => {
4203
+ const { formatMessage } = useIntl();
4204
+ const [{ query }] = useQueryParams();
4205
+ const navigate = useNavigate();
4206
+ const { trackUsage } = useTracking();
4207
+ const { pathname } = useLocation();
4208
+ const pluginsQueryParams = stringify({ plugins: query.plugins }, { encode: false });
4209
+ if (!window.strapi.features.isEnabled("cms-content-history")) {
4210
+ return null;
4211
+ }
4212
+ const handleOnClick = () => {
4213
+ const destination = { pathname: "history", search: pluginsQueryParams };
4214
+ trackUsage("willNavigate", {
4215
+ from: pathname,
4216
+ to: `${pathname}/${destination.pathname}`
4217
+ });
4218
+ navigate(destination);
4219
+ };
4220
+ return {
4221
+ icon: /* @__PURE__ */ jsx(ClockCounterClockwise, {}),
4222
+ label: formatMessage({
4223
+ id: "content-manager.history.document-action",
4224
+ defaultMessage: "Content History"
4225
+ }),
4226
+ onClick: handleOnClick,
4227
+ disabled: (
4228
+ /**
4229
+ * The user is creating a new document.
4230
+ * It hasn't been saved yet, so there's no history to go to
4231
+ */
4232
+ !document || /**
4233
+ * The document has been created but the current dimension has never been saved.
4234
+ * For example, the user is creating a new locale in an existing document,
4235
+ * so there's no history for the document in that locale
4236
+ */
4237
+ !document.id || /**
4238
+ * History is only available for content types created by the user.
4239
+ * These have the `api::` prefix, as opposed to the ones created by Strapi or plugins,
4240
+ * which start with `admin::` or `plugin::`
4241
+ */
4242
+ !model.startsWith("api::")
4243
+ ),
4244
+ position: "header"
4245
+ };
4246
+ };
4247
+ HistoryAction.type = "history";
4248
+ HistoryAction.position = "header";
4249
+ const historyAdmin = {
4250
+ bootstrap(app) {
4251
+ const { addDocumentAction } = app.getPlugin("content-manager").apis;
4252
+ addDocumentAction((actions2) => {
4253
+ const indexOfDeleteAction = actions2.findIndex((action) => action.type === "delete");
4254
+ actions2.splice(indexOfDeleteAction, 0, HistoryAction);
4255
+ return actions2;
4256
+ });
4257
+ }
4258
+ };
3819
4259
  const initialState = {
3820
4260
  collectionTypeLinks: [],
3821
4261
  components: [],
@@ -3852,6 +4292,88 @@ const { setInitialData } = actions;
3852
4292
  const reducer = combineReducers({
3853
4293
  app: reducer$1
3854
4294
  });
4295
+ const previewApi = contentManagerApi.injectEndpoints({
4296
+ endpoints: (builder) => ({
4297
+ getPreviewUrl: builder.query({
4298
+ query({ query, params }) {
4299
+ return {
4300
+ url: `/content-manager/preview/url/${params.contentType}`,
4301
+ method: "GET",
4302
+ config: {
4303
+ params: query
4304
+ }
4305
+ };
4306
+ }
4307
+ })
4308
+ })
4309
+ });
4310
+ const { useGetPreviewUrlQuery } = previewApi;
4311
+ const ConditionalTooltip = ({ isShown, label, children }) => {
4312
+ if (isShown) {
4313
+ return /* @__PURE__ */ jsx(Tooltip, { label, children });
4314
+ }
4315
+ return children;
4316
+ };
4317
+ const PreviewSidePanel = ({ model, documentId, document }) => {
4318
+ const { formatMessage } = useIntl();
4319
+ const { trackUsage } = useTracking();
4320
+ const { pathname } = useLocation();
4321
+ const [{ query }] = useQueryParams();
4322
+ const isModified = useForm("PreviewSidePanel", (state) => state.modified);
4323
+ const { data, error } = useGetPreviewUrlQuery({
4324
+ params: {
4325
+ contentType: model
4326
+ },
4327
+ query: {
4328
+ documentId,
4329
+ locale: document?.locale,
4330
+ status: document?.status
4331
+ }
4332
+ });
4333
+ if (!data?.data?.url || error) {
4334
+ return null;
4335
+ }
4336
+ const trackNavigation = () => {
4337
+ const destinationPathname = pathname.replace(/\/$/, "") + "/preview";
4338
+ trackUsage("willNavigate", { from: pathname, to: destinationPathname });
4339
+ };
4340
+ return {
4341
+ title: formatMessage({ id: "content-manager.preview.panel.title", defaultMessage: "Preview" }),
4342
+ content: /* @__PURE__ */ jsx(
4343
+ ConditionalTooltip,
4344
+ {
4345
+ label: formatMessage({
4346
+ id: "content-manager.preview.panel.button-disabled-tooltip",
4347
+ defaultMessage: "Please save to open the preview"
4348
+ }),
4349
+ isShown: isModified,
4350
+ children: /* @__PURE__ */ jsx(Box, { cursor: "not-allowed", width: "100%", children: /* @__PURE__ */ jsx(
4351
+ Button,
4352
+ {
4353
+ variant: "tertiary",
4354
+ tag: Link,
4355
+ to: { pathname: "preview", search: stringify(query, { encode: false }) },
4356
+ onClick: trackNavigation,
4357
+ width: "100%",
4358
+ disabled: isModified,
4359
+ pointerEvents: isModified ? "none" : void 0,
4360
+ tabIndex: isModified ? -1 : void 0,
4361
+ children: formatMessage({
4362
+ id: "content-manager.preview.panel.button",
4363
+ defaultMessage: "Open preview"
4364
+ })
4365
+ }
4366
+ ) })
4367
+ }
4368
+ )
4369
+ };
4370
+ };
4371
+ const previewAdmin = {
4372
+ bootstrap(app) {
4373
+ const contentManagerPluginApis = app.getPlugin("content-manager").apis;
4374
+ contentManagerPluginApis.addEditViewSidePanel([PreviewSidePanel]);
4375
+ }
4376
+ };
3855
4377
  const index = {
3856
4378
  register(app) {
3857
4379
  const cm = new ContentManagerPlugin();
@@ -3866,15 +4388,32 @@ const index = {
3866
4388
  defaultMessage: "Content Manager"
3867
4389
  },
3868
4390
  permissions: [],
3869
- Component: () => import("./layout-omucV6TV.mjs").then((mod) => ({ default: mod.Layout })),
3870
4391
  position: 1
3871
4392
  });
4393
+ app.router.addRoute({
4394
+ path: "content-manager/*",
4395
+ lazy: async () => {
4396
+ const { Layout } = await import("./layout-CxDMdJ13.mjs");
4397
+ return {
4398
+ Component: Layout
4399
+ };
4400
+ },
4401
+ children: routes
4402
+ });
3872
4403
  app.registerPlugin(cm.config);
3873
4404
  },
4405
+ bootstrap(app) {
4406
+ if (typeof historyAdmin.bootstrap === "function") {
4407
+ historyAdmin.bootstrap(app);
4408
+ }
4409
+ if (typeof previewAdmin.bootstrap === "function") {
4410
+ previewAdmin.bootstrap(app);
4411
+ }
4412
+ },
3874
4413
  async registerTrads({ locales }) {
3875
4414
  const importedTrads = await Promise.all(
3876
4415
  locales.map((locale) => {
3877
- 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-9GwRW_ku.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 }) => {
4416
+ 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-D65uIF6Y.mjs"), "./translations/es.json": () => import("./es-D34tqjMw.mjs"), "./translations/eu.json": () => import("./eu-CdALomew.mjs"), "./translations/fr.json": () => import("./fr-DBseuRuB.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 }) => {
3878
4417
  return {
3879
4418
  data: prefixPluginTranslations(data, PLUGIN_ID),
3880
4419
  locale
@@ -3891,22 +4430,27 @@ const index = {
3891
4430
  }
3892
4431
  };
3893
4432
  export {
3894
- ATTRIBUTE_TYPES_THAT_CANNOT_BE_MAIN_FIELD as A,
4433
+ useUpdateContentTypeConfigurationMutation as A,
3895
4434
  BulkActionsRenderer as B,
3896
4435
  COLLECTION_TYPES as C,
3897
4436
  DocumentStatus as D,
3898
- extractContentTypeComponents as E,
3899
- DEFAULT_SETTINGS as F,
3900
- convertEditLayoutToFieldLayouts as G,
4437
+ ATTRIBUTE_TYPES_THAT_CANNOT_BE_MAIN_FIELD as E,
4438
+ extractContentTypeComponents as F,
4439
+ DEFAULT_SETTINGS as G,
3901
4440
  HOOKS as H,
3902
4441
  InjectionZone as I,
3903
- useDocument as J,
3904
- index as K,
3905
- useDocumentActions as L,
4442
+ convertEditLayoutToFieldLayouts as J,
4443
+ removeFieldsThatDontExistOnSchema as K,
4444
+ prepareTempKeys as L,
4445
+ useDocument as M,
4446
+ useGetPreviewUrlQuery as N,
4447
+ index as O,
3906
4448
  Panels as P,
4449
+ useContentManagerContext as Q,
3907
4450
  RelativeTime as R,
3908
4451
  SINGLE_TYPES as S,
3909
4452
  TableActions as T,
4453
+ useDocumentActions as U,
3910
4454
  useGetInitialDataQuery as a,
3911
4455
  useGetAllContentTypeSettingsQuery as b,
3912
4456
  useDoc as c,
@@ -3919,19 +4463,19 @@ export {
3919
4463
  Header as j,
3920
4464
  PERMISSIONS as k,
3921
4465
  DocumentRBAC as l,
3922
- DOCUMENT_META_FIELDS as m,
3923
- useDocLayout as n,
3924
- useGetContentTypeConfigurationQuery as o,
3925
- CREATOR_FIELDS as p,
3926
- getMainField as q,
3927
- routes as r,
4466
+ useDocLayout as m,
4467
+ createDefaultForm as n,
4468
+ CLONE_PATH as o,
4469
+ useGetContentTypeConfigurationQuery as p,
4470
+ CREATOR_FIELDS as q,
4471
+ getMainField as r,
3928
4472
  setInitialData as s,
3929
- getDisplayName as t,
4473
+ transformDocument as t,
3930
4474
  useContentTypeSchema as u,
3931
- checkIfAttributeIsDisplayable as v,
3932
- useGetAllDocumentsQuery as w,
3933
- convertListLayoutToFieldLayouts as x,
3934
- capitalise as y,
3935
- useUpdateContentTypeConfigurationMutation as z
4475
+ getDisplayName as v,
4476
+ checkIfAttributeIsDisplayable as w,
4477
+ useGetAllDocumentsQuery as x,
4478
+ convertListLayoutToFieldLayouts as y,
4479
+ capitalise as z
3936
4480
  };
3937
- //# sourceMappingURL=index-Dahjdw4h.mjs.map
4481
+ //# sourceMappingURL=index-EH8ZtHd5.mjs.map