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

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 (227) 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-DmwmiFQy.mjs → ComponentConfigurationPage-9_4yUE9L.mjs} +4 -4
  5. package/dist/_chunks/{ComponentConfigurationPage-DmwmiFQy.mjs.map → ComponentConfigurationPage-9_4yUE9L.mjs.map} +1 -1
  6. package/dist/_chunks/{ComponentConfigurationPage-C-49MccQ.js → ComponentConfigurationPage-DBSh-kET.js} +5 -6
  7. package/dist/_chunks/{ComponentConfigurationPage-C-49MccQ.js.map → ComponentConfigurationPage-DBSh-kET.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-DjFJw56M.js → EditConfigurationPage-Bl_U2JgH.js} +5 -6
  12. package/dist/_chunks/{EditConfigurationPage-DjFJw56M.js.map → EditConfigurationPage-Bl_U2JgH.js.map} +1 -1
  13. package/dist/_chunks/{EditConfigurationPage-JT3E7NZy.mjs → EditConfigurationPage-COe6hjPC.mjs} +4 -4
  14. package/dist/_chunks/{EditConfigurationPage-JT3E7NZy.mjs.map → EditConfigurationPage-COe6hjPC.mjs.map} +1 -1
  15. package/dist/_chunks/{EditViewPage-zT3fBr4Y.js → EditViewPage-D4yFJET6.js} +36 -49
  16. package/dist/_chunks/EditViewPage-D4yFJET6.js.map +1 -0
  17. package/dist/_chunks/{EditViewPage-CPj61RMh.mjs → EditViewPage-DrmVmYN0.mjs} +34 -46
  18. package/dist/_chunks/EditViewPage-DrmVmYN0.mjs.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-y5g1SRsh.js → Form-C4rSaGsz.js} +39 -21
  22. package/dist/_chunks/Form-C4rSaGsz.js.map +1 -0
  23. package/dist/_chunks/{Form-DHrru2AV.mjs → Form-DamaxNpG.mjs} +37 -18
  24. package/dist/_chunks/Form-DamaxNpG.mjs.map +1 -0
  25. package/dist/_chunks/{History-Bru_KoeP.mjs → History-D1PreDSY.mjs} +108 -116
  26. package/dist/_chunks/History-D1PreDSY.mjs.map +1 -0
  27. package/dist/_chunks/{History-CqN6K7SX.js → History-DTm8UCCQ.js} +118 -127
  28. package/dist/_chunks/History-DTm8UCCQ.js.map +1 -0
  29. package/dist/_chunks/{Field-Boxf9Ajp.js → Input-B7sapvBG.js} +1431 -1312
  30. package/dist/_chunks/Input-B7sapvBG.js.map +1 -0
  31. package/dist/_chunks/{Field-dha5VnIQ.mjs → Input-CZ1YvjHR.mjs} +1439 -1320
  32. package/dist/_chunks/Input-CZ1YvjHR.mjs.map +1 -0
  33. package/dist/_chunks/{ListConfigurationPage-D8wGABj0.mjs → ListConfigurationPage-Bbi32isk.mjs} +25 -12
  34. package/dist/_chunks/ListConfigurationPage-Bbi32isk.mjs.map +1 -0
  35. package/dist/_chunks/{ListConfigurationPage-R_p-SbHZ.js → ListConfigurationPage-ysFMjKI3.js} +25 -13
  36. package/dist/_chunks/ListConfigurationPage-ysFMjKI3.js.map +1 -0
  37. package/dist/_chunks/{ListViewPage-SID6TRb9.mjs → ListViewPage-Bud_jBDQ.mjs} +122 -78
  38. package/dist/_chunks/ListViewPage-Bud_jBDQ.mjs.map +1 -0
  39. package/dist/_chunks/{ListViewPage-pEw_zug9.js → ListViewPage-DTuuxU3n.js} +121 -78
  40. package/dist/_chunks/ListViewPage-DTuuxU3n.js.map +1 -0
  41. package/dist/_chunks/{NoContentTypePage-C5dcQojD.js → NoContentTypePage-CL7VVeYs.js} +2 -2
  42. package/dist/_chunks/{NoContentTypePage-C5dcQojD.js.map → NoContentTypePage-CL7VVeYs.js.map} +1 -1
  43. package/dist/_chunks/{NoContentTypePage-CJ7UXwrQ.mjs → NoContentTypePage-DVhkugsf.mjs} +2 -2
  44. package/dist/_chunks/{NoContentTypePage-CJ7UXwrQ.mjs.map → NoContentTypePage-DVhkugsf.mjs.map} +1 -1
  45. package/dist/_chunks/{NoPermissionsPage-B7syEq5E.mjs → NoPermissionsPage-CMdM-dCo.mjs} +2 -2
  46. package/dist/_chunks/{NoPermissionsPage-B7syEq5E.mjs.map → NoPermissionsPage-CMdM-dCo.mjs.map} +1 -1
  47. package/dist/_chunks/{NoPermissionsPage-BtPrImPP.js → NoPermissionsPage-v7I599vC.js} +2 -2
  48. package/dist/_chunks/{NoPermissionsPage-BtPrImPP.js.map → NoPermissionsPage-v7I599vC.js.map} +1 -1
  49. package/dist/_chunks/Preview-BNuU0SuQ.mjs +287 -0
  50. package/dist/_chunks/Preview-BNuU0SuQ.mjs.map +1 -0
  51. package/dist/_chunks/Preview-Cxq-uI6D.js +305 -0
  52. package/dist/_chunks/Preview-Cxq-uI6D.js.map +1 -0
  53. package/dist/_chunks/{Relations-B9Crnhnn.mjs → Relations-C2Ahkrdg.mjs} +76 -42
  54. package/dist/_chunks/Relations-C2Ahkrdg.mjs.map +1 -0
  55. package/dist/_chunks/{Relations-DjTQ5kGB.js → Relations-CWS79QQn.js} +76 -43
  56. package/dist/_chunks/Relations-CWS79QQn.js.map +1 -0
  57. package/dist/_chunks/{en-fbKQxLGn.js → en-BR48D_RH.js} +39 -18
  58. package/dist/_chunks/{en-fbKQxLGn.js.map → en-BR48D_RH.js.map} +1 -1
  59. package/dist/_chunks/{en-Ux26r5pl.mjs → en-D65uIF6Y.mjs} +39 -18
  60. package/dist/_chunks/{en-Ux26r5pl.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-DVPWZkbS.js → index-DQsvBb_N.js} +1463 -762
  71. package/dist/_chunks/index-DQsvBb_N.js.map +1 -0
  72. package/dist/_chunks/{index-DJXJw9V5.mjs → index-ZKrsjv-2.mjs} +1481 -780
  73. package/dist/_chunks/index-ZKrsjv-2.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-Dm6fbiQj.js → layout-Cl0NhlQB.js} +26 -14
  79. package/dist/_chunks/layout-Cl0NhlQB.js.map +1 -0
  80. package/dist/_chunks/{layout-Bau7ZfLV.mjs → layout-fQk1rMk9.mjs} +26 -13
  81. package/dist/_chunks/layout-fQk1rMk9.mjs.map +1 -0
  82. package/dist/_chunks/{objects-gigeqt7s.js → objects-BcXOv6_9.js} +2 -4
  83. package/dist/_chunks/{objects-gigeqt7s.js.map → objects-BcXOv6_9.js.map} +1 -1
  84. package/dist/_chunks/{objects-mKMAmfec.mjs → objects-D6yBsdmx.mjs} +2 -4
  85. package/dist/_chunks/{objects-mKMAmfec.mjs.map → objects-D6yBsdmx.mjs.map} +1 -1
  86. package/dist/_chunks/{relations-CKnpRgrN.js → relations-BRfBxVbX.js} +6 -7
  87. package/dist/_chunks/relations-BRfBxVbX.js.map +1 -0
  88. package/dist/_chunks/{relations-BH_kBSJ0.mjs → relations-BakOFl_1.mjs} +6 -7
  89. package/dist/_chunks/relations-BakOFl_1.mjs.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-CZGy2Vjf.mjs +29 -0
  95. package/dist/_chunks/usePrev-CZGy2Vjf.mjs.map +1 -0
  96. package/dist/_chunks/{usePrev-B9w_-eYc.js → usePrev-D5J_2fEu.js} +14 -1
  97. package/dist/_chunks/usePrev-D5J_2fEu.js.map +1 -0
  98. package/dist/admin/index.js +3 -1
  99. package/dist/admin/index.js.map +1 -1
  100. package/dist/admin/index.mjs +6 -4
  101. package/dist/admin/src/content-manager.d.ts +3 -2
  102. package/dist/admin/src/exports.d.ts +2 -1
  103. package/dist/admin/src/history/index.d.ts +3 -0
  104. package/dist/admin/src/history/services/historyVersion.d.ts +1 -1
  105. package/dist/admin/src/hooks/useDocument.d.ts +49 -1
  106. package/dist/admin/src/index.d.ts +1 -0
  107. package/dist/admin/src/pages/EditView/EditViewPage.d.ts +9 -1
  108. package/dist/admin/src/pages/EditView/components/DocumentActions.d.ts +2 -1
  109. package/dist/admin/src/pages/EditView/components/DocumentStatus.d.ts +3 -3
  110. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/Code.d.ts +7 -0
  111. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/utils/prismLanguages.d.ts +49 -0
  112. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/utils/constants.d.ts +1 -0
  113. package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.d.ts +4 -1
  114. package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/Field.d.ts +4 -1
  115. package/dist/admin/src/pages/EditView/components/FormInputs/Relations.d.ts +20 -0
  116. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/EditorLayout.d.ts +2 -2
  117. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygFooter.d.ts +2 -2
  118. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygStyles.d.ts +4 -48
  119. package/dist/admin/src/pages/EditView/components/FormLayout.d.ts +27 -0
  120. package/dist/admin/src/pages/EditView/components/Header.d.ts +11 -11
  121. package/dist/admin/src/pages/EditView/utils/data.d.ts +1 -0
  122. package/dist/admin/src/preview/components/PreviewContent.d.ts +2 -0
  123. package/dist/admin/src/preview/components/PreviewHeader.d.ts +2 -0
  124. package/dist/admin/src/preview/components/PreviewSidePanel.d.ts +3 -0
  125. package/dist/admin/src/preview/index.d.ts +4 -0
  126. package/dist/admin/src/preview/pages/Preview.d.ts +11 -0
  127. package/dist/admin/src/preview/routes.d.ts +3 -0
  128. package/dist/admin/src/preview/services/preview.d.ts +3 -0
  129. package/dist/admin/src/router.d.ts +1 -1
  130. package/dist/admin/src/services/api.d.ts +1 -1
  131. package/dist/admin/src/services/components.d.ts +2 -2
  132. package/dist/admin/src/services/contentTypes.d.ts +3 -3
  133. package/dist/admin/src/services/documents.d.ts +19 -20
  134. package/dist/admin/src/services/init.d.ts +1 -1
  135. package/dist/admin/src/services/relations.d.ts +2 -2
  136. package/dist/admin/src/services/uid.d.ts +3 -3
  137. package/dist/admin/src/utils/validation.d.ts +4 -1
  138. package/dist/server/index.js +762 -432
  139. package/dist/server/index.js.map +1 -1
  140. package/dist/server/index.mjs +763 -432
  141. package/dist/server/index.mjs.map +1 -1
  142. package/dist/server/src/bootstrap.d.ts.map +1 -1
  143. package/dist/server/src/controllers/collection-types.d.ts.map +1 -1
  144. package/dist/server/src/controllers/index.d.ts.map +1 -1
  145. package/dist/server/src/controllers/relations.d.ts.map +1 -1
  146. package/dist/server/src/controllers/uid.d.ts.map +1 -1
  147. package/dist/server/src/controllers/utils/metadata.d.ts +16 -1
  148. package/dist/server/src/controllers/utils/metadata.d.ts.map +1 -1
  149. package/dist/server/src/controllers/validation/dimensions.d.ts +4 -2
  150. package/dist/server/src/controllers/validation/dimensions.d.ts.map +1 -1
  151. package/dist/server/src/history/controllers/history-version.d.ts +1 -1
  152. package/dist/server/src/history/controllers/history-version.d.ts.map +1 -1
  153. package/dist/server/src/history/services/history.d.ts +3 -3
  154. package/dist/server/src/history/services/history.d.ts.map +1 -1
  155. package/dist/server/src/history/services/lifecycles.d.ts.map +1 -1
  156. package/dist/server/src/history/services/utils.d.ts +8 -12
  157. package/dist/server/src/history/services/utils.d.ts.map +1 -1
  158. package/dist/server/src/index.d.ts +7 -6
  159. package/dist/server/src/index.d.ts.map +1 -1
  160. package/dist/server/src/policies/hasPermissions.d.ts.map +1 -1
  161. package/dist/server/src/preview/controllers/index.d.ts +2 -0
  162. package/dist/server/src/preview/controllers/index.d.ts.map +1 -0
  163. package/dist/server/src/preview/controllers/preview.d.ts +13 -0
  164. package/dist/server/src/preview/controllers/preview.d.ts.map +1 -0
  165. package/dist/server/src/preview/controllers/validation/preview.d.ts +6 -0
  166. package/dist/server/src/preview/controllers/validation/preview.d.ts.map +1 -0
  167. package/dist/server/src/preview/index.d.ts +4 -0
  168. package/dist/server/src/preview/index.d.ts.map +1 -0
  169. package/dist/server/src/preview/routes/index.d.ts +8 -0
  170. package/dist/server/src/preview/routes/index.d.ts.map +1 -0
  171. package/dist/server/src/preview/routes/preview.d.ts +4 -0
  172. package/dist/server/src/preview/routes/preview.d.ts.map +1 -0
  173. package/dist/server/src/preview/services/index.d.ts +16 -0
  174. package/dist/server/src/preview/services/index.d.ts.map +1 -0
  175. package/dist/server/src/preview/services/preview-config.d.ts +32 -0
  176. package/dist/server/src/preview/services/preview-config.d.ts.map +1 -0
  177. package/dist/server/src/preview/services/preview.d.ts +12 -0
  178. package/dist/server/src/preview/services/preview.d.ts.map +1 -0
  179. package/dist/server/src/preview/utils.d.ts +19 -0
  180. package/dist/server/src/preview/utils.d.ts.map +1 -0
  181. package/dist/server/src/register.d.ts.map +1 -1
  182. package/dist/server/src/routes/index.d.ts.map +1 -1
  183. package/dist/server/src/services/document-manager.d.ts.map +1 -1
  184. package/dist/server/src/services/document-metadata.d.ts +12 -10
  185. package/dist/server/src/services/document-metadata.d.ts.map +1 -1
  186. package/dist/server/src/services/index.d.ts +7 -6
  187. package/dist/server/src/services/index.d.ts.map +1 -1
  188. package/dist/server/src/services/permission-checker.d.ts.map +1 -1
  189. package/dist/server/src/services/utils/populate.d.ts +2 -2
  190. package/dist/server/src/services/utils/populate.d.ts.map +1 -1
  191. package/dist/server/src/utils/index.d.ts +2 -0
  192. package/dist/server/src/utils/index.d.ts.map +1 -1
  193. package/dist/shared/contracts/collection-types.d.ts +3 -1
  194. package/dist/shared/contracts/collection-types.d.ts.map +1 -1
  195. package/dist/shared/contracts/index.d.ts +1 -0
  196. package/dist/shared/contracts/index.d.ts.map +1 -1
  197. package/dist/shared/contracts/preview.d.ts +27 -0
  198. package/dist/shared/contracts/preview.d.ts.map +1 -0
  199. package/dist/shared/index.js +4 -0
  200. package/dist/shared/index.js.map +1 -1
  201. package/dist/shared/index.mjs +4 -0
  202. package/dist/shared/index.mjs.map +1 -1
  203. package/package.json +17 -16
  204. package/dist/_chunks/EditViewPage-CPj61RMh.mjs.map +0 -1
  205. package/dist/_chunks/EditViewPage-zT3fBr4Y.js.map +0 -1
  206. package/dist/_chunks/Field-Boxf9Ajp.js.map +0 -1
  207. package/dist/_chunks/Field-dha5VnIQ.mjs.map +0 -1
  208. package/dist/_chunks/Form-DHrru2AV.mjs.map +0 -1
  209. package/dist/_chunks/Form-y5g1SRsh.js.map +0 -1
  210. package/dist/_chunks/History-Bru_KoeP.mjs.map +0 -1
  211. package/dist/_chunks/History-CqN6K7SX.js.map +0 -1
  212. package/dist/_chunks/ListConfigurationPage-D8wGABj0.mjs.map +0 -1
  213. package/dist/_chunks/ListConfigurationPage-R_p-SbHZ.js.map +0 -1
  214. package/dist/_chunks/ListViewPage-SID6TRb9.mjs.map +0 -1
  215. package/dist/_chunks/ListViewPage-pEw_zug9.js.map +0 -1
  216. package/dist/_chunks/Relations-B9Crnhnn.mjs.map +0 -1
  217. package/dist/_chunks/Relations-DjTQ5kGB.js.map +0 -1
  218. package/dist/_chunks/index-DJXJw9V5.mjs.map +0 -1
  219. package/dist/_chunks/index-DVPWZkbS.js.map +0 -1
  220. package/dist/_chunks/layout-Bau7ZfLV.mjs.map +0 -1
  221. package/dist/_chunks/layout-Dm6fbiQj.js.map +0 -1
  222. package/dist/_chunks/relations-BH_kBSJ0.mjs.map +0 -1
  223. package/dist/_chunks/relations-CKnpRgrN.js.map +0 -1
  224. package/dist/_chunks/usePrev-B9w_-eYc.js.map +0 -1
  225. package/dist/_chunks/usePrev-DH6iah0A.mjs +0 -16
  226. package/dist/_chunks/usePrev-DH6iah0A.mjs.map +0 -1
  227. 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 { Button, Menu, VisuallyHidden, Flex, Box, Typography, Dialog, Modal, Radio, Status, SingleSelect, SingleSelectOption, Loader, IconButton, Tooltip, LinkButton } from "@strapi/design-system";
