@strapi/content-manager 0.0.0-next.64bd4f3d1efcc9420d27c4f4d2013677ded62360 → 0.0.0-next.6d1dbc97a99dbfe8847598f6cbea3f7a1df2c89c

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