@strapi/content-manager 0.0.0-experimental.2cfaca2410c03f1dee31ca18c06aedfb313e0fb4 → 0.0.0-experimental.2f08d92b24a4731a9b10bae850bce95a2eb7340e

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