@strapi/i18n 0.0.0-next.973df62640087231761ffaeb1c2b5d0d706346d8 → 0.0.0-next.9c630ba4333dffc2c1c8150d9226dfbb67b02e09

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 (458) hide show
  1. package/dist/admin/components/BulkLocaleActionModal.js +262 -0
  2. package/dist/admin/components/BulkLocaleActionModal.js.map +1 -0
  3. package/dist/admin/components/BulkLocaleActionModal.mjs +260 -0
  4. package/dist/admin/components/BulkLocaleActionModal.mjs.map +1 -0
  5. package/dist/admin/components/CMHeaderActions.js +957 -0
  6. package/dist/admin/components/CMHeaderActions.js.map +1 -0
  7. package/dist/admin/components/CMHeaderActions.mjs +931 -0
  8. package/dist/admin/components/CMHeaderActions.mjs.map +1 -0
  9. package/dist/admin/components/CMListViewModalsAdditionalInformation.js +69 -0
  10. package/dist/admin/components/CMListViewModalsAdditionalInformation.js.map +1 -0
  11. package/dist/admin/components/CMListViewModalsAdditionalInformation.mjs +65 -0
  12. package/dist/admin/components/CMListViewModalsAdditionalInformation.mjs.map +1 -0
  13. package/dist/admin/components/CheckboxConfirmation.js +155 -0
  14. package/dist/admin/components/CheckboxConfirmation.js.map +1 -0
  15. package/dist/admin/components/CheckboxConfirmation.mjs +134 -0
  16. package/dist/admin/components/CheckboxConfirmation.mjs.map +1 -0
  17. package/dist/admin/components/CreateLocale.js +395 -0
  18. package/dist/admin/components/CreateLocale.js.map +1 -0
  19. package/dist/admin/components/CreateLocale.mjs +369 -0
  20. package/dist/admin/components/CreateLocale.mjs.map +1 -0
  21. package/dist/admin/components/DeleteLocale.js +90 -0
  22. package/dist/admin/components/DeleteLocale.js.map +1 -0
  23. package/dist/admin/components/DeleteLocale.mjs +69 -0
  24. package/dist/admin/components/DeleteLocale.mjs.map +1 -0
  25. package/dist/admin/components/EditLocale.js +212 -0
  26. package/dist/admin/components/EditLocale.js.map +1 -0
  27. package/dist/admin/components/EditLocale.mjs +190 -0
  28. package/dist/admin/components/EditLocale.mjs.map +1 -0
  29. package/dist/admin/components/LocaleListCell.js +102 -0
  30. package/dist/admin/components/LocaleListCell.js.map +1 -0
  31. package/dist/admin/components/LocaleListCell.mjs +100 -0
  32. package/dist/admin/components/LocaleListCell.mjs.map +1 -0
  33. package/dist/admin/components/LocalePicker.js +105 -0
  34. package/dist/admin/components/LocalePicker.js.map +1 -0
  35. package/dist/admin/components/LocalePicker.mjs +84 -0
  36. package/dist/admin/components/LocalePicker.mjs.map +1 -0
  37. package/dist/admin/components/LocaleTable.js +143 -0
  38. package/dist/admin/components/LocaleTable.js.map +1 -0
  39. package/dist/admin/components/LocaleTable.mjs +122 -0
  40. package/dist/admin/components/LocaleTable.mjs.map +1 -0
  41. package/dist/admin/constants.js +37 -0
  42. package/dist/admin/constants.js.map +1 -0
  43. package/dist/admin/constants.mjs +35 -0
  44. package/dist/admin/constants.mjs.map +1 -0
  45. package/dist/admin/contentManagerHooks/editView.js +109 -0
  46. package/dist/admin/contentManagerHooks/editView.js.map +1 -0
  47. package/dist/admin/contentManagerHooks/editView.mjs +88 -0
  48. package/dist/admin/contentManagerHooks/editView.mjs.map +1 -0
  49. package/dist/admin/contentManagerHooks/listView.js +44 -0
  50. package/dist/admin/contentManagerHooks/listView.js.map +1 -0
  51. package/dist/admin/contentManagerHooks/listView.mjs +42 -0
  52. package/dist/admin/contentManagerHooks/listView.mjs.map +1 -0
  53. package/dist/admin/contentReleasesHooks/releaseDetailsView.js +20 -0
  54. package/dist/admin/contentReleasesHooks/releaseDetailsView.js.map +1 -0
  55. package/dist/admin/contentReleasesHooks/releaseDetailsView.mjs +18 -0
  56. package/dist/admin/contentReleasesHooks/releaseDetailsView.mjs.map +1 -0
  57. package/dist/admin/hooks/useAILocalizationJobsPolling.js +110 -0
  58. package/dist/admin/hooks/useAILocalizationJobsPolling.js.map +1 -0
  59. package/dist/admin/hooks/useAILocalizationJobsPolling.mjs +89 -0
  60. package/dist/admin/hooks/useAILocalizationJobsPolling.mjs.map +1 -0
  61. package/dist/admin/hooks/useI18n.js +78 -0
  62. package/dist/admin/hooks/useI18n.js.map +1 -0
  63. package/dist/admin/hooks/useI18n.mjs +57 -0
  64. package/dist/admin/hooks/useI18n.mjs.map +1 -0
  65. package/dist/admin/index.js +226 -5
  66. package/dist/admin/index.js.map +1 -1
  67. package/dist/admin/index.mjs +202 -5
  68. package/dist/admin/index.mjs.map +1 -1
  69. package/dist/admin/middlewares/extendCTBAttributeInitialData.js +71 -0
  70. package/dist/admin/middlewares/extendCTBAttributeInitialData.js.map +1 -0
  71. package/dist/admin/middlewares/extendCTBAttributeInitialData.mjs +69 -0
  72. package/dist/admin/middlewares/extendCTBAttributeInitialData.mjs.map +1 -0
  73. package/dist/admin/middlewares/extendCTBInitialData.js +40 -0
  74. package/dist/admin/middlewares/extendCTBInitialData.js.map +1 -0
  75. package/dist/admin/middlewares/extendCTBInitialData.mjs +38 -0
  76. package/dist/admin/middlewares/extendCTBInitialData.mjs.map +1 -0
  77. package/dist/admin/middlewares/rbac-middleware.js +49 -0
  78. package/dist/admin/middlewares/rbac-middleware.js.map +1 -0
  79. package/dist/admin/middlewares/rbac-middleware.mjs +28 -0
  80. package/dist/admin/middlewares/rbac-middleware.mjs.map +1 -0
  81. package/dist/admin/pages/SettingsPage.js +182 -0
  82. package/dist/admin/pages/SettingsPage.js.map +1 -0
  83. package/dist/admin/pages/SettingsPage.mjs +179 -0
  84. package/dist/admin/pages/SettingsPage.mjs.map +1 -0
  85. package/dist/admin/pluginId.js +6 -0
  86. package/dist/admin/pluginId.js.map +1 -0
  87. package/dist/admin/pluginId.mjs +4 -0
  88. package/dist/admin/pluginId.mjs.map +1 -0
  89. package/dist/admin/services/aiLocalizationJobs.js +26 -0
  90. package/dist/admin/services/aiLocalizationJobs.js.map +1 -0
  91. package/dist/admin/services/aiLocalizationJobs.mjs +24 -0
  92. package/dist/admin/services/aiLocalizationJobs.mjs.map +1 -0
  93. package/dist/admin/services/api.js +15 -0
  94. package/dist/admin/services/api.js.map +1 -0
  95. package/dist/admin/services/api.mjs +13 -0
  96. package/dist/admin/services/api.mjs.map +1 -0
  97. package/dist/admin/services/locales.js +72 -0
  98. package/dist/admin/services/locales.js.map +1 -0
  99. package/dist/admin/services/locales.mjs +66 -0
  100. package/dist/admin/services/locales.mjs.map +1 -0
  101. package/dist/admin/services/relations.js +23 -0
  102. package/dist/admin/services/relations.js.map +1 -0
  103. package/dist/admin/services/relations.mjs +21 -0
  104. package/dist/admin/services/relations.mjs.map +1 -0
  105. package/dist/admin/services/settings.js +29 -0
  106. package/dist/admin/services/settings.js.map +1 -0
  107. package/dist/admin/services/settings.mjs +26 -0
  108. package/dist/admin/services/settings.mjs.map +1 -0
  109. package/dist/admin/src/components/CMHeaderActions.d.ts +18 -5
  110. package/dist/admin/src/components/LocaleListCell.d.ts +5 -4
  111. package/dist/admin/src/components/tests/CreateLocale.test.d.ts +1 -0
  112. package/dist/admin/src/components/tests/DeleteLocale.test.d.ts +1 -0
  113. package/dist/admin/src/components/tests/EditLocale.test.d.ts +1 -0
  114. package/dist/admin/src/components/tests/LocaleListCell.test.d.ts +1 -0
  115. package/dist/admin/src/contentReleasesHooks/releaseDetailsView.d.ts +1 -1
  116. package/dist/admin/src/hooks/useAILocalizationJobsPolling.d.ts +9 -0
  117. package/dist/admin/src/pages/tests/SettingsPage.test.d.ts +1 -0
  118. package/dist/admin/src/services/aiLocalizationJobs.d.ts +6 -0
  119. package/dist/admin/src/services/api.d.ts +1 -1
  120. package/dist/admin/src/services/locales.d.ts +1 -1
  121. package/dist/admin/src/services/relations.d.ts +1 -1
  122. package/dist/admin/src/services/settings.d.ts +5 -0
  123. package/dist/admin/src/utils/schemas.d.ts +642 -16
  124. package/dist/admin/tests/server.d.ts +1 -0
  125. package/dist/admin/tests/utils.d.ts +6 -0
  126. package/dist/admin/translations/de.json.js +66 -0
  127. package/dist/admin/translations/de.json.js.map +1 -0
  128. package/dist/admin/translations/de.json.mjs +64 -0
  129. package/dist/admin/translations/de.json.mjs.map +1 -0
  130. package/dist/admin/translations/dk.json.js +66 -0
  131. package/dist/admin/translations/dk.json.js.map +1 -0
  132. package/dist/admin/translations/dk.json.mjs +64 -0
  133. package/dist/admin/translations/dk.json.mjs.map +1 -0
  134. package/dist/admin/translations/en.json.js +91 -0
  135. package/dist/admin/translations/en.json.js.map +1 -0
  136. package/dist/admin/translations/en.json.mjs +89 -0
  137. package/dist/admin/translations/en.json.mjs.map +1 -0
  138. package/dist/admin/translations/es.json.js +66 -0
  139. package/dist/admin/translations/es.json.js.map +1 -0
  140. package/dist/admin/translations/es.json.mjs +64 -0
  141. package/dist/admin/translations/es.json.mjs.map +1 -0
  142. package/dist/admin/translations/fr.json.js +66 -0
  143. package/dist/admin/translations/fr.json.js.map +1 -0
  144. package/dist/admin/translations/fr.json.mjs +64 -0
  145. package/dist/admin/translations/fr.json.mjs.map +1 -0
  146. package/dist/admin/translations/ko.json.js +65 -0
  147. package/dist/admin/translations/ko.json.js.map +1 -0
  148. package/dist/admin/translations/ko.json.mjs +63 -0
  149. package/dist/admin/translations/ko.json.mjs.map +1 -0
  150. package/dist/admin/translations/pl.json.js +66 -0
  151. package/dist/admin/translations/pl.json.js.map +1 -0
  152. package/dist/admin/translations/pl.json.mjs +64 -0
  153. package/dist/admin/translations/pl.json.mjs.map +1 -0
  154. package/dist/admin/translations/ru.json.js +68 -0
  155. package/dist/admin/translations/ru.json.js.map +1 -0
  156. package/dist/admin/translations/ru.json.mjs +66 -0
  157. package/dist/admin/translations/ru.json.mjs.map +1 -0
  158. package/dist/admin/translations/tr.json.js +66 -0
  159. package/dist/admin/translations/tr.json.js.map +1 -0
  160. package/dist/admin/translations/tr.json.mjs +64 -0
  161. package/dist/admin/translations/tr.json.mjs.map +1 -0
  162. package/dist/admin/translations/uk.json.js +82 -0
  163. package/dist/admin/translations/uk.json.js.map +1 -0
  164. package/dist/admin/translations/uk.json.mjs +80 -0
  165. package/dist/admin/translations/uk.json.mjs.map +1 -0
  166. package/dist/admin/translations/zh-Hans.json.js +57 -0
  167. package/dist/admin/translations/zh-Hans.json.js.map +1 -0
  168. package/dist/admin/translations/zh-Hans.json.mjs +55 -0
  169. package/dist/admin/translations/zh-Hans.json.mjs.map +1 -0
  170. package/dist/admin/translations/zh.json.js +66 -0
  171. package/dist/admin/translations/zh.json.js.map +1 -0
  172. package/dist/admin/translations/zh.json.mjs +64 -0
  173. package/dist/admin/translations/zh.json.mjs.map +1 -0
  174. package/dist/admin/utils/baseQuery.js +8 -0
  175. package/dist/admin/utils/baseQuery.js.map +1 -0
  176. package/dist/admin/utils/baseQuery.mjs +6 -0
  177. package/dist/admin/utils/baseQuery.mjs.map +1 -0
  178. package/dist/admin/utils/clean.js +70 -0
  179. package/dist/admin/utils/clean.js.map +1 -0
  180. package/dist/admin/utils/clean.mjs +68 -0
  181. package/dist/admin/utils/clean.mjs.map +1 -0
  182. package/dist/admin/utils/fields.js +34 -0
  183. package/dist/admin/utils/fields.js.map +1 -0
  184. package/dist/admin/utils/fields.mjs +31 -0
  185. package/dist/admin/utils/fields.mjs.map +1 -0
  186. package/dist/admin/utils/getTranslation.js +8 -0
  187. package/dist/admin/utils/getTranslation.js.map +1 -0
  188. package/dist/admin/utils/getTranslation.mjs +6 -0
  189. package/dist/admin/utils/getTranslation.mjs.map +1 -0
  190. package/dist/admin/utils/prefixPluginTranslations.js +11 -0
  191. package/dist/admin/utils/prefixPluginTranslations.js.map +1 -0
  192. package/dist/admin/utils/prefixPluginTranslations.mjs +9 -0
  193. package/dist/admin/utils/prefixPluginTranslations.mjs.map +1 -0
  194. package/dist/admin/utils/schemas.js +74 -0
  195. package/dist/admin/utils/schemas.js.map +1 -0
  196. package/dist/admin/utils/schemas.mjs +72 -0
  197. package/dist/admin/utils/schemas.mjs.map +1 -0
  198. package/dist/admin/utils/strings.js +6 -0
  199. package/dist/admin/utils/strings.js.map +1 -0
  200. package/dist/admin/utils/strings.mjs +4 -0
  201. package/dist/admin/utils/strings.mjs.map +1 -0
  202. package/dist/server/bootstrap.js +81 -0
  203. package/dist/server/bootstrap.js.map +1 -0
  204. package/dist/server/bootstrap.mjs +79 -0
  205. package/dist/server/bootstrap.mjs.map +1 -0
  206. package/dist/server/constants/index.js +29 -0
  207. package/dist/server/constants/index.js.map +1 -0
  208. package/dist/server/constants/index.mjs +25 -0
  209. package/dist/server/constants/index.mjs.map +1 -0
  210. package/dist/server/constants/iso-locales.json.js +2427 -0
  211. package/dist/server/constants/iso-locales.json.js.map +1 -0
  212. package/dist/server/constants/iso-locales.json.mjs +2425 -0
  213. package/dist/server/constants/iso-locales.json.mjs.map +1 -0
  214. package/dist/server/content-types/index.js +10 -0
  215. package/dist/server/content-types/index.js.map +1 -0
  216. package/dist/server/content-types/index.mjs +8 -0
  217. package/dist/server/content-types/index.mjs.map +1 -0
  218. package/dist/server/content-types/locale/index.js +10 -0
  219. package/dist/server/content-types/locale/index.js.map +1 -0
  220. package/dist/server/content-types/locale/index.mjs +8 -0
  221. package/dist/server/content-types/locale/index.mjs.map +1 -0
  222. package/dist/server/content-types/locale/schema.json.js +46 -0
  223. package/dist/server/content-types/locale/schema.json.js.map +1 -0
  224. package/dist/server/content-types/locale/schema.json.mjs +38 -0
  225. package/dist/server/content-types/locale/schema.json.mjs.map +1 -0
  226. package/dist/server/controllers/ai-localization-jobs.js +47 -0
  227. package/dist/server/controllers/ai-localization-jobs.js.map +1 -0
  228. package/dist/server/controllers/ai-localization-jobs.mjs +45 -0
  229. package/dist/server/controllers/ai-localization-jobs.mjs.map +1 -0
  230. package/dist/server/controllers/content-types.js +76 -0
  231. package/dist/server/controllers/content-types.js.map +1 -0
  232. package/dist/server/controllers/content-types.mjs +74 -0
  233. package/dist/server/controllers/content-types.mjs.map +1 -0
  234. package/dist/server/controllers/index.js +18 -0
  235. package/dist/server/controllers/index.js.map +1 -0
  236. package/dist/server/controllers/index.mjs +16 -0
  237. package/dist/server/controllers/index.mjs.map +1 -0
  238. package/dist/server/controllers/iso-locales.js +13 -0
  239. package/dist/server/controllers/iso-locales.js.map +1 -0
  240. package/dist/server/controllers/iso-locales.mjs +11 -0
  241. package/dist/server/controllers/iso-locales.mjs.map +1 -0
  242. package/dist/server/controllers/locales.js +108 -0
  243. package/dist/server/controllers/locales.js.map +1 -0
  244. package/dist/server/controllers/locales.mjs +87 -0
  245. package/dist/server/controllers/locales.mjs.map +1 -0
  246. package/dist/server/controllers/settings.js +24 -0
  247. package/dist/server/controllers/settings.js.map +1 -0
  248. package/dist/server/controllers/settings.mjs +22 -0
  249. package/dist/server/controllers/settings.mjs.map +1 -0
  250. package/dist/server/controllers/validate-locale-creation.js +47 -0
  251. package/dist/server/controllers/validate-locale-creation.js.map +1 -0
  252. package/dist/server/controllers/validate-locale-creation.mjs +45 -0
  253. package/dist/server/controllers/validate-locale-creation.mjs.map +1 -0
  254. package/dist/server/domain/locale.js +11 -0
  255. package/dist/server/domain/locale.js.map +1 -0
  256. package/dist/server/domain/locale.mjs +9 -0
  257. package/dist/server/domain/locale.mjs.map +1 -0
  258. package/dist/server/graphql.js +115 -0
  259. package/dist/server/graphql.js.map +1 -0
  260. package/dist/server/graphql.mjs +113 -0
  261. package/dist/server/graphql.mjs.map +1 -0
  262. package/dist/server/index.js +18 -3453
  263. package/dist/server/index.js.map +1 -1
  264. package/dist/server/index.mjs +17 -3435
  265. package/dist/server/index.mjs.map +1 -1
  266. package/dist/server/models/ai-localization-job.js +60 -0
  267. package/dist/server/models/ai-localization-job.js.map +1 -0
  268. package/dist/server/models/ai-localization-job.mjs +57 -0
  269. package/dist/server/models/ai-localization-job.mjs.map +1 -0
  270. package/dist/server/register.js +81 -0
  271. package/dist/server/register.js.map +1 -0
  272. package/dist/server/register.mjs +79 -0
  273. package/dist/server/register.mjs.map +1 -0
  274. package/dist/server/routes/admin.js +142 -0
  275. package/dist/server/routes/admin.js.map +1 -0
  276. package/dist/server/routes/admin.mjs +140 -0
  277. package/dist/server/routes/admin.mjs.map +1 -0
  278. package/dist/server/routes/content-api.js +19 -0
  279. package/dist/server/routes/content-api.js.map +1 -0
  280. package/dist/server/routes/content-api.mjs +17 -0
  281. package/dist/server/routes/content-api.mjs.map +1 -0
  282. package/dist/server/routes/index.js +12 -0
  283. package/dist/server/routes/index.js.map +1 -0
  284. package/dist/server/routes/index.mjs +10 -0
  285. package/dist/server/routes/index.mjs.map +1 -0
  286. package/dist/server/routes/validation/locale.js +57 -0
  287. package/dist/server/routes/validation/locale.js.map +1 -0
  288. package/dist/server/routes/validation/locale.mjs +36 -0
  289. package/dist/server/routes/validation/locale.mjs.map +1 -0
  290. package/dist/server/services/ai-localization-jobs.js +64 -0
  291. package/dist/server/services/ai-localization-jobs.js.map +1 -0
  292. package/dist/server/services/ai-localization-jobs.mjs +62 -0
  293. package/dist/server/services/ai-localization-jobs.mjs.map +1 -0
  294. package/dist/server/services/ai-localizations.js +272 -0
  295. package/dist/server/services/ai-localizations.js.map +1 -0
  296. package/dist/server/services/ai-localizations.mjs +270 -0
  297. package/dist/server/services/ai-localizations.mjs.map +1 -0
  298. package/dist/server/services/content-types.js +157 -0
  299. package/dist/server/services/content-types.js.map +1 -0
  300. package/dist/server/services/content-types.mjs +155 -0
  301. package/dist/server/services/content-types.mjs.map +1 -0
  302. package/dist/server/services/index.js +28 -0
  303. package/dist/server/services/index.js.map +1 -0
  304. package/dist/server/services/index.mjs +26 -0
  305. package/dist/server/services/index.mjs.map +1 -0
  306. package/dist/server/services/iso-locales.js +12 -0
  307. package/dist/server/services/iso-locales.js.map +1 -0
  308. package/dist/server/services/iso-locales.mjs +10 -0
  309. package/dist/server/services/iso-locales.mjs.map +1 -0
  310. package/dist/server/services/locales.js +114 -0
  311. package/dist/server/services/locales.js.map +1 -0
  312. package/dist/server/services/locales.mjs +112 -0
  313. package/dist/server/services/locales.mjs.map +1 -0
  314. package/dist/server/services/localizations.js +68 -0
  315. package/dist/server/services/localizations.js.map +1 -0
  316. package/dist/server/services/localizations.mjs +66 -0
  317. package/dist/server/services/localizations.mjs.map +1 -0
  318. package/dist/server/services/metrics.js +30 -0
  319. package/dist/server/services/metrics.js.map +1 -0
  320. package/dist/server/services/metrics.mjs +28 -0
  321. package/dist/server/services/metrics.mjs.map +1 -0
  322. package/dist/server/services/permissions/actions.js +136 -0
  323. package/dist/server/services/permissions/actions.js.map +1 -0
  324. package/dist/server/services/permissions/actions.mjs +134 -0
  325. package/dist/server/services/permissions/actions.mjs.map +1 -0
  326. package/dist/server/services/permissions/engine.js +52 -0
  327. package/dist/server/services/permissions/engine.js.map +1 -0
  328. package/dist/server/services/permissions/engine.mjs +50 -0
  329. package/dist/server/services/permissions/engine.mjs.map +1 -0
  330. package/dist/server/services/permissions/sections-builder.js +45 -0
  331. package/dist/server/services/permissions/sections-builder.js.map +1 -0
  332. package/dist/server/services/permissions/sections-builder.mjs +43 -0
  333. package/dist/server/services/permissions/sections-builder.mjs.map +1 -0
  334. package/dist/server/services/permissions.js +14 -0
  335. package/dist/server/services/permissions.js.map +1 -0
  336. package/dist/server/services/permissions.mjs +12 -0
  337. package/dist/server/services/permissions.mjs.map +1 -0
  338. package/dist/server/services/sanitize/index.js +34 -0
  339. package/dist/server/services/sanitize/index.js.map +1 -0
  340. package/dist/server/services/sanitize/index.mjs +32 -0
  341. package/dist/server/services/sanitize/index.mjs.map +1 -0
  342. package/dist/server/services/settings.js +25 -0
  343. package/dist/server/services/settings.js.map +1 -0
  344. package/dist/server/services/settings.mjs +23 -0
  345. package/dist/server/services/settings.mjs.map +1 -0
  346. package/dist/server/src/bootstrap.d.ts.map +1 -1
  347. package/dist/server/src/controllers/ai-localization-jobs.d.ts +17 -0
  348. package/dist/server/src/controllers/ai-localization-jobs.d.ts.map +1 -0
  349. package/dist/server/src/controllers/index.d.ts +10 -0
  350. package/dist/server/src/controllers/index.d.ts.map +1 -1
  351. package/dist/server/src/controllers/settings.d.ts +7 -0
  352. package/dist/server/src/controllers/settings.d.ts.map +1 -0
  353. package/dist/server/src/index.d.ts +47 -8
  354. package/dist/server/src/index.d.ts.map +1 -1
  355. package/dist/server/src/models/ai-localization-job.d.ts +5 -0
  356. package/dist/server/src/models/ai-localization-job.d.ts.map +1 -0
  357. package/dist/server/src/models/index.d.ts +5 -0
  358. package/dist/server/src/models/index.d.ts.map +1 -0
  359. package/dist/server/src/register.d.ts +1 -1
  360. package/dist/server/src/register.d.ts.map +1 -1
  361. package/dist/server/src/routes/admin.d.ts.map +1 -1
  362. package/dist/server/src/routes/content-api.d.ts +5 -8
  363. package/dist/server/src/routes/content-api.d.ts.map +1 -1
  364. package/dist/server/src/routes/index.d.ts +3 -7
  365. package/dist/server/src/routes/index.d.ts.map +1 -1
  366. package/dist/server/src/routes/validation/index.d.ts +2 -0
  367. package/dist/server/src/routes/validation/index.d.ts.map +1 -0
  368. package/dist/server/src/routes/validation/locale.d.ts +41 -0
  369. package/dist/server/src/routes/validation/locale.d.ts.map +1 -0
  370. package/dist/server/src/services/ai-localization-jobs.d.ts +26 -0
  371. package/dist/server/src/services/ai-localization-jobs.d.ts.map +1 -0
  372. package/dist/server/src/services/ai-localizations.d.ts +18 -0
  373. package/dist/server/src/services/ai-localizations.d.ts.map +1 -0
  374. package/dist/server/src/services/index.d.ts +33 -0
  375. package/dist/server/src/services/index.d.ts.map +1 -1
  376. package/dist/server/src/services/localizations.d.ts +1 -1
  377. package/dist/server/src/services/localizations.d.ts.map +1 -1
  378. package/dist/server/src/services/settings.d.ts +13 -0
  379. package/dist/server/src/services/settings.d.ts.map +1 -0
  380. package/dist/server/src/utils/index.d.ts +7 -1
  381. package/dist/server/src/utils/index.d.ts.map +1 -1
  382. package/dist/server/src/validation/settings.d.ts +12 -0
  383. package/dist/server/src/validation/settings.d.ts.map +1 -0
  384. package/dist/server/utils/index.js +16 -0
  385. package/dist/server/utils/index.js.map +1 -0
  386. package/dist/server/utils/index.mjs +13 -0
  387. package/dist/server/utils/index.mjs.map +1 -0
  388. package/dist/server/validation/content-types.js +18 -0
  389. package/dist/server/validation/content-types.js.map +1 -0
  390. package/dist/server/validation/content-types.mjs +16 -0
  391. package/dist/server/validation/content-types.mjs.map +1 -0
  392. package/dist/server/validation/locales.js +23 -0
  393. package/dist/server/validation/locales.js.map +1 -0
  394. package/dist/server/validation/locales.mjs +20 -0
  395. package/dist/server/validation/locales.mjs.map +1 -0
  396. package/dist/server/validation/settings.js +11 -0
  397. package/dist/server/validation/settings.js.map +1 -0
  398. package/dist/server/validation/settings.mjs +9 -0
  399. package/dist/server/validation/settings.mjs.map +1 -0
  400. package/dist/shared/contracts/ai-localization-jobs.d.ts +27 -0
  401. package/dist/shared/contracts/ai-localization-jobs.d.ts.map +1 -0
  402. package/dist/shared/contracts/content-manager.d.ts +1 -1
  403. package/dist/shared/contracts/settings.d.ts +40 -0
  404. package/dist/shared/contracts/shared.d.ts +1 -1
  405. package/dist/shared/contracts/shared.d.ts.map +1 -0
  406. package/package.json +21 -16
  407. package/dist/_chunks/SettingsPage-D0hqaut-.js +0 -574
  408. package/dist/_chunks/SettingsPage-D0hqaut-.js.map +0 -1
  409. package/dist/_chunks/SettingsPage-D67CaQAB.mjs +0 -554
  410. package/dist/_chunks/SettingsPage-D67CaQAB.mjs.map +0 -1
  411. package/dist/_chunks/de-9eCAqqrB.mjs +0 -66
  412. package/dist/_chunks/de-9eCAqqrB.mjs.map +0 -1
  413. package/dist/_chunks/de-DtWiGdHl.js +0 -66
  414. package/dist/_chunks/de-DtWiGdHl.js.map +0 -1
  415. package/dist/_chunks/dk-2qBjxt-P.mjs +0 -66
  416. package/dist/_chunks/dk-2qBjxt-P.mjs.map +0 -1
  417. package/dist/_chunks/dk-D8C-casx.js +0 -66
  418. package/dist/_chunks/dk-D8C-casx.js.map +0 -1
  419. package/dist/_chunks/en-BKBz3tro.js +0 -81
  420. package/dist/_chunks/en-BKBz3tro.js.map +0 -1
  421. package/dist/_chunks/en-DlXfy6Gy.mjs +0 -81
  422. package/dist/_chunks/en-DlXfy6Gy.mjs.map +0 -1
  423. package/dist/_chunks/es-DS-XFGSw.js +0 -66
  424. package/dist/_chunks/es-DS-XFGSw.js.map +0 -1
  425. package/dist/_chunks/es-DlmMVaBG.mjs +0 -66
  426. package/dist/_chunks/es-DlmMVaBG.mjs.map +0 -1
  427. package/dist/_chunks/fr-3S6ke71d.mjs +0 -66
  428. package/dist/_chunks/fr-3S6ke71d.mjs.map +0 -1
  429. package/dist/_chunks/fr-BTjekDpq.js +0 -66
  430. package/dist/_chunks/fr-BTjekDpq.js.map +0 -1
  431. package/dist/_chunks/index-46DNtLCn.js +0 -1635
  432. package/dist/_chunks/index-46DNtLCn.js.map +0 -1
  433. package/dist/_chunks/index-CNR8i3KM.mjs +0 -1613
  434. package/dist/_chunks/index-CNR8i3KM.mjs.map +0 -1
  435. package/dist/_chunks/ko-DmcGUBQ3.js +0 -65
  436. package/dist/_chunks/ko-DmcGUBQ3.js.map +0 -1
  437. package/dist/_chunks/ko-qTjQ8IMw.mjs +0 -65
  438. package/dist/_chunks/ko-qTjQ8IMw.mjs.map +0 -1
  439. package/dist/_chunks/pl-B67TSHqT.mjs +0 -66
  440. package/dist/_chunks/pl-B67TSHqT.mjs.map +0 -1
  441. package/dist/_chunks/pl-Cn5RYonZ.js +0 -66
  442. package/dist/_chunks/pl-Cn5RYonZ.js.map +0 -1
  443. package/dist/_chunks/ru-BMBgVL3s.js +0 -68
  444. package/dist/_chunks/ru-BMBgVL3s.js.map +0 -1
  445. package/dist/_chunks/ru-hagMa57T.mjs +0 -68
  446. package/dist/_chunks/ru-hagMa57T.mjs.map +0 -1
  447. package/dist/_chunks/tr-CarUU76c.js +0 -66
  448. package/dist/_chunks/tr-CarUU76c.js.map +0 -1
  449. package/dist/_chunks/tr-Dw_jmkG-.mjs +0 -66
  450. package/dist/_chunks/tr-Dw_jmkG-.mjs.map +0 -1
  451. package/dist/_chunks/zh-57YM4amO.mjs +0 -66
  452. package/dist/_chunks/zh-57YM4amO.mjs.map +0 -1
  453. package/dist/_chunks/zh-CukOviB0.js +0 -66
  454. package/dist/_chunks/zh-CukOviB0.js.map +0 -1
  455. package/dist/_chunks/zh-Hans-DSHIXAa3.js +0 -57
  456. package/dist/_chunks/zh-Hans-DSHIXAa3.js.map +0 -1
  457. package/dist/_chunks/zh-Hans-Dyc-aR-h.mjs +0 -57
  458. package/dist/_chunks/zh-Hans-Dyc-aR-h.mjs.map +0 -1
