@strapi/content-manager 0.0.0-next.64bd4f3d1efcc9420d27c4f4d2013677ded62360 → 0.0.0-next.6d1dbc97a99dbfe8847598f6cbea3f7a1df2c89c

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