6
+ import { Menu, Button, VisuallyHidden, Flex, Dialog, Modal, Typography, Radio, Status, Box, SingleSelect, SingleSelectOption, IconButton, 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,7 +282,9 @@ 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({
@@ -208,7 +298,12 @@ const documentApi = contentManagerApi.injectEndpoints({
208
298
  params: query
209
299
  }
210
300
  }),
211
- 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
+ }
212
307
  }),
213
308
  cloneDocument: builder.mutation({
214
309
  query: ({ model, sourceId, data, params }) => ({
@@ -219,7 +314,11 @@ const documentApi = contentManagerApi.injectEndpoints({
219
314
  params
220
315
  }
221
316
  }),
222
- 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
+ ]
223
322
  }),
224
323
  /**
225
324
  * Creates a new collection-type document. This should ONLY be used for collection-types.
@@ -236,8 +335,22 @@ const documentApi = contentManagerApi.injectEndpoints({
236
335
  }),
237
336
  invalidatesTags: (result, _error, { model }) => [
238
337
  { type: "Document", id: `${model}_LIST` },
239
- "Relations"
240
- ]
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
+ }
241
354
  }),
242
355
  deleteDocument: builder.mutation({
243
356
  query: ({ collectionType, model, documentId, params }) => ({
@@ -248,7 +361,8 @@ const documentApi = contentManagerApi.injectEndpoints({
248
361
  }
249
362
  }),
250
363
  invalidatesTags: (_result, _error, { collectionType, model }) => [
251
- { type: "Document", id: collectionType !== SINGLE_TYPES ? `${model}_LIST` : model }
364
+ { type: "Document", id: collectionType !== SINGLE_TYPES ? `${model}_LIST` : model },
365
+ "RecentDocumentList"
252
366
  ]
253
367
  }),
254
368
  deleteManyDocuments: builder.mutation({
@@ -260,7 +374,10 @@ const documentApi = contentManagerApi.injectEndpoints({
260
374
  params
261
375
  }
262
376
  }),
263
- invalidatesTags: (_res, _error, { model }) => [{ type: "Document", id: `${model}_LIST` }]
377
+ invalidatesTags: (_res, _error, { model }) => [
378
+ { type: "Document", id: `${model}_LIST` },
379
+ "RecentDocumentList"
380
+ ]
264
381
  }),
265
382
  discardDocument: builder.mutation({
266
383
  query: ({ collectionType, model, documentId, params }) => ({
@@ -277,7 +394,9 @@ const documentApi = contentManagerApi.injectEndpoints({
277
394
  id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
278
395
  },
279
396
  { type: "Document", id: `${model}_LIST` },
280
- "Relations"
397
+ "Relations",
398
+ { type: "UidAvailability", id: model },
399
+ "RecentDocumentList"
281
400
  ];
282
401
  }
283
402
  }),
@@ -290,11 +409,12 @@ const documentApi = contentManagerApi.injectEndpoints({
290
409
  url: `/content-manager/collection-types/${model}`,
291
410
  method: "GET",
292
411
  config: {
293
- params
412
+ params: stringify(params, { encode: true })
294
413
  }
295
414
  }),
296
415
  providesTags: (result, _error, arg) => {
297
416
  return [
417
+ { type: "Document", id: `ALL_LIST` },
298
418
  { type: "Document", id: `${arg.model}_LIST` },
299
419
  ...result?.results.map(({ documentId }) => ({
300
420
  type: "Document",
@@ -333,6 +453,11 @@ const documentApi = contentManagerApi.injectEndpoints({
333
453
  {
334
454
  type: "Document",
335
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`
336
461
  }
337
462
  ];
338
463
  }
@@ -366,7 +491,8 @@ const documentApi = contentManagerApi.injectEndpoints({
366
491
  id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
367
492
  },
368
493
  { type: "Document", id: `${model}_LIST` },
369
- "Relations"
494
+ "Relations",
495
+ "RecentDocumentList"
370
496
  ];
371
497
  }
372
498
  }),
@@ -396,8 +522,23 @@ const documentApi = contentManagerApi.injectEndpoints({
396
522
  type: "Document",
397
523
  id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
398
524
  },
399
- "Relations"
525
+ "Relations",
526
+ { type: "UidAvailability", id: model },
527
+ "RecentDocumentList",
528
+ "RecentDocumentList"
400
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
+ }
401
542
  }
402
543
  }),
403
544
  unpublishDocument: builder.mutation({
@@ -414,7 +555,8 @@ const documentApi = contentManagerApi.injectEndpoints({
414
555
  {
415
556
  type: "Document",
416
557
  id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
417
- }
558
+ },
559
+ "RecentDocumentList"
418
560
  ];
419
561
  }
420
562
  }),
@@ -427,7 +569,10 @@ const documentApi = contentManagerApi.injectEndpoints({
427
569
  params
428
570
  }
429
571
  }),
430
- 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
+ ]
431
576
  })
432
577
  })
433
578
  });
@@ -450,8 +595,7 @@ const {
450
595
  useUnpublishManyDocumentsMutation
451
596
  } = documentApi;
452
597
  const buildValidParams = (query) => {
453
- if (!query)
454
- return query;
598
+ if (!query) return query;
455
599
  const { plugins: _, ...validQueryParams } = {
456
600
  ...query,
457
601
  ...Object.values(query?.plugins ?? {}).reduce(
@@ -459,28 +603,44 @@ const buildValidParams = (query) => {
459
603
  {}
460
604
  )
461
605
  };
462
- if ("_q" in validQueryParams) {
463
- validQueryParams._q = encodeURIComponent(validQueryParams._q);
464
- }
465
606
  return validQueryParams;
466
607
  };
467
608
  const isBaseQueryError = (error) => {
468
609
  return error.name !== void 0;
469
610
  };
470
- 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 }) => {
471
630
  const createModelSchema = (attributes2) => yup.object().shape(
472
631
  Object.entries(attributes2).reduce((acc, [name, attribute]) => {
473
632
  if (DOCUMENT_META_FIELDS.includes(name)) {
474
633
  return acc;
475
634
  }
476
635
  const validations = [
636
+ addNullableValidation,
477
637
  addRequiredValidation,
478
638
  addMinLengthValidation,
479
639
  addMaxLengthValidation,
480
640
  addMinValidation,
481
641
  addMaxValidation,
482
642
  addRegexValidation
483
- ].map((fn) => fn(attribute));
643
+ ].map((fn) => fn(attribute, options));
484
644
  const transformSchema = pipe(...validations);
485
645
  switch (attribute.type) {
486
646
  case "component": {
@@ -490,12 +650,12 @@ const createYupSchema = (attributes = {}, components = {}) => {
490
650
  ...acc,
491
651
  [name]: transformSchema(
492
652
  yup.array().of(createModelSchema(attributes3).nullable(false))
493
- )
653
+ ).test(arrayValidator(attribute, options))
494
654
  };
495
655
  } else {
496
656
  return {
497
657
  ...acc,
498
- [name]: transformSchema(createModelSchema(attributes3))
658
+ [name]: transformSchema(createModelSchema(attributes3).nullable())
499
659
  };
500
660
  }
501
661
  }
@@ -517,7 +677,7 @@ const createYupSchema = (attributes = {}, components = {}) => {
517
677
  }
518
678
  )
519
679
  )
520
- )
680
+ ).test(arrayValidator(attribute, options))
521
681
  };
522
682
  case "relation":
523
683
  return {
@@ -529,7 +689,7 @@ const createYupSchema = (attributes = {}, components = {}) => {
529
689
  } else if (Array.isArray(value)) {
530
690
  return yup.array().of(
531
691
  yup.object().shape({
532
- id: yup.string().required()
692
+ id: yup.number().required()
533
693
  })
534
694
  );
535
695
  } else if (typeof value === "object") {
@@ -581,6 +741,14 @@ const createAttributeSchema = (attribute) => {
581
741
  if (!value || typeof value === "string" && value.length === 0) {
582
742
  return true;
583
743
  }
744
+ if (typeof value === "object") {
745
+ try {
746
+ JSON.stringify(value);
747
+ return true;
748
+ } catch (err) {
749
+ return false;
750
+ }
751
+ }
584
752
  try {
585
753
  JSON.parse(value);
586
754
  return true;
@@ -599,13 +767,7 @@ const createAttributeSchema = (attribute) => {
599
767
  return yup.mixed();
600
768
  }
601
769
  };
602
- const addRequiredValidation = (attribute) => (schema) => {
603
- if (attribute.required) {
604
- return schema.required({
605
- id: translatedErrors.required.id,
606
- defaultMessage: "This field is required."
607
- });
608
- }
770
+ const nullableSchema = (schema) => {
609
771
  return schema?.nullable ? schema.nullable() : (
610
772
  // In some cases '.nullable' will not be available on the schema.
611
773
  // e.g. when the schema has been built using yup.lazy (e.g. for relations).
@@ -613,7 +775,22 @@ const addRequiredValidation = (attribute) => (schema) => {
613
775
  schema
614
776
  );
615
777
  };
616
- 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
+ }
617
794
  if ("minLength" in attribute && attribute.minLength && Number.isInteger(attribute.minLength) && "min" in schema) {
618
795
  return schema.min(attribute.minLength, {
619
796
  ...translatedErrors.minLength,
@@ -635,10 +812,13 @@ const addMaxLengthValidation = (attribute) => (schema) => {
635
812
  }
636
813
  return schema;
637
814
  };
638
- const addMinValidation = (attribute) => (schema) => {
639
- 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) {
640
820
  const min = toInteger(attribute.min);
641
- if ("min" in schema && min) {
821
+ if (min) {
642
822
  return schema.min(min, {
643
823
  ...translatedErrors.min,
644
824
  values: {
@@ -756,16 +936,115 @@ const extractContentTypeComponents = (attributes = {}, allComponents = {}) => {
756
936
  }, {});
757
937
  return componentsByKey;
758
938
  };
759
- 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);
760
1038
  const { toggleNotification } = useNotification();
761
1039
  const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();
1040
+ const { isLoading: isLoadingSchemas, schemas } = useContentTypeSchema();
762
1041
  const {
763
- currentData: data,
764
- isLoading: isLoadingDocument,
765
- isFetching: isFetchingDocument,
766
- error
767
- } = useGetDocumentQuery(args, opts);
768
- const { components, schema, isLoading: isLoadingSchema } = useContentTypeSchema(args.model);
1042
+ data,
1043
+ isLoading: isLoadingConfigs,
1044
+ error,
1045
+ isFetching: isFetchingConfigs
1046
+ } = useGetContentTypeConfigurationQuery(model);
1047
+ const isLoading = isLoadingSchemas || isFetchingConfigs || isLoadingConfigs;
769
1048
  React.useEffect(() => {
770
1049
  if (error) {
771
1050
  toggleNotification({
@@ -773,40 +1052,284 @@ const useDocument = (args, opts) => {
773
1052
  message: formatAPIError(error)
774
1053
  });
775
1054
  }
776
- }, [toggleNotification, error, formatAPIError, args.collectionType]);
777
- const validationSchema = React.useMemo(() => {
778
- if (!schema) {
779
- return null;
780
- }
781
- return createYupSchema(schema.attributes, components);
782
- }, [schema, components]);
783
- const validate = React.useCallback(
784
- (document) => {
785
- if (!validationSchema) {
786
- throw new Error(
787
- "There is no validation schema generated, this is likely due to the schema not being loaded yet."
788
- );
789
- }
790
- try {
791
- validationSchema.validateSync(document, { abortEarly: false, strict: true });
792
- return null;
793
- } catch (error2) {
794
- if (error2 instanceof ValidationError) {
795
- return getYupValidationErrors(error2);
796
- }
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
+ }
797
1305
  throw error2;
798
1306
  }
799
1307
  },
800
1308
  [validationSchema]
801
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
+ );
802
1320
  const isLoading = isLoadingDocument || isFetchingDocument || isLoadingSchema;
1321
+ const hasError = !!error;
803
1322
  return {
804
1323
  components,
805
- document: data?.data,
806
- meta: data?.meta,
1324
+ document,
1325
+ meta,
807
1326
  isLoading,
1327
+ hasError,
808
1328
  schema,
809
- validate
1329
+ schemas,
1330
+ validate,
1331
+ getTitle,
1332
+ getInitialFormValues
810
1333
  };
811
1334
  };
812
1335
  const useDoc = () => {
@@ -819,22 +1342,60 @@ const useDoc = () => {
819
1342
  if (!slug) {
820
1343
  throw new Error("Could not find model in url params");
821
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;
822
1352
  return {
823
1353
  collectionType,
824
1354
  model: slug,
825
- id: origin || id === "create" ? void 0 : id,
826
- ...useDocument(
827
- { documentId: origin || id, model: slug, collectionType, params },
828
- {
829
- skip: id === "create" || !origin && !id && collectionType !== SINGLE_TYPES
830
- }
831
- )
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
832
1396
  };
833
1397
  };
834
1398
  const prefixPluginTranslations = (trad, pluginId) => {
835
- if (!pluginId) {
836
- throw new TypeError("pluginId can't be empty");
837
- }
838
1399
  return Object.keys(trad).reduce((acc, current) => {
839
1400
  acc[`${pluginId}.${current}`] = trad[current];
840
1401
  return acc;
@@ -850,6 +1411,8 @@ const useDocumentActions = () => {
850
1411
  const { formatMessage } = useIntl();
851
1412
  const { trackUsage } = useTracking();
852
1413
  const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();
1414
+ const navigate = useNavigate();
1415
+ const setCurrentStep = useGuidedTour("useDocumentActions", (state) => state.setCurrentStep);
853
1416
  const [deleteDocument] = useDeleteDocumentMutation();
854
1417
  const _delete = React.useCallback(
855
1418
  async ({ collectionType, model, documentId, params }, trackerProperty) => {
@@ -1164,6 +1727,7 @@ const useDocumentActions = () => {
1164
1727
  defaultMessage: "Saved document"
1165
1728
  })
1166
1729
  });
1730
+ setCurrentStep("contentManager.success");
1167
1731
  return res.data;
1168
1732
  } catch (err) {
1169
1733
  toggleNotification({
@@ -1185,7 +1749,6 @@ const useDocumentActions = () => {
1185
1749
  sourceId
1186
1750
  });
1187
1751
  if ("error" in res) {
1188
- toggleNotification({ type: "danger", message: formatAPIError(res.error) });
1189
1752
  return { error: res.error };
1190
1753
  }
1191
1754
  toggleNotification({
@@ -1204,7 +1767,7 @@ const useDocumentActions = () => {
1204
1767
  throw err;
1205
1768
  }
1206
1769
  },
1207
- [autoCloneDocument, formatAPIError, formatMessage, toggleNotification]
1770
+ [autoCloneDocument, formatMessage, toggleNotification]
1208
1771
  );
1209
1772
  const [cloneDocument] = useCloneDocumentMutation();
1210
1773
  const clone = React.useCallback(
@@ -1230,6 +1793,7 @@ const useDocumentActions = () => {
1230
1793
  defaultMessage: "Cloned document"
1231
1794
  })
1232
1795
  });
1796
+ navigate(`../../${res.data.data.documentId}`, { relative: "path" });
1233
1797
  return res.data;
1234
1798
  } catch (err) {
1235
1799
  toggleNotification({
@@ -1240,7 +1804,7 @@ const useDocumentActions = () => {
1240
1804
  throw err;
1241
1805
  }
1242
1806
  },
1243
- [cloneDocument, trackUsage, toggleNotification, formatMessage, formatAPIError]
1807
+ [cloneDocument, trackUsage, toggleNotification, formatMessage, formatAPIError, navigate]
1244
1808
  );
1245
1809
  const [getDoc] = useLazyGetDocumentQuery();
1246
1810
  const getDocument = React.useCallback(
@@ -1265,10 +1829,10 @@ const useDocumentActions = () => {
1265
1829
  update
1266
1830
  };
1267
1831
  };
1268
- const ProtectedHistoryPage = lazy(
1269
- () => import("./History-Bru_KoeP.mjs").then((mod) => ({ default: mod.ProtectedHistoryPage }))
1832
+ const ProtectedHistoryPage = React.lazy(
1833
+ () => import("./History-D1PreDSY.mjs").then((mod) => ({ default: mod.ProtectedHistoryPage }))
1270
1834
  );
1271
- const routes$1 = [
1835
+ const routes$2 = [
1272
1836
  {
1273
1837
  path: ":collectionType/:slug/:id/history",
1274
1838
  Component: ProtectedHistoryPage
@@ -1278,32 +1842,45 @@ const routes$1 = [
1278
1842
  Component: ProtectedHistoryPage
1279
1843
  }
1280
1844
  ];
1281
- const ProtectedEditViewPage = lazy(
1282
- () => import("./EditViewPage-CPj61RMh.mjs").then((mod) => ({ default: mod.ProtectedEditViewPage }))
1845
+ const ProtectedPreviewPage = React.lazy(
1846
+ () => import("./Preview-BNuU0SuQ.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-DrmVmYN0.mjs").then((mod) => ({ default: mod.ProtectedEditViewPage }))
1283
1860
  );
1284
1861
  const ProtectedListViewPage = lazy(
1285
- () => import("./ListViewPage-SID6TRb9.mjs").then((mod) => ({ default: mod.ProtectedListViewPage }))
1862
+ () => import("./ListViewPage-Bud_jBDQ.mjs").then((mod) => ({ default: mod.ProtectedListViewPage }))
1286
1863
  );
1287
1864
  const ProtectedListConfiguration = lazy(
1288
- () => import("./ListConfigurationPage-D8wGABj0.mjs").then((mod) => ({
1865
+ () => import("./ListConfigurationPage-Bbi32isk.mjs").then((mod) => ({
1289
1866
  default: mod.ProtectedListConfiguration
1290
1867
  }))
1291
1868
  );
1292
1869
  const ProtectedEditConfigurationPage = lazy(
1293
- () => import("./EditConfigurationPage-JT3E7NZy.mjs").then((mod) => ({
1870
+ () => import("./EditConfigurationPage-COe6hjPC.mjs").then((mod) => ({
1294
1871
  default: mod.ProtectedEditConfigurationPage
1295
1872
  }))
1296
1873
  );
1297
1874
  const ProtectedComponentConfigurationPage = lazy(
1298
- () => import("./ComponentConfigurationPage-DmwmiFQy.mjs").then((mod) => ({
1875
+ () => import("./ComponentConfigurationPage-9_4yUE9L.mjs").then((mod) => ({
1299
1876
  default: mod.ProtectedComponentConfigurationPage
1300
1877
  }))
1301
1878
  );
1302
1879
  const NoPermissions = lazy(
1303
- () => import("./NoPermissionsPage-B7syEq5E.mjs").then((mod) => ({ default: mod.NoPermissions }))
1880
+ () => import("./NoPermissionsPage-CMdM-dCo.mjs").then((mod) => ({ default: mod.NoPermissions }))
1304
1881
  );
1305
1882
  const NoContentType = lazy(
1306
- () => import("./NoContentTypePage-CJ7UXwrQ.mjs").then((mod) => ({ default: mod.NoContentType }))
1883
+ () => import("./NoContentTypePage-DVhkugsf.mjs").then((mod) => ({ default: mod.NoContentType }))
1307
1884
  );
1308
1885
  const CollectionTypePages = () => {
1309
1886
  const { collectionType } = useParams();
@@ -1315,7 +1892,7 @@ const CollectionTypePages = () => {
1315
1892
  const CLONE_RELATIVE_PATH = ":collectionType/:slug/clone/:origin";
1316
1893
  const CLONE_PATH = `/content-manager/${CLONE_RELATIVE_PATH}`;
1317
1894
  const LIST_RELATIVE_PATH = ":collectionType/:slug";
1318
- const LIST_PATH = `/content-manager/${LIST_RELATIVE_PATH}`;
1895
+ const LIST_PATH = `/content-manager/collection-types/:slug`;
1319
1896
  const routes = [
1320
1897
  {
1321
1898
  path: LIST_RELATIVE_PATH,
@@ -1349,6 +1926,7 @@ const routes = [
1349
1926
  path: "no-content-types",
1350
1927
  Component: NoContentType
1351
1928
  },
1929
+ ...routes$2,
1352
1930
  ...routes$1
1353
1931
  ];
1354
1932
  const DocumentActions = ({ actions: actions2 }) => {
@@ -1417,12 +1995,14 @@ const DocumentActionButton = (action) => {
1417
1995
  /* @__PURE__ */ jsx(
1418
1996
  Button,
1419
1997
  {
1420
- flex: 1,
1998
+ flex: "auto",
1421
1999
  startIcon: action.icon,
1422
2000
  disabled: action.disabled,
1423
2001
  onClick: handleClick(action),
1424
2002
  justifyContent: "center",
1425
2003
  variant: action.variant || "default",
2004
+ paddingTop: "7px",
2005
+ paddingBottom: "7px",
1426
2006
  children: action.label
1427
2007
  }
1428
2008
  ),
