@strapi/content-manager 0.0.0-experimental.baa6cf22298e591b4d52d8e59c60406d7a9f137f → 0.0.0-experimental.bd3419429b8caba37ca42ac08edb57cd4b5e1c47

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