@strapi/content-manager 0.0.0-experimental.abc → 0.0.0-experimental.abcfb5ddb536afe8e2213d4a4508536549e89f16

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