@strapi/content-manager 0.0.0-next.b558642be856459a3e6c076f5d76fffbfc5fc5a1 → 0.0.0-next.b8a93ec6cfca2f18075819bb617db6bca123b8e2

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