@strapi/content-manager 0.0.0-experimental.9612538209f3c68285c5dea8fe26f96e7e470afd → 0.0.0-experimental.9678892591ed5d28450369e1511b3d21cb7db4f9

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