@strapi/content-manager 0.0.0-experimental.cb311d9fcfbd8e441f790aea232f0a39bdd90e16 → 0.0.0-experimental.cbffd35b6dcd522ced2dc08f13ce2c2ec983514b

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