@strapi/content-manager 0.0.0-experimental.dd3311938ac827f1fa8560c8840a9a394f5896c0 → 0.0.0-experimental.ddb35414098c2a2816cae28a6abd5be1c4d8a58a

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