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

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