@@ -0,0 +1,931 @@
1
+ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
2
+ import * as React from 'react';
3
+ import { skipToken } from '@reduxjs/toolkit/query';
4
+ import { useQueryParams, useForm, useNotification, useAPIErrorHandler, Table } from '@strapi/admin/strapi-admin';
5
+ import { useAIAvailability } from '@strapi/admin/strapi-admin/ee';
6
+ import { unstable_useDocument, unstable_useDocumentActions, buildValidParams } from '@strapi/content-manager/strapi-admin';
7
+ import { Status, SingleSelectOption, Box, Typography, Flex, Link, Dialog, Field, SingleSelect, Button, Modal } from '@strapi/design-system';
8
+ import { Trash, Sparkle, Earth, WarningCircle, Plus, ListPlus, Cross } from '@strapi/icons';
9
+ import { useIntl } from 'react-intl';
10
+ import { NavLink, useNavigate } from 'react-router-dom';
11
+ import { styled } from 'styled-components';
12
+ import { useAILocalizationJobsPolling } from '../hooks/useAILocalizationJobsPolling.mjs';
13
+ import { useI18n } from '../hooks/useI18n.mjs';
14
+ import { useGetAILocalizationJobsByDocumentQuery } from '../services/aiLocalizationJobs.mjs';
15
+ import { useGetLocalesQuery } from '../services/locales.mjs';
16
+ import { useGetManyDraftRelationCountQuery } from '../services/relations.mjs';
17
+ import { useGetSettingsQuery } from '../services/settings.mjs';
18
+ import { cleanData } from '../utils/clean.mjs';
19
+ import { getTranslation } from '../utils/getTranslation.mjs';
20
+ import { capitalize } from '../utils/strings.mjs';
21
+ import { BulkLocaleActionModal } from './BulkLocaleActionModal.mjs';
22
+
23
+ const statusVariants = {
24
+ draft: 'secondary',
25
+ published: 'success',
26
+ modified: 'alternative'
27
+ };
28
+ const LocaleOption = ({ isDraftAndPublishEnabled, locale, status, entryExists })=>{
29
+ const { formatMessage } = useIntl();
30
+ if (!entryExists) {
31
+ return formatMessage({
32
+ id: getTranslation('CMEditViewLocalePicker.locale.create'),
33
+ defaultMessage: 'Create <bold>{locale}</bold> locale'
34
+ }, {
35
+ bold: (locale)=>/*#__PURE__*/ jsx("b", {
36
+ children: locale
37
+ }),
38
+ locale: locale.name
39
+ });
40
+ }
41
+ return /*#__PURE__*/ jsxs(Flex, {
42
+ width: "100%",
43
+ gap: 1,
44
+ justifyContent: "space-between",
45
+ children: [
46
+ /*#__PURE__*/ jsx(Typography, {
47
+ children: locale.name
48
+ }),
49
+ isDraftAndPublishEnabled ? /*#__PURE__*/ jsx(Status, {
50
+ display: "flex",
51
+ paddingLeft: "6px",
52
+ paddingRight: "6px",
53
+ paddingTop: "2px",
54
+ paddingBottom: "2px",
55
+ size: "S",
56
+ variant: statusVariants[status],
57
+ children: /*#__PURE__*/ jsx(Typography, {
58
+ tag: "span",
59
+ variant: "pi",
60
+ fontWeight: "bold",
61
+ children: capitalize(status)
62
+ })
63
+ }) : null
64
+ ]
65
+ });
66
+ };
67
+ const LocaleOptionStartIcon = ({ entryWithLocaleExists, translationStatus, index })=>{
68
+ const isAiAvailable = useAIAvailability();
69
+ if (!entryWithLocaleExists) {
70
+ return /*#__PURE__*/ jsx(Plus, {});
71
+ }
72
+ if (isAiAvailable && index !== 0 && translationStatus === 'failed') {
73
+ return /*#__PURE__*/ jsx(WarningCircle, {
74
+ fill: "warning600"
75
+ });
76
+ }
77
+ return null;
78
+ };
79
+ const LocalePickerAction = ({ document, meta, model, collectionType, documentId })=>{
80
+ const { formatMessage } = useIntl();
81
+ const [{ query }, setQuery] = useQueryParams();
82
+ const { hasI18n, canCreate, canRead } = useI18n();
83
+ const { data: locales = [] } = useGetLocalesQuery();
84
+ const currentDesiredLocale = query.plugins?.i18n?.locale;
85
+ const { schema } = unstable_useDocument({
86
+ model,
87
+ collectionType,
88
+ documentId,
89
+ params: {
90
+ locale: currentDesiredLocale
91
+ }
92
+ });
93
+ const { data: jobData } = useGetAILocalizationJobsByDocumentQuery({
94
+ documentId: documentId,
95
+ model: model,
96
+ collectionType: collectionType
97
+ });
98
+ const { data: settings } = useGetSettingsQuery();
99
+ const isAiAvailable = useAIAvailability();
100
+ const setValues = useForm('LocalePickerAction', (state)=>state.setValues);
101
+ const handleSelect = React.useCallback((value)=>{
102
+ setQuery({
103
+ plugins: {
104
+ ...query.plugins,
105
+ i18n: {
106
+ locale: value
107
+ }
108
+ }
109
+ });
110
+ }, [
111
+ query.plugins,
112
+ setQuery
113
+ ]);
114
+ const nonTranslatedFields = React.useMemo(()=>{
115
+ if (!schema?.attributes) return [];
116
+ return Object.keys(schema.attributes).filter((field)=>{
117
+ const attribute = schema.attributes[field];
118
+ return attribute?.pluginOptions?.i18n?.localized === false;
119
+ });
120
+ }, [
121
+ schema?.attributes
122
+ ]);
123
+ const sourceLocaleData = React.useMemo(()=>{
124
+ if (!Array.isArray(locales) || !meta?.availableLocales) return null;
125
+ const defaultLocale = locales.find((locale)=>locale.isDefault);
126
+ const existingLocales = meta.availableLocales.map((loc)=>loc.locale);
127
+ const sourceLocaleCode = defaultLocale && existingLocales.includes(defaultLocale.code) && defaultLocale.code !== currentDesiredLocale ? defaultLocale.code : existingLocales.find((locale)=>locale !== currentDesiredLocale);
128
+ if (!sourceLocaleCode) return null;
129
+ // Find the document data from availableLocales (now includes non-translatable fields)
130
+ const sourceLocaleDoc = meta.availableLocales.find((loc)=>loc.locale === sourceLocaleCode);
131
+ return sourceLocaleDoc ? {
132
+ locale: sourceLocaleCode,
133
+ data: sourceLocaleDoc
134
+ } : null;
135
+ }, [
136
+ locales,
137
+ meta?.availableLocales,
138
+ currentDesiredLocale
139
+ ]);
140
+ /**
141
+ * Prefilling form with non-translatable fields from already existing locale
142
+ */ React.useEffect(()=>{
143
+ // Only run when creating a new locale (no document ID yet) and when we have non-translatable fields
144
+ if (!document?.id && nonTranslatedFields.length > 0 && sourceLocaleData?.data) {
145
+ const dataToSet = nonTranslatedFields.reduce((acc, field)=>{
146
+ acc[field] = sourceLocaleData.data[field];
147
+ return acc;
148
+ }, {});
149
+ if (Object.keys(dataToSet).length > 0) {
150
+ setValues(dataToSet);
151
+ }
152
+ }
153
+ }, [
154
+ document?.id,
155
+ nonTranslatedFields,
156
+ sourceLocaleData?.data,
157
+ setValues
158
+ ]);
159
+ React.useEffect(()=>{
160
+ if (!Array.isArray(locales) || !hasI18n) {
161
+ return;
162
+ }
163
+ /**
164
+ * Handle the case where the current locale query param doesn't exist
165
+ * in the list of available locales, so we redirect to the default locale.
166
+ */ const doesLocaleExist = locales.find((loc)=>loc.code === currentDesiredLocale);
167
+ const defaultLocale = locales.find((locale)=>locale.isDefault);
168
+ if (!doesLocaleExist && defaultLocale?.code) {
169
+ handleSelect(defaultLocale.code);
170
+ }
171
+ }, [
172
+ handleSelect,
173
+ hasI18n,
174
+ locales,
175
+ currentDesiredLocale
176
+ ]);
177
+ const currentLocale = Array.isArray(locales) ? locales.find((locale)=>locale.code === currentDesiredLocale) : undefined;
178
+ // Use meta.availableLocales instead of document.localizations
179
+ // meta.availableLocales contains all locales for the document, even when creating new locales
180
+ const availableLocales = meta?.availableLocales ?? [];
181
+ const documentLocalizations = document?.localizations ?? [];
182
+ // Prefer meta.availableLocales as it's more reliable, fallback to document.localizations
183
+ const allLocalizations = availableLocales.length > 0 ? availableLocales : documentLocalizations;
184
+ const allCurrentLocales = [
185
+ {
186
+ status: getDocumentStatus(document, meta),
187
+ locale: currentLocale?.code
188
+ },
189
+ ...allLocalizations
190
+ ];
191
+ if (!hasI18n || !Array.isArray(locales) || locales.length === 0) {
192
+ return null;
193
+ }
194
+ const displayedLocales = locales.filter((locale)=>{
195
+ /**
196
+ * If you can read we allow you to see the locale exists
197
+ * otherwise the locale is hidden.
198
+ */ return canRead.includes(locale.code);
199
+ });
200
+ return {
201
+ label: formatMessage({
202
+ id: getTranslation('Settings.locales.modal.locales.label'),
203
+ defaultMessage: 'Locales'
204
+ }),
205
+ options: displayedLocales.map((locale, index)=>{
206
+ const entryWithLocaleExists = allCurrentLocales.some((doc)=>doc.locale === locale.code);
207
+ const currentLocaleDoc = allCurrentLocales.find((doc)=>'locale' in doc ? doc.locale === locale.code : false);
208
+ const permissionsToCheck = currentLocaleDoc ? canRead : canCreate;
209
+ if (window.strapi.future.isEnabled('unstableAILocalizations') && isAiAvailable && settings?.data?.aiLocalizations) {
210
+ return {
211
+ _render: ()=>/*#__PURE__*/ jsxs(React.Fragment, {
212
+ children: [
213
+ /*#__PURE__*/ jsx(SingleSelectOption, {
214
+ disabled: !permissionsToCheck.includes(locale.code),
215
+ startIcon: /*#__PURE__*/ jsx(LocaleOptionStartIcon, {
216
+ entryWithLocaleExists: entryWithLocaleExists,
217
+ translationStatus: jobData?.data?.status,
218
+ index: index
219
+ }),
220
+ value: locale.code,
221
+ children: /*#__PURE__*/ jsx(LocaleOption, {
222
+ isDraftAndPublishEnabled: !!schema?.options?.draftAndPublish,
223
+ locale: locale,
224
+ status: currentLocaleDoc?.status,
225
+ entryExists: entryWithLocaleExists
226
+ })
227
+ }, locale.code),
228
+ index === 0 && /*#__PURE__*/ jsx(Box, {
229
+ paddingRight: 4,
230
+ paddingLeft: 4,
231
+ paddingTop: 2,
232
+ paddingBottom: 2,
233
+ children: /*#__PURE__*/ jsx(Typography, {
234
+ variant: "sigma",
235
+ children: formatMessage({
236
+ id: getTranslation('CMEditViewLocalePicker.locale.ai-translations'),
237
+ defaultMessage: 'AI Translations'
238
+ })
239
+ })
240
+ })
241
+ ]
242
+ }, index)
243
+ };
244
+ }
245
+ return {
246
+ disabled: !permissionsToCheck.includes(locale.code),
247
+ value: locale.code,
248
+ label: /*#__PURE__*/ jsx(LocaleOption, {
249
+ isDraftAndPublishEnabled: !!schema?.options?.draftAndPublish,
250
+ locale: locale,
251
+ status: currentLocaleDoc?.status,
252
+ entryExists: entryWithLocaleExists,
253
+ translationStatus: jobData?.data?.status
254
+ }),
255
+ startIcon: /*#__PURE__*/ jsx(LocaleOptionStartIcon, {
256
+ entryWithLocaleExists: entryWithLocaleExists
257
+ })
258
+ };
259
+ }),
260
+ customizeContent: ()=>currentLocale?.name,
261
+ onSelect: handleSelect,
262
+ value: currentLocale
263
+ };
264
+ };
265
+ const getDocumentStatus = (document, meta)=>{
266
+ const docStatus = document?.status;
267
+ const statuses = meta?.availableStatus ?? [];
268
+ /**
269
+ * Creating an entry
270
+ */ if (!docStatus) {
271
+ return 'draft';
272
+ }
273
+ /**
274
+ * We're viewing a draft, but the document could have a published version
275
+ */ if (docStatus === 'draft' && statuses.find((doc)=>doc.publishedAt !== null)) {
276
+ return 'published';
277
+ }
278
+ return docStatus;
279
+ };
280
+ /* -------------------------------------------------------------------------------------------------
281
+ * AISettingsStatusAction
282
+ * -----------------------------------------------------------------------------------------------*/ const AITranslationStatusIcon = styled(Status)`
283
+ display: flex;
284
+ gap: ${({ theme })=>theme.spaces[1]};
285
+ justify-content: center;
286
+ align-items: center;
287
+ height: 100%;
288
+
289
+ // Disabled state
290
+ ${({ $isAISettingEnabled, theme })=>!$isAISettingEnabled && `
291
+ background-color: ${theme.colors.neutral150};
292
+ `}
293
+
294
+ svg {
295
+ ${({ $isAISettingEnabled, theme })=>!$isAISettingEnabled && `
296
+ fill: ${theme.colors.neutral300};
297
+ `}
298
+ }
299
+ `;
300
+ const AITranslationStatusAction = ({ documentId, model, collectionType })=>{
301
+ const { formatMessage } = useIntl();
302
+ const isAIAvailable = useAIAvailability();
303
+ const { data: settings } = useGetSettingsQuery();
304
+ const isAISettingEnabled = settings?.data?.aiLocalizations;
305
+ const { hasI18n } = useI18n();
306
+ // Poll for AI localizations jobs when AI is enabled and we have a documentId
307
+ const { status } = useAILocalizationJobsPolling({
308
+ documentId,
309
+ model,
310
+ collectionType
311
+ });
312
+ const statusVariant = (()=>{
313
+ if (status === 'failed') {
314
+ return 'warning';
315
+ }
316
+ if (isAISettingEnabled) {
317
+ return 'alternative';
318
+ }
319
+ return 'neutral';
320
+ })();
321
+ // Do not display this action when i18n is not available
322
+ if (!hasI18n) {
323
+ return null;
324
+ }
325
+ // Do not display this action when AI is not available
326
+ const hasAIFutureFlag = window.strapi.future.isEnabled('unstableAILocalizations');
327
+ if (!isAIAvailable || !hasAIFutureFlag) {
328
+ return null;
329
+ }
330
+ return {
331
+ _status: {
332
+ message: /*#__PURE__*/ jsx(Box, {
333
+ height: "100%",
334
+ "aria-label": formatMessage({
335
+ id: getTranslation('CMEditViewAITranslation.status-aria-label'),
336
+ defaultMessage: 'AI Translation Status'
337
+ }),
338
+ children: /*#__PURE__*/ jsx(AITranslationStatusIcon, {
339
+ $isAISettingEnabled: Boolean(isAISettingEnabled),
340
+ variant: statusVariant,
341
+ size: "S",
342
+ children: /*#__PURE__*/ jsx(Sparkle, {})
343
+ })
344
+ }),
345
+ tooltip: /*#__PURE__*/ jsxs(Flex, {
346
+ direction: "column",
347
+ padding: 4,
348
+ alignItems: "flex-start",
349
+ width: "25rem",
350
+ children: [
351
+ /*#__PURE__*/ jsx(Typography, {
352
+ variant: "pi",
353
+ fontWeight: "600",
354
+ children: formatMessage({
355
+ id: getTranslation('CMEditViewAITranslation.status-title'),
356
+ defaultMessage: '{enabled, select, true {AI translation enabled} false {AI translation disabled} other {AI translation disabled}}'
357
+ }, {
358
+ enabled: isAISettingEnabled
359
+ })
360
+ }),
361
+ /*#__PURE__*/ jsx(Typography, {
362
+ variant: "pi",
363
+ paddingTop: 1,
364
+ paddingBottom: 3,
365
+ children: formatMessage({
366
+ id: getTranslation('CMEditViewAITranslation.status-description'),
367
+ defaultMessage: 'Our AI translates content in all locales each time you save a modification.'
368
+ })
369
+ }),
370
+ /*#__PURE__*/ jsx(Link, {
371
+ fontSize: "inherit",
372
+ tag: NavLink,
373
+ to: "/settings/internationalization",
374
+ style: {
375
+ alignSelf: 'flex-end'
376
+ },
377
+ children: /*#__PURE__*/ jsx(Typography, {
378
+ variant: "pi",
379
+ textAlign: "right",
380
+ children: formatMessage({
381
+ id: getTranslation('CMEditViewAITranslation.settings-link'),
382
+ defaultMessage: '{enabled, select, true {Disable it in settings} false {Enable it in settings} other {Enable it in settings}}'
383
+ }, {
384
+ enabled: isAISettingEnabled
385
+ })
386
+ })
387
+ })
388
+ ]
389
+ })
390
+ }
391
+ };
392
+ };
393
+ /* -------------------------------------------------------------------------------------------------
394
+ * FillFromAnotherLocaleAction
395
+ * -----------------------------------------------------------------------------------------------*/ const FillFromAnotherLocaleAction = ({ documentId, meta, model, collectionType })=>{
396
+ const { formatMessage } = useIntl();
397
+ const [{ query }] = useQueryParams();
398
+ const { hasI18n } = useI18n();
399
+ const currentDesiredLocale = query.plugins?.i18n?.locale;
400
+ const [localeSelected, setLocaleSelected] = React.useState(null);
401
+ const setValues = useForm('FillFromAnotherLocale', (state)=>state.setValues);
402
+ const { getDocument } = unstable_useDocumentActions();
403
+ const { schema, components } = unstable_useDocument({
404
+ model,
405
+ documentId,
406
+ collectionType,
407
+ params: {
408
+ locale: currentDesiredLocale
409
+ }
410
+ });
411
+ const { data: locales = [] } = useGetLocalesQuery();
412
+ const isAIAvailable = useAIAvailability();
413
+ const { data: settings } = useGetSettingsQuery();
414
+ const isAISettingEnabled = settings?.data?.aiLocalizations;
415
+ const availableLocales = Array.isArray(locales) ? locales.filter((locale)=>meta?.availableLocales.some((l)=>l.locale === locale.code)) : [];
416
+ const fillFromLocale = (onClose)=>async ()=>{
417
+ const response = await getDocument({
418
+ collectionType,
419
+ model,
420
+ documentId,
421
+ params: {
422
+ locale: localeSelected
423
+ }
424
+ });
425
+ if (!response || !schema) {
426
+ return;
427
+ }
428
+ const { data } = response;
429
+ const cleanedData = cleanData(data, schema, components);
430
+ setValues(cleanedData);
431
+ onClose();
432
+ };
433
+ if (!hasI18n) {
434
+ return null;
435
+ }
436
+ // Do not display this action when AI is available and AI translations are enabled
437
+ const hasAIFutureFlag = window.strapi.future.isEnabled('unstableAILocalizations');
438
+ if (hasAIFutureFlag && isAIAvailable && isAISettingEnabled) {
439
+ return null;
440
+ }
441
+ return {
442
+ type: 'icon',
443
+ icon: /*#__PURE__*/ jsx(Earth, {}),
444
+ disabled: availableLocales.length === 0,
445
+ label: formatMessage({
446
+ id: getTranslation('CMEditViewCopyLocale.copy-text'),
447
+ defaultMessage: 'Fill in from another locale'
448
+ }),
449
+ dialog: {
450
+ type: 'dialog',
451
+ title: formatMessage({
452
+ id: getTranslation('CMEditViewCopyLocale.dialog.title'),
453
+ defaultMessage: 'Confirmation'
454
+ }),
455
+ content: ({ onClose })=>/*#__PURE__*/ jsxs(Fragment, {
456
+ children: [
457
+ /*#__PURE__*/ jsx(Dialog.Body, {
458
+ children: /*#__PURE__*/ jsxs(Flex, {
459
+ direction: "column",
460
+ gap: 3,
461
+ children: [
462
+ /*#__PURE__*/ jsx(WarningCircle, {
463
+ width: "24px",
464
+ height: "24px",
465
+ fill: "danger600"
466
+ }),
467
+ /*#__PURE__*/ jsx(Typography, {
468
+ textAlign: "center",
469
+ children: formatMessage({
470
+ id: getTranslation('CMEditViewCopyLocale.dialog.body'),
471
+ defaultMessage: 'Your current content will be erased and filled by the content of the selected locale:'
472
+ })
473
+ }),
474
+ /*#__PURE__*/ jsxs(Field.Root, {
475
+ width: "100%",
476
+ children: [
477
+ /*#__PURE__*/ jsx(Field.Label, {
478
+ children: formatMessage({
479
+ id: getTranslation('CMEditViewCopyLocale.dialog.field.label'),
480
+ defaultMessage: 'Locale'
481
+ })
482
+ }),
483
+ /*#__PURE__*/ jsx(SingleSelect, {
484
+ value: localeSelected,
485
+ placeholder: formatMessage({
486
+ id: getTranslation('CMEditViewCopyLocale.dialog.field.placeholder'),
487
+ defaultMessage: 'Select one locale...'
488
+ }),
489
+ // @ts-expect-error – the DS will handle numbers, but we're not allowing the API.
490
+ onChange: (value)=>setLocaleSelected(value),
491
+ children: availableLocales.map((locale)=>/*#__PURE__*/ jsx(SingleSelectOption, {
492
+ value: locale.code,
493
+ children: locale.name
494
+ }, locale.code))
495
+ })
496
+ ]
497
+ })
498
+ ]
499
+ })
500
+ }),
501
+ /*#__PURE__*/ jsx(Dialog.Footer, {
502
+ children: /*#__PURE__*/ jsxs(Flex, {
503
+ gap: 2,
504
+ width: "100%",
505
+ children: [
506
+ /*#__PURE__*/ jsx(Button, {
507
+ flex: "auto",
508
+ variant: "tertiary",
509
+ onClick: onClose,
510
+ children: formatMessage({
511
+ id: getTranslation('CMEditViewCopyLocale.cancel-text'),
512
+ defaultMessage: 'No, cancel'
513
+ })
514
+ }),
515
+ /*#__PURE__*/ jsx(Button, {
516
+ flex: "auto",
517
+ variant: "success",
518
+ onClick: fillFromLocale(onClose),
519
+ children: formatMessage({
520
+ id: getTranslation('CMEditViewCopyLocale.submit-text'),
521
+ defaultMessage: 'Yes, fill in'
522
+ })
523
+ })
524
+ ]
525
+ })
526
+ })
527
+ ]
528
+ })
529
+ }
530
+ };
531
+ };
532
+ /* -------------------------------------------------------------------------------------------------
533
+ * DeleteLocaleAction
534
+ * -----------------------------------------------------------------------------------------------*/ const DeleteLocaleAction = ({ document, documentId, model, collectionType })=>{
535
+ const { formatMessage } = useIntl();
536
+ const navigate = useNavigate();
537
+ const { toggleNotification } = useNotification();
538
+ const { delete: deleteAction, isLoading } = unstable_useDocumentActions();
539
+ const { hasI18n, canDelete } = useI18n();
540
+ // Get the current locale object, using the URL instead of document so it works while creating
541
+ const [{ query }] = useQueryParams();
542
+ const { data: locales = [] } = useGetLocalesQuery();
543
+ const currentDesiredLocale = query.plugins?.i18n?.locale;
544
+ const locale = !('error' in locales) && locales.find((loc)=>loc.code === currentDesiredLocale);
545
+ if (!hasI18n) {
546
+ return null;
547
+ }
548
+ return {
549
+ disabled: document?.locale && !canDelete.includes(document.locale) || !document || !document.id,
550
+ position: [
551
+ 'header',
552
+ 'table-row'
553
+ ],
554
+ label: formatMessage({
555
+ id: getTranslation('actions.delete.label'),
556
+ defaultMessage: 'Delete entry ({locale})'
557
+ }, {
558
+ locale: locale && locale.name
559
+ }),
560
+ icon: /*#__PURE__*/ jsx(StyledTrash, {}),
561
+ variant: 'danger',
562
+ dialog: {
563
+ type: 'dialog',
564
+ title: formatMessage({
565
+ id: getTranslation('actions.delete.dialog.title'),
566
+ defaultMessage: 'Confirmation'
567
+ }),
568
+ content: /*#__PURE__*/ jsxs(Flex, {
569
+ direction: "column",
570
+ gap: 2,
571
+ children: [
572
+ /*#__PURE__*/ jsx(WarningCircle, {
573
+ width: "24px",
574
+ height: "24px",
575
+ fill: "danger600"
576
+ }),
577
+ /*#__PURE__*/ jsx(Typography, {
578
+ tag: "p",
579
+ variant: "omega",
580
+ textAlign: "center",
581
+ children: formatMessage({
582
+ id: getTranslation('actions.delete.dialog.body'),
583
+ defaultMessage: 'Are you sure?'
584
+ })
585
+ })
586
+ ]
587
+ }),
588
+ loading: isLoading,
589
+ onConfirm: async ()=>{
590
+ const unableToDelete = // We are unable to delete a collection type without a document ID
591
+ // & unable to delete generally if there is no document locale
592
+ collectionType !== 'single-types' && !documentId || !document?.locale;
593
+ if (unableToDelete) {
594
+ console.error("You're trying to delete a document without an id or locale, this is likely a bug with Strapi. Please open an issue.");
595
+ toggleNotification({
596
+ message: formatMessage({
597
+ id: getTranslation('actions.delete.error'),
598
+ defaultMessage: 'An error occurred while trying to delete the document locale.'
599
+ }),
600
+ type: 'danger'
601
+ });
602
+ return;
603
+ }
604
+ const res = await deleteAction({
605
+ documentId,
606
+ model,
607
+ collectionType,
608
+ params: {
609
+ locale: document.locale
610
+ }
611
+ });
612
+ if (!('error' in res)) {
613
+ navigate({
614
+ pathname: `../${collectionType}/${model}`
615
+ }, {
616
+ replace: true
617
+ });
618
+ }
619
+ }
620
+ }
621
+ };
622
+ };
623
+ /* -------------------------------------------------------------------------------------------------
624
+ * BulkLocaleAction
625
+ *
626
+ * This component is used to handle bulk publish and unpublish actions on locales.
627
+ * -----------------------------------------------------------------------------------------------*/ const BulkLocaleAction = ({ document, documentId, model, collectionType, action })=>{
628
+ const locale = document?.locale ?? null;
629
+ const [{ query }] = useQueryParams();
630
+ const params = React.useMemo(()=>buildValidParams(query), [
631
+ query
632
+ ]);
633
+ const isOnPublishedTab = query.status === 'published';
634
+ const { formatMessage } = useIntl();
635
+ const { hasI18n, canPublish } = useI18n();
636
+ const { toggleNotification } = useNotification();
637
+ const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();
638
+ const [selectedRows, setSelectedRows] = React.useState([]);
639
+ const [isDraftRelationConfirmationOpen, setIsDraftRelationConfirmationOpen] = React.useState(false);
640
+ const { publishMany: publishManyAction, unpublishMany: unpublishManyAction } = unstable_useDocumentActions();
641
+ const { schema, validate } = unstable_useDocument({
642
+ model,
643
+ collectionType,
644
+ documentId,
645
+ params: {
646
+ locale
647
+ }
648
+ }, {
649
+ // No need to fetch the document, the data is already available in the `document` prop
650
+ skip: true
651
+ });
652
+ const { data: localesMetadata = [] } = useGetLocalesQuery(hasI18n ? undefined : skipToken);
653
+ const headers = [
654
+ {
655
+ label: formatMessage({
656
+ id: 'global.name',
657
+ defaultMessage: 'Name'
658
+ }),
659
+ name: 'name'
660
+ },
661
+ {
662
+ label: formatMessage({
663
+ id: getTranslation('CMEditViewBulkLocale.status'),
664
+ defaultMessage: 'Status'
665
+ }),
666
+ name: 'status'
667
+ },
668
+ {
669
+ label: formatMessage({
670
+ id: getTranslation('CMEditViewBulkLocale.publication-status'),
671
+ defaultMessage: 'Publication Status'
672
+ }),
673
+ name: 'publication-status'
674
+ }
675
+ ];
676
+ // Extract the rows for the bulk locale publish modal and any validation
677
+ // errors per locale
678
+ const [rows, validationErrors] = React.useMemo(()=>{
679
+ if (!document) {
680
+ return [
681
+ [],
682
+ {}
683
+ ];
684
+ }
685
+ const localizations = document.localizations ?? [];
686
+ // Build the rows for the bulk locale publish modal by combining the current
687
+ // document with all the available locales from the document meta
688
+ const locales = localizations.map((doc)=>{
689
+ const { locale, status } = doc;
690
+ return {
691
+ locale,
692
+ status
693
+ };
694
+ });
695
+ // Add the current document locale
696
+ locales.unshift({
697
+ locale: document.locale,
698
+ status: document.status
699
+ });
700
+ // Build the validation errors for each locale.
701
+ const allDocuments = [
702
+ document,
703
+ ...localizations
704
+ ];
705
+ const errors = allDocuments.reduce((errs, document)=>{
706
+ if (!document) {
707
+ return errs;
708
+ }
709
+ // Validate each locale entry via the useDocument validate function and store any errors in a dictionary
710
+ const validation = validate(document);
711
+ if (validation !== null) {
712
+ errs[document.locale] = validation;
713
+ }
714
+ return errs;
715
+ }, {});
716
+ return [
717
+ locales,
718
+ errors
719
+ ];
720
+ }, [
721
+ document,
722
+ validate
723
+ ]);
724
+ const isBulkPublish = action === 'bulk-publish';
725
+ const localesForAction = selectedRows.reduce((acc, selectedRow)=>{
726
+ const isValidLocale = // Validation errors are irrelevant if we are trying to unpublish
727
+ !isBulkPublish || !Object.keys(validationErrors).includes(selectedRow.locale);
728
+ const shouldAddLocale = isBulkPublish ? selectedRow.status !== 'published' && isValidLocale : selectedRow.status !== 'draft' && isValidLocale;
729
+ if (shouldAddLocale) {
730
+ acc.push(selectedRow.locale);
731
+ }
732
+ return acc;
733
+ }, []);
734
+ // TODO skipping this for now as there is a bug with the draft relation count that will be worked on separately
735
+ // see https://www.notion.so/strapi/Count-draft-relations-56901b492efb45ab90d42fe975b32bd8?pvs=4
736
+ const enableDraftRelationsCount = false;
737
+ const { data: draftRelationsCount = 0, isLoading: isDraftRelationsLoading, error: isDraftRelationsError } = useGetManyDraftRelationCountQuery({
738
+ model,
739
+ documentIds: [
740
+ documentId
741
+ ],
742
+ locale: localesForAction
743
+ }, {
744
+ skip: !enableDraftRelationsCount
745
+ });
746
+ React.useEffect(()=>{
747
+ if (isDraftRelationsError) {
748
+ toggleNotification({
749
+ type: 'danger',
750
+ message: formatAPIError(isDraftRelationsError)
751
+ });
752
+ }
753
+ }, [
754
+ isDraftRelationsError,
755
+ toggleNotification,
756
+ formatAPIError
757
+ ]);
758
+ if (!schema?.options?.draftAndPublish) {
759
+ return null;
760
+ }
761
+ if (!hasI18n) {
762
+ return null;
763
+ }
764
+ if (!documentId) {
765
+ return null;
766
+ }
767
+ // This document action can be enabled given that draft and publish and i18n are
768
+ // enabled and we can publish the current locale.
769
+ const publish = async ()=>{
770
+ await publishManyAction({
771
+ model,
772
+ documentIds: [
773
+ documentId
774
+ ],
775
+ params: {
776
+ ...params,
777
+ locale: localesForAction
778
+ }
779
+ });
780
+ setSelectedRows([]);
781
+ };
782
+ const unpublish = async ()=>{
783
+ await unpublishManyAction({
784
+ model,
785
+ documentIds: [
786
+ documentId
787
+ ],
788
+ params: {
789
+ ...params,
790
+ locale: localesForAction
791
+ }
792
+ });
793
+ setSelectedRows([]);
794
+ };
795
+ const handleAction = async ()=>{
796
+ if (draftRelationsCount > 0) {
797
+ setIsDraftRelationConfirmationOpen(true);
798
+ } else if (isBulkPublish) {
799
+ await publish();
800
+ } else {
801
+ await unpublish();
802
+ }
803
+ };
804
+ if (isDraftRelationConfirmationOpen) {
805
+ return {
806
+ label: formatMessage({
807
+ id: 'app.components.ConfirmDialog.title',
808
+ defaultMessage: 'Confirmation'
809
+ }),
810
+ variant: 'danger',
811
+ dialog: {
812
+ onCancel: ()=>{
813
+ setIsDraftRelationConfirmationOpen(false);
814
+ },
815
+ onConfirm: async ()=>{
816
+ await publish();
817
+ setIsDraftRelationConfirmationOpen(false);
818
+ },
819
+ type: 'dialog',
820
+ title: formatMessage({
821
+ id: getTranslation('actions.publish.dialog.title'),
822
+ defaultMessage: 'Confirmation'
823
+ }),
824
+ content: /*#__PURE__*/ jsxs(Flex, {
825
+ direction: "column",
826
+ alignItems: "center",
827
+ gap: 2,
828
+ children: [
829
+ /*#__PURE__*/ jsx(WarningCircle, {
830
+ width: "2.4rem",
831
+ height: "2.4rem",
832
+ fill: "danger600"
833
+ }),
834
+ /*#__PURE__*/ jsx(Typography, {
835
+ textAlign: "center",
836
+ children: formatMessage({
837
+ id: getTranslation('CMEditViewBulkLocale.draft-relation-warning'),
838
+ defaultMessage: 'Some locales are related to draft entries. Publishing them could leave broken links in your app.'
839
+ })
840
+ }),
841
+ /*#__PURE__*/ jsx(Typography, {
842
+ textAlign: "center",
843
+ children: formatMessage({
844
+ id: getTranslation('CMEditViewBulkLocale.continue-confirmation'),
845
+ defaultMessage: 'Are you sure you want to continue?'
846
+ })
847
+ })
848
+ ]
849
+ })
850
+ }
851
+ };
852
+ }
853
+ const hasPermission = selectedRows.map(({ locale })=>locale).every((locale)=>canPublish.includes(locale));
854
+ return {
855
+ label: formatMessage({
856
+ id: getTranslation(`CMEditViewBulkLocale.${isBulkPublish ? 'publish' : 'unpublish'}-title`),
857
+ defaultMessage: `${isBulkPublish ? 'Publish' : 'Unpublish'} Multiple Locales`
858
+ }),
859
+ variant: isBulkPublish ? 'secondary' : 'danger',
860
+ icon: isBulkPublish ? /*#__PURE__*/ jsx(ListPlus, {}) : /*#__PURE__*/ jsx(Cross, {}),
861
+ disabled: isOnPublishedTab || canPublish.length === 0,
862
+ position: [
863
+ 'panel'
864
+ ],
865
+ dialog: {
866
+ type: 'modal',
867
+ title: formatMessage({
868
+ id: getTranslation(`CMEditViewBulkLocale.${isBulkPublish ? 'publish' : 'unpublish'}-title`),
869
+ defaultMessage: `${isBulkPublish ? 'Publish' : 'Unpublish'} Multiple Locales`
870
+ }),
871
+ content: ()=>{
872
+ return /*#__PURE__*/ jsx(Table.Root, {
873
+ headers: headers,
874
+ rows: rows.map((row)=>({
875
+ ...row,
876
+ id: row.locale
877
+ })),
878
+ selectedRows: selectedRows,
879
+ onSelectedRowsChange: (tableSelectedRows)=>setSelectedRows(tableSelectedRows),
880
+ children: /*#__PURE__*/ jsx(BulkLocaleActionModal, {
881
+ validationErrors: validationErrors,
882
+ headers: headers,
883
+ rows: rows,
884
+ localesMetadata: localesMetadata,
885
+ action: action ?? 'bulk-publish'
886
+ })
887
+ });
888
+ },
889
+ footer: ()=>/*#__PURE__*/ jsx(Modal.Footer, {
890
+ justifyContent: "flex-end",
891
+ children: /*#__PURE__*/ jsx(Button, {
892
+ loading: isDraftRelationsLoading,
893
+ disabled: !hasPermission || localesForAction.length === 0,
894
+ variant: "default",
895
+ onClick: handleAction,
896
+ children: formatMessage({
897
+ id: isBulkPublish ? 'app.utils.publish' : 'app.utils.unpublish',
898
+ defaultMessage: isBulkPublish ? 'Publish' : 'Unpublish'
899
+ })
900
+ })
901
+ })
902
+ }
903
+ };
904
+ };
905
+ /* -------------------------------------------------------------------------------------------------
906
+ * BulkLocalePublishAction
907
+ * -----------------------------------------------------------------------------------------------*/ const BulkLocalePublishAction = (props)=>{
908
+ return BulkLocaleAction({
909
+ action: 'bulk-publish',
910
+ ...props
911
+ });
912
+ };
913
+ /* -------------------------------------------------------------------------------------------------
914
+ * BulkLocaleUnpublishAction
915
+ * -----------------------------------------------------------------------------------------------*/ const BulkLocaleUnpublishAction = (props)=>{
916
+ return BulkLocaleAction({
917
+ action: 'bulk-unpublish',
918
+ ...props
919
+ });
920
+ };
921
+ /**
922
+ * Because the icon system is completely broken, we have to do
923
+ * this to remove the fill from the cog.
924
+ */ const StyledTrash = styled(Trash)`
925
+ path {
926
+ fill: currentColor;
927
+ }
928
+ `;
929
+
930
+ export { AITranslationStatusAction, BulkLocalePublishAction, BulkLocaleUnpublishAction, DeleteLocaleAction, FillFromAnotherLocaleAction, LocalePickerAction };
931
+ //# sourceMappingURL=CMHeaderActions.mjs.map