@strapi/content-manager 0.0.0-experimental.e14656d3b8681880212c13260b9a2b340c182f2d → 0.0.0-experimental.e576af447d9f97e89e24c6daa32d8f714376cd5f

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