@strapi/content-manager 0.0.0-experimental.e9122b401c96877b6707775c4f893660eab93ae3 → 0.0.0-experimental.e9144fc8a193f9875a2c0832d689c14001c79f00

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