@strapi/content-manager 0.0.0 → 5.0.0-beta.10

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 (510) hide show
  1. package/README.md +9 -1
  2. package/dist/_chunks/CardDragPreview-C0QyJgRA.js +69 -0
  3. package/dist/_chunks/CardDragPreview-C0QyJgRA.js.map +1 -0
  4. package/dist/_chunks/CardDragPreview-DOxamsuj.mjs +70 -0
  5. package/dist/_chunks/CardDragPreview-DOxamsuj.mjs.map +1 -0
  6. package/dist/_chunks/ComponentConfigurationPage-BNrZY1Rt.js +255 -0
  7. package/dist/_chunks/ComponentConfigurationPage-BNrZY1Rt.js.map +1 -0
  8. package/dist/_chunks/ComponentConfigurationPage-DF4KsgJw.mjs +236 -0
  9. package/dist/_chunks/ComponentConfigurationPage-DF4KsgJw.mjs.map +1 -0
  10. package/dist/_chunks/ComponentIcon-BXdiCGQp.js +176 -0
  11. package/dist/_chunks/ComponentIcon-BXdiCGQp.js.map +1 -0
  12. package/dist/_chunks/ComponentIcon-u4bIXTFY.mjs +157 -0
  13. package/dist/_chunks/ComponentIcon-u4bIXTFY.mjs.map +1 -0
  14. package/dist/_chunks/EditConfigurationPage-CzBCnSlY.js +151 -0
  15. package/dist/_chunks/EditConfigurationPage-CzBCnSlY.js.map +1 -0
  16. package/dist/_chunks/EditConfigurationPage-Dn7sFfOu.mjs +132 -0
  17. package/dist/_chunks/EditConfigurationPage-Dn7sFfOu.mjs.map +1 -0
  18. package/dist/_chunks/EditViewPage-CEemNwSu.js +222 -0
  19. package/dist/_chunks/EditViewPage-CEemNwSu.js.map +1 -0
  20. package/dist/_chunks/EditViewPage-D2uq2uZS.mjs +203 -0
  21. package/dist/_chunks/EditViewPage-D2uq2uZS.mjs.map +1 -0
  22. package/dist/_chunks/Field-DvB4ig_f.mjs +5466 -0
  23. package/dist/_chunks/Field-DvB4ig_f.mjs.map +1 -0
  24. package/dist/_chunks/Field-KHBYihjn.js +5498 -0
  25. package/dist/_chunks/Field-KHBYihjn.js.map +1 -0
  26. package/dist/_chunks/FieldTypeIcon-CMlNO8PE.mjs +50 -0
  27. package/dist/_chunks/FieldTypeIcon-CMlNO8PE.mjs.map +1 -0
  28. package/dist/_chunks/FieldTypeIcon-Dnwq_IRF.js +49 -0
  29. package/dist/_chunks/FieldTypeIcon-Dnwq_IRF.js.map +1 -0
  30. package/dist/_chunks/Form-BGmF27Mb.mjs +739 -0
  31. package/dist/_chunks/Form-BGmF27Mb.mjs.map +1 -0
  32. package/dist/_chunks/Form-De_O8dNp.js +760 -0
  33. package/dist/_chunks/Form-De_O8dNp.js.map +1 -0
  34. package/dist/_chunks/History-Cqq6Csvj.mjs +1007 -0
  35. package/dist/_chunks/History-Cqq6Csvj.mjs.map +1 -0
  36. package/dist/_chunks/History-aALwb_34.js +1028 -0
  37. package/dist/_chunks/History-aALwb_34.js.map +1 -0
  38. package/dist/_chunks/ListConfigurationPage-Bke2024Z.mjs +620 -0
  39. package/dist/_chunks/ListConfigurationPage-Bke2024Z.mjs.map +1 -0
  40. package/dist/_chunks/ListConfigurationPage-DimG1pln.js +640 -0
  41. package/dist/_chunks/ListConfigurationPage-DimG1pln.js.map +1 -0
  42. package/dist/_chunks/ListViewPage-BO-JvrUA.js +834 -0
  43. package/dist/_chunks/ListViewPage-BO-JvrUA.js.map +1 -0
  44. package/dist/_chunks/ListViewPage-Cjbh5jyY.mjs +810 -0
  45. package/dist/_chunks/ListViewPage-Cjbh5jyY.mjs.map +1 -0
  46. package/dist/_chunks/NoContentTypePage-S-R1DXX2.js +51 -0
  47. package/dist/_chunks/NoContentTypePage-S-R1DXX2.js.map +1 -0
  48. package/dist/_chunks/NoContentTypePage-m6_m6mFn.mjs +51 -0
  49. package/dist/_chunks/NoContentTypePage-m6_m6mFn.mjs.map +1 -0
  50. package/dist/_chunks/NoPermissionsPage-CCMchuOR.mjs +23 -0
  51. package/dist/_chunks/NoPermissionsPage-CCMchuOR.mjs.map +1 -0
  52. package/dist/_chunks/NoPermissionsPage-wFEMKcdV.js +23 -0
  53. package/dist/_chunks/NoPermissionsPage-wFEMKcdV.js.map +1 -0
  54. package/dist/_chunks/Relations-PjEVbLqZ.js +714 -0
  55. package/dist/_chunks/Relations-PjEVbLqZ.js.map +1 -0
  56. package/dist/_chunks/Relations-i8F_imXr.mjs +694 -0
  57. package/dist/_chunks/Relations-i8F_imXr.mjs.map +1 -0
  58. package/dist/_chunks/ar-BUUWXIYu.js +226 -0
  59. package/dist/_chunks/ar-BUUWXIYu.js.map +1 -0
  60. package/dist/_chunks/ar-CCEVvqGG.mjs +226 -0
  61. package/dist/_chunks/ar-CCEVvqGG.mjs.map +1 -0
  62. package/dist/_chunks/ca-5U32ON2v.mjs +201 -0
  63. package/dist/_chunks/ca-5U32ON2v.mjs.map +1 -0
  64. package/dist/_chunks/ca-Cmk45QO6.js +201 -0
  65. package/dist/_chunks/ca-Cmk45QO6.js.map +1 -0
  66. package/dist/_chunks/cs-CM2aBUar.mjs +125 -0
  67. package/dist/_chunks/cs-CM2aBUar.mjs.map +1 -0
  68. package/dist/_chunks/cs-CkJy6B2v.js +125 -0
  69. package/dist/_chunks/cs-CkJy6B2v.js.map +1 -0
  70. package/dist/_chunks/de-C72KDNOl.mjs +199 -0
  71. package/dist/_chunks/de-C72KDNOl.mjs.map +1 -0
  72. package/dist/_chunks/de-CCEmbAah.js +199 -0
  73. package/dist/_chunks/de-CCEmbAah.js.map +1 -0
  74. package/dist/_chunks/en-Ux26r5pl.mjs +291 -0
  75. package/dist/_chunks/en-Ux26r5pl.mjs.map +1 -0
  76. package/dist/_chunks/en-fbKQxLGn.js +291 -0
  77. package/dist/_chunks/en-fbKQxLGn.js.map +1 -0
  78. package/dist/_chunks/es-CeXiYflN.mjs +196 -0
  79. package/dist/_chunks/es-CeXiYflN.mjs.map +1 -0
  80. package/dist/_chunks/es-EUonQTon.js +196 -0
  81. package/dist/_chunks/es-EUonQTon.js.map +1 -0
  82. package/dist/_chunks/eu-CdALomew.mjs +202 -0
  83. package/dist/_chunks/eu-CdALomew.mjs.map +1 -0
  84. package/dist/_chunks/eu-VDH-3ovk.js +202 -0
  85. package/dist/_chunks/eu-VDH-3ovk.js.map +1 -0
  86. package/dist/_chunks/fr-B7kGGg3E.js +206 -0
  87. package/dist/_chunks/fr-B7kGGg3E.js.map +1 -0
  88. package/dist/_chunks/fr-CD9VFbPM.mjs +206 -0
  89. package/dist/_chunks/fr-CD9VFbPM.mjs.map +1 -0
  90. package/dist/_chunks/gu-BRmF601H.js +200 -0
  91. package/dist/_chunks/gu-BRmF601H.js.map +1 -0
  92. package/dist/_chunks/gu-CNpaMDpH.mjs +200 -0
  93. package/dist/_chunks/gu-CNpaMDpH.mjs.map +1 -0
  94. package/dist/_chunks/hi-CCJBptSq.js +200 -0
  95. package/dist/_chunks/hi-CCJBptSq.js.map +1 -0
  96. package/dist/_chunks/hi-Dwvd04m3.mjs +200 -0
  97. package/dist/_chunks/hi-Dwvd04m3.mjs.map +1 -0
  98. package/dist/_chunks/hooks-BAaaKPS_.js +7 -0
  99. package/dist/_chunks/hooks-BAaaKPS_.js.map +1 -0
  100. package/dist/_chunks/hooks-E5u1mcgM.mjs +8 -0
  101. package/dist/_chunks/hooks-E5u1mcgM.mjs.map +1 -0
  102. package/dist/_chunks/hu-CeYvaaO0.mjs +202 -0
  103. package/dist/_chunks/hu-CeYvaaO0.mjs.map +1 -0
  104. package/dist/_chunks/hu-sNV_yLYy.js +202 -0
  105. package/dist/_chunks/hu-sNV_yLYy.js.map +1 -0
  106. package/dist/_chunks/id-B5Ser98A.js +160 -0
  107. package/dist/_chunks/id-B5Ser98A.js.map +1 -0
  108. package/dist/_chunks/id-BtwA9WJT.mjs +160 -0
  109. package/dist/_chunks/id-BtwA9WJT.mjs.map +1 -0
  110. package/dist/_chunks/index-B4Gj2Oe9.js +3791 -0
  111. package/dist/_chunks/index-B4Gj2Oe9.js.map +1 -0
  112. package/dist/_chunks/index-BAGok3Xa.mjs +3772 -0
  113. package/dist/_chunks/index-BAGok3Xa.mjs.map +1 -0
  114. package/dist/_chunks/it-BrVPqaf1.mjs +162 -0
  115. package/dist/_chunks/it-BrVPqaf1.mjs.map +1 -0
  116. package/dist/_chunks/it-DkBIs7vD.js +162 -0
  117. package/dist/_chunks/it-DkBIs7vD.js.map +1 -0
  118. package/dist/_chunks/ja-CcFe8diO.js +196 -0
  119. package/dist/_chunks/ja-CcFe8diO.js.map +1 -0
  120. package/dist/_chunks/ja-CtsUxOvk.mjs +196 -0
  121. package/dist/_chunks/ja-CtsUxOvk.mjs.map +1 -0
  122. package/dist/_chunks/ko-HVQRlfUI.mjs +195 -0
  123. package/dist/_chunks/ko-HVQRlfUI.mjs.map +1 -0
  124. package/dist/_chunks/ko-woFZPmLk.js +195 -0
  125. package/dist/_chunks/ko-woFZPmLk.js.map +1 -0
  126. package/dist/_chunks/layout-BybbePH7.mjs +458 -0
  127. package/dist/_chunks/layout-BybbePH7.mjs.map +1 -0
  128. package/dist/_chunks/layout-aK6fNSLK.js +476 -0
  129. package/dist/_chunks/layout-aK6fNSLK.js.map +1 -0
  130. package/dist/_chunks/ml-BihZwQit.mjs +200 -0
  131. package/dist/_chunks/ml-BihZwQit.mjs.map +1 -0
  132. package/dist/_chunks/ml-C2W8N8k1.js +200 -0
  133. package/dist/_chunks/ml-C2W8N8k1.js.map +1 -0
  134. package/dist/_chunks/ms-BuFotyP_.js +144 -0
  135. package/dist/_chunks/ms-BuFotyP_.js.map +1 -0
  136. package/dist/_chunks/ms-m_WjyWx7.mjs +144 -0
  137. package/dist/_chunks/ms-m_WjyWx7.mjs.map +1 -0
  138. package/dist/_chunks/nl-D4R9gHx5.mjs +202 -0
  139. package/dist/_chunks/nl-D4R9gHx5.mjs.map +1 -0
  140. package/dist/_chunks/nl-bbEOHChV.js +202 -0
  141. package/dist/_chunks/nl-bbEOHChV.js.map +1 -0
  142. package/dist/_chunks/objects-gigeqt7s.js +49 -0
  143. package/dist/_chunks/objects-gigeqt7s.js.map +1 -0
  144. package/dist/_chunks/objects-mKMAmfec.mjs +47 -0
  145. package/dist/_chunks/objects-mKMAmfec.mjs.map +1 -0
  146. package/dist/_chunks/pl-sbx9mSt_.mjs +199 -0
  147. package/dist/_chunks/pl-sbx9mSt_.mjs.map +1 -0
  148. package/dist/_chunks/pl-uzwG-hk7.js +199 -0
  149. package/dist/_chunks/pl-uzwG-hk7.js.map +1 -0
  150. package/dist/_chunks/pt-BR-BiOz37D9.js +201 -0
  151. package/dist/_chunks/pt-BR-BiOz37D9.js.map +1 -0
  152. package/dist/_chunks/pt-BR-C71iDxnh.mjs +201 -0
  153. package/dist/_chunks/pt-BR-C71iDxnh.mjs.map +1 -0
  154. package/dist/_chunks/pt-BsaFvS8-.mjs +95 -0
  155. package/dist/_chunks/pt-BsaFvS8-.mjs.map +1 -0
  156. package/dist/_chunks/pt-CeXQuq50.js +95 -0
  157. package/dist/_chunks/pt-CeXQuq50.js.map +1 -0
  158. package/dist/_chunks/relations-BZicUuRc.mjs +135 -0
  159. package/dist/_chunks/relations-BZicUuRc.mjs.map +1 -0
  160. package/dist/_chunks/relations-yBDEAWeN.js +134 -0
  161. package/dist/_chunks/relations-yBDEAWeN.js.map +1 -0
  162. package/dist/_chunks/ru-BE6A4Exp.mjs +231 -0
  163. package/dist/_chunks/ru-BE6A4Exp.mjs.map +1 -0
  164. package/dist/_chunks/ru-BT3ybNny.js +231 -0
  165. package/dist/_chunks/ru-BT3ybNny.js.map +1 -0
  166. package/dist/_chunks/sa-CcvkYInH.js +200 -0
  167. package/dist/_chunks/sa-CcvkYInH.js.map +1 -0
  168. package/dist/_chunks/sa-Dag0k-Z8.mjs +200 -0
  169. package/dist/_chunks/sa-Dag0k-Z8.mjs.map +1 -0
  170. package/dist/_chunks/sk-BFg-R8qJ.mjs +202 -0
  171. package/dist/_chunks/sk-BFg-R8qJ.mjs.map +1 -0
  172. package/dist/_chunks/sk-CvY09Xjv.js +202 -0
  173. package/dist/_chunks/sk-CvY09Xjv.js.map +1 -0
  174. package/dist/_chunks/sv-CUnfWGsh.mjs +202 -0
  175. package/dist/_chunks/sv-CUnfWGsh.mjs.map +1 -0
  176. package/dist/_chunks/sv-MYDuzgvT.js +202 -0
  177. package/dist/_chunks/sv-MYDuzgvT.js.map +1 -0
  178. package/dist/_chunks/th-BqbI8lIT.mjs +148 -0
  179. package/dist/_chunks/th-BqbI8lIT.mjs.map +1 -0
  180. package/dist/_chunks/th-D9_GfAjc.js +148 -0
  181. package/dist/_chunks/th-D9_GfAjc.js.map +1 -0
  182. package/dist/_chunks/tr-CgeK3wJM.mjs +199 -0
  183. package/dist/_chunks/tr-CgeK3wJM.mjs.map +1 -0
  184. package/dist/_chunks/tr-D9UH-O_R.js +199 -0
  185. package/dist/_chunks/tr-D9UH-O_R.js.map +1 -0
  186. package/dist/_chunks/uk-C8EiqJY7.js +144 -0
  187. package/dist/_chunks/uk-C8EiqJY7.js.map +1 -0
  188. package/dist/_chunks/uk-CR-zDhAY.mjs +144 -0
  189. package/dist/_chunks/uk-CR-zDhAY.mjs.map +1 -0
  190. package/dist/_chunks/useDragAndDrop-DdHgKsqq.mjs +231 -0
  191. package/dist/_chunks/useDragAndDrop-DdHgKsqq.mjs.map +1 -0
  192. package/dist/_chunks/useDragAndDrop-J0TUUbR6.js +249 -0
  193. package/dist/_chunks/useDragAndDrop-J0TUUbR6.js.map +1 -0
  194. package/dist/_chunks/usePrev-B9w_-eYc.js +15 -0
  195. package/dist/_chunks/usePrev-B9w_-eYc.js.map +1 -0
  196. package/dist/_chunks/usePrev-DH6iah0A.mjs +16 -0
  197. package/dist/_chunks/usePrev-DH6iah0A.mjs.map +1 -0
  198. package/dist/_chunks/vi-CJlYDheJ.js +111 -0
  199. package/dist/_chunks/vi-CJlYDheJ.js.map +1 -0
  200. package/dist/_chunks/vi-DUXIk_fw.mjs +111 -0
  201. package/dist/_chunks/vi-DUXIk_fw.mjs.map +1 -0
  202. package/dist/_chunks/zh-BWZspA60.mjs +209 -0
  203. package/dist/_chunks/zh-BWZspA60.mjs.map +1 -0
  204. package/dist/_chunks/zh-CQQfszqR.js +209 -0
  205. package/dist/_chunks/zh-CQQfszqR.js.map +1 -0
  206. package/dist/_chunks/zh-Hans-9kOncHGw.js +952 -0
  207. package/dist/_chunks/zh-Hans-9kOncHGw.js.map +1 -0
  208. package/dist/_chunks/zh-Hans-BPQcRIyH.mjs +952 -0
  209. package/dist/_chunks/zh-Hans-BPQcRIyH.mjs.map +1 -0
  210. package/dist/admin/index.js +12 -0
  211. package/dist/admin/index.js.map +1 -0
  212. package/dist/admin/index.mjs +12 -0
  213. package/dist/admin/index.mjs.map +1 -0
  214. package/dist/admin/src/components/ComponentIcon.d.ts +11 -0
  215. package/dist/admin/src/components/ConfigurationForm/EditFieldForm.d.ts +9 -0
  216. package/dist/admin/src/components/ConfigurationForm/Fields.d.ts +21 -0
  217. package/dist/admin/src/components/ConfigurationForm/Form.d.ts +32 -0
  218. package/dist/admin/src/components/DragLayer.d.ts +13 -0
  219. package/dist/admin/src/components/DragPreviews/CardDragPreview.d.ts +7 -0
  220. package/dist/admin/src/components/DragPreviews/ComponentDragPreview.d.ts +6 -0
  221. package/dist/admin/src/components/DragPreviews/RelationDragPreview.d.ts +11 -0
  222. package/dist/admin/src/components/FieldTypeIcon.d.ts +9 -0
  223. package/dist/admin/src/components/InjectionZone.d.ts +45 -0
  224. package/dist/admin/src/components/LeftMenu.d.ts +2 -0
  225. package/dist/admin/src/components/RelativeTime.d.ts +28 -0
  226. package/dist/admin/src/constants/attributes.d.ts +14 -0
  227. package/dist/admin/src/constants/collections.d.ts +3 -0
  228. package/dist/admin/src/constants/dragAndDrop.d.ts +8 -0
  229. package/dist/admin/src/constants/hooks.d.ts +26 -0
  230. package/dist/admin/src/constants/plugin.d.ts +3 -0
  231. package/dist/admin/src/content-manager.d.ts +133 -0
  232. package/dist/admin/src/exports.d.ts +12 -0
  233. package/dist/admin/src/features/DocumentRBAC.d.ts +36 -0
  234. package/dist/admin/src/history/components/HistoryAction.d.ts +3 -0
  235. package/dist/admin/src/history/components/VersionContent.d.ts +17 -0
  236. package/dist/admin/src/history/components/VersionHeader.d.ts +5 -0
  237. package/dist/admin/src/history/components/VersionInputRenderer.d.ts +19 -0
  238. package/dist/admin/src/history/components/VersionsList.d.ts +2 -0
  239. package/dist/admin/src/history/pages/History.d.ts +27 -0
  240. package/dist/admin/src/history/routes.d.ts +6 -0
  241. package/dist/admin/src/history/services/historyVersion.d.ts +12 -0
  242. package/dist/admin/src/hooks/useContentManagerInitData.d.ts +15 -0
  243. package/dist/admin/src/hooks/useContentTypeSchema.d.ts +25 -0
  244. package/dist/admin/src/hooks/useDebounce.d.ts +1 -0
  245. package/dist/admin/src/hooks/useDocument.d.ts +87 -0
  246. package/dist/admin/src/hooks/useDocumentActions.d.ts +123 -0
  247. package/dist/admin/src/hooks/useDocumentLayout.d.ts +137 -0
  248. package/dist/admin/src/hooks/useDragAndDrop.d.ts +51 -0
  249. package/dist/admin/src/hooks/useKeyboardDragAndDrop.d.ts +14 -0
  250. package/dist/admin/src/hooks/useLazyComponents.d.ts +13 -0
  251. package/dist/admin/src/hooks/useOnce.d.ts +2 -0
  252. package/dist/admin/src/hooks/usePrev.d.ts +1 -0
  253. package/dist/admin/src/index.d.ts +16 -0
  254. package/dist/admin/src/layout.d.ts +2 -0
  255. package/dist/admin/src/modules/app.d.ts +20 -0
  256. package/dist/admin/src/modules/hooks.d.ts +10 -0
  257. package/dist/admin/src/modules/reducers.d.ts +6 -0
  258. package/dist/admin/src/pages/ComponentConfigurationPage.d.ts +3 -0
  259. package/dist/admin/src/pages/EditConfigurationPage.d.ts +3 -0
  260. package/dist/admin/src/pages/EditView/EditViewPage.d.ts +3 -0
  261. package/dist/admin/src/pages/EditView/components/DocumentActions.d.ts +75 -0
  262. package/dist/admin/src/pages/EditView/components/DocumentStatus.d.ts +16 -0
  263. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/Code.d.ts +3 -0
  264. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/Heading.d.ts +3 -0
  265. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/Image.d.ts +3 -0
  266. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/Link.d.ts +3 -0
  267. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/List.d.ts +3 -0
  268. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/Paragraph.d.ts +3 -0
  269. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/Quote.d.ts +3 -0
  270. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/BlocksContent.d.ts +6 -0
  271. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/BlocksEditor.d.ts +61 -0
  272. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/BlocksInput.d.ts +11 -0
  273. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/BlocksToolbar.d.ts +10 -0
  274. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/EditorLayout.d.ts +10 -0
  275. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Modifiers.d.ts +16 -0
  276. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/plugins/withImages.d.ts +11 -0
  277. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/plugins/withLinks.d.ts +9 -0
  278. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/plugins/withStrapiSchema.d.ts +8 -0
  279. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/utils/constants.d.ts +4 -0
  280. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/utils/conversions.d.ts +13 -0
  281. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/utils/enterKey.d.ts +6 -0
  282. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/utils/links.d.ts +10 -0
  283. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/utils/types.d.ts +10 -0
  284. package/dist/admin/src/pages/EditView/components/FormInputs/Component/Initializer.d.ts +9 -0
  285. package/dist/admin/src/pages/EditView/components/FormInputs/Component/Input.d.ts +18 -0
  286. package/dist/admin/src/pages/EditView/components/FormInputs/Component/NonRepeatable.d.ts +5 -0
  287. package/dist/admin/src/pages/EditView/components/FormInputs/Component/Repeatable.d.ts +5 -0
  288. package/dist/admin/src/pages/EditView/components/FormInputs/ComponentContext.d.ts +42 -0
  289. package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/AddComponentButton.d.ts +11 -0
  290. package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/ComponentCard.d.ts +9 -0
  291. package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/ComponentCategory.d.ts +15 -0
  292. package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/ComponentPicker.d.ts +9 -0
  293. package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.d.ts +14 -0
  294. package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/DynamicZoneLabel.d.ts +12 -0
  295. package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/Field.d.ts +14 -0
  296. package/dist/admin/src/pages/EditView/components/FormInputs/NotAllowed.d.ts +7 -0
  297. package/dist/admin/src/pages/EditView/components/FormInputs/Relations.d.ts +18 -0
  298. package/dist/admin/src/pages/EditView/components/FormInputs/UID.d.ts +9 -0
  299. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/Editor.d.ts +17 -0
  300. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/EditorLayout.d.ts +14 -0
  301. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/Field.d.ts +11 -0
  302. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/PreviewWysiwyg.d.ts +5 -0
  303. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygFooter.d.ts +7 -0
  304. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygNav.d.ts +17 -0
  305. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygStyles.d.ts +62 -0
  306. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/utils/continueList.d.ts +5 -0
  307. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/utils/mdRenderer.d.ts +4 -0
  308. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/utils/utils.d.ts +16 -0
  309. package/dist/admin/src/pages/EditView/components/FormLayout.d.ts +5 -0
  310. package/dist/admin/src/pages/EditView/components/Header.d.ts +35 -0
  311. package/dist/admin/src/pages/EditView/components/InputRenderer.d.ts +9 -0
  312. package/dist/admin/src/pages/EditView/components/Panels.d.ts +10 -0
  313. package/dist/admin/src/pages/EditView/utils/data.d.ts +33 -0
  314. package/dist/admin/src/pages/EditView/utils/forms.d.ts +9 -0
  315. package/dist/admin/src/pages/ListConfiguration/ListConfigurationPage.d.ts +10 -0
  316. package/dist/admin/src/pages/ListConfiguration/components/DraggableCard.d.ts +12 -0
  317. package/dist/admin/src/pages/ListConfiguration/components/EditFieldForm.d.ts +8 -0
  318. package/dist/admin/src/pages/ListConfiguration/components/Header.d.ts +8 -0
  319. package/dist/admin/src/pages/ListConfiguration/components/Settings.d.ts +19 -0
  320. package/dist/admin/src/pages/ListConfiguration/components/SortDisplayedFields.d.ts +6 -0
  321. package/dist/admin/src/pages/ListView/ListViewPage.d.ts +3 -0
  322. package/dist/admin/src/pages/ListView/components/AutoCloneFailureModal.d.ts +7 -0
  323. package/dist/admin/src/pages/ListView/components/BulkActions/Actions.d.ts +24 -0
  324. package/dist/admin/src/pages/ListView/components/BulkActions/ConfirmBulkActionDialog.d.ts +15 -0
  325. package/dist/admin/src/pages/ListView/components/BulkActions/PublishAction.d.ts +14 -0
  326. package/dist/admin/src/pages/ListView/components/Filters.d.ts +8 -0
  327. package/dist/admin/src/pages/ListView/components/TableActions.d.ts +8 -0
  328. package/dist/admin/src/pages/ListView/components/TableCells/CellContent.d.ts +9 -0
  329. package/dist/admin/src/pages/ListView/components/TableCells/CellValue.d.ts +8 -0
  330. package/dist/admin/src/pages/ListView/components/TableCells/Components.d.ts +12 -0
  331. package/dist/admin/src/pages/ListView/components/TableCells/Media.d.ts +23 -0
  332. package/dist/admin/src/pages/ListView/components/TableCells/Relations.d.ts +12 -0
  333. package/dist/admin/src/pages/ListView/components/ViewSettingsMenu.d.ts +10 -0
  334. package/dist/admin/src/pages/NoContentTypePage.d.ts +2 -0
  335. package/dist/admin/src/pages/NoPermissionsPage.d.ts +2 -0
  336. package/dist/admin/src/router.d.ts +5 -0
  337. package/dist/admin/src/services/api.d.ts +2 -0
  338. package/dist/admin/src/services/components.d.ts +5 -0
  339. package/dist/admin/src/services/contentTypes.d.ts +17 -0
  340. package/dist/admin/src/services/documents.d.ts +101 -0
  341. package/dist/admin/src/services/init.d.ts +9 -0
  342. package/dist/admin/src/services/relations.d.ts +49 -0
  343. package/dist/admin/src/services/uid.d.ts +32 -0
  344. package/dist/admin/src/utils/api.d.ts +24 -0
  345. package/dist/admin/src/utils/attributes.d.ts +19 -0
  346. package/dist/admin/src/utils/objects.d.ts +33 -0
  347. package/dist/admin/src/utils/relations.d.ts +12 -0
  348. package/dist/admin/src/utils/strings.d.ts +2 -0
  349. package/dist/admin/src/utils/translations.d.ts +4 -0
  350. package/dist/admin/src/utils/urls.d.ts +2 -0
  351. package/dist/admin/src/utils/users.d.ts +6 -0
  352. package/dist/admin/src/utils/validation.d.ts +7 -0
  353. package/dist/server/index.js +4365 -0
  354. package/dist/server/index.js.map +1 -0
  355. package/dist/server/index.mjs +4341 -0
  356. package/dist/server/index.mjs.map +1 -0
  357. package/dist/server/src/bootstrap.d.ts +3 -0
  358. package/dist/server/src/bootstrap.d.ts.map +1 -0
  359. package/dist/server/src/config.d.ts +6 -0
  360. package/dist/server/src/config.d.ts.map +1 -0
  361. package/dist/server/src/constants/index.d.ts +6 -0
  362. package/dist/server/src/constants/index.d.ts.map +1 -0
  363. package/dist/server/src/controllers/collection-types.d.ts +23 -0
  364. package/dist/server/src/controllers/collection-types.d.ts.map +1 -0
  365. package/dist/server/src/controllers/components.d.ts +7 -0
  366. package/dist/server/src/controllers/components.d.ts.map +1 -0
  367. package/dist/server/src/controllers/content-types.d.ts +8 -0
  368. package/dist/server/src/controllers/content-types.d.ts.map +1 -0
  369. package/dist/server/src/controllers/index.d.ts +53 -0
  370. package/dist/server/src/controllers/index.d.ts.map +1 -0
  371. package/dist/server/src/controllers/init.d.ts +5 -0
  372. package/dist/server/src/controllers/init.d.ts.map +1 -0
  373. package/dist/server/src/controllers/relations.d.ts +13 -0
  374. package/dist/server/src/controllers/relations.d.ts.map +1 -0
  375. package/dist/server/src/controllers/single-types.d.ts +11 -0
  376. package/dist/server/src/controllers/single-types.d.ts.map +1 -0
  377. package/dist/server/src/controllers/uid.d.ts +6 -0
  378. package/dist/server/src/controllers/uid.d.ts.map +1 -0
  379. package/dist/server/src/controllers/utils/clone.d.ts +12 -0
  380. package/dist/server/src/controllers/utils/clone.d.ts.map +1 -0
  381. package/dist/server/src/controllers/utils/metadata.d.ts +8 -0
  382. package/dist/server/src/controllers/utils/metadata.d.ts.map +1 -0
  383. package/dist/server/src/controllers/validation/dimensions.d.ts +9 -0
  384. package/dist/server/src/controllers/validation/dimensions.d.ts.map +1 -0
  385. package/dist/server/src/controllers/validation/index.d.ts +20 -0
  386. package/dist/server/src/controllers/validation/index.d.ts.map +1 -0
  387. package/dist/server/src/controllers/validation/model-configuration.d.ts +22 -0
  388. package/dist/server/src/controllers/validation/model-configuration.d.ts.map +1 -0
  389. package/dist/server/src/controllers/validation/relations.d.ts +4 -0
  390. package/dist/server/src/controllers/validation/relations.d.ts.map +1 -0
  391. package/dist/server/src/destroy.d.ts +4 -0
  392. package/dist/server/src/destroy.d.ts.map +1 -0
  393. package/dist/server/src/history/constants.d.ts +3 -0
  394. package/dist/server/src/history/constants.d.ts.map +1 -0
  395. package/dist/server/src/history/controllers/history-version.d.ts +19 -0
  396. package/dist/server/src/history/controllers/history-version.d.ts.map +1 -0
  397. package/dist/server/src/history/controllers/index.d.ts +2 -0
  398. package/dist/server/src/history/controllers/index.d.ts.map +1 -0
  399. package/dist/server/src/history/controllers/validation/history-version.d.ts +2 -0
  400. package/dist/server/src/history/controllers/validation/history-version.d.ts.map +1 -0
  401. package/dist/server/src/history/index.d.ts +4 -0
  402. package/dist/server/src/history/index.d.ts.map +1 -0
  403. package/dist/server/src/history/models/history-version.d.ts +4 -0
  404. package/dist/server/src/history/models/history-version.d.ts.map +1 -0
  405. package/dist/server/src/history/routes/history-version.d.ts +4 -0
  406. package/dist/server/src/history/routes/history-version.d.ts.map +1 -0
  407. package/dist/server/src/history/routes/index.d.ts +8 -0
  408. package/dist/server/src/history/routes/index.d.ts.map +1 -0
  409. package/dist/server/src/history/services/history.d.ts +16 -0
  410. package/dist/server/src/history/services/history.d.ts.map +1 -0
  411. package/dist/server/src/history/services/index.d.ts +19 -0
  412. package/dist/server/src/history/services/index.d.ts.map +1 -0
  413. package/dist/server/src/history/services/lifecycles.d.ts +9 -0
  414. package/dist/server/src/history/services/lifecycles.d.ts.map +1 -0
  415. package/dist/server/src/history/services/utils.d.ts +44 -0
  416. package/dist/server/src/history/services/utils.d.ts.map +1 -0
  417. package/dist/server/src/history/utils.d.ts +22 -0
  418. package/dist/server/src/history/utils.d.ts.map +1 -0
  419. package/dist/server/src/index.d.ts +353 -0
  420. package/dist/server/src/index.d.ts.map +1 -0
  421. package/dist/server/src/middlewares/index.d.ts +3 -0
  422. package/dist/server/src/middlewares/index.d.ts.map +1 -0
  423. package/dist/server/src/middlewares/routing.d.ts +4 -0
  424. package/dist/server/src/middlewares/routing.d.ts.map +1 -0
  425. package/dist/server/src/policies/hasPermissions.d.ts +7 -0
  426. package/dist/server/src/policies/hasPermissions.d.ts.map +1 -0
  427. package/dist/server/src/policies/index.d.ts +9 -0
  428. package/dist/server/src/policies/index.d.ts.map +1 -0
  429. package/dist/server/src/register.d.ts +4 -0
  430. package/dist/server/src/register.d.ts.map +1 -0
  431. package/dist/server/src/routes/admin.d.ts +41 -0
  432. package/dist/server/src/routes/admin.d.ts.map +1 -0
  433. package/dist/server/src/routes/index.d.ts +43 -0
  434. package/dist/server/src/routes/index.d.ts.map +1 -0
  435. package/dist/server/src/services/components.d.ts +32 -0
  436. package/dist/server/src/services/components.d.ts.map +1 -0
  437. package/dist/server/src/services/configuration.d.ts +20 -0
  438. package/dist/server/src/services/configuration.d.ts.map +1 -0
  439. package/dist/server/src/services/content-types.d.ts +18 -0
  440. package/dist/server/src/services/content-types.d.ts.map +1 -0
  441. package/dist/server/src/services/data-mapper.d.ts +20 -0
  442. package/dist/server/src/services/data-mapper.d.ts.map +1 -0
  443. package/dist/server/src/services/document-manager.d.ts +48 -0
  444. package/dist/server/src/services/document-manager.d.ts.map +1 -0
  445. package/dist/server/src/services/document-metadata.d.ts +67 -0
  446. package/dist/server/src/services/document-metadata.d.ts.map +1 -0
  447. package/dist/server/src/services/field-sizes.d.ts +19 -0
  448. package/dist/server/src/services/field-sizes.d.ts.map +1 -0
  449. package/dist/server/src/services/index.d.ts +245 -0
  450. package/dist/server/src/services/index.d.ts.map +1 -0
  451. package/dist/server/src/services/metrics.d.ts +9 -0
  452. package/dist/server/src/services/metrics.d.ts.map +1 -0
  453. package/dist/server/src/services/permission-checker.d.ts +54 -0
  454. package/dist/server/src/services/permission-checker.d.ts.map +1 -0
  455. package/dist/server/src/services/permission.d.ts +12 -0
  456. package/dist/server/src/services/permission.d.ts.map +1 -0
  457. package/dist/server/src/services/populate-builder.d.ts +30 -0
  458. package/dist/server/src/services/populate-builder.d.ts.map +1 -0
  459. package/dist/server/src/services/uid.d.ts +25 -0
  460. package/dist/server/src/services/uid.d.ts.map +1 -0
  461. package/dist/server/src/services/utils/configuration/attributes.d.ts +17 -0
  462. package/dist/server/src/services/utils/configuration/attributes.d.ts.map +1 -0
  463. package/dist/server/src/services/utils/configuration/index.d.ts +21 -0
  464. package/dist/server/src/services/utils/configuration/index.d.ts.map +1 -0
  465. package/dist/server/src/services/utils/configuration/layouts.d.ts +14 -0
  466. package/dist/server/src/services/utils/configuration/layouts.d.ts.map +1 -0
  467. package/dist/server/src/services/utils/configuration/metadatas.d.ts +5 -0
  468. package/dist/server/src/services/utils/configuration/metadatas.d.ts.map +1 -0
  469. package/dist/server/src/services/utils/configuration/settings.d.ts +5 -0
  470. package/dist/server/src/services/utils/configuration/settings.d.ts.map +1 -0
  471. package/dist/server/src/services/utils/count.d.ts +5 -0
  472. package/dist/server/src/services/utils/count.d.ts.map +1 -0
  473. package/dist/server/src/services/utils/draft.d.ts +11 -0
  474. package/dist/server/src/services/utils/draft.d.ts.map +1 -0
  475. package/dist/server/src/services/utils/populate.d.ts +42 -0
  476. package/dist/server/src/services/utils/populate.d.ts.map +1 -0
  477. package/dist/server/src/services/utils/store.d.ts +16 -0
  478. package/dist/server/src/services/utils/store.d.ts.map +1 -0
  479. package/dist/server/src/utils/index.d.ts +9 -0
  480. package/dist/server/src/utils/index.d.ts.map +1 -0
  481. package/dist/server/src/validation/policies/hasPermissions.d.ts +2 -0
  482. package/dist/server/src/validation/policies/hasPermissions.d.ts.map +1 -0
  483. package/dist/shared/contracts/collection-types.d.ts +336 -0
  484. package/dist/shared/contracts/collection-types.d.ts.map +1 -0
  485. package/dist/shared/contracts/components.d.ts +65 -0
  486. package/dist/shared/contracts/components.d.ts.map +1 -0
  487. package/dist/shared/contracts/content-types.d.ts +113 -0
  488. package/dist/shared/contracts/content-types.d.ts.map +1 -0
  489. package/dist/shared/contracts/history-versions.d.ts +92 -0
  490. package/dist/shared/contracts/history-versions.d.ts.map +1 -0
  491. package/dist/shared/contracts/index.d.ts +10 -0
  492. package/dist/shared/contracts/index.d.ts.map +1 -0
  493. package/dist/shared/contracts/init.d.ts +24 -0
  494. package/dist/shared/contracts/init.d.ts.map +1 -0
  495. package/dist/shared/contracts/relations.d.ts +70 -0
  496. package/dist/shared/contracts/relations.d.ts.map +1 -0
  497. package/dist/shared/contracts/review-workflows.d.ts +78 -0
  498. package/dist/shared/contracts/review-workflows.d.ts.map +1 -0
  499. package/dist/shared/contracts/single-types.d.ts +113 -0
  500. package/dist/shared/contracts/single-types.d.ts.map +1 -0
  501. package/dist/shared/contracts/uid.d.ts +48 -0
  502. package/dist/shared/contracts/uid.d.ts.map +1 -0
  503. package/dist/shared/index.d.ts +2 -0
  504. package/dist/shared/index.d.ts.map +1 -0
  505. package/dist/shared/index.js +43 -0
  506. package/dist/shared/index.js.map +1 -0
  507. package/dist/shared/index.mjs +43 -0
  508. package/dist/shared/index.mjs.map +1 -0
  509. package/package.json +113 -2
  510. package/strapi-server.js +3 -0
