@strapi/content-manager 0.0.0-experimental.e9122b401c96877b6707775c4f893660eab93ae3 → 0.0.0-experimental.eb2d102c03f0984bece7258f6e0e8ab9ee39c82d

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