@strapi/content-manager 5.9.0 → 5.10.1

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