@@ -0,0 +1,3772 @@
1
+ import { ClockCounterClockwise, CrossCircle, More, WarningCircle, ListPlus, Pencil, Trash, Check, CheckCircle, ArrowsCounterClockwise, ChevronRight, Duplicate, Feather } from "@strapi/icons";
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";
7
+ import * as React from "react";
8
+ import { lazy } from "react";
9
+ import { Button, Menu, VisuallyHidden, Flex, Box, Typography, Dialog, Modal, Radio, Status, SingleSelect, SingleSelectOption, Loader, IconButton, Tooltip, LinkButton } from "@strapi/design-system";
10
+ import { styled } from "styled-components";
11
+ import * as yup from "yup";
12
+ import { ValidationError } from "yup";
13
+ import pipe from "lodash/fp/pipe";
14
+ import { intervalToDuration, isPast } from "date-fns";
15
+ import { createSlice, combineReducers } from "@reduxjs/toolkit";
16
+ const __variableDynamicImportRuntimeHelper = (glob, path) => {
17
+ const v = glob[path];
18
+ if (v) {
19
+ return typeof v === "function" ? v() : Promise.resolve(v);
20
+ }
21
+ return new Promise((_, reject) => {
22
+ (typeof queueMicrotask === "function" ? queueMicrotask : setTimeout)(reject.bind(null, new Error("Unknown variable dynamic import: " + path)));
23
+ });
24
+ };
25
+ const PLUGIN_ID = "content-manager";
26
+ const PERMISSIONS = [
27
+ "plugin::content-manager.explorer.create",
28
+ "plugin::content-manager.explorer.read",
29
+ "plugin::content-manager.explorer.update",
30
+ "plugin::content-manager.explorer.delete",
31
+ "plugin::content-manager.explorer.publish"
32
+ ];
33
+ const INJECTION_ZONES = {
34
+ editView: { informations: [], "right-links": [] },
35
+ listView: {
36
+ actions: [],
37
+ deleteModalAdditionalInfos: [],
38
+ publishModalAdditionalInfos: [],
39
+ unpublishModalAdditionalInfos: []
40
+ }
41
+ };
42
+ const InjectionZone = ({ area, ...props }) => {
43
+ const components = useInjectionZone(area);
44
+ return /* @__PURE__ */ jsx(Fragment, { children: components.map((component) => /* @__PURE__ */ jsx(component.Component, { ...props }, component.name)) });
45
+ };
46
+ const useInjectionZone = (area) => {
47
+ const getPlugin = useStrapiApp("useInjectionZone", (state) => state.getPlugin);
48
+ const contentManagerPlugin = getPlugin(PLUGIN_ID);
49
+ const [page, position] = area.split(".");
50
+ return contentManagerPlugin.getInjectedComponents(page, position);
51
+ };
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
+ const ID = "id";
89
+ const CREATED_BY_ATTRIBUTE_NAME = "createdBy";
90
+ const UPDATED_BY_ATTRIBUTE_NAME = "updatedBy";
91
+ const CREATOR_FIELDS = [CREATED_BY_ATTRIBUTE_NAME, UPDATED_BY_ATTRIBUTE_NAME];
92
+ const PUBLISHED_BY_ATTRIBUTE_NAME = "publishedBy";
93
+ const CREATED_AT_ATTRIBUTE_NAME = "createdAt";
94
+ const UPDATED_AT_ATTRIBUTE_NAME = "updatedAt";
95
+ const PUBLISHED_AT_ATTRIBUTE_NAME = "publishedAt";
96
+ const DOCUMENT_META_FIELDS = [
97
+ ID,
98
+ ...CREATOR_FIELDS,
99
+ PUBLISHED_BY_ATTRIBUTE_NAME,
100
+ CREATED_AT_ATTRIBUTE_NAME,
101
+ UPDATED_AT_ATTRIBUTE_NAME,
102
+ PUBLISHED_AT_ATTRIBUTE_NAME
103
+ ];
104
+ const ATTRIBUTE_TYPES_THAT_CANNOT_BE_MAIN_FIELD = [
105
+ "dynamiczone",
106
+ "json",
107
+ "text",
108
+ "relation",
109
+ "component",
110
+ "boolean",
111
+ "media",
112
+ "password",
113
+ "richtext",
114
+ "timestamp",
115
+ "blocks"
116
+ ];
117
+ const SINGLE_TYPES = "single-types";
118
+ const COLLECTION_TYPES = "collection-types";
119
+ const [DocumentRBACProvider, useDocumentRBAC] = createContext(
120
+ "DocumentRBAC",
121
+ {
122
+ canCreate: false,
123
+ canCreateFields: [],
124
+ canDelete: false,
125
+ canPublish: false,
126
+ canRead: false,
127
+ canReadFields: [],
128
+ canUpdate: false,
129
+ canUpdateFields: [],
130
+ canUserAction: () => false,
131
+ isLoading: false
132
+ }
133
+ );
134
+ const DocumentRBAC = ({ children, permissions }) => {
135
+ const { slug } = useParams();
136
+ if (!slug) {
137
+ throw new Error("Cannot find the slug param in the URL");
138
+ }
139
+ const userPermissions = useAuth("DocumentRBAC", (state) => state.permissions);
140
+ const contentTypePermissions = React.useMemo(() => {
141
+ const contentTypePermissions2 = userPermissions.filter(
142
+ (permission) => permission.subject === slug
143
+ );
144
+ return contentTypePermissions2.reduce((acc, permission) => {
145
+ const [action] = permission.action.split(".").slice(-1);
146
+ return { ...acc, [action]: [permission] };
147
+ }, {});
148
+ }, [slug, userPermissions]);
149
+ const { isLoading, allowedActions } = useRBAC(contentTypePermissions, permissions ?? void 0);
150
+ const canCreateFields = !isLoading && allowedActions.canCreate ? extractAndDedupeFields(contentTypePermissions.create) : [];
151
+ const canReadFields = !isLoading && allowedActions.canRead ? extractAndDedupeFields(contentTypePermissions.read) : [];
152
+ const canUpdateFields = !isLoading && allowedActions.canUpdate ? extractAndDedupeFields(contentTypePermissions.update) : [];
153
+ const canUserAction = React.useCallback(
154
+ (fieldName, fieldsUserCanAction, fieldType) => {
155
+ const name = removeNumericalStrings(fieldName.split("."));
156
+ const componentFieldNames = fieldsUserCanAction.filter((field) => field.split(".").length > 1);
157
+ if (fieldType === "component") {
158
+ return componentFieldNames.some((field) => {
159
+ return field.includes(name.join("."));
160
+ });
161
+ }
162
+ if (name.length > 1) {
163
+ return componentFieldNames.includes(name.join("."));
164
+ }
165
+ return fieldsUserCanAction.includes(fieldName);
166
+ },
167
+ []
168
+ );
169
+ if (isLoading) {
170
+ return /* @__PURE__ */ jsx(Page.Loading, {});
171
+ }
172
+ return /* @__PURE__ */ jsx(
173
+ DocumentRBACProvider,
174
+ {
175
+ isLoading,
176
+ canCreateFields,
177
+ canReadFields,
178
+ canUpdateFields,
179
+ canUserAction,
180
+ ...allowedActions,
181
+ children
182
+ }
183
+ );
184
+ };
185
+ const extractAndDedupeFields = (permissions = []) => permissions.flatMap((permission) => permission.properties?.fields).filter(
186
+ (field, index2, arr) => arr.indexOf(field) === index2 && typeof field === "string"
187
+ );
188
+ const removeNumericalStrings = (arr) => arr.filter((item) => isNaN(Number(item)));
189
+ const contentManagerApi = adminApi.enhanceEndpoints({
190
+ addTagTypes: [
191
+ "ComponentConfiguration",
192
+ "ContentTypesConfiguration",
193
+ "ContentTypeSettings",
194
+ "Document",
195
+ "InitialData",
196
+ "HistoryVersion",
197
+ "Relations"
198
+ ]
199
+ });
200
+ const documentApi = contentManagerApi.injectEndpoints({
201
+ overrideExisting: true,
202
+ endpoints: (builder) => ({
203
+ autoCloneDocument: builder.mutation({
204
+ query: ({ model, sourceId, query }) => ({
205
+ url: `/content-manager/collection-types/${model}/auto-clone/${sourceId}`,
206
+ method: "POST",
207
+ config: {
208
+ params: query
209
+ }
210
+ }),
211
+ invalidatesTags: (_result, _error, { model }) => [{ type: "Document", id: `${model}_LIST` }]
212
+ }),
213
+ cloneDocument: builder.mutation({
214
+ query: ({ model, sourceId, data, params }) => ({
215
+ url: `/content-manager/collection-types/${model}/clone/${sourceId}`,
216
+ method: "POST",
217
+ data,
218
+ config: {
219
+ params
220
+ }
221
+ }),
222
+ invalidatesTags: (_result, _error, { model }) => [{ type: "Document", id: `${model}_LIST` }]
223
+ }),
224
+ /**
225
+ * Creates a new collection-type document. This should ONLY be used for collection-types.
226
+ * single-types should always be using `updateDocument` since they always exist.
227
+ */
228
+ createDocument: builder.mutation({
229
+ query: ({ model, data, params }) => ({
230
+ url: `/content-manager/collection-types/${model}`,
231
+ method: "POST",
232
+ data,
233
+ config: {
234
+ params
235
+ }
236
+ }),
237
+ invalidatesTags: (result, _error, { model }) => [
238
+ { type: "Document", id: `${model}_LIST` },
239
+ "Relations"
240
+ ]
241
+ }),
242
+ deleteDocument: builder.mutation({
243
+ query: ({ collectionType, model, documentId, params }) => ({
244
+ url: `/content-manager/${collectionType}/${model}${collectionType !== SINGLE_TYPES && documentId ? `/${documentId}` : ""}`,
245
+ method: "DELETE",
246
+ config: {
247
+ params
248
+ }
249
+ }),
250
+ invalidatesTags: (_result, _error, { collectionType, model }) => [
251
+ { type: "Document", id: collectionType !== SINGLE_TYPES ? `${model}_LIST` : model }
252
+ ]
253
+ }),
254
+ deleteManyDocuments: builder.mutation({
255
+ query: ({ model, params, ...body }) => ({
256
+ url: `/content-manager/collection-types/${model}/actions/bulkDelete`,
257
+ method: "POST",
258
+ data: body,
259
+ config: {
260
+ params
261
+ }
262
+ }),
263
+ invalidatesTags: (_res, _error, { model }) => [{ type: "Document", id: `${model}_LIST` }]
264
+ }),
265
+ discardDocument: builder.mutation({
266
+ query: ({ collectionType, model, documentId, params }) => ({
267
+ url: documentId ? `/content-manager/${collectionType}/${model}/${documentId}/actions/discard` : `/content-manager/${collectionType}/${model}/actions/discard`,
268
+ method: "POST",
269
+ config: {
270
+ params
271
+ }
272
+ }),
273
+ invalidatesTags: (_result, _error, { collectionType, model, documentId }) => {
274
+ return [
275
+ {
276
+ type: "Document",
277
+ id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
278
+ },
279
+ { type: "Document", id: `${model}_LIST` },
280
+ "Relations"
281
+ ];
282
+ }
283
+ }),
284
+ /**
285
+ * Gets all documents of a collection type or single type.
286
+ * By passing different params you can get different results e.g. only published documents or 'es' documents.
287
+ */
288
+ getAllDocuments: builder.query({
289
+ query: ({ model, params }) => ({
290
+ url: `/content-manager/collection-types/${model}`,
291
+ method: "GET",
292
+ config: {
293
+ params
294
+ }
295
+ }),
296
+ providesTags: (result, _error, arg) => {
297
+ return [
298
+ { type: "Document", id: `${arg.model}_LIST` },
299
+ ...result?.results.map(({ documentId }) => ({
300
+ type: "Document",
301
+ id: `${arg.model}_${documentId}`
302
+ })) ?? []
303
+ ];
304
+ }
305
+ }),
306
+ getDraftRelationCount: builder.query({
307
+ query: ({ collectionType, model, documentId, params }) => ({
308
+ url: documentId ? `/content-manager/${collectionType}/${model}/${documentId}/actions/countDraftRelations` : `/content-manager/${collectionType}/${model}/actions/countDraftRelations`,
309
+ method: "GET",
310
+ config: {
311
+ params
312
+ }
313
+ })
314
+ }),
315
+ getDocument: builder.query({
316
+ // @ts-expect-error – TODO: fix ts error where data unknown doesn't work with response via an assertion?
317
+ queryFn: async ({ collectionType, model, documentId, params }, _api, _extraOpts, baseQuery) => {
318
+ const res = await baseQuery({
319
+ url: `/content-manager/${collectionType}/${model}${documentId ? `/${documentId}` : ""}`,
320
+ method: "GET",
321
+ config: {
322
+ params
323
+ }
324
+ });
325
+ if (res.error && res.error.name === "NotFoundError" && collectionType === SINGLE_TYPES) {
326
+ return { data: { document: void 0 }, error: void 0 };
327
+ }
328
+ return res;
329
+ },
330
+ providesTags: (result, _error, { collectionType, model, documentId }) => {
331
+ return [
332
+ // we prefer the result's id because we don't fetch single-types with an ID.
333
+ {
334
+ type: "Document",
335
+ id: collectionType !== SINGLE_TYPES ? `${model}_${result && "documentId" in result ? result.documentId : documentId}` : model
336
+ }
337
+ ];
338
+ }
339
+ }),
340
+ getManyDraftRelationCount: builder.query({
341
+ query: ({ model, ...params }) => ({
342
+ url: `/content-manager/collection-types/${model}/actions/countManyEntriesDraftRelations`,
343
+ method: "GET",
344
+ config: {
345
+ params
346
+ }
347
+ }),
348
+ transformResponse: (response) => response.data
349
+ }),
350
+ /**
351
+ * This endpoint will either create or update documents at the same time as publishing.
352
+ */
353
+ publishDocument: builder.mutation({
354
+ query: ({ collectionType, model, documentId, params, data }) => ({
355
+ url: documentId ? `/content-manager/${collectionType}/${model}/${documentId}/actions/publish` : `/content-manager/${collectionType}/${model}/actions/publish`,
356
+ method: "POST",
357
+ data,
358
+ config: {
359
+ params
360
+ }
361
+ }),
362
+ invalidatesTags: (_result, _error, { collectionType, model, documentId }) => {
363
+ return [
364
+ {
365
+ type: "Document",
366
+ id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
367
+ },
368
+ { type: "Document", id: `${model}_LIST` },
369
+ "Relations"
370
+ ];
371
+ }
372
+ }),
373
+ publishManyDocuments: builder.mutation({
374
+ query: ({ model, params, ...body }) => ({
375
+ url: `/content-manager/collection-types/${model}/actions/bulkPublish`,
376
+ method: "POST",
377
+ data: body,
378
+ config: {
379
+ params
380
+ }
381
+ }),
382
+ invalidatesTags: (_res, _error, { model, documentIds }) => documentIds.map((id) => ({ type: "Document", id: `${model}_${id}` }))
383
+ }),
384
+ updateDocument: builder.mutation({
385
+ query: ({ collectionType, model, documentId, data, params }) => ({
386
+ url: `/content-manager/${collectionType}/${model}${documentId ? `/${documentId}` : ""}`,
387
+ method: "PUT",
388
+ data,
389
+ config: {
390
+ params
391
+ }
392
+ }),
393
+ invalidatesTags: (_result, _error, { collectionType, model, documentId }) => {
394
+ return [
395
+ {
396
+ type: "Document",
397
+ id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
398
+ },
399
+ "Relations"
400
+ ];
401
+ }
402
+ }),
403
+ unpublishDocument: builder.mutation({
404
+ query: ({ collectionType, model, documentId, params, data }) => ({
405
+ url: documentId ? `/content-manager/${collectionType}/${model}/${documentId}/actions/unpublish` : `/content-manager/${collectionType}/${model}/actions/unpublish`,
406
+ method: "POST",
407
+ data,
408
+ config: {
409
+ params
410
+ }
411
+ }),
412
+ invalidatesTags: (_result, _error, { collectionType, model, documentId }) => {
413
+ return [
414
+ {
415
+ type: "Document",
416
+ id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
417
+ }
418
+ ];
419
+ }
420
+ }),
421
+ unpublishManyDocuments: builder.mutation({
422
+ query: ({ model, params, ...body }) => ({
423
+ url: `/content-manager/collection-types/${model}/actions/bulkUnpublish`,
424
+ method: "POST",
425
+ data: body,
426
+ config: {
427
+ params
428
+ }
429
+ }),
430
+ invalidatesTags: (_res, _error, { model, documentIds }) => documentIds.map((id) => ({ type: "Document", id: `${model}_${id}` }))
431
+ })
432
+ })
433
+ });
434
+ const {
435
+ useAutoCloneDocumentMutation,
436
+ useCloneDocumentMutation,
437
+ useCreateDocumentMutation,
438
+ useDeleteDocumentMutation,
439
+ useDeleteManyDocumentsMutation,
440
+ useDiscardDocumentMutation,
441
+ useGetAllDocumentsQuery,
442
+ useLazyGetDocumentQuery,
443
+ useGetDocumentQuery,
444
+ useLazyGetDraftRelationCountQuery,
445
+ useGetManyDraftRelationCountQuery,
446
+ usePublishDocumentMutation,
447
+ usePublishManyDocumentsMutation,
448
+ useUpdateDocumentMutation,
449
+ useUnpublishDocumentMutation,
450
+ useUnpublishManyDocumentsMutation
451
+ } = documentApi;
452
+ const buildValidParams = (query) => {
453
+ if (!query)
454
+ return query;
455
+ const { plugins: _, ...validQueryParams } = {
456
+ ...query,
457
+ ...Object.values(query?.plugins ?? {}).reduce(
458
+ (acc, current) => Object.assign(acc, current),
459
+ {}
460
+ )
461
+ };
462
+ if ("_q" in validQueryParams) {
463
+ validQueryParams._q = encodeURIComponent(validQueryParams._q);
464
+ }
465
+ return validQueryParams;
466
+ };
467
+ const isBaseQueryError = (error) => {
468
+ return error.name !== void 0;
469
+ };
470
+ const createYupSchema = (attributes = {}, components = {}) => {
471
+ const createModelSchema = (attributes2) => yup.object().shape(
472
+ Object.entries(attributes2).reduce((acc, [name, attribute]) => {
473
+ if (DOCUMENT_META_FIELDS.includes(name)) {
474
+ return acc;
475
+ }
476
+ const validations = [
477
+ addRequiredValidation,
478
+ addMinLengthValidation,
479
+ addMaxLengthValidation,
480
+ addMinValidation,
481
+ addMaxValidation,
482
+ addRegexValidation
483
+ ].map((fn) => fn(attribute));
484
+ const transformSchema = pipe(...validations);
485
+ switch (attribute.type) {
486
+ case "component": {
487
+ const { attributes: attributes3 } = components[attribute.component];
488
+ if (attribute.repeatable) {
489
+ return {
490
+ ...acc,
491
+ [name]: transformSchema(
492
+ yup.array().of(createModelSchema(attributes3).nullable(false))
493
+ )
494
+ };
495
+ } else {
496
+ return {
497
+ ...acc,
498
+ [name]: transformSchema(createModelSchema(attributes3))
499
+ };
500
+ }
501
+ }
502
+ case "dynamiczone":
503
+ return {
504
+ ...acc,
505
+ [name]: transformSchema(
506
+ yup.array().of(
507
+ yup.lazy(
508
+ (data) => {
509
+ const attributes3 = components?.[data?.__component]?.attributes;
510
+ const validation = yup.object().shape({
511
+ __component: yup.string().required().oneOf(Object.keys(components))
512
+ }).nullable(false);
513
+ if (!attributes3) {
514
+ return validation;
515
+ }
516
+ return validation.concat(createModelSchema(attributes3));
517
+ }
518
+ )
519
+ )
520
+ )
521
+ };
522
+ case "relation":
523
+ return {
524
+ ...acc,
525
+ [name]: transformSchema(
526
+ yup.lazy((value) => {
527
+ if (!value) {
528
+ return yup.mixed().nullable(true);
529
+ } else if (Array.isArray(value)) {
530
+ return yup.array().of(
531
+ yup.object().shape({
532
+ id: yup.string().required()
533
+ })
534
+ );
535
+ } else if (typeof value === "object") {
536
+ return yup.object();
537
+ } else {
538
+ return yup.mixed().test(
539
+ "type-error",
540
+ "Relation values must be either null, an array of objects with {id} or an object.",
541
+ () => false
542
+ );
543
+ }
544
+ })
545
+ )
546
+ };
547
+ default:
548
+ return {
549
+ ...acc,
550
+ [name]: transformSchema(createAttributeSchema(attribute))
551
+ };
552
+ }
553
+ }, {})
554
+ ).default(null);
555
+ return createModelSchema(attributes);
556
+ };
557
+ const createAttributeSchema = (attribute) => {
558
+ switch (attribute.type) {
559
+ case "biginteger":
560
+ return yup.string().matches(/^-?\d*$/);
561
+ case "boolean":
562
+ return yup.boolean();
563
+ case "blocks":
564
+ return yup.mixed().test("isBlocks", translatedErrors.json, (value) => {
565
+ if (!value || Array.isArray(value)) {
566
+ return true;
567
+ } else {
568
+ return false;
569
+ }
570
+ });
571
+ case "decimal":
572
+ case "float":
573
+ case "integer":
574
+ return yup.number();
575
+ case "email":
576
+ return yup.string().email(translatedErrors.email);
577
+ case "enumeration":
578
+ return yup.string().oneOf([...attribute.enum, null]);
579
+ case "json":
580
+ return yup.mixed().test("isJSON", translatedErrors.json, (value) => {
581
+ if (!value || typeof value === "string" && value.length === 0) {
582
+ return true;
583
+ }
584
+ try {
585
+ JSON.parse(value);
586
+ return true;
587
+ } catch (err) {
588
+ return false;
589
+ }
590
+ });
591
+ case "password":
592
+ case "richtext":
593
+ case "string":
594
+ case "text":
595
+ return yup.string();
596
+ case "uid":
597
+ return yup.string().matches(/^[A-Za-z0-9-_.~]*$/);
598
+ default:
599
+ return yup.mixed();
600
+ }
601
+ };
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
+ }
609
+ return schema?.nullable ? schema.nullable() : (
610
+ // In some cases '.nullable' will not be available on the schema.
611
+ // e.g. when the schema has been built using yup.lazy (e.g. for relations).
612
+ // In these cases we should just return the schema as it is.
613
+ schema
614
+ );
615
+ };
616
+ const addMinLengthValidation = (attribute) => (schema) => {
617
+ if ("minLength" in attribute && attribute.minLength && Number.isInteger(attribute.minLength) && "min" in schema) {
618
+ return schema.min(attribute.minLength, {
619
+ ...translatedErrors.minLength,
620
+ values: {
621
+ min: attribute.minLength
622
+ }
623
+ });
624
+ }
625
+ return schema;
626
+ };
627
+ const addMaxLengthValidation = (attribute) => (schema) => {
628
+ if ("maxLength" in attribute && attribute.maxLength && Number.isInteger(attribute.maxLength) && "max" in schema) {
629
+ return schema.max(attribute.maxLength, {
630
+ ...translatedErrors.maxLength,
631
+ values: {
632
+ max: attribute.maxLength
633
+ }
634
+ });
635
+ }
636
+ return schema;
637
+ };
638
+ const addMinValidation = (attribute) => (schema) => {
639
+ if ("min" in attribute) {
640
+ const min = toInteger(attribute.min);
641
+ if ("min" in schema && min) {
642
+ return schema.min(min, {
643
+ ...translatedErrors.min,
644
+ values: {
645
+ min
646
+ }
647
+ });
648
+ }
649
+ }
650
+ return schema;
651
+ };
652
+ const addMaxValidation = (attribute) => (schema) => {
653
+ if ("max" in attribute) {
654
+ const max = toInteger(attribute.max);
655
+ if ("max" in schema && max) {
656
+ return schema.max(max, {
657
+ ...translatedErrors.max,
658
+ values: {
659
+ max
660
+ }
661
+ });
662
+ }
663
+ }
664
+ return schema;
665
+ };
666
+ const toInteger = (val) => {
667
+ if (typeof val === "number" || val === void 0) {
668
+ return val;
669
+ } else {
670
+ const num = Number(val);
671
+ return isNaN(num) ? void 0 : num;
672
+ }
673
+ };
674
+ const addRegexValidation = (attribute) => (schema) => {
675
+ if ("regex" in attribute && attribute.regex && "matches" in schema) {
676
+ return schema.matches(new RegExp(attribute.regex), {
677
+ message: {
678
+ id: translatedErrors.regex.id,
679
+ defaultMessage: "The value does not match the defined pattern."
680
+ },
681
+ excludeEmptyString: !attribute.required
682
+ });
683
+ }
684
+ return schema;
685
+ };
686
+ const initApi = contentManagerApi.injectEndpoints({
687
+ endpoints: (builder) => ({
688
+ getInitialData: builder.query({
689
+ query: () => "/content-manager/init",
690
+ transformResponse: (response) => response.data,
691
+ providesTags: ["InitialData"]
692
+ })
693
+ })
694
+ });
695
+ const { useGetInitialDataQuery } = initApi;
696
+ const useContentTypeSchema = (model) => {
697
+ const { toggleNotification } = useNotification();
698
+ const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();
699
+ const { data, error, isLoading, isFetching } = useGetInitialDataQuery(void 0);
700
+ const { components, contentType, contentTypes } = React.useMemo(() => {
701
+ const contentType2 = data?.contentTypes.find((ct) => ct.uid === model);
702
+ const componentsByKey = data?.components.reduce((acc, component) => {
703
+ acc[component.uid] = component;
704
+ return acc;
705
+ }, {});
706
+ const components2 = extractContentTypeComponents(contentType2?.attributes, componentsByKey);
707
+ return {
708
+ components: Object.keys(components2).length === 0 ? void 0 : components2,
709
+ contentType: contentType2,
710
+ contentTypes: data?.contentTypes ?? []
711
+ };
712
+ }, [model, data]);
713
+ React.useEffect(() => {
714
+ if (error) {
715
+ toggleNotification({
716
+ type: "danger",
717
+ message: formatAPIError(error)
718
+ });
719
+ }
720
+ }, [toggleNotification, error, formatAPIError]);
721
+ return {
722
+ // This must be memoized to avoid inifiinite re-renders where the empty object is different everytime.
723
+ components: React.useMemo(() => components ?? {}, [components]),
724
+ schema: contentType,
725
+ schemas: contentTypes,
726
+ isLoading: isLoading || isFetching
727
+ };
728
+ };
729
+ const extractContentTypeComponents = (attributes = {}, allComponents = {}) => {
730
+ const getComponents = (attributes2) => {
731
+ return attributes2.reduce((acc, attribute) => {
732
+ if (attribute.type === "component") {
733
+ const componentAttributes = Object.values(
734
+ allComponents[attribute.component]?.attributes ?? {}
735
+ );
736
+ acc.push(attribute.component, ...getComponents(componentAttributes));
737
+ } else if (attribute.type === "dynamiczone") {
738
+ acc.push(
739
+ ...attribute.components,
740
+ ...attribute.components.flatMap((componentUid) => {
741
+ const componentAttributes = Object.values(
742
+ allComponents[componentUid]?.attributes ?? {}
743
+ );
744
+ return getComponents(componentAttributes);
745
+ })
746
+ );
747
+ }
748
+ return acc;
749
+ }, []);
750
+ };
751
+ const componentUids = getComponents(Object.values(attributes));
752
+ const uniqueComponentUids = [...new Set(componentUids)];
753
+ const componentsByKey = uniqueComponentUids.reduce((acc, uid) => {
754
+ acc[uid] = allComponents[uid];
755
+ return acc;
756
+ }, {});
757
+ return componentsByKey;
758
+ };
759
+ const useDocument = (args, opts) => {
760
+ const { toggleNotification } = useNotification();
761
+ const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();
762
+ 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);
769
+ React.useEffect(() => {
770
+ if (error) {
771
+ toggleNotification({
772
+ type: "danger",
773
+ message: formatAPIError(error)
774
+ });
775
+ }
776
+ }, [toggleNotification, error, formatAPIError, args.collectionType]);
777
+ const validationSchema = React.useMemo(() => {
778
+ if (!schema) {
779
+ return null;
780
+ }
781
+ return createYupSchema(schema.attributes, components);
782
+ }, [schema, components]);
783
+ const validate = React.useCallback(
784
+ (document) => {
785
+ if (!validationSchema) {
786
+ throw new Error(
787
+ "There is no validation schema generated, this is likely due to the schema not being loaded yet."
788
+ );
789
+ }
790
+ try {
791
+ validationSchema.validateSync(document, { abortEarly: false, strict: true });
792
+ return null;
793
+ } catch (error2) {
794
+ if (error2 instanceof ValidationError) {
795
+ return getYupValidationErrors(error2);
796
+ }
797
+ throw error2;
798
+ }
799
+ },
800
+ [validationSchema]
801
+ );
802
+ const isLoading = isLoadingDocument || isFetchingDocument || isLoadingSchema;
803
+ return {
804
+ components,
805
+ document: data?.data,
806
+ meta: data?.meta,
807
+ isLoading,
808
+ schema,
809
+ validate
810
+ };
811
+ };
812
+ const useDoc = () => {
813
+ const { id, slug, collectionType, origin } = useParams();
814
+ const [{ query }] = useQueryParams();
815
+ const params = React.useMemo(() => buildValidParams(query), [query]);
816
+ if (!collectionType) {
817
+ throw new Error("Could not find collectionType in url params");
818
+ }
819
+ if (!slug) {
820
+ throw new Error("Could not find model in url params");
821
+ }
822
+ return {
823
+ collectionType,
824
+ 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
+ )
832
+ };
833
+ };
834
+ const prefixPluginTranslations = (trad, pluginId) => {
835
+ if (!pluginId) {
836
+ throw new TypeError("pluginId can't be empty");
837
+ }
838
+ return Object.keys(trad).reduce((acc, current) => {
839
+ acc[`${pluginId}.${current}`] = trad[current];
840
+ return acc;
841
+ }, {});
842
+ };
843
+ const getTranslation = (id) => `content-manager.${id}`;
844
+ const DEFAULT_UNEXPECTED_ERROR_MSG = {
845
+ id: "notification.error",
846
+ defaultMessage: "An error occurred, please try again"
847
+ };
848
+ const useDocumentActions = () => {
849
+ const { toggleNotification } = useNotification();
850
+ const { formatMessage } = useIntl();
851
+ const { trackUsage } = useTracking();
852
+ const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();
853
+ const [deleteDocument] = useDeleteDocumentMutation();
854
+ const _delete = React.useCallback(
855
+ async ({ collectionType, model, documentId, params }, trackerProperty) => {
856
+ try {
857
+ trackUsage("willDeleteEntry", trackerProperty);
858
+ const res = await deleteDocument({
859
+ collectionType,
860
+ model,
861
+ documentId,
862
+ params
863
+ });
864
+ if ("error" in res) {
865
+ toggleNotification({
866
+ type: "danger",
867
+ message: formatAPIError(res.error)
868
+ });
869
+ return { error: res.error };
870
+ }
871
+ toggleNotification({
872
+ type: "success",
873
+ message: formatMessage({
874
+ id: getTranslation("success.record.delete"),
875
+ defaultMessage: "Deleted document"
876
+ })
877
+ });
878
+ trackUsage("didDeleteEntry", trackerProperty);
879
+ return res.data;
880
+ } catch (err) {
881
+ toggleNotification({
882
+ type: "danger",
883
+ message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
884
+ });
885
+ trackUsage("didNotDeleteEntry", { error: err, ...trackerProperty });
886
+ throw err;
887
+ }
888
+ },
889
+ [trackUsage, deleteDocument, toggleNotification, formatMessage, formatAPIError]
890
+ );
891
+ const [deleteManyDocuments] = useDeleteManyDocumentsMutation();
892
+ const deleteMany = React.useCallback(
893
+ async ({ model, documentIds, params }) => {
894
+ try {
895
+ trackUsage("willBulkDeleteEntries");
896
+ const res = await deleteManyDocuments({
897
+ model,
898
+ documentIds,
899
+ params
900
+ });
901
+ if ("error" in res) {
902
+ toggleNotification({
903
+ type: "danger",
904
+ message: formatAPIError(res.error)
905
+ });
906
+ return { error: res.error };
907
+ }
908
+ toggleNotification({
909
+ type: "success",
910
+ title: formatMessage({
911
+ id: getTranslation("success.records.delete"),
912
+ defaultMessage: "Successfully deleted."
913
+ }),
914
+ message: ""
915
+ });
916
+ trackUsage("didBulkDeleteEntries");
917
+ return res.data;
918
+ } catch (err) {
919
+ toggleNotification({
920
+ type: "danger",
921
+ message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
922
+ });
923
+ trackUsage("didNotBulkDeleteEntries");
924
+ throw err;
925
+ }
926
+ },
927
+ [trackUsage, deleteManyDocuments, toggleNotification, formatMessage, formatAPIError]
928
+ );
929
+ const [discardDocument] = useDiscardDocumentMutation();
930
+ const discard = React.useCallback(
931
+ async ({ collectionType, model, documentId, params }) => {
932
+ try {
933
+ const res = await discardDocument({
934
+ collectionType,
935
+ model,
936
+ documentId,
937
+ params
938
+ });
939
+ if ("error" in res) {
940
+ toggleNotification({
941
+ type: "danger",
942
+ message: formatAPIError(res.error)
943
+ });
944
+ return { error: res.error };
945
+ }
946
+ toggleNotification({
947
+ type: "success",
948
+ message: formatMessage({
949
+ id: "content-manager.success.record.discard",
950
+ defaultMessage: "Changes discarded"
951
+ })
952
+ });
953
+ return res.data;
954
+ } catch (err) {
955
+ toggleNotification({
956
+ type: "danger",
957
+ message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
958
+ });
959
+ throw err;
960
+ }
961
+ },
962
+ [discardDocument, formatAPIError, formatMessage, toggleNotification]
963
+ );
964
+ const [publishDocument] = usePublishDocumentMutation();
965
+ const publish = React.useCallback(
966
+ async ({ collectionType, model, documentId, params }, data) => {
967
+ try {
968
+ trackUsage("willPublishEntry");
969
+ const res = await publishDocument({
970
+ collectionType,
971
+ model,
972
+ documentId,
973
+ data,
974
+ params
975
+ });
976
+ if ("error" in res) {
977
+ toggleNotification({ type: "danger", message: formatAPIError(res.error) });
978
+ return { error: res.error };
979
+ }
980
+ trackUsage("didPublishEntry");
981
+ toggleNotification({
982
+ type: "success",
983
+ message: formatMessage({
984
+ id: getTranslation("success.record.publish"),
985
+ defaultMessage: "Published document"
986
+ })
987
+ });
988
+ return res.data;
989
+ } catch (err) {
990
+ toggleNotification({
991
+ type: "danger",
992
+ message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
993
+ });
994
+ throw err;
995
+ }
996
+ },
997
+ [trackUsage, publishDocument, toggleNotification, formatMessage, formatAPIError]
998
+ );
999
+ const [publishManyDocuments] = usePublishManyDocumentsMutation();
1000
+ const publishMany = React.useCallback(
1001
+ async ({ model, documentIds, params }) => {
1002
+ try {
1003
+ const res = await publishManyDocuments({
1004
+ model,
1005
+ documentIds,
1006
+ params
1007
+ });
1008
+ if ("error" in res) {
1009
+ toggleNotification({ type: "danger", message: formatAPIError(res.error) });
1010
+ return { error: res.error };
1011
+ }
1012
+ toggleNotification({
1013
+ type: "success",
1014
+ message: formatMessage({
1015
+ id: getTranslation("success.record.publish"),
1016
+ defaultMessage: "Published document"
1017
+ })
1018
+ });
1019
+ return res.data;
1020
+ } catch (err) {
1021
+ toggleNotification({
1022
+ type: "danger",
1023
+ message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
1024
+ });
1025
+ throw err;
1026
+ }
1027
+ },
1028
+ [
1029
+ // trackUsage,
1030
+ publishManyDocuments,
1031
+ toggleNotification,
1032
+ formatMessage,
1033
+ formatAPIError
1034
+ ]
1035
+ );
1036
+ const [updateDocument] = useUpdateDocumentMutation();
1037
+ const update = React.useCallback(
1038
+ async ({ collectionType, model, documentId, params }, data, trackerProperty) => {
1039
+ try {
1040
+ trackUsage("willEditEntry", trackerProperty);
1041
+ const res = await updateDocument({
1042
+ collectionType,
1043
+ model,
1044
+ documentId,
1045
+ data,
1046
+ params
1047
+ });
1048
+ if ("error" in res) {
1049
+ toggleNotification({ type: "danger", message: formatAPIError(res.error) });
1050
+ trackUsage("didNotEditEntry", { error: res.error, ...trackerProperty });
1051
+ return { error: res.error };
1052
+ }
1053
+ trackUsage("didEditEntry", trackerProperty);
1054
+ toggleNotification({
1055
+ type: "success",
1056
+ message: formatMessage({
1057
+ id: getTranslation("success.record.save"),
1058
+ defaultMessage: "Saved document"
1059
+ })
1060
+ });
1061
+ return res.data;
1062
+ } catch (err) {
1063
+ trackUsage("didNotEditEntry", { error: err, ...trackerProperty });
1064
+ toggleNotification({
1065
+ type: "danger",
1066
+ message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
1067
+ });
1068
+ throw err;
1069
+ }
1070
+ },
1071
+ [trackUsage, updateDocument, toggleNotification, formatMessage, formatAPIError]
1072
+ );
1073
+ const [unpublishDocument] = useUnpublishDocumentMutation();
1074
+ const unpublish = React.useCallback(
1075
+ async ({ collectionType, model, documentId, params }, discardDraft = false) => {
1076
+ try {
1077
+ trackUsage("willUnpublishEntry");
1078
+ const res = await unpublishDocument({
1079
+ collectionType,
1080
+ model,
1081
+ documentId,
1082
+ params,
1083
+ data: {
1084
+ discardDraft
1085
+ }
1086
+ });
1087
+ if ("error" in res) {
1088
+ toggleNotification({ type: "danger", message: formatAPIError(res.error) });
1089
+ return { error: res.error };
1090
+ }
1091
+ trackUsage("didUnpublishEntry");
1092
+ toggleNotification({
1093
+ type: "success",
1094
+ message: formatMessage({
1095
+ id: getTranslation("success.record.unpublish"),
1096
+ defaultMessage: "Unpublished document"
1097
+ })
1098
+ });
1099
+ return res.data;
1100
+ } catch (err) {
1101
+ toggleNotification({
1102
+ type: "danger",
1103
+ message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
1104
+ });
1105
+ throw err;
1106
+ }
1107
+ },
1108
+ [trackUsage, unpublishDocument, toggleNotification, formatMessage, formatAPIError]
1109
+ );
1110
+ const [unpublishManyDocuments] = useUnpublishManyDocumentsMutation();
1111
+ const unpublishMany = React.useCallback(
1112
+ async ({ model, documentIds, params }) => {
1113
+ try {
1114
+ trackUsage("willBulkUnpublishEntries");
1115
+ const res = await unpublishManyDocuments({
1116
+ model,
1117
+ documentIds,
1118
+ params
1119
+ });
1120
+ if ("error" in res) {
1121
+ toggleNotification({ type: "danger", message: formatAPIError(res.error) });
1122
+ return { error: res.error };
1123
+ }
1124
+ trackUsage("didBulkUnpublishEntries");
1125
+ toggleNotification({
1126
+ type: "success",
1127
+ title: formatMessage({
1128
+ id: getTranslation("success.records.unpublish"),
1129
+ defaultMessage: "Successfully unpublished."
1130
+ }),
1131
+ message: ""
1132
+ });
1133
+ return res.data;
1134
+ } catch (err) {
1135
+ toggleNotification({
1136
+ type: "danger",
1137
+ message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
1138
+ });
1139
+ trackUsage("didNotBulkUnpublishEntries");
1140
+ throw err;
1141
+ }
1142
+ },
1143
+ [trackUsage, unpublishManyDocuments, toggleNotification, formatMessage, formatAPIError]
1144
+ );
1145
+ const [createDocument] = useCreateDocumentMutation();
1146
+ const create = React.useCallback(
1147
+ async ({ model, params }, data, trackerProperty) => {
1148
+ try {
1149
+ const res = await createDocument({
1150
+ model,
1151
+ data,
1152
+ params
1153
+ });
1154
+ if ("error" in res) {
1155
+ toggleNotification({ type: "danger", message: formatAPIError(res.error) });
1156
+ trackUsage("didNotCreateEntry", { error: res.error, ...trackerProperty });
1157
+ return { error: res.error };
1158
+ }
1159
+ trackUsage("didCreateEntry", trackerProperty);
1160
+ toggleNotification({
1161
+ type: "success",
1162
+ message: formatMessage({
1163
+ id: getTranslation("success.record.save"),
1164
+ defaultMessage: "Saved document"
1165
+ })
1166
+ });
1167
+ return res.data;
1168
+ } catch (err) {
1169
+ toggleNotification({
1170
+ type: "danger",
1171
+ message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
1172
+ });
1173
+ trackUsage("didNotCreateEntry", { error: err, ...trackerProperty });
1174
+ throw err;
1175
+ }
1176
+ },
1177
+ [createDocument, formatAPIError, formatMessage, toggleNotification, trackUsage]
1178
+ );
1179
+ const [autoCloneDocument] = useAutoCloneDocumentMutation();
1180
+ const autoClone = React.useCallback(
1181
+ async ({ model, sourceId }) => {
1182
+ try {
1183
+ const res = await autoCloneDocument({
1184
+ model,
1185
+ sourceId
1186
+ });
1187
+ if ("error" in res) {
1188
+ toggleNotification({ type: "danger", message: formatAPIError(res.error) });
1189
+ return { error: res.error };
1190
+ }
1191
+ toggleNotification({
1192
+ type: "success",
1193
+ message: formatMessage({
1194
+ id: getTranslation("success.record.clone"),
1195
+ defaultMessage: "Cloned document"
1196
+ })
1197
+ });
1198
+ return res.data;
1199
+ } catch (err) {
1200
+ toggleNotification({
1201
+ type: "danger",
1202
+ message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
1203
+ });
1204
+ throw err;
1205
+ }
1206
+ },
1207
+ [autoCloneDocument, formatAPIError, formatMessage, toggleNotification]
1208
+ );
1209
+ const [cloneDocument] = useCloneDocumentMutation();
1210
+ const clone = React.useCallback(
1211
+ async ({ model, documentId, params }, body, trackerProperty) => {
1212
+ try {
1213
+ const { id: _id, ...restBody } = body;
1214
+ const res = await cloneDocument({
1215
+ model,
1216
+ sourceId: documentId,
1217
+ data: restBody,
1218
+ params
1219
+ });
1220
+ if ("error" in res) {
1221
+ toggleNotification({ type: "danger", message: formatAPIError(res.error) });
1222
+ trackUsage("didNotCreateEntry", { error: res.error, ...trackerProperty });
1223
+ return { error: res.error };
1224
+ }
1225
+ trackUsage("didCreateEntry", trackerProperty);
1226
+ toggleNotification({
1227
+ type: "success",
1228
+ message: formatMessage({
1229
+ id: getTranslation("success.record.clone"),
1230
+ defaultMessage: "Cloned document"
1231
+ })
1232
+ });
1233
+ return res.data;
1234
+ } catch (err) {
1235
+ toggleNotification({
1236
+ type: "danger",
1237
+ message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
1238
+ });
1239
+ trackUsage("didNotCreateEntry", { error: err, ...trackerProperty });
1240
+ throw err;
1241
+ }
1242
+ },
1243
+ [cloneDocument, trackUsage, toggleNotification, formatMessage, formatAPIError]
1244
+ );
1245
+ const [getDoc] = useLazyGetDocumentQuery();
1246
+ const getDocument = React.useCallback(
1247
+ async (args) => {
1248
+ const { data } = await getDoc(args);
1249
+ return data;
1250
+ },
1251
+ [getDoc]
1252
+ );
1253
+ return {
1254
+ autoClone,
1255
+ clone,
1256
+ create,
1257
+ delete: _delete,
1258
+ deleteMany,
1259
+ discard,
1260
+ getDocument,
1261
+ publish,
1262
+ publishMany,
1263
+ unpublish,
1264
+ unpublishMany,
1265
+ update
1266
+ };
1267
+ };
1268
+ const ProtectedHistoryPage = lazy(
1269
+ () => import("./History-Cqq6Csvj.mjs").then((mod) => ({ default: mod.ProtectedHistoryPage }))
1270
+ );
1271
+ const routes$1 = [
1272
+ {
1273
+ path: ":collectionType/:slug/:id/history",
1274
+ Component: ProtectedHistoryPage
1275
+ },
1276
+ {
1277
+ path: ":collectionType/:slug/history",
1278
+ Component: ProtectedHistoryPage
1279
+ }
1280
+ ];
1281
+ const ProtectedEditViewPage = lazy(
1282
+ () => import("./EditViewPage-D2uq2uZS.mjs").then((mod) => ({ default: mod.ProtectedEditViewPage }))
1283
+ );
1284
+ const ProtectedListViewPage = lazy(
1285
+ () => import("./ListViewPage-Cjbh5jyY.mjs").then((mod) => ({ default: mod.ProtectedListViewPage }))
1286
+ );
1287
+ const ProtectedListConfiguration = lazy(
1288
+ () => import("./ListConfigurationPage-Bke2024Z.mjs").then((mod) => ({
1289
+ default: mod.ProtectedListConfiguration
1290
+ }))
1291
+ );
1292
+ const ProtectedEditConfigurationPage = lazy(
1293
+ () => import("./EditConfigurationPage-Dn7sFfOu.mjs").then((mod) => ({
1294
+ default: mod.ProtectedEditConfigurationPage
1295
+ }))
1296
+ );
1297
+ const ProtectedComponentConfigurationPage = lazy(
1298
+ () => import("./ComponentConfigurationPage-DF4KsgJw.mjs").then((mod) => ({
1299
+ default: mod.ProtectedComponentConfigurationPage
1300
+ }))
1301
+ );
1302
+ const NoPermissions = lazy(
1303
+ () => import("./NoPermissionsPage-CCMchuOR.mjs").then((mod) => ({ default: mod.NoPermissions }))
1304
+ );
1305
+ const NoContentType = lazy(
1306
+ () => import("./NoContentTypePage-m6_m6mFn.mjs").then((mod) => ({ default: mod.NoContentType }))
1307
+ );
1308
+ const CollectionTypePages = () => {
1309
+ const { collectionType } = useParams();
1310
+ if (collectionType !== COLLECTION_TYPES && collectionType !== SINGLE_TYPES) {
1311
+ return /* @__PURE__ */ jsx(Navigate, { to: "/404" });
1312
+ }
1313
+ return collectionType === COLLECTION_TYPES ? /* @__PURE__ */ jsx(ProtectedListViewPage, {}) : /* @__PURE__ */ jsx(ProtectedEditViewPage, {});
1314
+ };
1315
+ const CLONE_RELATIVE_PATH = ":collectionType/:slug/clone/:origin";
1316
+ const CLONE_PATH = `/content-manager/${CLONE_RELATIVE_PATH}`;
1317
+ const LIST_RELATIVE_PATH = ":collectionType/:slug";
1318
+ const LIST_PATH = `/content-manager/${LIST_RELATIVE_PATH}`;
1319
+ const routes = [
1320
+ {
1321
+ path: LIST_RELATIVE_PATH,
1322
+ element: /* @__PURE__ */ jsx(CollectionTypePages, {})
1323
+ },
1324
+ {
1325
+ path: ":collectionType/:slug/:id",
1326
+ Component: ProtectedEditViewPage
1327
+ },
1328
+ {
1329
+ path: CLONE_RELATIVE_PATH,
1330
+ Component: ProtectedEditViewPage
1331
+ },
1332
+ {
1333
+ path: ":collectionType/:slug/configurations/list",
1334
+ Component: ProtectedListConfiguration
1335
+ },
1336
+ {
1337
+ path: "components/:slug/configurations/edit",
1338
+ Component: ProtectedComponentConfigurationPage
1339
+ },
1340
+ {
1341
+ path: ":collectionType/:slug/configurations/edit",
1342
+ Component: ProtectedEditConfigurationPage
1343
+ },
1344
+ {
1345
+ path: "403",
1346
+ Component: NoPermissions
1347
+ },
1348
+ {
1349
+ path: "no-content-types",
1350
+ Component: NoContentType
1351
+ },
1352
+ ...routes$1
1353
+ ];
1354
+ const DocumentActions = ({ actions: actions2 }) => {
1355
+ const { formatMessage } = useIntl();
1356
+ const [primaryAction, secondaryAction, ...restActions] = actions2.filter((action) => {
1357
+ if (action.position === void 0) {
1358
+ return true;
1359
+ }
1360
+ const positions = Array.isArray(action.position) ? action.position : [action.position];
1361
+ return positions.includes("panel");
1362
+ });
1363
+ if (!primaryAction) {
1364
+ return null;
1365
+ }
1366
+ return /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 2, alignItems: "stretch", width: "100%", children: [
1367
+ /* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
1368
+ /* @__PURE__ */ jsx(DocumentActionButton, { ...primaryAction, variant: primaryAction.variant || "default" }),
1369
+ restActions.length > 0 ? /* @__PURE__ */ jsx(
1370
+ DocumentActionsMenu,
1371
+ {
1372
+ actions: restActions,
1373
+ label: formatMessage({
1374
+ id: "content-manager.containers.edit.panels.default.more-actions",
1375
+ defaultMessage: "More document actions"
1376
+ })
1377
+ }
1378
+ ) : null
1379
+ ] }),
1380
+ secondaryAction ? /* @__PURE__ */ jsx(
1381
+ DocumentActionButton,
1382
+ {
1383
+ ...secondaryAction,
1384
+ variant: secondaryAction.variant || "secondary"
1385
+ }
1386
+ ) : null
1387
+ ] });
1388
+ };
1389
+ const DocumentActionButton = (action) => {
1390
+ const [dialogId, setDialogId] = React.useState(null);
1391
+ const { toggleNotification } = useNotification();
1392
+ const handleClick = (action2) => async (e) => {
1393
+ const { onClick = () => false, dialog, id } = action2;
1394
+ const muteDialog = await onClick(e);
1395
+ if (dialog && !muteDialog) {
1396
+ switch (dialog.type) {
1397
+ case "notification":
1398
+ toggleNotification({
1399
+ title: dialog.title,
1400
+ message: dialog.content,
1401
+ type: dialog.status,
1402
+ timeout: dialog.timeout,
1403
+ onClose: dialog.onClose
1404
+ });
1405
+ break;
1406
+ case "dialog":
1407
+ case "modal":
1408
+ e.preventDefault();
1409
+ setDialogId(id);
1410
+ }
1411
+ }
1412
+ };
1413
+ const handleClose = () => {
1414
+ setDialogId(null);
1415
+ };
1416
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
1417
+ /* @__PURE__ */ jsx(
1418
+ Button,
1419
+ {
1420
+ flex: 1,
1421
+ startIcon: action.icon,
1422
+ disabled: action.disabled,
1423
+ onClick: handleClick(action),
1424
+ justifyContent: "center",
1425
+ variant: action.variant || "default",
1426
+ children: action.label
1427
+ }
1428
+ ),
1429
+ action.dialog?.type === "dialog" ? /* @__PURE__ */ jsx(
1430
+ DocumentActionConfirmDialog,
1431
+ {
1432
+ ...action.dialog,
1433
+ variant: action.variant,
1434
+ isOpen: dialogId === action.id,
1435
+ onClose: handleClose
1436
+ }
1437
+ ) : null,
1438
+ action.dialog?.type === "modal" ? /* @__PURE__ */ jsx(
1439
+ DocumentActionModal,
1440
+ {
1441
+ ...action.dialog,
1442
+ onModalClose: handleClose,
1443
+ isOpen: dialogId === action.id
1444
+ }
1445
+ ) : null
1446
+ ] });
1447
+ };
1448
+ const DocumentActionsMenu = ({
1449
+ actions: actions2,
1450
+ children,
1451
+ label,
1452
+ variant = "tertiary"
1453
+ }) => {
1454
+ const [isOpen, setIsOpen] = React.useState(false);
1455
+ const [dialogId, setDialogId] = React.useState(null);
1456
+ const { formatMessage } = useIntl();
1457
+ const { toggleNotification } = useNotification();
1458
+ const isDisabled = actions2.every((action) => action.disabled) || actions2.length === 0;
1459
+ const handleClick = (action) => async (e) => {
1460
+ const { onClick = () => false, dialog, id } = action;
1461
+ const muteDialog = await onClick(e);
1462
+ if (dialog && !muteDialog) {
1463
+ switch (dialog.type) {
1464
+ case "notification":
1465
+ toggleNotification({
1466
+ title: dialog.title,
1467
+ message: dialog.content,
1468
+ type: dialog.status,
1469
+ timeout: dialog.timeout,
1470
+ onClose: dialog.onClose
1471
+ });
1472
+ break;
1473
+ case "dialog":
1474
+ case "modal":
1475
+ setDialogId(id);
1476
+ }
1477
+ }
1478
+ };
1479
+ const handleClose = () => {
1480
+ setDialogId(null);
1481
+ setIsOpen(false);
1482
+ };
1483
+ return /* @__PURE__ */ jsxs(Menu.Root, { open: isOpen, onOpenChange: setIsOpen, children: [
1484
+ /* @__PURE__ */ jsxs(
1485
+ Menu.Trigger,
1486
+ {
1487
+ disabled: isDisabled,
1488
+ size: "S",
1489
+ endIcon: null,
1490
+ paddingTop: "7px",
1491
+ paddingLeft: "9px",
1492
+ paddingRight: "9px",
1493
+ variant,
1494
+ children: [
1495
+ /* @__PURE__ */ jsx(More, { "aria-hidden": true, focusable: false }),
1496
+ /* @__PURE__ */ jsx(VisuallyHidden, { tag: "span", children: label || formatMessage({
1497
+ id: "content-manager.containers.edit.panels.default.more-actions",
1498
+ defaultMessage: "More document actions"
1499
+ }) })
1500
+ ]
1501
+ }
1502
+ ),
1503
+ /* @__PURE__ */ jsxs(Menu.Content, { top: "4px", maxHeight: void 0, popoverPlacement: "bottom-end", children: [
1504
+ actions2.map((action) => {
1505
+ return /* @__PURE__ */ jsx(
1506
+ Menu.Item,
1507
+ {
1508
+ disabled: action.disabled,
1509
+ onSelect: handleClick(action),
1510
+ 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
+ ] })
1533
+ },
1534
+ action.id
1535
+ );
1536
+ }),
1537
+ children
1538
+ ] }),
1539
+ actions2.map((action) => {
1540
+ return /* @__PURE__ */ jsxs(React.Fragment, { children: [
1541
+ action.dialog?.type === "dialog" ? /* @__PURE__ */ jsx(
1542
+ DocumentActionConfirmDialog,
1543
+ {
1544
+ ...action.dialog,
1545
+ variant: action.variant,
1546
+ isOpen: dialogId === action.id,
1547
+ onClose: handleClose
1548
+ }
1549
+ ) : null,
1550
+ action.dialog?.type === "modal" ? /* @__PURE__ */ jsx(
1551
+ DocumentActionModal,
1552
+ {
1553
+ ...action.dialog,
1554
+ onModalClose: handleClose,
1555
+ isOpen: dialogId === action.id
1556
+ }
1557
+ ) : null
1558
+ ] }, action.id);
1559
+ })
1560
+ ] });
1561
+ };
1562
+ const convertActionVariantToColor = (variant = "secondary") => {
1563
+ switch (variant) {
1564
+ case "danger":
1565
+ return "danger600";
1566
+ case "secondary":
1567
+ return void 0;
1568
+ case "success":
1569
+ return "success600";
1570
+ default:
1571
+ return "primary600";
1572
+ }
1573
+ };
1574
+ const convertActionVariantToIconColor = (variant = "secondary") => {
1575
+ switch (variant) {
1576
+ case "danger":
1577
+ return "danger600";
1578
+ case "secondary":
1579
+ return "neutral500";
1580
+ case "success":
1581
+ return "success600";
1582
+ default:
1583
+ return "primary600";
1584
+ }
1585
+ };
1586
+ const DocumentActionConfirmDialog = ({
1587
+ onClose,
1588
+ onCancel,
1589
+ onConfirm,
1590
+ title,
1591
+ content,
1592
+ isOpen,
1593
+ variant = "secondary"
1594
+ }) => {
1595
+ const { formatMessage } = useIntl();
1596
+ const handleClose = async () => {
1597
+ if (onCancel) {
1598
+ await onCancel();
1599
+ }
1600
+ onClose();
1601
+ };
1602
+ const handleConfirm = async () => {
1603
+ if (onConfirm) {
1604
+ await onConfirm();
1605
+ }
1606
+ onClose();
1607
+ };
1608
+ return /* @__PURE__ */ jsx(Dialog.Root, { open: isOpen, onOpenChange: handleClose, children: /* @__PURE__ */ jsxs(Dialog.Content, { children: [
1609
+ /* @__PURE__ */ jsx(Dialog.Header, { children: title }),
1610
+ /* @__PURE__ */ jsx(Dialog.Body, { children: content }),
1611
+ /* @__PURE__ */ jsxs(Dialog.Footer, { children: [
1612
+ /* @__PURE__ */ jsx(Dialog.Cancel, { children: /* @__PURE__ */ jsx(Button, { variant: "tertiary", children: formatMessage({
1613
+ id: "app.components.Button.cancel",
1614
+ defaultMessage: "Cancel"
1615
+ }) }) }),
1616
+ /* @__PURE__ */ jsx(Button, { onClick: handleConfirm, variant, children: formatMessage({
1617
+ id: "app.components.Button.confirm",
1618
+ defaultMessage: "Confirm"
1619
+ }) })
1620
+ ] })
1621
+ ] }) });
1622
+ };
1623
+ const DocumentActionModal = ({
1624
+ isOpen,
1625
+ title,
1626
+ onClose,
1627
+ footer: Footer,
1628
+ content: Content,
1629
+ onModalClose
1630
+ }) => {
1631
+ const handleClose = () => {
1632
+ if (onClose) {
1633
+ onClose();
1634
+ }
1635
+ onModalClose();
1636
+ };
1637
+ return /* @__PURE__ */ jsx(Modal.Root, { open: isOpen, onOpenChange: handleClose, children: /* @__PURE__ */ jsxs(Modal.Content, { children: [
1638
+ /* @__PURE__ */ jsx(Modal.Header, { children: /* @__PURE__ */ jsx(Modal.Title, { children: title }) }),
1639
+ typeof Content === "function" ? /* @__PURE__ */ jsx(Content, { onClose: handleClose }) : /* @__PURE__ */ jsx(Modal.Body, { children: Content }),
1640
+ typeof Footer === "function" ? /* @__PURE__ */ jsx(Footer, { onClose: handleClose }) : Footer
1641
+ ] }) });
1642
+ };
1643
+ const PublishAction$1 = ({
1644
+ activeTab,
1645
+ documentId,
1646
+ model,
1647
+ collectionType,
1648
+ meta,
1649
+ document
1650
+ }) => {
1651
+ const { schema } = useDoc();
1652
+ const navigate = useNavigate();
1653
+ const { toggleNotification } = useNotification();
1654
+ const { _unstableFormatValidationErrors: formatValidationErrors } = useAPIErrorHandler();
1655
+ const isCloning = useMatch(CLONE_PATH) !== null;
1656
+ 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
+ );
1661
+ const { publish } = useDocumentActions();
1662
+ const [{ query, rawQuery }] = useQueryParams();
1663
+ const params = React.useMemo(() => buildValidParams(query), [query]);
1664
+ const modified = useForm("PublishAction", ({ modified: modified2 }) => modified2);
1665
+ const setSubmitting = useForm("PublishAction", ({ setSubmitting: setSubmitting2 }) => setSubmitting2);
1666
+ const isSubmitting = useForm("PublishAction", ({ isSubmitting: isSubmitting2 }) => isSubmitting2);
1667
+ const validate = useForm("PublishAction", (state) => state.validate);
1668
+ const setErrors = useForm("PublishAction", (state) => state.setErrors);
1669
+ const formValues = useForm("PublishAction", ({ values }) => values);
1670
+ const isDocumentPublished = (document?.[PUBLISHED_AT_ATTRIBUTE_NAME] || meta?.availableStatus.some((doc) => doc[PUBLISHED_AT_ATTRIBUTE_NAME] !== null)) && document?.status !== "modified";
1671
+ if (!schema?.options?.draftAndPublish) {
1672
+ return null;
1673
+ }
1674
+ return {
1675
+ /**
1676
+ * Disabled when:
1677
+ * - currently if you're cloning a document we don't support publish & clone at the same time.
1678
+ * - the form is submitting
1679
+ * - the active tab is the published tab
1680
+ * - the document is already published & not modified
1681
+ * - the document is being created & not modified
1682
+ * - 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
+ */
1686
+ disabled: isCloning || isSubmitting || activeTab === "published" || !modified && isDocumentPublished || !modified && !document?.documentId || !canPublish || Boolean(!document?.documentId && !canCreate || document?.documentId && !canUpdate),
1687
+ label: formatMessage({
1688
+ id: "app.utils.publish",
1689
+ defaultMessage: "Publish"
1690
+ }),
1691
+ 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));
1721
+ }
1722
+ } finally {
1723
+ setSubmitting(false);
1724
+ }
1725
+ }
1726
+ };
1727
+ };
1728
+ PublishAction$1.type = "publish";
1729
+ const UpdateAction = ({
1730
+ activeTab,
1731
+ documentId,
1732
+ model,
1733
+ collectionType
1734
+ }) => {
1735
+ const navigate = useNavigate();
1736
+ const { toggleNotification } = useNotification();
1737
+ const { _unstableFormatValidationErrors: formatValidationErrors } = useAPIErrorHandler();
1738
+ const cloneMatch = useMatch(CLONE_PATH);
1739
+ const isCloning = cloneMatch !== null;
1740
+ const { formatMessage } = useIntl();
1741
+ const { canCreate, canUpdate } = useDocumentRBAC("UpdateAction", ({ canCreate: canCreate2, canUpdate: canUpdate2 }) => ({
1742
+ canCreate: canCreate2,
1743
+ canUpdate: canUpdate2
1744
+ }));
1745
+ const { create, update, clone } = useDocumentActions();
1746
+ const [{ query, rawQuery }] = useQueryParams();
1747
+ const params = React.useMemo(() => buildValidParams(query), [query]);
1748
+ const isSubmitting = useForm("UpdateAction", ({ isSubmitting: isSubmitting2 }) => isSubmitting2);
1749
+ const modified = useForm("UpdateAction", ({ modified: modified2 }) => modified2);
1750
+ const setSubmitting = useForm("UpdateAction", ({ setSubmitting: setSubmitting2 }) => setSubmitting2);
1751
+ const document = useForm("UpdateAction", ({ values }) => values);
1752
+ const validate = useForm("UpdateAction", (state) => state.validate);
1753
+ const setErrors = useForm("UpdateAction", (state) => state.setErrors);
1754
+ 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(
1785
+ {
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}`,
1795
+ 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
+ },
1808
+ document
1809
+ );
1810
+ if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
1811
+ setErrors(formatValidationErrors(res.error));
1812
+ } else {
1813
+ resetForm();
1814
+ }
1815
+ } else {
1816
+ const res = await create(
1817
+ {
1818
+ model,
1819
+ params
1820
+ },
1821
+ document
1822
+ );
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
+ }
1831
+ }
1832
+ } finally {
1833
+ setSubmitting(false);
1834
+ }
1835
+ }
1836
+ };
1837
+ };
1838
+ UpdateAction.type = "update";
1839
+ const UNPUBLISH_DRAFT_OPTIONS = {
1840
+ KEEP: "keep",
1841
+ DISCARD: "discard"
1842
+ };
1843
+ const UnpublishAction$1 = ({
1844
+ activeTab,
1845
+ documentId,
1846
+ model,
1847
+ collectionType,
1848
+ document
1849
+ }) => {
1850
+ const { formatMessage } = useIntl();
1851
+ const { schema } = useDoc();
1852
+ const canPublish = useDocumentRBAC("UnpublishAction", ({ canPublish: canPublish2 }) => canPublish2);
1853
+ const { unpublish } = useDocumentActions();
1854
+ const [{ query }] = useQueryParams();
1855
+ const params = React.useMemo(() => buildValidParams(query), [query]);
1856
+ const { toggleNotification } = useNotification();
1857
+ const [shouldKeepDraft, setShouldKeepDraft] = React.useState(true);
1858
+ const isDocumentModified = document?.status === "modified";
1859
+ const handleChange = (value) => {
1860
+ setShouldKeepDraft(value === UNPUBLISH_DRAFT_OPTIONS.KEEP);
1861
+ };
1862
+ if (!schema?.options?.draftAndPublish) {
1863
+ return null;
1864
+ }
1865
+ return {
1866
+ disabled: !canPublish || activeTab === "published" || document?.status !== "published" && document?.status !== "modified",
1867
+ label: formatMessage({
1868
+ id: "app.utils.unpublish",
1869
+ defaultMessage: "Unpublish"
1870
+ }),
1871
+ icon: /* @__PURE__ */ jsx(StyledCrossCircle, {}),
1872
+ onClick: async () => {
1873
+ if (!documentId && collectionType !== SINGLE_TYPES || isDocumentModified) {
1874
+ if (!documentId) {
1875
+ console.error(
1876
+ "You're trying to unpublish a document without an id, this is likely a bug with Strapi. Please open an issue."
1877
+ );
1878
+ toggleNotification({
1879
+ message: formatMessage({
1880
+ id: "content-manager.actions.unpublish.error",
1881
+ defaultMessage: "An error occurred while trying to unpublish the document."
1882
+ }),
1883
+ type: "danger"
1884
+ });
1885
+ }
1886
+ return;
1887
+ }
1888
+ await unpublish({
1889
+ collectionType,
1890
+ model,
1891
+ documentId,
1892
+ params
1893
+ });
1894
+ },
1895
+ dialog: isDocumentModified ? {
1896
+ type: "dialog",
1897
+ title: formatMessage({
1898
+ id: "app.components.ConfirmDialog.title",
1899
+ defaultMessage: "Confirmation"
1900
+ }),
1901
+ content: /* @__PURE__ */ jsxs(Flex, { alignItems: "flex-start", direction: "column", gap: 6, children: [
1902
+ /* @__PURE__ */ jsxs(Flex, { width: "100%", direction: "column", gap: 2, children: [
1903
+ /* @__PURE__ */ jsx(WarningCircle, { width: "24px", height: "24px", fill: "danger600" }),
1904
+ /* @__PURE__ */ jsx(Typography, { tag: "p", variant: "omega", textAlign: "center", children: formatMessage({
1905
+ id: "content-manager.actions.unpublish.dialog.body",
1906
+ defaultMessage: "Are you sure?"
1907
+ }) })
1908
+ ] }),
1909
+ /* @__PURE__ */ jsxs(
1910
+ Radio.Group,
1911
+ {
1912
+ defaultValue: UNPUBLISH_DRAFT_OPTIONS.KEEP,
1913
+ name: "discard-options",
1914
+ "aria-label": formatMessage({
1915
+ id: "content-manager.actions.unpublish.dialog.radio-label",
1916
+ defaultMessage: "Choose an option to unpublish the document."
1917
+ }),
1918
+ onValueChange: handleChange,
1919
+ children: [
1920
+ /* @__PURE__ */ jsx(Radio.Item, { checked: shouldKeepDraft, value: UNPUBLISH_DRAFT_OPTIONS.KEEP, children: formatMessage({
1921
+ id: "content-manager.actions.unpublish.dialog.option.keep-draft",
1922
+ defaultMessage: "Keep draft"
1923
+ }) }),
1924
+ /* @__PURE__ */ jsx(Radio.Item, { checked: !shouldKeepDraft, value: UNPUBLISH_DRAFT_OPTIONS.DISCARD, children: formatMessage({
1925
+ id: "content-manager.actions.unpublish.dialog.option.replace-draft",
1926
+ defaultMessage: "Replace draft"
1927
+ }) })
1928
+ ]
1929
+ }
1930
+ )
1931
+ ] }),
1932
+ onConfirm: async () => {
1933
+ if (!documentId && collectionType !== SINGLE_TYPES) {
1934
+ console.error(
1935
+ "You're trying to unpublish a document without an id, this is likely a bug with Strapi. Please open an issue."
1936
+ );
1937
+ toggleNotification({
1938
+ message: formatMessage({
1939
+ id: "content-manager.actions.unpublish.error",
1940
+ defaultMessage: "An error occurred while trying to unpublish the document."
1941
+ }),
1942
+ type: "danger"
1943
+ });
1944
+ }
1945
+ await unpublish(
1946
+ {
1947
+ collectionType,
1948
+ model,
1949
+ documentId,
1950
+ params
1951
+ },
1952
+ !shouldKeepDraft
1953
+ );
1954
+ }
1955
+ } : void 0,
1956
+ variant: "danger",
1957
+ position: ["panel", "table-row"]
1958
+ };
1959
+ };
1960
+ UnpublishAction$1.type = "unpublish";
1961
+ const DiscardAction = ({
1962
+ activeTab,
1963
+ documentId,
1964
+ model,
1965
+ collectionType,
1966
+ document
1967
+ }) => {
1968
+ const { formatMessage } = useIntl();
1969
+ const { schema } = useDoc();
1970
+ const canUpdate = useDocumentRBAC("DiscardAction", ({ canUpdate: canUpdate2 }) => canUpdate2);
1971
+ const { discard } = useDocumentActions();
1972
+ const [{ query }] = useQueryParams();
1973
+ const params = React.useMemo(() => buildValidParams(query), [query]);
1974
+ if (!schema?.options?.draftAndPublish) {
1975
+ return null;
1976
+ }
1977
+ return {
1978
+ disabled: !canUpdate || activeTab === "published" || document?.status !== "modified",
1979
+ label: formatMessage({
1980
+ id: "content-manager.actions.discard.label",
1981
+ defaultMessage: "Discard changes"
1982
+ }),
1983
+ icon: /* @__PURE__ */ jsx(StyledCrossCircle, {}),
1984
+ position: ["panel", "table-row"],
1985
+ variant: "danger",
1986
+ dialog: {
1987
+ type: "dialog",
1988
+ title: formatMessage({
1989
+ id: "app.components.ConfirmDialog.title",
1990
+ defaultMessage: "Confirmation"
1991
+ }),
1992
+ content: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 2, children: [
1993
+ /* @__PURE__ */ jsx(WarningCircle, { width: "24px", height: "24px", fill: "danger600" }),
1994
+ /* @__PURE__ */ jsx(Typography, { tag: "p", variant: "omega", textAlign: "center", children: formatMessage({
1995
+ id: "content-manager.actions.discard.dialog.body",
1996
+ defaultMessage: "Are you sure?"
1997
+ }) })
1998
+ ] }),
1999
+ onConfirm: async () => {
2000
+ await discard({
2001
+ collectionType,
2002
+ model,
2003
+ documentId,
2004
+ params
2005
+ });
2006
+ }
2007
+ }
2008
+ };
2009
+ };
2010
+ DiscardAction.type = "discard";
2011
+ const StyledCrossCircle = styled(CrossCircle)`
2012
+ path {
2013
+ fill: currentColor;
2014
+ }
2015
+ `;
2016
+ const DEFAULT_ACTIONS = [PublishAction$1, UpdateAction, UnpublishAction$1, DiscardAction];
2017
+ const intervals = ["years", "months", "days", "hours", "minutes", "seconds"];
2018
+ const RelativeTime = React.forwardRef(
2019
+ ({ timestamp, customIntervals = [], ...restProps }, forwardedRef) => {
2020
+ const { formatRelativeTime, formatDate, formatTime } = useIntl();
2021
+ const interval = intervalToDuration({
2022
+ start: timestamp,
2023
+ end: Date.now()
2024
+ // see https://github.com/date-fns/date-fns/issues/2891 – No idea why it's all partial it returns it every time.
2025
+ });
2026
+ const unit = intervals.find((intervalUnit) => {
2027
+ return interval[intervalUnit] > 0 && Object.keys(interval).includes(intervalUnit);
2028
+ });
2029
+ const relativeTime = isPast(timestamp) ? -interval[unit] : interval[unit];
2030
+ const customInterval = customIntervals.find(
2031
+ (custom) => interval[custom.unit] < custom.threshold
2032
+ );
2033
+ const displayText = customInterval ? customInterval.text : formatRelativeTime(relativeTime, unit, { numeric: "auto" });
2034
+ return /* @__PURE__ */ jsx(
2035
+ "time",
2036
+ {
2037
+ ref: forwardedRef,
2038
+ dateTime: timestamp.toISOString(),
2039
+ role: "time",
2040
+ title: `${formatDate(timestamp)} ${formatTime(timestamp)}`,
2041
+ ...restProps,
2042
+ children: displayText
2043
+ }
2044
+ );
2045
+ }
2046
+ );
2047
+ const getDisplayName = ({
2048
+ firstname,
2049
+ lastname,
2050
+ username,
2051
+ email
2052
+ } = {}) => {
2053
+ if (username) {
2054
+ return username;
2055
+ }
2056
+ if (firstname) {
2057
+ return `${firstname} ${lastname ?? ""}`.trim();
2058
+ }
2059
+ return email ?? "";
2060
+ };
2061
+ 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) }) });
2065
+ };
2066
+ const Header = ({ isCreating, status, title: documentTitle = "Untitled" }) => {
2067
+ const { formatMessage } = useIntl();
2068
+ const isCloning = useMatch(CLONE_PATH) !== null;
2069
+ const title = isCreating ? formatMessage({
2070
+ id: "content-manager.containers.edit.title.new",
2071
+ defaultMessage: "Create an entry"
2072
+ }) : 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,
2077
+ {
2078
+ width: "100%",
2079
+ justifyContent: "space-between",
2080
+ paddingTop: 1,
2081
+ gap: "80px",
2082
+ alignItems: "flex-start",
2083
+ children: [
2084
+ /* @__PURE__ */ jsx(Typography, { variant: "alpha", tag: "h1", children: title }),
2085
+ /* @__PURE__ */ jsx(HeaderToolbar, {})
2086
+ ]
2087
+ }
2088
+ ),
2089
+ status ? /* @__PURE__ */ jsx(DocumentStatus, { status: isCloning ? "draft" : status }) : null
2090
+ ] });
2091
+ };
2092
+ const HeaderToolbar = () => {
2093
+ const { formatMessage } = useIntl();
2094
+ const isCloning = useMatch(CLONE_PATH) !== null;
2095
+ const [
2096
+ {
2097
+ query: { status = "draft" }
2098
+ }
2099
+ ] = useQueryParams();
2100
+ const { model, id, document, meta, collectionType } = useDoc();
2101
+ const plugins = useStrapiApp("HeaderToolbar", (state) => state.plugins);
2102
+ return /* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
2103
+ /* @__PURE__ */ jsx(
2104
+ DescriptionComponentRenderer,
2105
+ {
2106
+ props: {
2107
+ activeTab: status,
2108
+ model,
2109
+ documentId: id,
2110
+ document: isCloning ? void 0 : document,
2111
+ meta: isCloning ? void 0 : meta,
2112
+ collectionType
2113
+ },
2114
+ descriptions: plugins["content-manager"].apis.getHeaderActions(),
2115
+ children: (actions2) => {
2116
+ if (actions2.length > 0) {
2117
+ return /* @__PURE__ */ jsx(HeaderActions, { actions: actions2 });
2118
+ } else {
2119
+ return null;
2120
+ }
2121
+ }
2122
+ }
2123
+ ),
2124
+ /* @__PURE__ */ jsx(
2125
+ DescriptionComponentRenderer,
2126
+ {
2127
+ props: {
2128
+ activeTab: status,
2129
+ model,
2130
+ documentId: id,
2131
+ document: isCloning ? void 0 : document,
2132
+ meta: isCloning ? void 0 : meta,
2133
+ collectionType
2134
+ },
2135
+ descriptions: plugins["content-manager"].apis.getDocumentActions(),
2136
+ children: (actions2) => {
2137
+ const headerActions = actions2.filter((action) => {
2138
+ const positions = Array.isArray(action.position) ? action.position : [action.position];
2139
+ return positions.includes("header");
2140
+ });
2141
+ return /* @__PURE__ */ jsx(
2142
+ DocumentActionsMenu,
2143
+ {
2144
+ actions: headerActions,
2145
+ label: formatMessage({
2146
+ id: "content-manager.containers.edit.header.more-actions",
2147
+ defaultMessage: "More actions"
2148
+ }),
2149
+ children: /* @__PURE__ */ jsx(Information, { activeTab: status })
2150
+ }
2151
+ );
2152
+ }
2153
+ }
2154
+ )
2155
+ ] });
2156
+ };
2157
+ const Information = ({ activeTab }) => {
2158
+ const { formatMessage } = useIntl();
2159
+ const { document, meta } = useDoc();
2160
+ if (!document || !document.id) {
2161
+ return null;
2162
+ }
2163
+ const createAndUpdateDocument = activeTab === "draft" ? document : meta?.availableStatus.find((status) => status.publishedAt === null);
2164
+ const publishDocument = activeTab === "published" ? document : meta?.availableStatus.find((status) => status.publishedAt !== null);
2165
+ const creator = createAndUpdateDocument?.[CREATED_BY_ATTRIBUTE_NAME] ? getDisplayName(createAndUpdateDocument[CREATED_BY_ATTRIBUTE_NAME]) : null;
2166
+ const updator = createAndUpdateDocument?.[UPDATED_BY_ATTRIBUTE_NAME] ? getDisplayName(createAndUpdateDocument[UPDATED_BY_ATTRIBUTE_NAME]) : null;
2167
+ const information = [
2168
+ {
2169
+ isDisplayed: !!publishDocument?.[PUBLISHED_AT_ATTRIBUTE_NAME],
2170
+ label: formatMessage({
2171
+ id: "content-manager.containers.edit.information.last-published.label",
2172
+ defaultMessage: "Last published"
2173
+ }),
2174
+ value: formatMessage(
2175
+ {
2176
+ id: "content-manager.containers.edit.information.last-published.value",
2177
+ defaultMessage: `Published {time}{isAnonymous, select, true {} other { by {author}}}`
2178
+ },
2179
+ {
2180
+ time: /* @__PURE__ */ jsx(RelativeTime, { timestamp: new Date(publishDocument?.[PUBLISHED_AT_ATTRIBUTE_NAME]) }),
2181
+ isAnonymous: !publishDocument?.[PUBLISHED_BY_ATTRIBUTE_NAME],
2182
+ author: publishDocument?.[PUBLISHED_BY_ATTRIBUTE_NAME] ? getDisplayName(publishDocument?.[PUBLISHED_BY_ATTRIBUTE_NAME]) : null
2183
+ }
2184
+ )
2185
+ },
2186
+ {
2187
+ isDisplayed: !!createAndUpdateDocument?.[UPDATED_AT_ATTRIBUTE_NAME],
2188
+ label: formatMessage({
2189
+ id: "content-manager.containers.edit.information.last-draft.label",
2190
+ defaultMessage: "Last draft"
2191
+ }),
2192
+ value: formatMessage(
2193
+ {
2194
+ id: "content-manager.containers.edit.information.last-draft.value",
2195
+ defaultMessage: `Modified {time}{isAnonymous, select, true {} other { by {author}}}`
2196
+ },
2197
+ {
2198
+ time: /* @__PURE__ */ jsx(
2199
+ RelativeTime,
2200
+ {
2201
+ timestamp: new Date(createAndUpdateDocument?.[UPDATED_AT_ATTRIBUTE_NAME])
2202
+ }
2203
+ ),
2204
+ isAnonymous: !updator,
2205
+ author: updator
2206
+ }
2207
+ )
2208
+ },
2209
+ {
2210
+ isDisplayed: !!createAndUpdateDocument?.[CREATED_AT_ATTRIBUTE_NAME],
2211
+ label: formatMessage({
2212
+ id: "content-manager.containers.edit.information.document.label",
2213
+ defaultMessage: "Document"
2214
+ }),
2215
+ value: formatMessage(
2216
+ {
2217
+ id: "content-manager.containers.edit.information.document.value",
2218
+ defaultMessage: `Created {time}{isAnonymous, select, true {} other { by {author}}}`
2219
+ },
2220
+ {
2221
+ time: /* @__PURE__ */ jsx(
2222
+ RelativeTime,
2223
+ {
2224
+ timestamp: new Date(createAndUpdateDocument?.[CREATED_AT_ATTRIBUTE_NAME])
2225
+ }
2226
+ ),
2227
+ isAnonymous: !creator,
2228
+ author: creator
2229
+ }
2230
+ )
2231
+ }
2232
+ ].filter((info) => info.isDisplayed);
2233
+ return /* @__PURE__ */ jsx(
2234
+ Flex,
2235
+ {
2236
+ borderWidth: "1px 0 0 0",
2237
+ borderStyle: "solid",
2238
+ borderColor: "neutral150",
2239
+ direction: "column",
2240
+ marginTop: 2,
2241
+ tag: "dl",
2242
+ padding: 5,
2243
+ gap: 3,
2244
+ alignItems: "flex-start",
2245
+ marginLeft: "-0.4rem",
2246
+ marginRight: "-0.4rem",
2247
+ width: "calc(100% + 8px)",
2248
+ children: information.map((info) => /* @__PURE__ */ jsxs(Flex, { gap: 1, direction: "column", alignItems: "flex-start", children: [
2249
+ /* @__PURE__ */ jsx(Typography, { tag: "dt", variant: "pi", fontWeight: "bold", children: info.label }),
2250
+ /* @__PURE__ */ jsx(Typography, { tag: "dd", variant: "pi", textColor: "neutral600", children: info.value })
2251
+ ] }, info.label))
2252
+ }
2253
+ );
2254
+ };
2255
+ const HeaderActions = ({ actions: actions2 }) => {
2256
+ return /* @__PURE__ */ jsx(Flex, { children: actions2.map((action) => {
2257
+ if ("options" in action) {
2258
+ return /* @__PURE__ */ jsx(
2259
+ SingleSelect,
2260
+ {
2261
+ size: "S",
2262
+ disabled: action.disabled,
2263
+ "aria-label": action.label,
2264
+ onChange: action.onSelect,
2265
+ value: action.value,
2266
+ children: action.options.map(({ label, ...option }) => /* @__PURE__ */ jsx(SingleSelectOption, { ...option, children: label }, option.value))
2267
+ },
2268
+ action.id
2269
+ );
2270
+ } else {
2271
+ return null;
2272
+ }
2273
+ }) });
2274
+ };
2275
+ const ConfigureTheViewAction = ({ collectionType, model }) => {
2276
+ const navigate = useNavigate();
2277
+ const { formatMessage } = useIntl();
2278
+ return {
2279
+ label: formatMessage({
2280
+ id: "app.links.configure-view",
2281
+ defaultMessage: "Configure the view"
2282
+ }),
2283
+ icon: /* @__PURE__ */ jsx(ListPlus, {}),
2284
+ onClick: () => {
2285
+ navigate(`../${collectionType}/${model}/configurations/edit`);
2286
+ },
2287
+ position: "header"
2288
+ };
2289
+ };
2290
+ ConfigureTheViewAction.type = "configure-the-view";
2291
+ const EditTheModelAction = ({ model }) => {
2292
+ const navigate = useNavigate();
2293
+ const { formatMessage } = useIntl();
2294
+ return {
2295
+ label: formatMessage({
2296
+ id: "content-manager.link-to-ctb",
2297
+ defaultMessage: "Edit the model"
2298
+ }),
2299
+ icon: /* @__PURE__ */ jsx(Pencil, {}),
2300
+ onClick: () => {
2301
+ navigate(`/plugins/content-type-builder/content-types/${model}`);
2302
+ },
2303
+ position: "header"
2304
+ };
2305
+ };
2306
+ EditTheModelAction.type = "edit-the-model";
2307
+ const DeleteAction$1 = ({ documentId, model, collectionType, document }) => {
2308
+ const navigate = useNavigate();
2309
+ const { formatMessage } = useIntl();
2310
+ const listViewPathMatch = useMatch(LIST_PATH);
2311
+ const canDelete = useDocumentRBAC("DeleteAction", (state) => state.canDelete);
2312
+ const { delete: deleteAction } = useDocumentActions();
2313
+ const { toggleNotification } = useNotification();
2314
+ const setSubmitting = useForm("DeleteAction", (state) => state.setSubmitting);
2315
+ return {
2316
+ disabled: !canDelete || !document,
2317
+ label: formatMessage({
2318
+ id: "content-manager.actions.delete.label",
2319
+ defaultMessage: "Delete document"
2320
+ }),
2321
+ icon: /* @__PURE__ */ jsx(Trash, {}),
2322
+ dialog: {
2323
+ type: "dialog",
2324
+ title: formatMessage({
2325
+ id: "app.components.ConfirmDialog.title",
2326
+ defaultMessage: "Confirmation"
2327
+ }),
2328
+ content: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 2, children: [
2329
+ /* @__PURE__ */ jsx(WarningCircle, { width: "24px", height: "24px", fill: "danger600" }),
2330
+ /* @__PURE__ */ jsx(Typography, { tag: "p", variant: "omega", textAlign: "center", children: formatMessage({
2331
+ id: "content-manager.actions.delete.dialog.body",
2332
+ defaultMessage: "Are you sure?"
2333
+ }) })
2334
+ ] }),
2335
+ onConfirm: async () => {
2336
+ if (!listViewPathMatch) {
2337
+ setSubmitting(true);
2338
+ }
2339
+ try {
2340
+ if (!documentId && collectionType !== SINGLE_TYPES) {
2341
+ console.error(
2342
+ "You're trying to delete a document without an id, this is likely a bug with Strapi. Please open an issue."
2343
+ );
2344
+ toggleNotification({
2345
+ message: formatMessage({
2346
+ id: "content-manager.actions.delete.error",
2347
+ defaultMessage: "An error occurred while trying to delete the document."
2348
+ }),
2349
+ type: "danger"
2350
+ });
2351
+ return;
2352
+ }
2353
+ const res = await deleteAction({
2354
+ documentId,
2355
+ model,
2356
+ collectionType,
2357
+ params: {
2358
+ locale: "*"
2359
+ }
2360
+ });
2361
+ if (!("error" in res)) {
2362
+ navigate({ pathname: `../${collectionType}/${model}` }, { replace: true });
2363
+ }
2364
+ } finally {
2365
+ if (!listViewPathMatch) {
2366
+ setSubmitting(false);
2367
+ }
2368
+ }
2369
+ }
2370
+ },
2371
+ variant: "danger",
2372
+ position: ["header", "table-row"]
2373
+ };
2374
+ };
2375
+ DeleteAction$1.type = "delete";
2376
+ const DEFAULT_HEADER_ACTIONS = [EditTheModelAction, ConfigureTheViewAction, DeleteAction$1];
2377
+ const Panels = () => {
2378
+ const isCloning = useMatch(CLONE_PATH) !== null;
2379
+ const [
2380
+ {
2381
+ query: { status }
2382
+ }
2383
+ ] = useQueryParams({
2384
+ status: "draft"
2385
+ });
2386
+ const { model, id, document, meta, collectionType } = useDoc();
2387
+ const plugins = useStrapiApp("Panels", (state) => state.plugins);
2388
+ const props = {
2389
+ activeTab: status,
2390
+ model,
2391
+ documentId: id,
2392
+ document: isCloning ? void 0 : document,
2393
+ meta: isCloning ? void 0 : meta,
2394
+ collectionType
2395
+ };
2396
+ return /* @__PURE__ */ jsx(Flex, { direction: "column", alignItems: "stretch", gap: 2, children: /* @__PURE__ */ jsx(
2397
+ DescriptionComponentRenderer,
2398
+ {
2399
+ props,
2400
+ descriptions: plugins["content-manager"].apis.getEditViewSidePanels(),
2401
+ children: (panels) => panels.map(({ content, id: id2, ...description }) => /* @__PURE__ */ jsx(Panel, { ...description, children: content }, id2))
2402
+ }
2403
+ ) });
2404
+ };
2405
+ const ActionsPanel = () => {
2406
+ const { formatMessage } = useIntl();
2407
+ return {
2408
+ title: formatMessage({
2409
+ id: "content-manager.containers.edit.panels.default.title",
2410
+ defaultMessage: "Document"
2411
+ }),
2412
+ content: /* @__PURE__ */ jsx(ActionsPanelContent, {})
2413
+ };
2414
+ };
2415
+ ActionsPanel.type = "actions";
2416
+ const ActionsPanelContent = () => {
2417
+ const isCloning = useMatch(CLONE_PATH) !== null;
2418
+ const [
2419
+ {
2420
+ query: { status = "draft" }
2421
+ }
2422
+ ] = useQueryParams();
2423
+ const { model, id, document, meta, collectionType } = useDoc();
2424
+ const plugins = useStrapiApp("ActionsPanel", (state) => state.plugins);
2425
+ const props = {
2426
+ activeTab: status,
2427
+ model,
2428
+ documentId: id,
2429
+ document: isCloning ? void 0 : document,
2430
+ meta: isCloning ? void 0 : meta,
2431
+ collectionType
2432
+ };
2433
+ return /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 2, width: "100%", children: [
2434
+ /* @__PURE__ */ jsx(
2435
+ DescriptionComponentRenderer,
2436
+ {
2437
+ props,
2438
+ descriptions: plugins["content-manager"].apis.getDocumentActions(),
2439
+ children: (actions2) => /* @__PURE__ */ jsx(DocumentActions, { actions: actions2 })
2440
+ }
2441
+ ),
2442
+ /* @__PURE__ */ jsx(InjectionZone, { area: "editView.right-links", slug: model })
2443
+ ] });
2444
+ };
2445
+ const Panel = React.forwardRef(({ children, title }, ref) => {
2446
+ return /* @__PURE__ */ jsxs(
2447
+ Flex,
2448
+ {
2449
+ ref,
2450
+ tag: "aside",
2451
+ "aria-labelledby": "additional-information",
2452
+ background: "neutral0",
2453
+ borderColor: "neutral150",
2454
+ hasRadius: true,
2455
+ paddingBottom: 4,
2456
+ paddingLeft: 4,
2457
+ paddingRight: 4,
2458
+ paddingTop: 4,
2459
+ shadow: "tableShadow",
2460
+ gap: 3,
2461
+ direction: "column",
2462
+ justifyContent: "stretch",
2463
+ alignItems: "flex-start",
2464
+ children: [
2465
+ /* @__PURE__ */ jsx(Typography, { tag: "h2", variant: "sigma", textTransform: "uppercase", children: title }),
2466
+ children
2467
+ ]
2468
+ }
2469
+ );
2470
+ });
2471
+ const HOOKS = {
2472
+ /**
2473
+ * Hook that allows to mutate the displayed headers of the list view table
2474
+ * @constant
2475
+ * @type {string}
2476
+ */
2477
+ INJECT_COLUMN_IN_TABLE: "Admin/CM/pages/ListView/inject-column-in-table",
2478
+ /**
2479
+ * Hook that allows to mutate the CM's collection types links pre-set filters
2480
+ * @constant
2481
+ * @type {string}
2482
+ */
2483
+ MUTATE_COLLECTION_TYPES_LINKS: "Admin/CM/pages/App/mutate-collection-types-links",
2484
+ /**
2485
+ * Hook that allows to mutate the CM's edit view layout
2486
+ * @constant
2487
+ * @type {string}
2488
+ */
2489
+ MUTATE_EDIT_VIEW_LAYOUT: "Admin/CM/pages/EditView/mutate-edit-view-layout",
2490
+ /**
2491
+ * Hook that allows to mutate the CM's single types links pre-set filters
2492
+ * @constant
2493
+ * @type {string}
2494
+ */
2495
+ MUTATE_SINGLE_TYPES_LINKS: "Admin/CM/pages/App/mutate-single-types-links"
2496
+ };
2497
+ const contentTypesApi = contentManagerApi.injectEndpoints({
2498
+ endpoints: (builder) => ({
2499
+ getContentTypeConfiguration: builder.query({
2500
+ query: (uid) => ({
2501
+ url: `/content-manager/content-types/${uid}/configuration`,
2502
+ method: "GET"
2503
+ }),
2504
+ transformResponse: (response) => response.data,
2505
+ providesTags: (_result, _error, uid) => [
2506
+ { type: "ContentTypesConfiguration", id: uid },
2507
+ { type: "ContentTypeSettings", id: "LIST" }
2508
+ ]
2509
+ }),
2510
+ getAllContentTypeSettings: builder.query({
2511
+ query: () => "/content-manager/content-types-settings",
2512
+ transformResponse: (response) => response.data,
2513
+ providesTags: [{ type: "ContentTypeSettings", id: "LIST" }]
2514
+ }),
2515
+ updateContentTypeConfiguration: builder.mutation({
2516
+ query: ({ uid, ...body }) => ({
2517
+ url: `/content-manager/content-types/${uid}/configuration`,
2518
+ method: "PUT",
2519
+ data: body
2520
+ }),
2521
+ transformResponse: (response) => response.data,
2522
+ invalidatesTags: (_result, _error, { uid }) => [
2523
+ { type: "ContentTypesConfiguration", id: uid },
2524
+ { type: "ContentTypeSettings", id: "LIST" },
2525
+ // Is this necessary?
2526
+ { type: "InitialData" }
2527
+ ]
2528
+ })
2529
+ })
2530
+ });
2531
+ const {
2532
+ useGetContentTypeConfigurationQuery,
2533
+ useGetAllContentTypeSettingsQuery,
2534
+ useUpdateContentTypeConfigurationMutation
2535
+ } = contentTypesApi;
2536
+ const checkIfAttributeIsDisplayable = (attribute) => {
2537
+ const { type } = attribute;
2538
+ if (type === "relation") {
2539
+ return !attribute.relation.toLowerCase().includes("morph");
2540
+ }
2541
+ return !["json", "dynamiczone", "richtext", "password", "blocks"].includes(type) && !!type;
2542
+ };
2543
+ const getMainField = (attribute, mainFieldName, { schemas, components }) => {
2544
+ if (!mainFieldName) {
2545
+ return void 0;
2546
+ }
2547
+ const mainFieldType = attribute.type === "component" ? components[attribute.component].attributes[mainFieldName].type : (
2548
+ // @ts-expect-error – `targetModel` does exist on the attribute for a relation.
2549
+ schemas.find((schema) => schema.uid === attribute.targetModel)?.attributes[mainFieldName].type
2550
+ );
2551
+ return {
2552
+ name: mainFieldName,
2553
+ type: mainFieldType ?? "string"
2554
+ };
2555
+ };
2556
+ const DEFAULT_SETTINGS = {
2557
+ bulkable: false,
2558
+ filterable: false,
2559
+ searchable: false,
2560
+ pagination: false,
2561
+ defaultSortBy: "",
2562
+ defaultSortOrder: "asc",
2563
+ mainField: "id",
2564
+ pageSize: 10
2565
+ };
2566
+ const useDocumentLayout = (model) => {
2567
+ const { schema, components } = useDocument({ model, collectionType: "" }, { skip: true });
2568
+ const [{ query }] = useQueryParams();
2569
+ const runHookWaterfall = useStrapiApp("useDocumentLayout", (state) => state.runHookWaterfall);
2570
+ const { toggleNotification } = useNotification();
2571
+ const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();
2572
+ const { isLoading: isLoadingSchemas, schemas } = useContentTypeSchema();
2573
+ const {
2574
+ data,
2575
+ isLoading: isLoadingConfigs,
2576
+ error,
2577
+ isFetching: isFetchingConfigs
2578
+ } = useGetContentTypeConfigurationQuery(model);
2579
+ const isLoading = isLoadingSchemas || isFetchingConfigs || isLoadingConfigs;
2580
+ React.useEffect(() => {
2581
+ if (error) {
2582
+ toggleNotification({
2583
+ type: "danger",
2584
+ message: formatAPIError(error)
2585
+ });
2586
+ }
2587
+ }, [error, formatAPIError, toggleNotification]);
2588
+ const editLayout = React.useMemo(
2589
+ () => data && !isLoading ? formatEditLayout(data, { schemas, schema, components }) : {
2590
+ layout: [],
2591
+ components: {},
2592
+ metadatas: {},
2593
+ options: {},
2594
+ settings: DEFAULT_SETTINGS
2595
+ },
2596
+ [data, isLoading, schemas, schema, components]
2597
+ );
2598
+ const listLayout = React.useMemo(() => {
2599
+ return data && !isLoading ? formatListLayout(data, { schemas, schema, components }) : {
2600
+ layout: [],
2601
+ metadatas: {},
2602
+ options: {},
2603
+ settings: DEFAULT_SETTINGS
2604
+ };
2605
+ }, [data, isLoading, schemas, schema, components]);
2606
+ const { layout: edit } = React.useMemo(
2607
+ () => runHookWaterfall(HOOKS.MUTATE_EDIT_VIEW_LAYOUT, {
2608
+ layout: editLayout,
2609
+ query
2610
+ }),
2611
+ [editLayout, query, runHookWaterfall]
2612
+ );
2613
+ return {
2614
+ error,
2615
+ isLoading,
2616
+ edit,
2617
+ list: listLayout
2618
+ };
2619
+ };
2620
+ const useDocLayout = () => {
2621
+ const { model } = useDoc();
2622
+ return useDocumentLayout(model);
2623
+ };
2624
+ const formatEditLayout = (data, {
2625
+ schemas,
2626
+ schema,
2627
+ components
2628
+ }) => {
2629
+ let currentPanelIndex = 0;
2630
+ const panelledEditAttributes = convertEditLayoutToFieldLayouts(
2631
+ data.contentType.layouts.edit,
2632
+ schema?.attributes,
2633
+ data.contentType.metadatas,
2634
+ { configurations: data.components, schemas: components },
2635
+ schemas
2636
+ ).reduce((panels, row) => {
2637
+ if (row.some((field) => field.type === "dynamiczone")) {
2638
+ panels.push([row]);
2639
+ currentPanelIndex += 2;
2640
+ } else {
2641
+ if (!panels[currentPanelIndex]) {
2642
+ panels.push([]);
2643
+ }
2644
+ panels[currentPanelIndex].push(row);
2645
+ }
2646
+ return panels;
2647
+ }, []);
2648
+ const componentEditAttributes = Object.entries(data.components).reduce(
2649
+ (acc, [uid, configuration]) => {
2650
+ acc[uid] = {
2651
+ layout: convertEditLayoutToFieldLayouts(
2652
+ configuration.layouts.edit,
2653
+ components[uid].attributes,
2654
+ configuration.metadatas
2655
+ ),
2656
+ settings: {
2657
+ ...configuration.settings,
2658
+ icon: components[uid].info.icon,
2659
+ displayName: components[uid].info.displayName
2660
+ }
2661
+ };
2662
+ return acc;
2663
+ },
2664
+ {}
2665
+ );
2666
+ const editMetadatas = Object.entries(data.contentType.metadatas).reduce(
2667
+ (acc, [attribute, metadata]) => {
2668
+ return {
2669
+ ...acc,
2670
+ [attribute]: metadata.edit
2671
+ };
2672
+ },
2673
+ {}
2674
+ );
2675
+ return {
2676
+ layout: panelledEditAttributes,
2677
+ components: componentEditAttributes,
2678
+ metadatas: editMetadatas,
2679
+ settings: {
2680
+ ...data.contentType.settings,
2681
+ displayName: schema?.info.displayName
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
+ );
2719
+ };
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
+ );
2741
+ 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
+ }
2750
+ };
2751
+ };
2752
+ const convertListLayoutToFieldLayouts = (columns, attributes = {}, metadatas, components, schemas = []) => {
2753
+ return columns.map((name) => {
2754
+ const attribute = attributes[name];
2755
+ if (!attribute) {
2756
+ return null;
2757
+ }
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);
2772
+ };
2773
+ const ConfirmBulkActionDialog = ({
2774
+ onToggleDialog,
2775
+ isOpen = false,
2776
+ dialogBody,
2777
+ endAction
2778
+ }) => {
2779
+ const { formatMessage } = useIntl();
2780
+ return /* @__PURE__ */ jsx(Dialog.Root, { onOpenChange: onToggleDialog, open: isOpen, children: /* @__PURE__ */ jsxs(Dialog.Content, { children: [
2781
+ /* @__PURE__ */ jsx(Dialog.Header, { children: formatMessage({
2782
+ id: "app.components.ConfirmDialog.title",
2783
+ defaultMessage: "Confirmation"
2784
+ }) }),
2785
+ /* @__PURE__ */ jsx(Dialog.Body, { children: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
2786
+ /* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(WarningCircle, { width: "24px", height: "24px", fill: "danger600" }) }),
2787
+ dialogBody
2788
+ ] }) }),
2789
+ /* @__PURE__ */ jsxs(Dialog.Footer, { children: [
2790
+ /* @__PURE__ */ jsx(Dialog.Cancel, { children: /* @__PURE__ */ jsx(Button, { fullWidth: true, onClick: onToggleDialog, variant: "tertiary", children: formatMessage({
2791
+ id: "app.components.Button.cancel",
2792
+ defaultMessage: "Cancel"
2793
+ }) }) }),
2794
+ endAction
2795
+ ] })
2796
+ ] }) });
2797
+ };
2798
+ const BoldChunk$1 = (chunks) => /* @__PURE__ */ jsx(Typography, { fontWeight: "bold", children: chunks });
2799
+ const ConfirmDialogPublishAll = ({
2800
+ isOpen,
2801
+ onToggleDialog,
2802
+ isConfirmButtonLoading = false,
2803
+ onConfirm
2804
+ }) => {
2805
+ const { formatMessage } = useIntl();
2806
+ const selectedEntries = useTable("ConfirmDialogPublishAll", (state) => state.selectedRows);
2807
+ const { toggleNotification } = useNotification();
2808
+ const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler(getTranslation);
2809
+ const { model, schema } = useDoc();
2810
+ const [{ query }] = useQueryParams();
2811
+ const {
2812
+ data: countDraftRelations = 0,
2813
+ isLoading,
2814
+ error
2815
+ } = useGetManyDraftRelationCountQuery(
2816
+ {
2817
+ model,
2818
+ documentIds: selectedEntries.map((entry) => entry.documentId),
2819
+ locale: query?.plugins?.i18n?.locale
2820
+ },
2821
+ {
2822
+ skip: selectedEntries.length === 0
2823
+ }
2824
+ );
2825
+ React.useEffect(() => {
2826
+ if (error) {
2827
+ toggleNotification({ type: "danger", message: formatAPIError(error) });
2828
+ }
2829
+ }, [error, formatAPIError, toggleNotification]);
2830
+ if (error) {
2831
+ return null;
2832
+ }
2833
+ return /* @__PURE__ */ jsx(
2834
+ ConfirmBulkActionDialog,
2835
+ {
2836
+ isOpen: isOpen && !isLoading,
2837
+ onToggleDialog,
2838
+ dialogBody: /* @__PURE__ */ jsxs(Fragment, { children: [
2839
+ /* @__PURE__ */ jsxs(Typography, { id: "confirm-description", textAlign: "center", children: [
2840
+ countDraftRelations > 0 && formatMessage(
2841
+ {
2842
+ id: getTranslation(`popUpwarning.warning.bulk-has-draft-relations.message`),
2843
+ 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
+ },
2845
+ {
2846
+ b: BoldChunk$1,
2847
+ count: countDraftRelations,
2848
+ entities: selectedEntries.length
2849
+ }
2850
+ ),
2851
+ formatMessage({
2852
+ id: getTranslation("popUpWarning.bodyMessage.contentType.publish.all"),
2853
+ defaultMessage: "Are you sure you want to publish these entries?"
2854
+ })
2855
+ ] }),
2856
+ schema?.pluginOptions && "i18n" in schema.pluginOptions && schema?.pluginOptions.i18n && /* @__PURE__ */ jsx(Typography, { textColor: "danger500", textAlign: "center", children: formatMessage(
2857
+ {
2858
+ id: getTranslation("Settings.list.actions.publishAdditionalInfos"),
2859
+ defaultMessage: "This will publish the active locale versions <em>(from Internationalization)</em>"
2860
+ },
2861
+ {
2862
+ em: Emphasis
2863
+ }
2864
+ ) })
2865
+ ] }),
2866
+ endAction: /* @__PURE__ */ jsx(
2867
+ Button,
2868
+ {
2869
+ onClick: onConfirm,
2870
+ variant: "secondary",
2871
+ startIcon: /* @__PURE__ */ jsx(Check, {}),
2872
+ loading: isConfirmButtonLoading,
2873
+ children: formatMessage({
2874
+ id: "app.utils.publish",
2875
+ defaultMessage: "Publish"
2876
+ })
2877
+ }
2878
+ )
2879
+ }
2880
+ );
2881
+ };
2882
+ const TypographyMaxWidth = styled(Typography)`
2883
+ max-width: 300px;
2884
+ `;
2885
+ const formatErrorMessages = (errors, parentKey, formatMessage) => {
2886
+ const messages = [];
2887
+ Object.entries(errors).forEach(([key, value]) => {
2888
+ const currentKey = parentKey ? `${parentKey}.${key}` : key;
2889
+ if (typeof value === "object" && value !== null && !Array.isArray(value)) {
2890
+ if ("id" in value && "defaultMessage" in value) {
2891
+ messages.push(
2892
+ formatMessage(
2893
+ {
2894
+ id: `${value.id}.withField`,
2895
+ defaultMessage: value.defaultMessage
2896
+ },
2897
+ { field: currentKey }
2898
+ )
2899
+ );
2900
+ } else {
2901
+ messages.push(...formatErrorMessages(value, currentKey, formatMessage));
2902
+ }
2903
+ } else {
2904
+ messages.push(
2905
+ formatMessage(
2906
+ {
2907
+ id: `${value}.withField`,
2908
+ defaultMessage: value
2909
+ },
2910
+ { field: currentKey }
2911
+ )
2912
+ );
2913
+ }
2914
+ });
2915
+ return messages;
2916
+ };
2917
+ const EntryValidationText = ({ validationErrors, status }) => {
2918
+ const { formatMessage } = useIntl();
2919
+ if (validationErrors) {
2920
+ const validationErrorsMessages = formatErrorMessages(validationErrors, "", formatMessage).join(
2921
+ " "
2922
+ );
2923
+ return /* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
2924
+ /* @__PURE__ */ jsx(CrossCircle, { fill: "danger600" }),
2925
+ /* @__PURE__ */ jsx(Tooltip, { description: validationErrorsMessages, children: /* @__PURE__ */ jsx(TypographyMaxWidth, { textColor: "danger600", variant: "omega", fontWeight: "semiBold", ellipsis: true, children: validationErrorsMessages }) })
2926
+ ] });
2927
+ }
2928
+ if (status === "published") {
2929
+ return /* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
2930
+ /* @__PURE__ */ jsx(CheckCircle, { fill: "success600" }),
2931
+ /* @__PURE__ */ jsx(Typography, { textColor: "success600", fontWeight: "bold", children: formatMessage({
2932
+ id: "content-manager.bulk-publish.already-published",
2933
+ defaultMessage: "Already Published"
2934
+ }) })
2935
+ ] });
2936
+ }
2937
+ if (status === "modified") {
2938
+ return /* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
2939
+ /* @__PURE__ */ jsx(ArrowsCounterClockwise, { fill: "alternative600" }),
2940
+ /* @__PURE__ */ jsx(Typography, { children: formatMessage({
2941
+ id: "content-manager.bulk-publish.modified",
2942
+ defaultMessage: "Ready to publish changes"
2943
+ }) })
2944
+ ] });
2945
+ }
2946
+ return /* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
2947
+ /* @__PURE__ */ jsx(CheckCircle, { fill: "success600" }),
2948
+ /* @__PURE__ */ jsx(Typography, { children: formatMessage({
2949
+ id: "app.utils.ready-to-publish",
2950
+ defaultMessage: "Ready to publish"
2951
+ }) })
2952
+ ] });
2953
+ };
2954
+ const TABLE_HEADERS = [
2955
+ { name: "id", label: "id" },
2956
+ { name: "name", label: "name" },
2957
+ { name: "status", label: "status" },
2958
+ { name: "publicationStatus", label: "Publication status" }
2959
+ ];
2960
+ const SelectedEntriesTableContent = ({
2961
+ isPublishing,
2962
+ rowsToDisplay = [],
2963
+ entriesToPublish = [],
2964
+ validationErrors = {}
2965
+ }) => {
2966
+ const { pathname } = useLocation();
2967
+ const { formatMessage } = useIntl();
2968
+ const {
2969
+ list: {
2970
+ settings: { mainField }
2971
+ }
2972
+ } = useDocLayout();
2973
+ const shouldDisplayMainField = mainField != null && mainField !== "id";
2974
+ return /* @__PURE__ */ jsxs(Table.Content, { children: [
2975
+ /* @__PURE__ */ jsxs(Table.Head, { children: [
2976
+ /* @__PURE__ */ jsx(Table.HeaderCheckboxCell, {}),
2977
+ TABLE_HEADERS.filter((head) => head.name !== "name" || shouldDisplayMainField).map(
2978
+ (head) => /* @__PURE__ */ jsx(Table.HeaderCell, { ...head }, head.name)
2979
+ )
2980
+ ] }),
2981
+ /* @__PURE__ */ jsx(Table.Loading, {}),
2982
+ /* @__PURE__ */ jsx(Table.Body, { children: rowsToDisplay.map((row, index2) => /* @__PURE__ */ jsxs(Table.Row, { children: [
2983
+ /* @__PURE__ */ jsx(Table.CheckboxCell, { id: row.id }),
2984
+ /* @__PURE__ */ jsx(Table.Cell, { children: /* @__PURE__ */ jsx(Typography, { children: row.id }) }),
2985
+ shouldDisplayMainField && /* @__PURE__ */ jsx(Table.Cell, { children: /* @__PURE__ */ jsx(Typography, { children: row[mainField] }) }),
2986
+ /* @__PURE__ */ jsx(Table.Cell, { children: /* @__PURE__ */ jsx(DocumentStatus, { status: row.status, maxWidth: "min-content" }) }),
2987
+ /* @__PURE__ */ jsx(Table.Cell, { children: isPublishing && entriesToPublish.includes(row.documentId) ? /* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
2988
+ /* @__PURE__ */ jsx(Typography, { children: formatMessage({
2989
+ id: "content-manager.success.record.publishing",
2990
+ defaultMessage: "Publishing..."
2991
+ }) }),
2992
+ /* @__PURE__ */ jsx(Loader, { small: true })
2993
+ ] }) : /* @__PURE__ */ jsx(
2994
+ EntryValidationText,
2995
+ {
2996
+ validationErrors: validationErrors[row.documentId],
2997
+ status: row.status
2998
+ }
2999
+ ) }),
3000
+ /* @__PURE__ */ jsx(Table.Cell, { children: /* @__PURE__ */ jsx(
3001
+ IconButton,
3002
+ {
3003
+ tag: Link,
3004
+ to: {
3005
+ pathname: `${pathname}/${row.documentId}`,
3006
+ search: row.locale && `?plugins[i18n][locale]=${row.locale}`
3007
+ },
3008
+ 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
+ ),
3021
+ target: "_blank",
3022
+ marginLeft: "auto",
3023
+ children: /* @__PURE__ */ jsx(Pencil, {})
3024
+ }
3025
+ ) })
3026
+ ] }, row.id)) })
3027
+ ] });
3028
+ };
3029
+ const BoldChunk = (chunks) => /* @__PURE__ */ jsx(Typography, { fontWeight: "bold", children: chunks });
3030
+ const SelectedEntriesModalContent = ({
3031
+ listViewSelectedEntries,
3032
+ toggleModal,
3033
+ setListViewSelectedDocuments,
3034
+ model
3035
+ }) => {
3036
+ const { formatMessage } = useIntl();
3037
+ const { schema, components } = useContentTypeSchema(model);
3038
+ const documentIds = listViewSelectedEntries.map(({ documentId }) => documentId);
3039
+ const [{ query }] = useQueryParams();
3040
+ const params = React.useMemo(() => buildValidParams(query), [query]);
3041
+ const { data, isLoading, isFetching, refetch } = useGetAllDocumentsQuery(
3042
+ {
3043
+ model,
3044
+ params: {
3045
+ page: "1",
3046
+ pageSize: documentIds.length.toString(),
3047
+ sort: query.sort,
3048
+ filters: {
3049
+ documentId: {
3050
+ $in: documentIds
3051
+ }
3052
+ },
3053
+ locale: query.plugins?.i18n?.locale
3054
+ }
3055
+ },
3056
+ {
3057
+ selectFromResult: ({ data: data2, ...restRes }) => ({ data: data2?.results ?? [], ...restRes })
3058
+ }
3059
+ );
3060
+ const { rows, validationErrors } = React.useMemo(() => {
3061
+ if (data.length > 0 && schema) {
3062
+ const validate = createYupSchema(schema.attributes, components);
3063
+ const validationErrors2 = {};
3064
+ const rows2 = data.map((entry) => {
3065
+ try {
3066
+ validate.validateSync(entry, { abortEarly: false });
3067
+ return entry;
3068
+ } catch (e) {
3069
+ if (e instanceof ValidationError) {
3070
+ validationErrors2[entry.documentId] = getYupValidationErrors(e);
3071
+ }
3072
+ return entry;
3073
+ }
3074
+ });
3075
+ return { rows: rows2, validationErrors: validationErrors2 };
3076
+ }
3077
+ return {
3078
+ rows: [],
3079
+ validationErrors: {}
3080
+ };
3081
+ }, [components, data, schema]);
3082
+ const [publishedCount, setPublishedCount] = React.useState(0);
3083
+ const [isDialogOpen, setIsDialogOpen] = React.useState(false);
3084
+ const { publishMany: bulkPublishAction } = useDocumentActions();
3085
+ const [, { isLoading: isSubmittingForm }] = usePublishManyDocumentsMutation();
3086
+ const selectedRows = useTable("publishAction", (state) => state.selectedRows);
3087
+ const selectedEntries = rows.filter(
3088
+ (entry) => selectedRows.some((selectedEntry) => selectedEntry.documentId === entry.documentId)
3089
+ );
3090
+ const entriesToPublish = selectedEntries.filter((entry) => !validationErrors[entry.documentId]).map((entry) => entry.documentId);
3091
+ const selectedEntriesWithErrorsCount = selectedEntries.filter(
3092
+ ({ documentId }) => validationErrors[documentId]
3093
+ ).length;
3094
+ const selectedEntriesPublished = selectedEntries.filter(
3095
+ ({ status }) => status === "published"
3096
+ ).length;
3097
+ const selectedEntriesWithNoErrorsCount = selectedEntries.length - selectedEntriesWithErrorsCount - selectedEntriesPublished;
3098
+ const toggleDialog = () => setIsDialogOpen((prev) => !prev);
3099
+ const handleConfirmBulkPublish = async () => {
3100
+ toggleDialog();
3101
+ const res = await bulkPublishAction({ model, documentIds: entriesToPublish, params });
3102
+ if (!("error" in res)) {
3103
+ setPublishedCount(res.count);
3104
+ const unpublishedEntries = rows.filter((row) => {
3105
+ return !entriesToPublish.includes(row.documentId);
3106
+ });
3107
+ setListViewSelectedDocuments(unpublishedEntries);
3108
+ }
3109
+ };
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
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
3138
+ /* @__PURE__ */ jsxs(Modal.Body, { children: [
3139
+ /* @__PURE__ */ jsx(Typography, { children: getFormattedCountMessage() }),
3140
+ /* @__PURE__ */ jsx(Box, { marginTop: 5, children: /* @__PURE__ */ jsx(
3141
+ SelectedEntriesTableContent,
3142
+ {
3143
+ isPublishing: isSubmittingForm,
3144
+ rowsToDisplay: rows,
3145
+ entriesToPublish,
3146
+ validationErrors
3147
+ }
3148
+ ) })
3149
+ ] }),
3150
+ /* @__PURE__ */ jsxs(Modal.Footer, { children: [
3151
+ /* @__PURE__ */ jsx(Button, { onClick: toggleModal, variant: "tertiary", children: formatMessage({
3152
+ id: "app.components.Button.cancel",
3153
+ defaultMessage: "Cancel"
3154
+ }) }),
3155
+ /* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
3156
+ /* @__PURE__ */ jsx(Button, { onClick: refetch, variant: "tertiary", loading: isFetching, children: formatMessage({ id: "app.utils.refresh", defaultMessage: "Refresh" }) }),
3157
+ /* @__PURE__ */ jsx(
3158
+ Button,
3159
+ {
3160
+ onClick: toggleDialog,
3161
+ disabled: selectedEntries.length === 0 || selectedEntries.length === selectedEntriesWithErrorsCount || selectedEntriesPublished === selectedEntries.length || isLoading,
3162
+ loading: isSubmittingForm,
3163
+ children: formatMessage({ id: "app.utils.publish", defaultMessage: "Publish" })
3164
+ }
3165
+ )
3166
+ ] })
3167
+ ] }),
3168
+ /* @__PURE__ */ jsx(
3169
+ ConfirmDialogPublishAll,
3170
+ {
3171
+ isOpen: isDialogOpen,
3172
+ onToggleDialog: toggleDialog,
3173
+ isConfirmButtonLoading: isSubmittingForm,
3174
+ onConfirm: handleConfirmBulkPublish
3175
+ }
3176
+ )
3177
+ ] });
3178
+ };
3179
+ const PublishAction = ({ documents, model }) => {
3180
+ const { formatMessage } = useIntl();
3181
+ const hasPublishPermission = useDocumentRBAC("unpublishAction", (state) => state.canPublish);
3182
+ const showPublishButton = hasPublishPermission && documents.some(({ status }) => status !== "published");
3183
+ const setListViewSelectedDocuments = useTable("publishAction", (state) => state.selectRow);
3184
+ const refetchList = () => {
3185
+ contentManagerApi.util.invalidateTags([{ type: "Document", id: `${model}_LIST` }]);
3186
+ };
3187
+ if (!showPublishButton)
3188
+ return null;
3189
+ return {
3190
+ actionType: "publish",
3191
+ variant: "tertiary",
3192
+ label: formatMessage({ id: "app.utils.publish", defaultMessage: "Publish" }),
3193
+ dialog: {
3194
+ type: "modal",
3195
+ title: formatMessage({
3196
+ id: getTranslation("containers.ListPage.selectedEntriesModal.title"),
3197
+ defaultMessage: "Publish entries"
3198
+ }),
3199
+ content: ({ onClose }) => {
3200
+ return /* @__PURE__ */ jsx(Table.Root, { rows: documents, defaultSelectedRows: documents, headers: TABLE_HEADERS, children: /* @__PURE__ */ jsx(
3201
+ SelectedEntriesModalContent,
3202
+ {
3203
+ listViewSelectedEntries: documents,
3204
+ toggleModal: () => {
3205
+ onClose();
3206
+ refetchList();
3207
+ },
3208
+ setListViewSelectedDocuments,
3209
+ model
3210
+ }
3211
+ ) });
3212
+ },
3213
+ onClose: () => {
3214
+ refetchList();
3215
+ }
3216
+ }
3217
+ };
3218
+ };
3219
+ const BulkActionsRenderer = () => {
3220
+ const plugins = useStrapiApp("BulkActionsRenderer", (state) => state.plugins);
3221
+ const { model, collectionType } = useDoc();
3222
+ const { selectedRows } = useTable("BulkActionsRenderer", (state) => state);
3223
+ return /* @__PURE__ */ jsx(Flex, { gap: 2, children: /* @__PURE__ */ jsx(
3224
+ DescriptionComponentRenderer,
3225
+ {
3226
+ props: {
3227
+ model,
3228
+ collectionType,
3229
+ documents: selectedRows
3230
+ },
3231
+ descriptions: plugins["content-manager"].apis.getBulkActions(),
3232
+ children: (actions2) => actions2.map((action) => /* @__PURE__ */ jsx(DocumentActionButton, { ...action }, action.id))
3233
+ }
3234
+ ) });
3235
+ };
3236
+ const DeleteAction = ({ documents, model }) => {
3237
+ const { formatMessage } = useIntl();
3238
+ const { schema: contentType } = useDoc();
3239
+ const selectRow = useTable("DeleteAction", (state) => state.selectRow);
3240
+ const hasI18nEnabled = Boolean(contentType?.pluginOptions?.i18n);
3241
+ const [{ query }] = useQueryParams();
3242
+ const params = React.useMemo(() => buildValidParams(query), [query]);
3243
+ const hasDeletePermission = useDocumentRBAC("deleteAction", (state) => state.canDelete);
3244
+ const { deleteMany: bulkDeleteAction } = useDocumentActions();
3245
+ const documentIds = documents.map(({ documentId }) => documentId);
3246
+ const handleConfirmBulkDelete = async () => {
3247
+ const res = await bulkDeleteAction({
3248
+ documentIds,
3249
+ model,
3250
+ params
3251
+ });
3252
+ if (!("error" in res)) {
3253
+ selectRow([]);
3254
+ }
3255
+ };
3256
+ if (!hasDeletePermission)
3257
+ return null;
3258
+ return {
3259
+ variant: "danger-light",
3260
+ label: formatMessage({ id: "global.delete", defaultMessage: "Delete" }),
3261
+ dialog: {
3262
+ type: "dialog",
3263
+ title: formatMessage({
3264
+ id: "app.components.ConfirmDialog.title",
3265
+ defaultMessage: "Confirmation"
3266
+ }),
3267
+ content: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
3268
+ /* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(WarningCircle, { width: "24px", height: "24px", fill: "danger600" }) }),
3269
+ /* @__PURE__ */ jsx(Typography, { id: "confirm-description", textAlign: "center", children: formatMessage({
3270
+ id: "popUpWarning.bodyMessage.contentType.delete.all",
3271
+ defaultMessage: "Are you sure you want to delete these entries?"
3272
+ }) }),
3273
+ hasI18nEnabled && /* @__PURE__ */ jsx(Box, { textAlign: "center", padding: 3, children: /* @__PURE__ */ jsx(Typography, { textColor: "danger500", children: formatMessage(
3274
+ {
3275
+ id: getTranslation("Settings.list.actions.deleteAdditionalInfos"),
3276
+ defaultMessage: "This will delete the active locale versions <em>(from Internationalization)</em>"
3277
+ },
3278
+ {
3279
+ em: Emphasis
3280
+ }
3281
+ ) }) })
3282
+ ] }),
3283
+ onConfirm: handleConfirmBulkDelete
3284
+ }
3285
+ };
3286
+ };
3287
+ DeleteAction.type = "delete";
3288
+ const UnpublishAction = ({ documents, model }) => {
3289
+ const { formatMessage } = useIntl();
3290
+ const { schema } = useDoc();
3291
+ const selectRow = useTable("UnpublishAction", (state) => state.selectRow);
3292
+ const hasPublishPermission = useDocumentRBAC("unpublishAction", (state) => state.canPublish);
3293
+ const hasI18nEnabled = Boolean(schema?.pluginOptions?.i18n);
3294
+ const hasDraftAndPublishEnabled = Boolean(schema?.options?.draftAndPublish);
3295
+ const { unpublishMany: bulkUnpublishAction } = useDocumentActions();
3296
+ const documentIds = documents.map(({ documentId }) => documentId);
3297
+ const [{ query }] = useQueryParams();
3298
+ const params = React.useMemo(() => buildValidParams(query), [query]);
3299
+ const handleConfirmBulkUnpublish = async () => {
3300
+ const data = await bulkUnpublishAction({ documentIds, model, params });
3301
+ if (!("error" in data)) {
3302
+ selectRow([]);
3303
+ }
3304
+ };
3305
+ const showUnpublishButton = hasDraftAndPublishEnabled && hasPublishPermission && documents.some((entry) => entry.status === "published" || entry.status === "modified");
3306
+ if (!showUnpublishButton)
3307
+ return null;
3308
+ return {
3309
+ variant: "tertiary",
3310
+ label: formatMessage({ id: "app.utils.unpublish", defaultMessage: "Unpublish" }),
3311
+ dialog: {
3312
+ type: "dialog",
3313
+ title: formatMessage({
3314
+ id: "app.components.ConfirmDialog.title",
3315
+ defaultMessage: "Confirmation"
3316
+ }),
3317
+ content: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
3318
+ /* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(WarningCircle, { width: "24px", height: "24px", fill: "danger600" }) }),
3319
+ /* @__PURE__ */ jsx(Typography, { id: "confirm-description", textAlign: "center", children: formatMessage({
3320
+ id: "popUpWarning.bodyMessage.contentType.unpublish.all",
3321
+ defaultMessage: "Are you sure you want to unpublish these entries?"
3322
+ }) }),
3323
+ hasI18nEnabled && /* @__PURE__ */ jsx(Box, { textAlign: "center", padding: 3, children: /* @__PURE__ */ jsx(Typography, { textColor: "danger500", children: formatMessage(
3324
+ {
3325
+ id: getTranslation("Settings.list.actions.unpublishAdditionalInfos"),
3326
+ defaultMessage: "This will unpublish the active locale versions <em>(from Internationalization)</em>"
3327
+ },
3328
+ {
3329
+ em: Emphasis
3330
+ }
3331
+ ) }) })
3332
+ ] }),
3333
+ confirmButton: formatMessage({
3334
+ id: "app.utils.unpublish",
3335
+ defaultMessage: "Unpublish"
3336
+ }),
3337
+ onConfirm: handleConfirmBulkUnpublish
3338
+ }
3339
+ };
3340
+ };
3341
+ UnpublishAction.type = "unpublish";
3342
+ const Emphasis = (chunks) => /* @__PURE__ */ jsx(Typography, { fontWeight: "semiBold", textColor: "danger500", children: chunks });
3343
+ const DEFAULT_BULK_ACTIONS = [PublishAction, UnpublishAction, DeleteAction];
3344
+ const AutoCloneFailureModalBody = ({ prohibitedFields }) => {
3345
+ const { formatMessage } = useIntl();
3346
+ const getDefaultErrorMessage = (reason) => {
3347
+ switch (reason) {
3348
+ case "relation":
3349
+ return "Duplicating the relation could remove it from the original entry.";
3350
+ case "unique":
3351
+ return "Identical values in a unique field are not allowed";
3352
+ default:
3353
+ return reason;
3354
+ }
3355
+ };
3356
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
3357
+ /* @__PURE__ */ jsx(Typography, { variant: "beta", children: formatMessage({
3358
+ id: getTranslation("containers.list.autoCloneModal.title"),
3359
+ defaultMessage: "This entry can't be duplicated directly."
3360
+ }) }),
3361
+ /* @__PURE__ */ jsx(Box, { marginTop: 2, children: /* @__PURE__ */ jsx(Typography, { textColor: "neutral600", children: formatMessage({
3362
+ id: getTranslation("containers.list.autoCloneModal.description"),
3363
+ defaultMessage: "A new entry will be created with the same content, but you'll have to change the following fields to save it."
3364
+ }) }) }),
3365
+ /* @__PURE__ */ jsx(Flex, { marginTop: 6, gap: 2, direction: "column", alignItems: "stretch", children: prohibitedFields.map(([fieldPath, reason]) => /* @__PURE__ */ jsxs(
3366
+ Flex,
3367
+ {
3368
+ direction: "column",
3369
+ gap: 2,
3370
+ alignItems: "flex-start",
3371
+ borderColor: "neutral200",
3372
+ hasRadius: true,
3373
+ padding: 6,
3374
+ children: [
3375
+ /* @__PURE__ */ jsx(Flex, { direction: "row", tag: "ol", children: fieldPath.map((pathSegment, index2) => /* @__PURE__ */ jsxs(Typography, { fontWeight: "semiBold", tag: "li", children: [
3376
+ pathSegment,
3377
+ index2 !== fieldPath.length - 1 && /* @__PURE__ */ jsx(
3378
+ ChevronRight,
3379
+ {
3380
+ fill: "neutral500",
3381
+ height: "0.8rem",
3382
+ width: "0.8rem",
3383
+ style: { margin: "0 0.8rem" }
3384
+ }
3385
+ )
3386
+ ] }, index2)) }),
3387
+ /* @__PURE__ */ jsx(Typography, { tag: "p", textColor: "neutral600", children: formatMessage({
3388
+ id: getTranslation(`containers.list.autoCloneModal.error.${reason}`),
3389
+ defaultMessage: getDefaultErrorMessage(reason)
3390
+ }) })
3391
+ ]
3392
+ },
3393
+ fieldPath.join()
3394
+ )) })
3395
+ ] });
3396
+ };
3397
+ const TableActions = ({ document }) => {
3398
+ const { formatMessage } = useIntl();
3399
+ const { model, collectionType } = useDoc();
3400
+ const plugins = useStrapiApp("TableActions", (state) => state.plugins);
3401
+ const props = {
3402
+ activeTab: null,
3403
+ model,
3404
+ documentId: document.documentId,
3405
+ collectionType,
3406
+ document
3407
+ };
3408
+ return /* @__PURE__ */ jsx(
3409
+ DescriptionComponentRenderer,
3410
+ {
3411
+ props,
3412
+ descriptions: plugins["content-manager"].apis.getDocumentActions(),
3413
+ children: (actions2) => {
3414
+ const tableRowActions = actions2.filter((action) => {
3415
+ const positions = Array.isArray(action.position) ? action.position : [action.position];
3416
+ return positions.includes("table-row");
3417
+ });
3418
+ return /* @__PURE__ */ jsx(
3419
+ DocumentActionsMenu,
3420
+ {
3421
+ actions: tableRowActions,
3422
+ label: formatMessage({
3423
+ id: "content-manager.containers.list.table.row-actions",
3424
+ defaultMessage: "Row action"
3425
+ }),
3426
+ variant: "ghost"
3427
+ }
3428
+ );
3429
+ }
3430
+ }
3431
+ );
3432
+ };
3433
+ const EditAction = ({ documentId }) => {
3434
+ const navigate = useNavigate();
3435
+ const { formatMessage } = useIntl();
3436
+ const { canRead } = useDocumentRBAC("EditAction", ({ canRead: canRead2 }) => ({ canRead: canRead2 }));
3437
+ const { toggleNotification } = useNotification();
3438
+ const [{ query }] = useQueryParams();
3439
+ return {
3440
+ disabled: !canRead,
3441
+ icon: /* @__PURE__ */ jsx(StyledPencil, {}),
3442
+ label: formatMessage({
3443
+ id: "content-manager.actions.edit.label",
3444
+ defaultMessage: "Edit"
3445
+ }),
3446
+ position: "table-row",
3447
+ onClick: async () => {
3448
+ if (!documentId) {
3449
+ console.error(
3450
+ "You're trying to edit a document without an id, this is likely a bug with Strapi. Please open an issue."
3451
+ );
3452
+ toggleNotification({
3453
+ message: formatMessage({
3454
+ id: "content-manager.actions.edit.error",
3455
+ defaultMessage: "An error occurred while trying to edit the document."
3456
+ }),
3457
+ type: "danger"
3458
+ });
3459
+ return;
3460
+ }
3461
+ navigate({
3462
+ pathname: documentId,
3463
+ search: stringify({
3464
+ plugins: query.plugins
3465
+ })
3466
+ });
3467
+ }
3468
+ };
3469
+ };
3470
+ EditAction.type = "edit";
3471
+ const StyledPencil = styled(Pencil)`
3472
+ path {
3473
+ fill: currentColor;
3474
+ }
3475
+ `;
3476
+ const CloneAction = ({ model, documentId }) => {
3477
+ const navigate = useNavigate();
3478
+ const { formatMessage } = useIntl();
3479
+ const { canCreate } = useDocumentRBAC("CloneAction", ({ canCreate: canCreate2 }) => ({ canCreate: canCreate2 }));
3480
+ const { toggleNotification } = useNotification();
3481
+ const { autoClone } = useDocumentActions();
3482
+ const [prohibitedFields, setProhibitedFields] = React.useState([]);
3483
+ return {
3484
+ disabled: !canCreate,
3485
+ icon: /* @__PURE__ */ jsx(StyledDuplicate, {}),
3486
+ label: formatMessage({
3487
+ id: "content-manager.actions.clone.label",
3488
+ defaultMessage: "Duplicate"
3489
+ }),
3490
+ position: "table-row",
3491
+ onClick: async () => {
3492
+ if (!documentId) {
3493
+ console.error(
3494
+ "You're trying to clone a document in the table without an id, this is likely a bug with Strapi. Please open an issue."
3495
+ );
3496
+ toggleNotification({
3497
+ message: formatMessage({
3498
+ id: "content-manager.actions.clone.error",
3499
+ defaultMessage: "An error occurred while trying to clone the document."
3500
+ }),
3501
+ type: "danger"
3502
+ });
3503
+ return;
3504
+ }
3505
+ const res = await autoClone({ model, sourceId: documentId });
3506
+ if ("data" in res) {
3507
+ navigate(res.data.documentId);
3508
+ return true;
3509
+ }
3510
+ if (isBaseQueryError(res.error) && res.error.details && typeof res.error.details === "object" && "prohibitedFields" in res.error.details && Array.isArray(res.error.details.prohibitedFields)) {
3511
+ const prohibitedFields2 = res.error.details.prohibitedFields;
3512
+ setProhibitedFields(prohibitedFields2);
3513
+ }
3514
+ },
3515
+ dialog: {
3516
+ type: "modal",
3517
+ title: formatMessage({
3518
+ id: "content-manager.containers.list.autoCloneModal.header",
3519
+ defaultMessage: "Duplicate"
3520
+ }),
3521
+ content: /* @__PURE__ */ jsx(AutoCloneFailureModalBody, { prohibitedFields }),
3522
+ footer: ({ onClose }) => {
3523
+ return /* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", children: [
3524
+ /* @__PURE__ */ jsx(Button, { onClick: onClose, variant: "tertiary", children: formatMessage({
3525
+ id: "cancel",
3526
+ defaultMessage: "Cancel"
3527
+ }) }),
3528
+ /* @__PURE__ */ jsx(
3529
+ LinkButton,
3530
+ {
3531
+ tag: NavLink,
3532
+ to: {
3533
+ pathname: `clone/${documentId}`
3534
+ },
3535
+ children: formatMessage({
3536
+ id: "content-manager.containers.list.autoCloneModal.create",
3537
+ defaultMessage: "Create"
3538
+ })
3539
+ }
3540
+ )
3541
+ ] });
3542
+ }
3543
+ }
3544
+ };
3545
+ };
3546
+ CloneAction.type = "clone";
3547
+ const StyledDuplicate = styled(Duplicate)`
3548
+ path {
3549
+ fill: currentColor;
3550
+ }
3551
+ `;
3552
+ const DEFAULT_TABLE_ROW_ACTIONS = [EditAction, CloneAction];
3553
+ class ContentManagerPlugin {
3554
+ /**
3555
+ * The following properties are the stored ones provided by any plugins registering with
3556
+ * the content-manager. The function calls however, need to be called at runtime in the
3557
+ * application, so instead we collate them and run them later with the complete list incl.
3558
+ * ones already registered & the context of the view.
3559
+ */
3560
+ bulkActions = [...DEFAULT_BULK_ACTIONS];
3561
+ documentActions = [
3562
+ ...DEFAULT_ACTIONS,
3563
+ ...DEFAULT_TABLE_ROW_ACTIONS,
3564
+ ...DEFAULT_HEADER_ACTIONS,
3565
+ HistoryAction
3566
+ ];
3567
+ editViewSidePanels = [ActionsPanel];
3568
+ headerActions = [];
3569
+ constructor() {
3570
+ }
3571
+ addEditViewSidePanel(panels) {
3572
+ if (Array.isArray(panels)) {
3573
+ this.editViewSidePanels = [...this.editViewSidePanels, ...panels];
3574
+ } else if (typeof panels === "function") {
3575
+ this.editViewSidePanels = panels(this.editViewSidePanels);
3576
+ } else {
3577
+ throw new Error(
3578
+ `Expected the \`panels\` passed to \`addEditViewSidePanel\` to be an array or a function, but received ${getPrintableType(
3579
+ panels
3580
+ )}`
3581
+ );
3582
+ }
3583
+ }
3584
+ addDocumentAction(actions2) {
3585
+ if (Array.isArray(actions2)) {
3586
+ this.documentActions = [...this.documentActions, ...actions2];
3587
+ } else if (typeof actions2 === "function") {
3588
+ this.documentActions = actions2(this.documentActions);
3589
+ } else {
3590
+ throw new Error(
3591
+ `Expected the \`actions\` passed to \`addDocumentAction\` to be an array or a function, but received ${getPrintableType(
3592
+ actions2
3593
+ )}`
3594
+ );
3595
+ }
3596
+ }
3597
+ addDocumentHeaderAction(actions2) {
3598
+ if (Array.isArray(actions2)) {
3599
+ this.headerActions = [...this.headerActions, ...actions2];
3600
+ } else if (typeof actions2 === "function") {
3601
+ this.headerActions = actions2(this.headerActions);
3602
+ } else {
3603
+ throw new Error(
3604
+ `Expected the \`actions\` passed to \`addDocumentHeaderAction\` to be an array or a function, but received ${getPrintableType(
3605
+ actions2
3606
+ )}`
3607
+ );
3608
+ }
3609
+ }
3610
+ addBulkAction(actions2) {
3611
+ if (Array.isArray(actions2)) {
3612
+ this.bulkActions = [...this.bulkActions, ...actions2];
3613
+ } else if (typeof actions2 === "function") {
3614
+ this.bulkActions = actions2(this.bulkActions);
3615
+ } else {
3616
+ throw new Error(
3617
+ `Expected the \`actions\` passed to \`addBulkAction\` to be an array or a function, but received ${getPrintableType(
3618
+ actions2
3619
+ )}`
3620
+ );
3621
+ }
3622
+ }
3623
+ get config() {
3624
+ return {
3625
+ id: PLUGIN_ID,
3626
+ name: "Content Manager",
3627
+ injectionZones: INJECTION_ZONES,
3628
+ apis: {
3629
+ addBulkAction: this.addBulkAction.bind(this),
3630
+ addDocumentAction: this.addDocumentAction.bind(this),
3631
+ addDocumentHeaderAction: this.addDocumentHeaderAction.bind(this),
3632
+ addEditViewSidePanel: this.addEditViewSidePanel.bind(this),
3633
+ getBulkActions: () => this.bulkActions,
3634
+ getDocumentActions: () => this.documentActions,
3635
+ getEditViewSidePanels: () => this.editViewSidePanels,
3636
+ getHeaderActions: () => this.headerActions
3637
+ }
3638
+ };
3639
+ }
3640
+ }
3641
+ const getPrintableType = (value) => {
3642
+ const nativeType = typeof value;
3643
+ if (nativeType === "object") {
3644
+ if (value === null)
3645
+ return "null";
3646
+ if (Array.isArray(value))
3647
+ return "array";
3648
+ if (value instanceof Object && value.constructor.name !== "Object") {
3649
+ return value.constructor.name;
3650
+ }
3651
+ }
3652
+ return nativeType;
3653
+ };
3654
+ const initialState = {
3655
+ collectionTypeLinks: [],
3656
+ components: [],
3657
+ fieldSizes: {},
3658
+ models: [],
3659
+ singleTypeLinks: [],
3660
+ isLoading: true
3661
+ };
3662
+ const appSlice = createSlice({
3663
+ name: "app",
3664
+ initialState,
3665
+ reducers: {
3666
+ setInitialData(state, action) {
3667
+ const {
3668
+ authorizedCollectionTypeLinks,
3669
+ authorizedSingleTypeLinks,
3670
+ components,
3671
+ contentTypeSchemas,
3672
+ fieldSizes
3673
+ } = action.payload;
3674
+ state.collectionTypeLinks = authorizedCollectionTypeLinks.filter(
3675
+ ({ isDisplayed }) => isDisplayed
3676
+ );
3677
+ state.singleTypeLinks = authorizedSingleTypeLinks.filter(({ isDisplayed }) => isDisplayed);
3678
+ state.components = components;
3679
+ state.models = contentTypeSchemas;
3680
+ state.fieldSizes = fieldSizes;
3681
+ state.isLoading = false;
3682
+ }
3683
+ }
3684
+ });
3685
+ const { actions, reducer: reducer$1 } = appSlice;
3686
+ const { setInitialData } = actions;
3687
+ const reducer = combineReducers({
3688
+ app: reducer$1
3689
+ });
3690
+ const index = {
3691
+ register(app) {
3692
+ const cm = new ContentManagerPlugin();
3693
+ app.addReducers({
3694
+ [PLUGIN_ID]: reducer
3695
+ });
3696
+ app.addMenuLink({
3697
+ to: PLUGIN_ID,
3698
+ icon: Feather,
3699
+ intlLabel: {
3700
+ id: `content-manager.plugin.name`,
3701
+ defaultMessage: "Content Manager"
3702
+ },
3703
+ permissions: [],
3704
+ Component: () => import("./layout-BybbePH7.mjs").then((mod) => ({ default: mod.Layout })),
3705
+ position: 1
3706
+ });
3707
+ app.registerPlugin(cm.config);
3708
+ },
3709
+ async registerTrads({ locales }) {
3710
+ const importedTrads = await Promise.all(
3711
+ locales.map((locale) => {
3712
+ 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 }) => {
3713
+ return {
3714
+ data: prefixPluginTranslations(data, PLUGIN_ID),
3715
+ locale
3716
+ };
3717
+ }).catch(() => {
3718
+ return {
3719
+ data: {},
3720
+ locale
3721
+ };
3722
+ });
3723
+ })
3724
+ );
3725
+ return Promise.resolve(importedTrads);
3726
+ }
3727
+ };
3728
+ export {
3729
+ ATTRIBUTE_TYPES_THAT_CANNOT_BE_MAIN_FIELD as A,
3730
+ BulkActionsRenderer as B,
3731
+ COLLECTION_TYPES as C,
3732
+ DocumentStatus as D,
3733
+ extractContentTypeComponents as E,
3734
+ DEFAULT_SETTINGS as F,
3735
+ convertEditLayoutToFieldLayouts as G,
3736
+ HOOKS as H,
3737
+ InjectionZone as I,
3738
+ useDocument as J,
3739
+ index as K,
3740
+ useDocumentActions as L,
3741
+ Panels as P,
3742
+ RelativeTime as R,
3743
+ SINGLE_TYPES as S,
3744
+ TableActions as T,
3745
+ useGetInitialDataQuery as a,
3746
+ useGetAllContentTypeSettingsQuery as b,
3747
+ useDoc as c,
3748
+ buildValidParams as d,
3749
+ contentManagerApi as e,
3750
+ useDocumentRBAC as f,
3751
+ getTranslation as g,
3752
+ useDocumentLayout as h,
3753
+ createYupSchema as i,
3754
+ Header as j,
3755
+ PERMISSIONS as k,
3756
+ DocumentRBAC as l,
3757
+ DOCUMENT_META_FIELDS as m,
3758
+ useDocLayout as n,
3759
+ useGetContentTypeConfigurationQuery as o,
3760
+ CREATOR_FIELDS as p,
3761
+ getMainField as q,
3762
+ routes as r,
3763
+ setInitialData as s,
3764
+ getDisplayName as t,
3765
+ useContentTypeSchema as u,
3766
+ checkIfAttributeIsDisplayable as v,
3767
+ useGetAllDocumentsQuery as w,
3768
+ convertListLayoutToFieldLayouts as x,
3769
+ capitalise as y,
3770
+ useUpdateContentTypeConfigurationMutation as z
3771
+ };
3772
+ //# sourceMappingURL=index-BAGok3Xa.mjs.map