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