@strapi/content-manager 0.0.0-experimental.abc → 0.0.0-experimental.abcfb5ddb536afe8e2213d4a4508536549e89f16

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