@strapi/content-manager 0.0.0-experimental.bd712ad3930045f4a5d2144c119e0b7856e97fc4 → 0.0.0-experimental.be7746d32e70ba7219186219896ff4ae64735740

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