@strapi/content-manager 0.0.0-experimental.78b47df46708173ab4833373f694257729db4b9e → 0.0.0-experimental.7b579e6415ea4434ccb2c2aa52a86b67ff2e7a64

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