@strapi/content-manager 0.0.0-experimental.60f3ded53a22a24d208ebf6df9b84c118aa97abf → 0.0.0-experimental.614aaf36aaf7e94667b876f02949c3651d9715da

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