@@ -1430,7 +2010,7 @@ const DocumentActionButton = (action) => {
1430
2010
  DocumentActionConfirmDialog,
1431
2011
  {
1432
2012
  ...action.dialog,
1433
- variant: action.variant,
2013
+ variant: action.dialog?.variant ?? action.variant,
1434
2014
  isOpen: dialogId === action.id,
1435
2015
  onClose: handleClose
1436
2016
  }
@@ -1445,6 +2025,11 @@ const DocumentActionButton = (action) => {
1445
2025
  ) : null
1446
2026
  ] });
1447
2027
  };
2028
+ const MenuItem = styled(Menu.Item)`
2029
+ &:hover {
2030
+ background: ${({ theme, isVariantDanger, isDisabled }) => isVariantDanger && !isDisabled ? theme.colors.danger100 : "neutral"};
2031
+ }
2032
+ `;
1448
2033
  const DocumentActionsMenu = ({
1449
2034
  actions: actions2,
1450
2035
  children,
@@ -1487,9 +2072,9 @@ const DocumentActionsMenu = ({
1487
2072
  disabled: isDisabled,
1488
2073
  size: "S",
1489
2074
  endIcon: null,
1490
- paddingTop: "7px",
1491
- paddingLeft: "9px",
1492
- paddingRight: "9px",
2075
+ paddingTop: "4px",
2076
+ paddingLeft: "7px",
2077
+ paddingRight: "7px",
1493
2078
  variant,
1494
2079
  children: [
1495
2080
  /* @__PURE__ */ jsx(More, { "aria-hidden": true, focusable: false }),
@@ -1500,36 +2085,35 @@ const DocumentActionsMenu = ({
1500
2085
  ]
1501
2086
  }
1502
2087
  ),
1503
- /* @__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: [
1504
2089
  actions2.map((action) => {
1505
2090
  return /* @__PURE__ */ jsx(
1506
- Menu.Item,
2091
+ MenuItem,
1507
2092
  {
1508
2093
  disabled: action.disabled,
1509
2094
  onSelect: handleClick(action),
1510
2095
  display: "block",
1511
- children: /* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", gap: 4, children: [
1512
- /* @__PURE__ */ jsxs(Flex, { color: convertActionVariantToColor(action.variant), gap: 2, tag: "span", children: [
1513
- /* @__PURE__ */ jsx(Box, { tag: "span", color: convertActionVariantToIconColor(action.variant), children: action.icon }),
1514
- action.label
1515
- ] }),
1516
- action.id.startsWith("HistoryAction") && /* @__PURE__ */ jsx(
1517
- Flex,
1518
- {
1519
- alignItems: "center",
1520
- background: "alternative100",
1521
- borderStyle: "solid",
1522
- borderColor: "alternative200",
1523
- borderWidth: "1px",
1524
- height: 5,
1525
- paddingLeft: 2,
1526
- paddingRight: 2,
1527
- hasRadius: true,
1528
- color: "alternative600",
1529
- children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", fontWeight: "bold", lineHeight: 1, children: formatMessage({ id: "global.new", defaultMessage: "New" }) })
1530
- }
1531
- )
1532
- ] })
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
+ ) })
1533
2117
  },
