@strapi/content-manager 0.0.0-experimental.745741d19e90275ca6f7c928ca19f9bb0fd9d933 → 0.0.0-experimental.75b9c6babc2f67877cfc879041cfff9fb966e742

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