@strapi/content-manager 5.8.1 → 5.10.0

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