1534
2118
  action.id
1535
2119
  );
@@ -1609,11 +2193,11 @@ const DocumentActionConfirmDialog = ({
1609
2193
  /* @__PURE__ */ jsx(Dialog.Header, { children: title }),
1610
2194
  /* @__PURE__ */ jsx(Dialog.Body, { children: content }),
1611
2195
  /* @__PURE__ */ jsxs(Dialog.Footer, { children: [
1612
- /* @__PURE__ */ jsx(Dialog.Cancel, { children: /* @__PURE__ */ jsx(Button, { variant: "tertiary", children: formatMessage({
2196
+ /* @__PURE__ */ jsx(Dialog.Cancel, { children: /* @__PURE__ */ jsx(Button, { variant: "tertiary", fullWidth: true, children: formatMessage({
1613
2197
  id: "app.components.Button.cancel",
1614
2198
  defaultMessage: "Cancel"
1615
2199
  }) }) }),
1616
- /* @__PURE__ */ jsx(Button, { onClick: handleConfirm, variant, children: formatMessage({
2200
+ /* @__PURE__ */ jsx(Button, { onClick: handleConfirm, variant, fullWidth: true, children: formatMessage({
1617
2201
  id: "app.components.Button.confirm",
1618
2202
  defaultMessage: "Confirm"
1619
2203
  }) })
@@ -1640,6 +2224,18 @@ const DocumentActionModal = ({
1640
2224
  typeof Footer === "function" ? /* @__PURE__ */ jsx(Footer, { onClose: handleClose }) : Footer
1641
2225
  ] }) });
1642
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;
2238
+ };
1643
2239
  const PublishAction$1 = ({
1644
2240
  activeTab,
1645
2241
  documentId,
@@ -1652,13 +2248,18 @@ const PublishAction$1 = ({
1652
2248
  const navigate = useNavigate();
1653
2249
  const { toggleNotification } = useNotification();
1654
2250
  const { _unstableFormatValidationErrors: formatValidationErrors } = useAPIErrorHandler();
2251
+ const isListView = useMatch(LIST_PATH) !== null;
1655
2252
  const isCloning = useMatch(CLONE_PATH) !== null;
2253
+ const { id } = useParams();
1656
2254
  const { formatMessage } = useIntl();
1657
- const { canPublish, canCreate, canUpdate } = useDocumentRBAC(
1658
- "PublishAction",
1659
- ({ canPublish: canPublish2, canCreate: canCreate2, canUpdate: canUpdate2 }) => ({ canPublish: canPublish2, canCreate: canCreate2, canUpdate: canUpdate2 })
1660
- );
2255
+ const canPublish = useDocumentRBAC("PublishAction", ({ canPublish: canPublish2 }) => canPublish2);
1661
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);
1662
2263
  const [{ query, rawQuery }] = useQueryParams();
1663
2264
  const params = React.useMemo(() => buildValidParams(query), [query]);
1664
2265
  const modified = useForm("PublishAction", ({ modified: modified2 }) => modified2);
@@ -1667,10 +2268,107 @@ const PublishAction$1 = ({
1667
2268
  const validate = useForm("PublishAction", (state) => state.validate);
1668
2269
  const setErrors = useForm("PublishAction", (state) => state.setErrors);
1669
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]);
1670
2326
  const isDocumentPublished = (document?.[PUBLISHED_AT_ATTRIBUTE_NAME] || meta?.availableStatus.some((doc) => doc[PUBLISHED_AT_ATTRIBUTE_NAME] !== null)) && document?.status !== "modified";
1671
2327
  if (!schema?.options?.draftAndPublish) {
1672
2328
  return null;
1673
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;
1674
2372
  return {
1675
2373
  /**
1676
2374
  * Disabled when:
@@ -1680,52 +2378,40 @@ const PublishAction$1 = ({
1680
2378
  * - the document is already published & not modified
1681
2379
  * - the document is being created & not modified
1682
2380
  * - the user doesn't have the permission to publish
1683
- * - the user doesn't have the permission to create a new document
1684
- * - the user doesn't have the permission to update the document
1685
2381
  */
1686
- 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,
1687
2383
  label: formatMessage({
1688
2384
  id: "app.utils.publish",
1689
2385
  defaultMessage: "Publish"
1690
2386
  }),
1691
2387
  onClick: async () => {
1692
- setSubmitting(true);
1693
- try {
1694
- const { errors } = await validate();
1695
- if (errors) {
1696
- toggleNotification({
1697
- type: "danger",
1698
- message: formatMessage({
1699
- id: "content-manager.validation.error",
1700
- defaultMessage: "There are validation errors in your document. Please fix them before saving."
1701
- })
1702
- });
1703
- return;
1704
- }
1705
- const res = await publish(
1706
- {
1707
- collectionType,
1708
- model,
1709
- documentId,
1710
- params
1711
- },
1712
- formValues
1713
- );
1714
- if ("data" in res && collectionType !== SINGLE_TYPES) {
1715
- navigate({
1716
- pathname: `../${collectionType}/${model}/${res.data.documentId}`,
1717
- search: rawQuery
1718
- });
1719
- } else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
1720
- setErrors(formatValidationErrors(res.error));
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
1721
2405
  }
1722
- } finally {
1723
- setSubmitting(false);
2406
+ ),
2407
+ onConfirm: async () => {
2408
+ await performPublish();
1724
2409
  }
1725
- }
2410
+ } : void 0
1726
2411
  };
1727
2412
  };
1728
2413
  PublishAction$1.type = "publish";
2414
+ PublishAction$1.position = "panel";
1729
2415
  const UpdateAction = ({
1730
2416
  activeTab,
1731
2417
  documentId,
@@ -1738,10 +2424,6 @@ const UpdateAction = ({
1738
2424
  const cloneMatch = useMatch(CLONE_PATH);
1739
2425
  const isCloning = cloneMatch !== null;
1740
2426
  const { formatMessage } = useIntl();
1741
- const { canCreate, canUpdate } = useDocumentRBAC("UpdateAction", ({ canCreate: canCreate2, canUpdate: canUpdate2 }) => ({
1742
- canCreate: canCreate2,
1743
- canUpdate: canUpdate2
1744
- }));
1745
2427
  const { create, update, clone } = useDocumentActions();
1746
2428
  const [{ query, rawQuery }] = useQueryParams();
1747
2429
  const params = React.useMemo(() => buildValidParams(query), [query]);
@@ -1752,90 +2434,134 @@ const UpdateAction = ({
1752
2434
  const validate = useForm("UpdateAction", (state) => state.validate);
1753
2435
  const setErrors = useForm("UpdateAction", (state) => state.setErrors);
1754
2436
  const resetForm = useForm("PublishAction", ({ resetForm: resetForm2 }) => resetForm2);
1755
- return {
1756
- /**
1757
- * Disabled when:
1758
- * - the form is submitting
1759
- * - the document is not modified & we're not cloning (you can save a clone entity straight away)
1760
- * - the active tab is the published tab
1761
- * - the user doesn't have the permission to create a new document
1762
- * - the user doesn't have the permission to update the document
1763
- */
1764
- disabled: isSubmitting || !modified && !isCloning || activeTab === "published" || Boolean(!documentId && !canCreate || documentId && !canUpdate),
1765
- label: formatMessage({
1766
- id: "content-manager.containers.Edit.save",
1767
- defaultMessage: "Save"
1768
- }),
1769
- onClick: async () => {
1770
- setSubmitting(true);
1771
- try {
1772
- const { errors } = await validate();
1773
- if (errors) {
1774
- toggleNotification({
1775
- type: "danger",
1776
- message: formatMessage({
1777
- id: "content-manager.validation.error",
1778
- defaultMessage: "There are validation errors in your document. Please fix them before saving."
1779
- })
1780
- });
1781
- return;
1782
- }
1783
- if (isCloning) {
1784
- 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(
1785
2467
  {
1786
- model,
1787
- documentId: cloneMatch.params.origin,
1788
- params
1789
- },
1790
- document
1791
- );
1792
- if ("data" in res) {
1793
- navigate({
1794
- pathname: `../${collectionType}/${model}/${res.data.documentId}`,
2468
+ pathname: `../${res.data.documentId}`,
1795
2469
  search: rawQuery
1796
- });
1797
- } else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
1798
- setErrors(formatValidationErrors(res.error));
1799
- }
1800
- } else if (documentId || collectionType === SINGLE_TYPES) {
1801
- const res = await update(
1802
- {
1803
- collectionType,
1804
- model,
1805
- documentId,
1806
- params
1807
2470
  },
1808
- document
2471
+ { relative: "path" }
1809
2472
  );
1810
- if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
1811
- setErrors(formatValidationErrors(res.error));
1812
- } else {
1813
- resetForm();
1814
- }
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));
1815
2488
  } else {
1816
- 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(
1817
2501
  {
1818
- model,
1819
- params
2502
+ pathname: `../${res.data.documentId}`,
2503
+ search: rawQuery
1820
2504
  },
1821
- document
2505
+ { replace: true, relative: "path" }
1822
2506
  );
1823
- if ("data" in res && collectionType !== SINGLE_TYPES) {
1824
- navigate({
1825
- pathname: `../${collectionType}/${model}/${res.data.documentId}`,
1826
- search: rawQuery
1827
- });
1828
- } else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
1829
- setErrors(formatValidationErrors(res.error));
1830
- }
2507
+ } else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
2508
+ setErrors(formatValidationErrors(res.error));
1831
2509
  }
1832
- } finally {
1833
- setSubmitting(false);
1834
2510
  }
2511
+ } finally {
2512
+ setSubmitting(false);
1835
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
1836
2561
  };
1837
2562
  };
1838
2563
  UpdateAction.type = "update";
2564
+ UpdateAction.position = "panel";
1839
2565
  const UNPUBLISH_DRAFT_OPTIONS = {
1840
2566
  KEEP: "keep",
1841
2567
  DISCARD: "discard"
@@ -1868,7 +2594,7 @@ const UnpublishAction$1 = ({
1868
2594
  id: "app.utils.unpublish",
1869
2595
  defaultMessage: "Unpublish"
1870
2596
  }),
1871
- icon: /* @__PURE__ */ jsx(StyledCrossCircle, {}),
2597
+ icon: /* @__PURE__ */ jsx(Cross, {}),
1872
2598
  onClick: async () => {
1873
2599
  if (!documentId && collectionType !== SINGLE_TYPES || isDocumentModified) {
1874
2600
  if (!documentId) {
@@ -1958,6 +2684,7 @@ const UnpublishAction$1 = ({
1958
2684
  };
1959
2685
  };
1960
2686
  UnpublishAction$1.type = "unpublish";
2687
+ UnpublishAction$1.position = "panel";
1961
2688
  const DiscardAction = ({
1962
2689
  activeTab,
1963
2690
  documentId,
@@ -1980,7 +2707,7 @@ const DiscardAction = ({
1980
2707
  id: "content-manager.actions.discard.label",
1981
2708
  defaultMessage: "Discard changes"
1982
2709
  }),
1983
- icon: /* @__PURE__ */ jsx(StyledCrossCircle, {}),
2710
+ icon: /* @__PURE__ */ jsx(Cross, {}),
1984
2711
  position: ["panel", "table-row"],
1985
2712
  variant: "danger",
1986
2713
  dialog: {
@@ -2008,11 +2735,7 @@ const DiscardAction = ({
2008
2735
  };
2009
2736
  };
2010
2737
  DiscardAction.type = "discard";
2011
- const StyledCrossCircle = styled(CrossCircle)`
2012
- path {
2013
- fill: currentColor;
2014
- }
2015
- `;
2738
+ DiscardAction.position = "panel";
2016
2739
  const DEFAULT_ACTIONS = [PublishAction$1, UpdateAction, UnpublishAction$1, DiscardAction];
2017
2740
  const intervals = ["years", "months", "days", "hours", "minutes", "seconds"];
2018
2741
  const RelativeTime = React.forwardRef(
@@ -2025,7 +2748,7 @@ const RelativeTime = React.forwardRef(
2025
2748
  });
2026
2749
  const unit = intervals.find((intervalUnit) => {
2027
2750
  return interval[intervalUnit] > 0 && Object.keys(interval).includes(intervalUnit);
2028
- });
2751
+ }) ?? "seconds";
2029
2752
  const relativeTime = isPast(timestamp) ? -interval[unit] : interval[unit];
2030
2753
  const customInterval = customIntervals.find(
2031
2754
  (custom) => interval[custom.unit] < custom.threshold
@@ -2059,34 +2782,34 @@ const getDisplayName = ({
2059
2782
  return email ?? "";
2060
2783
  };
2061
2784
  const capitalise = (str) => str.charAt(0).toUpperCase() + str.slice(1);
2062
- const DocumentStatus = ({ status = "draft", ...restProps }) => {
2063
- const statusVariant = status === "draft" ? "primary" : status === "published" ? "success" : "alternative";
2064
- return /* @__PURE__ */ jsx(Status, { ...restProps, showBullet: false, size: "S", variant: statusVariant, children: /* @__PURE__ */ jsx(Typography, { tag: "span", variant: "omega", fontWeight: "bold", children: capitalise(status) }) });
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
+ }) }) });
2065
2792
  };
2066
2793
  const Header = ({ isCreating, status, title: documentTitle = "Untitled" }) => {
2067
2794
  const { formatMessage } = useIntl();
2068
2795
  const isCloning = useMatch(CLONE_PATH) !== null;
2796
+ const params = useParams();
2069
2797
  const title = isCreating ? formatMessage({
2070
2798
  id: "content-manager.containers.edit.title.new",
2071
2799
  defaultMessage: "Create an entry"
2072
2800
  }) : documentTitle;
2073
- return /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "flex-start", paddingTop: 8, paddingBottom: 4, gap: 3, children: [
2074
- /* @__PURE__ */ jsx(BackButton, {}),
2075
- /* @__PURE__ */ jsxs(
2076
- Flex,
2801
+ return /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "flex-start", paddingTop: 6, paddingBottom: 4, gap: 2, children: [
2802
+ /* @__PURE__ */ jsx(
2803
+ BackButton,
2077
2804
  {
2078
- width: "100%",
2079
- justifyContent: "space-between",
2080
- paddingTop: 1,
2081
- gap: "80px",
2082
- alignItems: "flex-start",
2083
- children: [
2084
- /* @__PURE__ */ jsx(Typography, { variant: "alpha", tag: "h1", children: title }),
2085
- /* @__PURE__ */ jsx(HeaderToolbar, {})
2086
- ]
2805
+ fallback: params.collectionType === SINGLE_TYPES ? void 0 : `../${COLLECTION_TYPES}/${params.slug}`
2087
2806
  }
2088
2807
  ),
2089
- 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
2090
2813
  ] });
2091
2814
  };
2092
2815
  const HeaderToolbar = () => {
@@ -2132,7 +2855,7 @@ const HeaderToolbar = () => {
2132
2855
  meta: isCloning ? void 0 : meta,
2133
2856
  collectionType
2134
2857
  },
2135
- descriptions: plugins["content-manager"].apis.getDocumentActions(),
2858
+ descriptions: plugins["content-manager"].apis.getDocumentActions("header"),
2136
2859
  children: (actions2) => {
2137
2860
  const headerActions = actions2.filter((action) => {
2138
2861
  const positions = Array.isArray(action.position) ? action.position : [action.position];
@@ -2169,12 +2892,12 @@ const Information = ({ activeTab }) => {
2169
2892
  isDisplayed: !!publishDocument?.[PUBLISHED_AT_ATTRIBUTE_NAME],
2170
2893
  label: formatMessage({
2171
2894
  id: "content-manager.containers.edit.information.last-published.label",
2172
- defaultMessage: "Last published"
2895
+ defaultMessage: "Published"
2173
2896
  }),
2174
2897
  value: formatMessage(
2175
2898
  {
2176
2899
  id: "content-manager.containers.edit.information.last-published.value",
2177
- defaultMessage: `Published {time}{isAnonymous, select, true {} other { by {author}}}`
2900
+ defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
2178
2901
  },
2179
2902
  {
2180
2903
  time: /* @__PURE__ */ jsx(RelativeTime, { timestamp: new Date(publishDocument?.[PUBLISHED_AT_ATTRIBUTE_NAME]) }),
@@ -2187,12 +2910,12 @@ const Information = ({ activeTab }) => {
2187
2910
  isDisplayed: !!createAndUpdateDocument?.[UPDATED_AT_ATTRIBUTE_NAME],
2188
2911
  label: formatMessage({
2189
2912
  id: "content-manager.containers.edit.information.last-draft.label",
2190
- defaultMessage: "Last draft"
2913
+ defaultMessage: "Updated"
2191
2914
  }),
2192
2915
  value: formatMessage(
2193
2916
  {
2194
2917
  id: "content-manager.containers.edit.information.last-draft.value",
2195
- defaultMessage: `Modified {time}{isAnonymous, select, true {} other { by {author}}}`
2918
+ defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
2196
2919
  },
2197
2920
  {
2198
2921
  time: /* @__PURE__ */ jsx(
@@ -2210,12 +2933,12 @@ const Information = ({ activeTab }) => {
2210
2933
  isDisplayed: !!createAndUpdateDocument?.[CREATED_AT_ATTRIBUTE_NAME],
2211
2934
  label: formatMessage({
2212
2935
  id: "content-manager.containers.edit.information.document.label",
2213
- defaultMessage: "Document"
2936
+ defaultMessage: "Created"
2214
2937
  }),
2215
2938
  value: formatMessage(
2216
2939
  {
2217
2940
  id: "content-manager.containers.edit.information.document.value",
2218
- defaultMessage: `Created {time}{isAnonymous, select, true {} other { by {author}}}`
2941
+ defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
2219
2942
  },
2220
2943
  {
2221
2944
  time: /* @__PURE__ */ jsx(
@@ -2253,25 +2976,77 @@ const Information = ({ activeTab }) => {
2253
2976
  );
2254
2977
  };
2255
2978
  const HeaderActions = ({ actions: actions2 }) => {
2256
- return /* @__PURE__ */ jsx(Flex, { children: actions2.map((action) => {
2257
- 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) {
2258
2995
  return /* @__PURE__ */ jsx(
2259
2996
  SingleSelect,
2260
2997
  {
2261
2998
  size: "S",
2262
- disabled: action.disabled,
2263
- "aria-label": action.label,
2264
2999
  onChange: action.onSelect,
2265
- value: action.value,
3000
+ "aria-label": action.label,
3001
+ ...action,
2266
3002
  children: action.options.map(({ label, ...option }) => /* @__PURE__ */ jsx(SingleSelectOption, { ...option, children: label }, option.value))
2267
3003
  },
2268
3004
  action.id
2269
3005
  );
2270
3006
  } else {
2271
- 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
+ }
2272
3029
  }
2273
3030
  }) });
2274
3031
  };
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
+ };
2275
3050
  const ConfigureTheViewAction = ({ collectionType, model }) => {
2276
3051
  const navigate = useNavigate();
2277
3052
  const { formatMessage } = useIntl();
@@ -2288,6 +3063,7 @@ const ConfigureTheViewAction = ({ collectionType, model }) => {
2288
3063
  };
2289
3064
  };
2290
3065
  ConfigureTheViewAction.type = "configure-the-view";
3066
+ ConfigureTheViewAction.position = "header";
2291
3067
  const EditTheModelAction = ({ model }) => {
2292
3068
  const navigate = useNavigate();
2293
3069
  const { formatMessage } = useIntl();
@@ -2304,6 +3080,7 @@ const EditTheModelAction = ({ model }) => {
2304
3080
  };
2305
3081
  };
2306
3082
  EditTheModelAction.type = "edit-the-model";
3083
+ EditTheModelAction.position = "header";
2307
3084
  const DeleteAction$1 = ({ documentId, model, collectionType, document }) => {
2308
3085
  const navigate = useNavigate();
2309
3086
  const { formatMessage } = useIntl();
@@ -2312,12 +3089,16 @@ const DeleteAction$1 = ({ documentId, model, collectionType, document }) => {
2312
3089
  const { delete: deleteAction } = useDocumentActions();
2313
3090
  const { toggleNotification } = useNotification();
2314
3091
  const setSubmitting = useForm("DeleteAction", (state) => state.setSubmitting);
3092
+ const isLocalized = document?.locale != null;
2315
3093
  return {
2316
3094
  disabled: !canDelete || !document,
2317
- label: formatMessage({
2318
- id: "content-manager.actions.delete.label",
2319
- defaultMessage: "Delete document"
2320
- }),
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
+ ),
2321
3102
  icon: /* @__PURE__ */ jsx(Trash, {}),
2322
3103
  dialog: {
2323
3104
  type: "dialog",
@@ -2373,6 +3154,7 @@ const DeleteAction$1 = ({ documentId, model, collectionType, document }) => {
2373
3154
  };
2374
3155
  };
2375
3156
  DeleteAction$1.type = "delete";
3157
+ DeleteAction$1.position = ["header", "table-row"];
2376
3158
  const DEFAULT_HEADER_ACTIONS = [EditTheModelAction, ConfigureTheViewAction, DeleteAction$1];
2377
3159
  const Panels = () => {
2378
3160
  const isCloning = useMatch(CLONE_PATH) !== null;
@@ -2399,377 +3181,75 @@ const Panels = () => {
2399
3181
  props,
2400
3182
  descriptions: plugins["content-manager"].apis.getEditViewSidePanels(),
2401
3183
  children: (panels) => panels.map(({ content, id: id2, ...description }) => /* @__PURE__ */ jsx(Panel, { ...description, children: content }, id2))
2402
- }
2403
- ) });
2404
- };
2405
- const ActionsPanel = () => {
2406
- const { formatMessage } = useIntl();
2407
- return {
2408
- title: formatMessage({
2409
- id: "content-manager.containers.edit.panels.default.title",
2410
- defaultMessage: "Document"
2411
- }),
2412
- content: /* @__PURE__ */ jsx(ActionsPanelContent, {})
2413
- };
2414
- };
2415
- ActionsPanel.type = "actions";
2416
- const ActionsPanelContent = () => {
2417
- const isCloning = useMatch(CLONE_PATH) !== null;
2418
- const [
2419
- {
2420
- query: { status = "draft" }
2421
- }
2422
- ] = useQueryParams();
2423
- const { model, id, document, meta, collectionType } = useDoc();
2424
- const plugins = useStrapiApp("ActionsPanel", (state) => state.plugins);
2425
- const props = {
2426
- activeTab: status,
2427
- model,
2428
- documentId: id,
2429
- document: isCloning ? void 0 : document,
2430
- meta: isCloning ? void 0 : meta,
2431
- collectionType
2432
- };
2433
- return /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 2, width: "100%", children: [
2434
- /* @__PURE__ */ jsx(
2435
- DescriptionComponentRenderer,
2436
- {
2437
- props,
2438
- descriptions: plugins["content-manager"].apis.getDocumentActions(),
2439
- children: (actions2) => /* @__PURE__ */ jsx(DocumentActions, { actions: actions2 })
2440
- }
2441
- ),
2442
- /* @__PURE__ */ jsx(InjectionZone, { area: "editView.right-links", slug: model })
2443
- ] });
2444
- };
2445
- const Panel = React.forwardRef(({ children, title }, ref) => {
2446
- return /* @__PURE__ */ jsxs(
2447
- Flex,
2448
- {
2449
- ref,
2450
- tag: "aside",
2451
- "aria-labelledby": "additional-information",
2452
- background: "neutral0",
2453
- borderColor: "neutral150",
2454
- hasRadius: true,
2455
- paddingBottom: 4,
2456
- paddingLeft: 4,
2457
- paddingRight: 4,
2458
- paddingTop: 4,
2459
- shadow: "tableShadow",
2460
- gap: 3,
2461
- direction: "column",
2462
- justifyContent: "stretch",
2463
- alignItems: "flex-start",
2464
- children: [
2465
- /* @__PURE__ */ jsx(Typography, { tag: "h2", variant: "sigma", textTransform: "uppercase", children: title }),
2466
- children
2467
- ]
2468
- }
2469
- );
2470
- });
2471
- const HOOKS = {
2472
- /**
2473
- * Hook that allows to mutate the displayed headers of the list view table
2474
- * @constant
2475
- * @type {string}
2476
- */
2477
- INJECT_COLUMN_IN_TABLE: "Admin/CM/pages/ListView/inject-column-in-table",
2478
- /**
2479
- * Hook that allows to mutate the CM's collection types links pre-set filters
2480
- * @constant
2481
- * @type {string}
2482
- */
2483
- MUTATE_COLLECTION_TYPES_LINKS: "Admin/CM/pages/App/mutate-collection-types-links",
2484
- /**
2485
- * Hook that allows to mutate the CM's edit view layout
2486
- * @constant
2487
- * @type {string}
2488
- */
2489
- MUTATE_EDIT_VIEW_LAYOUT: "Admin/CM/pages/EditView/mutate-edit-view-layout",
2490
- /**
2491
- * Hook that allows to mutate the CM's single types links pre-set filters
2492
- * @constant
2493
- * @type {string}
2494
- */
2495
- MUTATE_SINGLE_TYPES_LINKS: "Admin/CM/pages/App/mutate-single-types-links"
2496
- };
2497
- const contentTypesApi = contentManagerApi.injectEndpoints({
2498
- endpoints: (builder) => ({
2499
- getContentTypeConfiguration: builder.query({
2500
- query: (uid) => ({
2501
- url: `/content-manager/content-types/${uid}/configuration`,
2502
- method: "GET"
2503
- }),
2504
- transformResponse: (response) => response.data,
2505
- providesTags: (_result, _error, uid) => [
2506
- { type: "ContentTypesConfiguration", id: uid },
2507
- { type: "ContentTypeSettings", id: "LIST" }
2508
- ]
2509
- }),
2510
- getAllContentTypeSettings: builder.query({
2511
- query: () => "/content-manager/content-types-settings",
2512
- transformResponse: (response) => response.data,
2513
- providesTags: [{ type: "ContentTypeSettings", id: "LIST" }]
2514
- }),
2515
- updateContentTypeConfiguration: builder.mutation({
2516
- query: ({ uid, ...body }) => ({
2517
- url: `/content-manager/content-types/${uid}/configuration`,
2518
- method: "PUT",
2519
- data: body
2520
- }),
2521
- transformResponse: (response) => response.data,
2522
- invalidatesTags: (_result, _error, { uid }) => [
2523
- { type: "ContentTypesConfiguration", id: uid },
2524
- { type: "ContentTypeSettings", id: "LIST" },
2525
- // Is this necessary?
2526
- { type: "InitialData" }
2527
- ]
2528
- })
2529
- })
2530
- });
2531
- const {
2532
- useGetContentTypeConfigurationQuery,
2533
- useGetAllContentTypeSettingsQuery,
2534
- useUpdateContentTypeConfigurationMutation
2535
- } = contentTypesApi;
2536
- const checkIfAttributeIsDisplayable = (attribute) => {
2537
- const { type } = attribute;
2538
- if (type === "relation") {
2539
- return !attribute.relation.toLowerCase().includes("morph");
2540
- }
2541
- return !["json", "dynamiczone", "richtext", "password", "blocks"].includes(type) && !!type;
2542
- };
2543
- const getMainField = (attribute, mainFieldName, { schemas, components }) => {
2544
- if (!mainFieldName) {
2545
- return void 0;
2546
- }
2547
- const mainFieldType = attribute.type === "component" ? components[attribute.component].attributes[mainFieldName].type : (
2548
- // @ts-expect-error – `targetModel` does exist on the attribute for a relation.
2549
- schemas.find((schema) => schema.uid === attribute.targetModel)?.attributes[mainFieldName].type
2550
- );
2551
- return {
2552
- name: mainFieldName,
2553
- type: mainFieldType ?? "string"
2554
- };
2555
- };
2556
- const DEFAULT_SETTINGS = {
2557
- bulkable: false,
2558
- filterable: false,
2559
- searchable: false,
2560
- pagination: false,
2561
- defaultSortBy: "",
2562
- defaultSortOrder: "asc",
2563
- mainField: "id",
2564
- pageSize: 10
2565
- };
2566
- const useDocumentLayout = (model) => {
2567
- const { schema, components } = useDocument({ model, collectionType: "" }, { skip: true });
2568
- const [{ query }] = useQueryParams();
2569
- const runHookWaterfall = useStrapiApp("useDocumentLayout", (state) => state.runHookWaterfall);
2570
- const { toggleNotification } = useNotification();
2571
- const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();
2572
- const { isLoading: isLoadingSchemas, schemas } = useContentTypeSchema();
2573
- const {
2574
- data,
2575
- isLoading: isLoadingConfigs,
2576
- error,
2577
- isFetching: isFetchingConfigs
2578
- } = useGetContentTypeConfigurationQuery(model);
2579
- const isLoading = isLoadingSchemas || isFetchingConfigs || isLoadingConfigs;
2580
- React.useEffect(() => {
2581
- if (error) {
2582
- toggleNotification({
2583
- type: "danger",
2584
- message: formatAPIError(error)
2585
- });
2586
- }
2587
- }, [error, formatAPIError, toggleNotification]);
2588
- const editLayout = React.useMemo(
2589
- () => data && !isLoading ? formatEditLayout(data, { schemas, schema, components }) : {
2590
- layout: [],
2591
- components: {},
2592
- metadatas: {},
2593
- options: {},
2594
- settings: DEFAULT_SETTINGS
2595
- },
2596
- [data, isLoading, schemas, schema, components]
2597
- );
2598
- const listLayout = React.useMemo(() => {
2599
- return data && !isLoading ? formatListLayout(data, { schemas, schema, components }) : {
2600
- layout: [],
2601
- metadatas: {},
2602
- options: {},
2603
- settings: DEFAULT_SETTINGS
2604
- };
2605
- }, [data, isLoading, schemas, schema, components]);
2606
- const { layout: edit } = React.useMemo(
2607
- () => runHookWaterfall(HOOKS.MUTATE_EDIT_VIEW_LAYOUT, {
2608
- layout: editLayout,
2609
- query
2610
- }),
2611
- [editLayout, query, runHookWaterfall]
2612
- );
2613
- return {
2614
- error,
2615
- isLoading,
2616
- edit,
2617
- list: listLayout
2618
- };
2619
- };
2620
- const useDocLayout = () => {
2621
- const { model } = useDoc();
2622
- return useDocumentLayout(model);
2623
- };
2624
- const formatEditLayout = (data, {
2625
- schemas,
2626
- schema,
2627
- components
2628
- }) => {
2629
- let currentPanelIndex = 0;
2630
- const panelledEditAttributes = convertEditLayoutToFieldLayouts(
2631
- data.contentType.layouts.edit,
2632
- schema?.attributes,
2633
- data.contentType.metadatas,
2634
- { configurations: data.components, schemas: components },
2635
- schemas
2636
- ).reduce((panels, row) => {
2637
- if (row.some((field) => field.type === "dynamiczone")) {
2638
- panels.push([row]);
2639
- currentPanelIndex += 2;
2640
- } else {
2641
- if (!panels[currentPanelIndex]) {
2642
- panels.push([]);
2643
- }
2644
- panels[currentPanelIndex].push(row);
2645
- }
2646
- return panels;
2647
- }, []);
2648
- const componentEditAttributes = Object.entries(data.components).reduce(
2649
- (acc, [uid, configuration]) => {
2650
- acc[uid] = {
2651
- layout: convertEditLayoutToFieldLayouts(
2652
- configuration.layouts.edit,
2653
- components[uid].attributes,
2654
- configuration.metadatas
2655
- ),
2656
- settings: {
2657
- ...configuration.settings,
2658
- icon: components[uid].info.icon,
2659
- displayName: components[uid].info.displayName
2660
- }
2661
- };
2662
- return acc;
2663
- },
2664
- {}
2665
- );
2666
- const editMetadatas = Object.entries(data.contentType.metadatas).reduce(
2667
- (acc, [attribute, metadata]) => {
2668
- return {
2669
- ...acc,
2670
- [attribute]: metadata.edit
2671
- };
2672
- },
2673
- {}
2674
- );
2675
- return {
2676
- layout: panelledEditAttributes,
2677
- components: componentEditAttributes,
2678
- metadatas: editMetadatas,
2679
- settings: {
2680
- ...data.contentType.settings,
2681
- displayName: schema?.info.displayName
2682
- },
2683
- options: {
2684
- ...schema?.options,
2685
- ...schema?.pluginOptions,
2686
- ...data.contentType.options
2687
- }
2688
- };
2689
- };
2690
- const convertEditLayoutToFieldLayouts = (rows, attributes = {}, metadatas, components, schemas = []) => {
2691
- return rows.map(
2692
- (row) => row.map((field) => {
2693
- const attribute = attributes[field.name];
2694
- if (!attribute) {
2695
- return null;
2696
- }
2697
- const { edit: metadata } = metadatas[field.name];
2698
- const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
2699
- return {
2700
- attribute,
2701
- disabled: !metadata.editable,
2702
- hint: metadata.description,
2703
- label: metadata.label ?? "",
2704
- name: field.name,
2705
- // @ts-expect-error – mainField does exist on the metadata for a relation.
2706
- mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
2707
- schemas,
2708
- components: components?.schemas ?? {}
2709
- }),
2710
- placeholder: metadata.placeholder ?? "",
2711
- required: attribute.required ?? false,
2712
- size: field.size,
2713
- unique: "unique" in attribute ? attribute.unique : false,
2714
- visible: metadata.visible ?? true,
2715
- type: attribute.type
2716
- };
2717
- }).filter((field) => field !== null)
2718
- );
3184
+ }
3185
+ ) });
2719
3186
  };
2720
- const formatListLayout = (data, {
2721
- schemas,
2722
- schema,
2723
- components
2724
- }) => {
2725
- const listMetadatas = Object.entries(data.contentType.metadatas).reduce(
2726
- (acc, [attribute, metadata]) => {
2727
- return {
2728
- ...acc,
2729
- [attribute]: metadata.list
2730
- };
2731
- },
2732
- {}
2733
- );
2734
- const listAttributes = convertListLayoutToFieldLayouts(
2735
- data.contentType.layouts.list,
2736
- schema?.attributes,
2737
- listMetadatas,
2738
- { configurations: data.components, schemas: components },
2739
- schemas
2740
- );
3187
+ const ActionsPanel = () => {
3188
+ const { formatMessage } = useIntl();
2741
3189
  return {
2742
- layout: listAttributes,
2743
- settings: { ...data.contentType.settings, displayName: schema?.info.displayName },
2744
- metadatas: listMetadatas,
2745
- options: {
2746
- ...schema?.options,
2747
- ...schema?.pluginOptions,
2748
- ...data.contentType.options
2749
- }
3190
+ title: formatMessage({
3191
+ id: "content-manager.containers.edit.panels.default.title",
3192
+ defaultMessage: "Entry"
3193
+ }),
3194
+ content: /* @__PURE__ */ jsx(ActionsPanelContent, {})
2750
3195
  };
2751
3196
  };
2752
- const convertListLayoutToFieldLayouts = (columns, attributes = {}, metadatas, components, schemas = []) => {
2753
- return columns.map((name) => {
2754
- const attribute = attributes[name];
2755
- if (!attribute) {
2756
- return null;
3197
+ ActionsPanel.type = "actions";
3198
+ const ActionsPanelContent = () => {
3199
+ const isCloning = useMatch(CLONE_PATH) !== null;
3200
+ const [
3201
+ {
3202
+ query: { status = "draft" }
2757
3203
  }
2758
- const metadata = metadatas[name];
2759
- const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
2760
- return {
2761
- attribute,
2762
- label: metadata.label ?? "",
2763
- mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
2764
- schemas,
2765
- components: components?.schemas ?? {}
2766
- }),
2767
- name,
2768
- searchable: metadata.searchable ?? true,
2769
- sortable: metadata.sortable ?? true
2770
- };
2771
- }).filter((field) => field !== null);
3204
+ ] = useQueryParams();
3205
+ const { model, id, document, meta, collectionType } = useDoc();
3206
+ const plugins = useStrapiApp("ActionsPanel", (state) => state.plugins);
3207
+ const props = {
3208
+ activeTab: status,
3209
+ model,
3210
+ documentId: id,
3211
+ document: isCloning ? void 0 : document,
3212
+ meta: isCloning ? void 0 : meta,
3213
+ collectionType
3214
+ };
3215
+ return /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 2, width: "100%", children: [
3216
+ /* @__PURE__ */ jsx(
3217
+ DescriptionComponentRenderer,
3218
+ {
3219
+ props,
3220
+ descriptions: plugins["content-manager"].apis.getDocumentActions("panel"),
3221
+ children: (actions2) => /* @__PURE__ */ jsx(DocumentActions, { actions: actions2 })
3222
+ }
3223
+ ),
3224
+ /* @__PURE__ */ jsx(InjectionZone, { area: "editView.right-links", slug: model })
3225
+ ] });
2772
3226
  };
3227
+ const Panel = React.forwardRef(({ children, title }, ref) => {
3228
+ return /* @__PURE__ */ jsxs(
3229
+ Flex,
3230
+ {
3231
+ ref,
3232
+ tag: "aside",
3233
+ "aria-labelledby": "additional-information",
3234
+ background: "neutral0",
3235
+ borderColor: "neutral150",
3236
+ hasRadius: true,
3237
+ paddingBottom: 4,
3238
+ paddingLeft: 4,
3239
+ paddingRight: 4,
3240
+ paddingTop: 4,
3241
+ shadow: "tableShadow",
3242
+ gap: 3,
3243
+ direction: "column",
3244
+ justifyContent: "stretch",
3245
+ alignItems: "flex-start",
3246
+ children: [
3247
+ /* @__PURE__ */ jsx(Typography, { tag: "h2", variant: "sigma", textTransform: "uppercase", textColor: "neutral600", children: title }),
3248
+ children
3249
+ ]
3250
+ }
3251
+ );
3252
+ });
2773
3253
  const ConfirmBulkActionDialog = ({
2774
3254
  onToggleDialog,
2775
3255
  isOpen = false,
@@ -2777,7 +3257,7 @@ const ConfirmBulkActionDialog = ({
2777
3257
  endAction
2778
3258
  }) => {
2779
3259
  const { formatMessage } = useIntl();
2780
- return /* @__PURE__ */ jsx(Dialog.Root, { onOpenChange: onToggleDialog, open: isOpen, children: /* @__PURE__ */ jsxs(Dialog.Content, { children: [
3260
+ return /* @__PURE__ */ jsx(Dialog.Root, { open: isOpen, children: /* @__PURE__ */ jsxs(Dialog.Content, { children: [
2781
3261
  /* @__PURE__ */ jsx(Dialog.Header, { children: formatMessage({
2782
3262
  id: "app.components.ConfirmDialog.title",
2783
3263
  defaultMessage: "Confirmation"
@@ -2795,7 +3275,7 @@ const ConfirmBulkActionDialog = ({
2795
3275
  ] })
2796
3276
  ] }) });
2797
3277
  };
2798
- const BoldChunk$1 = (chunks) => /* @__PURE__ */ jsx(Typography, { fontWeight: "bold", children: chunks });
3278
+ const BoldChunk = (chunks) => /* @__PURE__ */ jsx(Typography, { fontWeight: "bold", children: chunks });
2799
3279
  const ConfirmDialogPublishAll = ({
2800
3280
  isOpen,
2801
3281
  onToggleDialog,
@@ -2808,6 +3288,7 @@ const ConfirmDialogPublishAll = ({
2808
3288
  const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler(getTranslation);
2809
3289
  const { model, schema } = useDoc();
2810
3290
  const [{ query }] = useQueryParams();
3291
+ const enableDraftRelationsCount = false;
2811
3292
  const {
2812
3293
  data: countDraftRelations = 0,
2813
3294
  isLoading,
@@ -2819,7 +3300,7 @@ const ConfirmDialogPublishAll = ({
2819
3300
  locale: query?.plugins?.i18n?.locale
2820
3301
  },
2821
3302
  {
2822
- skip: selectedEntries.length === 0
3303
+ skip: !enableDraftRelationsCount
2823
3304
  }
2824
3305
  );
2825
3306
  React.useEffect(() => {
@@ -2843,7 +3324,7 @@ const ConfirmDialogPublishAll = ({
2843
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. "
2844
3325
  },
2845
3326
  {
2846
- b: BoldChunk$1,
3327
+ b: BoldChunk,
2847
3328
  count: countDraftRelations,
2848
3329
  entities: selectedEntries.length
2849
3330
  }
@@ -2882,6 +3363,16 @@ const ConfirmDialogPublishAll = ({
2882
3363
  const TypographyMaxWidth = styled(Typography)`
2883
3364
  max-width: 300px;
2884
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
+ `;
2885
3376
  const formatErrorMessages = (errors, parentKey, formatMessage) => {
2886
3377
  const messages = [];
2887
3378
  Object.entries(errors).forEach(([key, value]) => {
@@ -2898,7 +3389,14 @@ const formatErrorMessages = (errors, parentKey, formatMessage) => {
2898
3389
  )
2899
3390
  );
2900
3391
  } else {
2901
- 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
+ );
2902
3400
  }
2903
3401
  } else {
2904
3402
  messages.push(
@@ -2979,7 +3477,7 @@ const SelectedEntriesTableContent = ({
2979
3477
  )
2980
3478
  ] }),
2981
3479
  /* @__PURE__ */ jsx(Table.Loading, {}),
2982
- /* @__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: [
2983
3481
  /* @__PURE__ */ jsx(Table.CheckboxCell, { id: row.id }),
2984
3482
  /* @__PURE__ */ jsx(Table.Cell, { children: /* @__PURE__ */ jsx(Typography, { children: row.id }) }),
2985
3483
  shouldDisplayMainField && /* @__PURE__ */ jsx(Table.Cell, { children: /* @__PURE__ */ jsx(Typography, { children: row[mainField] }) }),
@@ -2997,7 +3495,7 @@ const SelectedEntriesTableContent = ({
2997
3495
  status: row.status
2998
3496
  }
2999
3497
  ) }),
3000
- /* @__PURE__ */ jsx(Table.Cell, { children: /* @__PURE__ */ jsx(
3498
+ /* @__PURE__ */ jsx(Table.Cell, { children: /* @__PURE__ */ jsx(Flex, { children: /* @__PURE__ */ jsx(
3001
3499
  IconButton,
3002
3500
  {
3003
3501
  tag: Link,
@@ -3006,27 +3504,86 @@ const SelectedEntriesTableContent = ({
3006
3504
  search: row.locale && `?plugins[i18n][locale]=${row.locale}`
3007
3505
  },
3008
3506
  state: { from: pathname },
3009
- label: formatMessage(
3010
- { id: "app.component.HelperPluginTable.edit", defaultMessage: "Edit {target}" },
3011
- {
3012
- target: formatMessage(
3013
- {
3014
- id: "content-manager.components.ListViewHelperPluginTable.row-line",
3015
- defaultMessage: "item line {number}"
3016
- },
3017
- { number: index2 + 1 }
3018
- )
3019
- }
3020
- ),
3507
+ label: formatMessage({
3508
+ id: "content-manager.bulk-publish.edit",
3509
+ defaultMessage: "Edit"
3510
+ }),
3021
3511
  target: "_blank",
3022
3512
  marginLeft: "auto",
3023
- children: /* @__PURE__ */ jsx(Pencil, {})
3513
+ variant: "ghost",
3514
+ children: /* @__PURE__ */ jsx(Pencil, { width: "1.6rem", height: "1.6rem" })
3024
3515
  }
3025
- ) })
3516
+ ) }) })
3026
3517
  ] }, row.id)) })
3027
3518
  ] });
3028
3519
  };
3029
- 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
+ };
3030
3587
  const SelectedEntriesModalContent = ({
3031
3588
  listViewSelectedEntries,
3032
3589
  toggleModal,
@@ -3059,7 +3616,13 @@ const SelectedEntriesModalContent = ({
3059
3616
  );
3060
3617
  const { rows, validationErrors } = React.useMemo(() => {
3061
3618
  if (data.length > 0 && schema) {
3062
- 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
+ );
3063
3626
  const validationErrors2 = {};
3064
3627
  const rows2 = data.map((entry) => {
3065
3628
  try {
@@ -3079,7 +3642,6 @@ const SelectedEntriesModalContent = ({
3079
3642
  validationErrors: {}
3080
3643
  };
3081
3644
  }, [components, data, schema]);
3082
- const [publishedCount, setPublishedCount] = React.useState(0);
3083
3645
  const [isDialogOpen, setIsDialogOpen] = React.useState(false);
3084
3646
  const { publishMany: bulkPublishAction } = useDocumentActions();
3085
3647
  const [, { isLoading: isSubmittingForm }] = usePublishManyDocumentsMutation();
@@ -3091,53 +3653,36 @@ const SelectedEntriesModalContent = ({
3091
3653
  const selectedEntriesWithErrorsCount = selectedEntries.filter(
3092
3654
  ({ documentId }) => validationErrors[documentId]
3093
3655
  ).length;
3094
- const selectedEntriesPublished = selectedEntries.filter(
3656
+ const selectedEntriesPublishedCount = selectedEntries.filter(
3095
3657
  ({ status }) => status === "published"
3096
3658
  ).length;
3097
- 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;
3098
3663
  const toggleDialog = () => setIsDialogOpen((prev) => !prev);
3099
3664
  const handleConfirmBulkPublish = async () => {
3100
3665
  toggleDialog();
3101
3666
  const res = await bulkPublishAction({ model, documentIds: entriesToPublish, params });
3102
3667
  if (!("error" in res)) {
3103
- setPublishedCount(res.count);
3104
3668
  const unpublishedEntries = rows.filter((row) => {
3105
3669
  return !entriesToPublish.includes(row.documentId);
3106
3670
  });
3107
3671
  setListViewSelectedDocuments(unpublishedEntries);
3108
3672
  }
3109
3673
  };
3110
- const getFormattedCountMessage = () => {
3111
- if (publishedCount) {
3112
- return formatMessage(
3113
- {
3114
- id: getTranslation("containers.list.selectedEntriesModal.publishedCount"),
3115
- 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."
3116
- },
3117
- {
3118
- publishedCount,
3119
- withErrorsCount: selectedEntriesWithErrorsCount,
3120
- b: BoldChunk
3121
- }
3122
- );
3123
- }
3124
- return formatMessage(
3125
- {
3126
- id: getTranslation("containers.list.selectedEntriesModal.selectedCount"),
3127
- 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."
3128
- },
3129
- {
3130
- readyToPublishCount: selectedEntriesWithNoErrorsCount,
3131
- withErrorsCount: selectedEntriesWithErrorsCount,
3132
- alreadyPublishedCount: selectedEntriesPublished,
3133
- b: BoldChunk
3134
- }
3135
- );
3136
- };
3137
3674
  return /* @__PURE__ */ jsxs(Fragment, { children: [
3138
3675
  /* @__PURE__ */ jsxs(Modal.Body, { children: [
3139
- /* @__PURE__ */ jsx(Typography, { children: getFormattedCountMessage() }),
3140
- /* @__PURE__ */ jsx(Box, { marginTop: 5, children: /* @__PURE__ */ jsx(
3676
+ /* @__PURE__ */ jsx(
3677
+ PublicationStatusGrid,
3678
+ {
3679
+ entriesReadyToPublishCount: selectedEntriesWithNoErrorsCount - selectedEntriesModifiedCount,
3680
+ entriesPublishedCount: selectedEntriesPublishedCount,
3681
+ entriesModifiedCount: selectedEntriesModifiedCount,
3682
+ entriesWithErrorsCount: selectedEntriesWithErrorsCount
3683
+ }
3684
+ ),
3685
+ /* @__PURE__ */ jsx(Box, { marginTop: 7, children: /* @__PURE__ */ jsx(
3141
3686
  SelectedEntriesTableContent,
3142
3687
  {
3143
3688
  isPublishing: isSubmittingForm,
@@ -3158,7 +3703,7 @@ const SelectedEntriesModalContent = ({
3158
3703
  Button,
3159
3704
  {
3160
3705
  onClick: toggleDialog,
3161
- disabled: selectedEntries.length === 0 || selectedEntries.length === selectedEntriesWithErrorsCount || selectedEntriesPublished === selectedEntries.length || isLoading,
3706
+ disabled: selectedEntries.length === 0 || selectedEntries.length === selectedEntriesWithErrorsCount || selectedEntriesPublishedCount === selectedEntries.length || isLoading,
3162
3707
  loading: isSubmittingForm,
3163
3708
  children: formatMessage({ id: "app.utils.publish", defaultMessage: "Publish" })
3164
3709
  }
@@ -3184,8 +3729,7 @@ const PublishAction = ({ documents, model }) => {
3184
3729
  const refetchList = () => {
3185
3730
  contentManagerApi.util.invalidateTags([{ type: "Document", id: `${model}_LIST` }]);
3186
3731
  };
3187
- if (!showPublishButton)
3188
- return null;
3732
+ if (!showPublishButton) return null;
3189
3733
  return {
3190
3734
  actionType: "publish",
3191
3735
  variant: "tertiary",
@@ -3253,8 +3797,7 @@ const DeleteAction = ({ documents, model }) => {
3253
3797
  selectRow([]);
3254
3798
  }
3255
3799
  };
3256
- if (!hasDeletePermission)
3257
- return null;
3800
+ if (!hasDeletePermission) return null;
3258
3801
  return {
3259
3802
  variant: "danger-light",
3260
3803
  label: formatMessage({ id: "global.delete", defaultMessage: "Delete" }),
@@ -3303,8 +3846,7 @@ const UnpublishAction = ({ documents, model }) => {
3303
3846
  }
3304
3847
  };
3305
3848
  const showUnpublishButton = hasDraftAndPublishEnabled && hasPublishPermission && documents.some((entry) => entry.status === "published" || entry.status === "modified");
3306
- if (!showUnpublishButton)
3307
- return null;
3849
+ if (!showUnpublishButton) return null;
3308
3850
  return {
3309
3851
  variant: "tertiary",
3310
3852
  label: formatMessage({ id: "app.utils.unpublish", defaultMessage: "Unpublish" }),
@@ -3409,7 +3951,7 @@ const TableActions = ({ document }) => {
3409
3951
  DescriptionComponentRenderer,
3410
3952
  {
3411
3953
  props,
3412
- descriptions: plugins["content-manager"].apis.getDocumentActions(),
3954
+ descriptions: plugins["content-manager"].apis.getDocumentActions("table-row").filter((action) => action.name !== "PublishAction"),
3413
3955
  children: (actions2) => {
3414
3956
  const tableRowActions = actions2.filter((action) => {
3415
3957
  const positions = Array.isArray(action.position) ? action.position : [action.position];
@@ -3468,6 +4010,7 @@ const EditAction = ({ documentId }) => {
3468
4010
  };
3469
4011
  };
3470
4012
  EditAction.type = "edit";
4013
+ EditAction.position = "table-row";
3471
4014
  const StyledPencil = styled(Pencil)`
3472
4015
  path {
3473
4016
  fill: currentColor;
@@ -3520,7 +4063,7 @@ const CloneAction = ({ model, documentId }) => {
3520
4063
  }),
3521
4064
  content: /* @__PURE__ */ jsx(AutoCloneFailureModalBody, { prohibitedFields }),
3522
4065
  footer: ({ onClose }) => {
3523
- return /* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", children: [
4066
+ return /* @__PURE__ */ jsxs(Modal.Footer, { children: [
3524
4067
  /* @__PURE__ */ jsx(Button, { onClick: onClose, variant: "tertiary", children: formatMessage({
3525
4068
  id: "cancel",
3526
4069
  defaultMessage: "Cancel"
@@ -3544,6 +4087,7 @@ const CloneAction = ({ model, documentId }) => {
3544
4087
  };
3545
4088
  };
3546
4089
  CloneAction.type = "clone";
4090
+ CloneAction.position = "table-row";
3547
4091
  const StyledDuplicate = styled(Duplicate)`
3548
4092
  path {
3549
4093
  fill: currentColor;
@@ -3561,8 +4105,7 @@ class ContentManagerPlugin {
3561
4105
  documentActions = [
3562
4106
  ...DEFAULT_ACTIONS,
3563
4107
  ...DEFAULT_TABLE_ROW_ACTIONS,
3564
- ...DEFAULT_HEADER_ACTIONS,
3565
- HistoryAction
4108
+ ...DEFAULT_HEADER_ACTIONS
3566
4109
  ];
3567
4110
  editViewSidePanels = [ActionsPanel];
3568
4111
  headerActions = [];
@@ -3631,7 +4174,14 @@ class ContentManagerPlugin {
3631
4174
  addDocumentHeaderAction: this.addDocumentHeaderAction.bind(this),
3632
4175
  addEditViewSidePanel: this.addEditViewSidePanel.bind(this),
3633
4176
  getBulkActions: () => this.bulkActions,
3634
- 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
+ },
3635
4185
  getEditViewSidePanels: () => this.editViewSidePanels,
3636
4186
  getHeaderActions: () => this.headerActions
3637
4187
  }
@@ -3641,16 +4191,71 @@ class ContentManagerPlugin {
3641
4191
  const getPrintableType = (value) => {
3642
4192
  const nativeType = typeof value;
3643
4193
  if (nativeType === "object") {
3644
- if (value === null)
3645
- return "null";
3646
- if (Array.isArray(value))
3647
- return "array";
4194
+ if (value === null) return "null";
4195
+ if (Array.isArray(value)) return "array";
3648
4196
  if (value instanceof Object && value.constructor.name !== "Object") {
3649
4197
  return value.constructor.name;
3650
4198
  }
3651
4199
  }
3652
4200
  return nativeType;
3653
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
+ };
3654
4259
  const initialState = {
3655
4260
  collectionTypeLinks: [],
3656
4261
  components: [],
@@ -3687,6 +4292,88 @@ const { setInitialData } = actions;
3687
4292
  const reducer = combineReducers({
3688
4293
  app: reducer$1
3689
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
+ };
3690
4377
  const index = {
3691
4378
  register(app) {
3692
4379
  const cm = new ContentManagerPlugin();
@@ -3706,7 +4393,7 @@ const index = {
3706
4393
  app.router.addRoute({
3707
4394
  path: "content-manager/*",
3708
4395
  lazy: async () => {
3709
- const { Layout } = await import("./layout-Bau7ZfLV.mjs");
4396
+ const { Layout } = await import("./layout-fQk1rMk9.mjs");
3710
4397
  return {
3711
4398
  Component: Layout
3712
4399
  };
@@ -3715,10 +4402,18 @@ const index = {
3715
4402
  });
3716
4403
  app.registerPlugin(cm.config);
3717
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
+ },
3718
4413
  async registerTrads({ locales }) {
3719
4414
  const importedTrads = await Promise.all(
3720
4415
  locales.map((locale) => {
3721
- return __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/ar.json": () => import("./ar-CCEVvqGG.mjs"), "./translations/ca.json": () => import("./ca-5U32ON2v.mjs"), "./translations/cs.json": () => import("./cs-CM2aBUar.mjs"), "./translations/de.json": () => import("./de-C72KDNOl.mjs"), "./translations/en.json": () => import("./en-Ux26r5pl.mjs"), "./translations/es.json": () => import("./es-CeXiYflN.mjs"), "./translations/eu.json": () => import("./eu-CdALomew.mjs"), "./translations/fr.json": () => import("./fr-CD9VFbPM.mjs"), "./translations/gu.json": () => import("./gu-CNpaMDpH.mjs"), "./translations/hi.json": () => import("./hi-Dwvd04m3.mjs"), "./translations/hu.json": () => import("./hu-CeYvaaO0.mjs"), "./translations/id.json": () => import("./id-BtwA9WJT.mjs"), "./translations/it.json": () => import("./it-BrVPqaf1.mjs"), "./translations/ja.json": () => import("./ja-CtsUxOvk.mjs"), "./translations/ko.json": () => import("./ko-HVQRlfUI.mjs"), "./translations/ml.json": () => import("./ml-BihZwQit.mjs"), "./translations/ms.json": () => import("./ms-m_WjyWx7.mjs"), "./translations/nl.json": () => import("./nl-D4R9gHx5.mjs"), "./translations/pl.json": () => import("./pl-sbx9mSt_.mjs"), "./translations/pt-BR.json": () => import("./pt-BR-C71iDxnh.mjs"), "./translations/pt.json": () => import("./pt-BsaFvS8-.mjs"), "./translations/ru.json": () => import("./ru-BE6A4Exp.mjs"), "./translations/sa.json": () => import("./sa-Dag0k-Z8.mjs"), "./translations/sk.json": () => import("./sk-BFg-R8qJ.mjs"), "./translations/sv.json": () => import("./sv-CUnfWGsh.mjs"), "./translations/th.json": () => import("./th-BqbI8lIT.mjs"), "./translations/tr.json": () => import("./tr-CgeK3wJM.mjs"), "./translations/uk.json": () => import("./uk-CR-zDhAY.mjs"), "./translations/vi.json": () => import("./vi-DUXIk_fw.mjs"), "./translations/zh-Hans.json": () => import("./zh-Hans-BPQcRIyH.mjs"), "./translations/zh.json": () => import("./zh-BWZspA60.mjs") }), `./translations/${locale}.json`).then(({ default: data }) => {
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 }) => {
3722
4417
  return {
3723
4418
  data: prefixPluginTranslations(data, PLUGIN_ID),
3724
4419
  locale
@@ -3735,21 +4430,27 @@ const index = {
3735
4430
  }
3736
4431
  };
3737
4432
  export {
3738
- ATTRIBUTE_TYPES_THAT_CANNOT_BE_MAIN_FIELD as A,
4433
+ useUpdateContentTypeConfigurationMutation as A,
3739
4434
  BulkActionsRenderer as B,
3740
4435
  COLLECTION_TYPES as C,
3741
4436
  DocumentStatus as D,
3742
- DEFAULT_SETTINGS as E,
3743
- convertEditLayoutToFieldLayouts as F,
3744
- useDocument as G,
4437
+ ATTRIBUTE_TYPES_THAT_CANNOT_BE_MAIN_FIELD as E,
4438
+ extractContentTypeComponents as F,
4439
+ DEFAULT_SETTINGS as G,
3745
4440
  HOOKS as H,
3746
4441
  InjectionZone as I,
3747
- index as J,
3748
- useDocumentActions as K,
4442
+ convertEditLayoutToFieldLayouts as J,
4443
+ removeFieldsThatDontExistOnSchema as K,
4444
+ prepareTempKeys as L,
4445
+ useDocument as M,
4446
+ useGetPreviewUrlQuery as N,
4447
+ index as O,
3749
4448
  Panels as P,
4449
+ useContentManagerContext as Q,
3750
4450
  RelativeTime as R,
3751
4451
  SINGLE_TYPES as S,
3752
4452
  TableActions as T,
4453
+ useDocumentActions as U,
3753
4454
  useGetInitialDataQuery as a,
3754
4455
  useGetAllContentTypeSettingsQuery as b,
3755
4456
  useDoc as c,
@@ -3762,19 +4463,19 @@ export {
3762
4463
  Header as j,
3763
4464
  PERMISSIONS as k,
3764
4465
  DocumentRBAC as l,
3765
- DOCUMENT_META_FIELDS as m,
3766
- useDocLayout as n,
3767
- useGetContentTypeConfigurationQuery as o,
3768
- CREATOR_FIELDS as p,
3769
- getMainField as q,
3770
- getDisplayName as r,
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,
3771
4472
  setInitialData as s,
3772
- checkIfAttributeIsDisplayable as t,
4473
+ transformDocument as t,
3773
4474
  useContentTypeSchema as u,
3774
- useGetAllDocumentsQuery as v,
3775
- convertListLayoutToFieldLayouts as w,
3776
- capitalise as x,
3777
- useUpdateContentTypeConfigurationMutation as y,
3778
- extractContentTypeComponents as z
4475
+ getDisplayName as v,
4476
+ checkIfAttributeIsDisplayable as w,
4477
+ useGetAllDocumentsQuery as x,
4478
+ convertListLayoutToFieldLayouts as y,
4479
+ capitalise as z
3779
4480
  };
3780
- //# sourceMappingURL=index-DJXJw9V5.mjs.map
4481
+ //# sourceMappingURL=index-ZKrsjv-2.mjs.map