@strapi/content-manager 0.0.0-experimental.e02b4637b3906c6d31048d00600d09a23a0edc3d → 0.0.0-experimental.e12978dcee698470990e9c5c63384faf2c307443

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