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