@strapi/content-manager 0.0.0-next.b0db56479de441dfe8feb37a43c7f6f6fecf75c1 → 0.0.0-next.b4e84114b7bd2b58e34af3f2a7febca9845e6f86

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