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