@strapi/i18n 0.0.0-next.5f27c76d39a0c192701bdc9daabce3bb59389ce3 → 0.0.0-next.62638801ce303ba9d03355a9f041541cc6668ae0

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 (190) hide show
  1. package/dist/admin/components/BulkLocaleActionModal.js +2 -2
  2. package/dist/admin/components/BulkLocaleActionModal.js.map +1 -1
  3. package/dist/admin/components/BulkLocaleActionModal.mjs +2 -2
  4. package/dist/admin/components/BulkLocaleActionModal.mjs.map +1 -1
  5. package/dist/admin/components/CMHeaderActions.js +294 -20
  6. package/dist/admin/components/CMHeaderActions.js.map +1 -1
  7. package/dist/admin/components/CMHeaderActions.mjs +298 -25
  8. package/dist/admin/components/CMHeaderActions.mjs.map +1 -1
  9. package/dist/admin/components/CreateLocale.js +8 -4
  10. package/dist/admin/components/CreateLocale.js.map +1 -1
  11. package/dist/admin/components/CreateLocale.mjs +9 -5
  12. package/dist/admin/components/CreateLocale.mjs.map +1 -1
  13. package/dist/admin/components/EditLocale.js +1 -1
  14. package/dist/admin/components/EditLocale.js.map +1 -1
  15. package/dist/admin/components/EditLocale.mjs +1 -1
  16. package/dist/admin/components/EditLocale.mjs.map +1 -1
  17. package/dist/admin/components/LocaleListCell.js +65 -45
  18. package/dist/admin/components/LocaleListCell.js.map +1 -1
  19. package/dist/admin/components/LocaleListCell.mjs +66 -46
  20. package/dist/admin/components/LocaleListCell.mjs.map +1 -1
  21. package/dist/admin/components/LocalePicker.js +18 -11
  22. package/dist/admin/components/LocalePicker.js.map +1 -1
  23. package/dist/admin/components/LocalePicker.mjs +19 -12
  24. package/dist/admin/components/LocalePicker.mjs.map +1 -1
  25. package/dist/admin/contentManagerHooks/editView.js +6 -3
  26. package/dist/admin/contentManagerHooks/editView.js.map +1 -1
  27. package/dist/admin/contentManagerHooks/editView.mjs +7 -4
  28. package/dist/admin/contentManagerHooks/editView.mjs.map +1 -1
  29. package/dist/admin/contentManagerHooks/listView.js +2 -1
  30. package/dist/admin/contentManagerHooks/listView.js.map +1 -1
  31. package/dist/admin/contentManagerHooks/listView.mjs +2 -1
  32. package/dist/admin/contentManagerHooks/listView.mjs.map +1 -1
  33. package/dist/admin/hooks/useAILocalizationJobsPolling.js +110 -0
  34. package/dist/admin/hooks/useAILocalizationJobsPolling.js.map +1 -0
  35. package/dist/admin/hooks/useAILocalizationJobsPolling.mjs +89 -0
  36. package/dist/admin/hooks/useAILocalizationJobsPolling.mjs.map +1 -0
  37. package/dist/admin/hooks/useI18n.js +4 -4
  38. package/dist/admin/hooks/useI18n.js.map +1 -1
  39. package/dist/admin/hooks/useI18n.mjs +4 -4
  40. package/dist/admin/hooks/useI18n.mjs.map +1 -1
  41. package/dist/admin/index.js +1 -0
  42. package/dist/admin/index.js.map +1 -1
  43. package/dist/admin/index.mjs +2 -1
  44. package/dist/admin/index.mjs.map +1 -1
  45. package/dist/admin/pages/SettingsPage.js +121 -46
  46. package/dist/admin/pages/SettingsPage.js.map +1 -1
  47. package/dist/admin/pages/SettingsPage.mjs +124 -30
  48. package/dist/admin/pages/SettingsPage.mjs.map +1 -1
  49. package/dist/admin/services/aiLocalizationJobs.js +26 -0
  50. package/dist/admin/services/aiLocalizationJobs.js.map +1 -0
  51. package/dist/admin/services/aiLocalizationJobs.mjs +24 -0
  52. package/dist/admin/services/aiLocalizationJobs.mjs.map +1 -0
  53. package/dist/admin/services/api.js +4 -1
  54. package/dist/admin/services/api.js.map +1 -1
  55. package/dist/admin/services/api.mjs +4 -1
  56. package/dist/admin/services/api.mjs.map +1 -1
  57. package/dist/admin/services/locales.js +4 -2
  58. package/dist/admin/services/locales.js.map +1 -1
  59. package/dist/admin/services/locales.mjs +4 -2
  60. package/dist/admin/services/locales.mjs.map +1 -1
  61. package/dist/admin/services/settings.js +30 -0
  62. package/dist/admin/services/settings.js.map +1 -0
  63. package/dist/admin/services/settings.mjs +27 -0
  64. package/dist/admin/services/settings.mjs.map +1 -0
  65. package/dist/admin/src/components/CMHeaderActions.d.ts +17 -4
  66. package/dist/admin/src/components/LocaleListCell.d.ts +2 -1
  67. package/dist/admin/src/hooks/useAILocalizationJobsPolling.d.ts +9 -0
  68. package/dist/admin/src/services/aiLocalizationJobs.d.ts +6 -0
  69. package/dist/admin/src/services/api.d.ts +1 -1
  70. package/dist/admin/src/services/locales.d.ts +1 -1
  71. package/dist/admin/src/services/relations.d.ts +1 -1
  72. package/dist/admin/src/services/settings.d.ts +5 -0
  73. package/dist/admin/translations/en.json.js +10 -0
  74. package/dist/admin/translations/en.json.js.map +1 -1
  75. package/dist/admin/translations/en.json.mjs +10 -0
  76. package/dist/admin/translations/en.json.mjs.map +1 -1
  77. package/dist/admin/utils/clean.js +2 -2
  78. package/dist/admin/utils/clean.js.map +1 -1
  79. package/dist/admin/utils/clean.mjs +2 -2
  80. package/dist/admin/utils/clean.mjs.map +1 -1
  81. package/dist/admin/utils/getTranslation.js.map +1 -1
  82. package/dist/admin/utils/getTranslation.mjs.map +1 -1
  83. package/dist/admin/utils/prefixPluginTranslations.js.map +1 -1
  84. package/dist/admin/utils/prefixPluginTranslations.mjs.map +1 -1
  85. package/dist/server/bootstrap.js +24 -8
  86. package/dist/server/bootstrap.js.map +1 -1
  87. package/dist/server/bootstrap.mjs +24 -8
  88. package/dist/server/bootstrap.mjs.map +1 -1
  89. package/dist/server/constants/iso-locales.json.js +4 -0
  90. package/dist/server/constants/iso-locales.json.js.map +1 -1
  91. package/dist/server/constants/iso-locales.json.mjs +4 -0
  92. package/dist/server/constants/iso-locales.json.mjs.map +1 -1
  93. package/dist/server/controllers/ai-localization-jobs.js +47 -0
  94. package/dist/server/controllers/ai-localization-jobs.js.map +1 -0
  95. package/dist/server/controllers/ai-localization-jobs.mjs +45 -0
  96. package/dist/server/controllers/ai-localization-jobs.mjs.map +1 -0
  97. package/dist/server/controllers/index.js +5 -1
  98. package/dist/server/controllers/index.js.map +1 -1
  99. package/dist/server/controllers/index.mjs +5 -1
  100. package/dist/server/controllers/index.mjs.map +1 -1
  101. package/dist/server/controllers/settings.js +24 -0
  102. package/dist/server/controllers/settings.js.map +1 -0
  103. package/dist/server/controllers/settings.mjs +22 -0
  104. package/dist/server/controllers/settings.mjs.map +1 -0
  105. package/dist/server/models/ai-localization-job.js +60 -0
  106. package/dist/server/models/ai-localization-job.js.map +1 -0
  107. package/dist/server/models/ai-localization-job.mjs +57 -0
  108. package/dist/server/models/ai-localization-job.mjs.map +1 -0
  109. package/dist/server/register.js +3 -1
  110. package/dist/server/register.js.map +1 -1
  111. package/dist/server/register.mjs +3 -1
  112. package/dist/server/register.mjs.map +1 -1
  113. package/dist/server/routes/admin.js +40 -0
  114. package/dist/server/routes/admin.js.map +1 -1
  115. package/dist/server/routes/admin.mjs +40 -0
  116. package/dist/server/routes/admin.mjs.map +1 -1
  117. package/dist/server/routes/content-api.js +11 -7
  118. package/dist/server/routes/content-api.js.map +1 -1
  119. package/dist/server/routes/content-api.mjs +11 -7
  120. package/dist/server/routes/content-api.mjs.map +1 -1
  121. package/dist/server/routes/index.mjs +2 -2
  122. package/dist/server/routes/validation/locale.js +57 -0
  123. package/dist/server/routes/validation/locale.js.map +1 -0
  124. package/dist/server/routes/validation/locale.mjs +36 -0
  125. package/dist/server/routes/validation/locale.mjs.map +1 -0
  126. package/dist/server/services/ai-localization-jobs.js +64 -0
  127. package/dist/server/services/ai-localization-jobs.js.map +1 -0
  128. package/dist/server/services/ai-localization-jobs.mjs +62 -0
  129. package/dist/server/services/ai-localization-jobs.mjs.map +1 -0
  130. package/dist/server/services/ai-localizations.js +268 -0
  131. package/dist/server/services/ai-localizations.js.map +1 -0
  132. package/dist/server/services/ai-localizations.mjs +266 -0
  133. package/dist/server/services/ai-localizations.mjs.map +1 -0
  134. package/dist/server/services/content-types.js.map +1 -1
  135. package/dist/server/services/content-types.mjs.map +1 -1
  136. package/dist/server/services/index.js +7 -1
  137. package/dist/server/services/index.js.map +1 -1
  138. package/dist/server/services/index.mjs +7 -1
  139. package/dist/server/services/index.mjs.map +1 -1
  140. package/dist/server/services/settings.js +25 -0
  141. package/dist/server/services/settings.js.map +1 -0
  142. package/dist/server/services/settings.mjs +23 -0
  143. package/dist/server/services/settings.mjs.map +1 -0
  144. package/dist/server/src/bootstrap.d.ts.map +1 -1
  145. package/dist/server/src/controllers/ai-localization-jobs.d.ts +17 -0
  146. package/dist/server/src/controllers/ai-localization-jobs.d.ts.map +1 -0
  147. package/dist/server/src/controllers/index.d.ts +10 -0
  148. package/dist/server/src/controllers/index.d.ts.map +1 -1
  149. package/dist/server/src/controllers/settings.d.ts +7 -0
  150. package/dist/server/src/controllers/settings.d.ts.map +1 -0
  151. package/dist/server/src/index.d.ts +47 -8
  152. package/dist/server/src/index.d.ts.map +1 -1
  153. package/dist/server/src/models/ai-localization-job.d.ts +5 -0
  154. package/dist/server/src/models/ai-localization-job.d.ts.map +1 -0
  155. package/dist/server/src/models/index.d.ts +5 -0
  156. package/dist/server/src/models/index.d.ts.map +1 -0
  157. package/dist/server/src/register.d.ts +1 -1
  158. package/dist/server/src/register.d.ts.map +1 -1
  159. package/dist/server/src/routes/admin.d.ts.map +1 -1
  160. package/dist/server/src/routes/content-api.d.ts +5 -8
  161. package/dist/server/src/routes/content-api.d.ts.map +1 -1
  162. package/dist/server/src/routes/index.d.ts +3 -7
  163. package/dist/server/src/routes/index.d.ts.map +1 -1
  164. package/dist/server/src/routes/validation/index.d.ts +2 -0
  165. package/dist/server/src/routes/validation/index.d.ts.map +1 -0
  166. package/dist/server/src/routes/validation/locale.d.ts +41 -0
  167. package/dist/server/src/routes/validation/locale.d.ts.map +1 -0
  168. package/dist/server/src/services/ai-localization-jobs.d.ts +26 -0
  169. package/dist/server/src/services/ai-localization-jobs.d.ts.map +1 -0
  170. package/dist/server/src/services/ai-localizations.d.ts +18 -0
  171. package/dist/server/src/services/ai-localizations.d.ts.map +1 -0
  172. package/dist/server/src/services/index.d.ts +33 -0
  173. package/dist/server/src/services/index.d.ts.map +1 -1
  174. package/dist/server/src/services/settings.d.ts +13 -0
  175. package/dist/server/src/services/settings.d.ts.map +1 -0
  176. package/dist/server/src/utils/index.d.ts +7 -1
  177. package/dist/server/src/utils/index.d.ts.map +1 -1
  178. package/dist/server/src/validation/settings.d.ts +12 -0
  179. package/dist/server/src/validation/settings.d.ts.map +1 -0
  180. package/dist/server/utils/index.js.map +1 -1
  181. package/dist/server/utils/index.mjs.map +1 -1
  182. package/dist/server/validation/settings.js +11 -0
  183. package/dist/server/validation/settings.js.map +1 -0
  184. package/dist/server/validation/settings.mjs +9 -0
  185. package/dist/server/validation/settings.mjs.map +1 -0
  186. package/dist/shared/contracts/ai-localization-jobs.d.ts +27 -0
  187. package/dist/shared/contracts/ai-localization-jobs.d.ts.map +1 -0
  188. package/dist/shared/contracts/settings.d.ts +40 -0
  189. package/dist/shared/contracts/shared.d.ts.map +1 -0
  190. package/package.json +13 -10
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAILocalizationJobsPolling.mjs","sources":["../../../admin/src/hooks/useAILocalizationJobsPolling.ts"],"sourcesContent":["import * as React from 'react';\n\nimport { useNotification, adminApi } from '@strapi/admin/strapi-admin';\nimport { useIntl } from 'react-intl';\nimport { useDispatch } from 'react-redux';\n\nimport { AILocalizationJobs } from '../../../shared/contracts/ai-localization-jobs';\nimport { useGetAILocalizationJobsByDocumentQuery } from '../services/aiLocalizationJobs';\nimport { getTranslation } from '../utils/getTranslation';\n\ninterface UseAILocalizationJobsPollingOptions {\n documentId?: string;\n model?: string;\n collectionType?: string;\n}\n\nexport const useAILocalizationJobsPolling = ({\n documentId,\n model,\n collectionType,\n}: UseAILocalizationJobsPollingOptions) => {\n const { toggleNotification } = useNotification();\n const { formatMessage } = useIntl();\n const dispatch = useDispatch();\n\n const [previousJobStatus, setPreviousJobStatus] = React.useState<\n AILocalizationJobs['status'] | null\n >(null);\n\n /**\n * NOTE:\n * Due to a limitation with RTK query it is not possible to dynamically update the polling interval\n * @see https://github.com/reduxjs/redux-toolkit/issues/1651\n */\n const { data: initialJobData } = useGetAILocalizationJobsByDocumentQuery({\n documentId: documentId!,\n model: model!,\n collectionType: collectionType!,\n });\n\n const shouldPoll =\n initialJobData?.data?.status === 'processing' || previousJobStatus === 'processing';\n const { data: jobData } = useGetAILocalizationJobsByDocumentQuery(\n { documentId: documentId!, model: model!, collectionType: collectionType! },\n {\n skip: !shouldPoll,\n pollingInterval: 1000,\n }\n );\n\n const job = jobData?.data || initialJobData?.data;\n const currentJobStatus = job?.status;\n\n const invalidateDocument = React.useCallback(() => {\n dispatch(\n adminApi.util.invalidateTags([\n {\n // @ts-expect-error tag isn't available\n type: 'Document',\n id: collectionType !== 'single-types' ? `${model}_${documentId}` : model,\n },\n ])\n );\n }, [dispatch, collectionType, model, documentId]);\n\n // Check for job status changes and trigger callbacks\n React.useEffect(() => {\n if (!currentJobStatus) return;\n\n // Detect transition from 'processing' to a terminal state\n if (previousJobStatus === 'processing' && currentJobStatus === 'completed') {\n toggleNotification({\n type: 'success',\n message: formatMessage({\n id: getTranslation('CMEditViewAITranslation.job-completed'),\n defaultMessage: 'AI translation completed successfully!',\n }),\n });\n invalidateDocument();\n }\n\n if (previousJobStatus === 'processing' && currentJobStatus === 'failed') {\n toggleNotification({\n type: 'warning',\n message: formatMessage({\n id: getTranslation('CMEditViewAITranslation.job-failed'),\n defaultMessage: 'AI translation failed. Please try again.',\n }),\n });\n invalidateDocument();\n }\n\n // Update the previous status if it changed\n if (previousJobStatus !== currentJobStatus) {\n setPreviousJobStatus(currentJobStatus);\n }\n }, [\n currentJobStatus,\n previousJobStatus,\n setPreviousJobStatus,\n toggleNotification,\n formatMessage,\n invalidateDocument,\n ]);\n\n return {\n status: job?.status,\n };\n};\n"],"names":["useAILocalizationJobsPolling","documentId","model","collectionType","toggleNotification","useNotification","formatMessage","useIntl","dispatch","useDispatch","previousJobStatus","setPreviousJobStatus","React","useState","data","initialJobData","useGetAILocalizationJobsByDocumentQuery","shouldPoll","status","jobData","skip","pollingInterval","job","currentJobStatus","invalidateDocument","useCallback","adminApi","util","invalidateTags","type","id","useEffect","message","getTranslation","defaultMessage"],"mappings":";;;;;;;AAgBO,MAAMA,+BAA+B,CAAC,EAC3CC,UAAU,EACVC,KAAK,EACLC,cAAc,EACsB,GAAA;IACpC,MAAM,EAAEC,kBAAkB,EAAE,GAAGC,eAAAA,EAAAA;IAC/B,MAAM,EAAEC,aAAa,EAAE,GAAGC,OAAAA,EAAAA;AAC1B,IAAA,MAAMC,QAAWC,GAAAA,WAAAA,EAAAA;AAEjB,IAAA,MAAM,CAACC,iBAAmBC,EAAAA,oBAAAA,CAAqB,GAAGC,KAAAA,CAAMC,QAAQ,CAE9D,IAAA,CAAA;AAEF;;;;AAIC,MACD,MAAM,EAAEC,IAAAA,EAAMC,cAAc,EAAE,GAAGC,uCAAwC,CAAA;QACvEf,UAAYA,EAAAA,UAAAA;QACZC,KAAOA,EAAAA,KAAAA;QACPC,cAAgBA,EAAAA;AAClB,KAAA,CAAA;AAEA,IAAA,MAAMc,UACJF,GAAAA,cAAAA,EAAgBD,IAAMI,EAAAA,MAAAA,KAAW,gBAAgBR,iBAAsB,KAAA,YAAA;AACzE,IAAA,MAAM,EAAEI,IAAAA,EAAMK,OAAO,EAAE,GAAGH,uCACxB,CAAA;QAAEf,UAAYA,EAAAA,UAAAA;QAAaC,KAAOA,EAAAA,KAAAA;QAAQC,cAAgBA,EAAAA;KAC1D,EAAA;AACEiB,QAAAA,IAAAA,EAAM,CAACH,UAAAA;QACPI,eAAiB,EAAA;AACnB,KAAA,CAAA;IAGF,MAAMC,GAAAA,GAAMH,OAASL,EAAAA,IAAAA,IAAQC,cAAgBD,EAAAA,IAAAA;AAC7C,IAAA,MAAMS,mBAAmBD,GAAKJ,EAAAA,MAAAA;IAE9B,MAAMM,kBAAAA,GAAqBZ,KAAMa,CAAAA,WAAW,CAAC,IAAA;AAC3CjB,QAAAA,QAAAA,CACEkB,QAASC,CAAAA,IAAI,CAACC,cAAc,CAAC;AAC3B,YAAA;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AA,EAAQI,GAAKJ,EAAAA;AACf,KAAA;AACF;;;;"}
@@ -3,6 +3,7 @@
3
3
  var React = require('react');
4
4
  var strapiAdmin = require('@strapi/admin/strapi-admin');
5
5
  var strapiAdmin$1 = require('@strapi/content-manager/strapi-admin');
6
+ var union = require('lodash/union');
6
7
  var reactRouterDom = require('react-router-dom');
7
8
  var fields = require('../utils/fields.js');
8
9
  var strings = require('../utils/strings.js');
@@ -39,10 +40,9 @@ var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
39
40
  const permissions = userPermissions.filter((permission)=>permission.subject === params.slug);
40
41
  return permissions.reduce((acc, permission)=>{
41
42
  const [actionShorthand] = permission.action.split('.').slice(-1);
42
- return {
43
- ...acc,
44
- [`can${strings.capitalize(actionShorthand)}`]: permission.properties?.locales ?? []
45
- };
43
+ const permissionKey = `can${strings.capitalize(actionShorthand)}`;
44
+ acc[permissionKey] = union(acc[permissionKey] ?? [], permission.properties?.locales ?? []);
45
+ return acc;
46
46
  }, {
47
47
  canCreate: [],
48
48
  canRead: [],
@@ -1 +1 @@
1
- {"version":3,"file":"useI18n.js","sources":["../../../admin/src/hooks/useI18n.ts"],"sourcesContent":["import * as React from 'react';\n\nimport { useAuth } from '@strapi/admin/strapi-admin';\nimport { unstable_useDocument as useDocument } from '@strapi/content-manager/strapi-admin';\nimport { useParams } from 'react-router-dom';\n\nimport { doesPluginOptionsHaveI18nLocalized } from '../utils/fields';\nimport { capitalize } from '../utils/strings';\n\ntype UseI18n = () => {\n hasI18n: boolean;\n canCreate: string[];\n canRead: string[];\n canUpdate: string[];\n canDelete: string[];\n canPublish: string[];\n};\n\n/**\n * @alpha\n * @description This hook is used to get the i18n status of a content type.\n * Also returns the CRUDP permission locale properties for the content type\n * so we know which locales the user can perform actions on.\n */\nconst useI18n: UseI18n = () => {\n // Extract the params from the URL to pass to our useDocument hook\n const params = useParams<{ collectionType: string; slug: string; model: string }>();\n\n const userPermissions = useAuth('useI18n', (state) => state.permissions);\n const actions = React.useMemo(() => {\n const permissions = userPermissions.filter((permission) => permission.subject === params.slug);\n\n return permissions.reduce<Omit<ReturnType<UseI18n>, 'hasI18n'>>(\n (acc, permission) => {\n const [actionShorthand] = permission.action.split('.').slice(-1);\n\n return {\n ...acc,\n [`can${capitalize(actionShorthand)}`]: permission.properties?.locales ?? [],\n };\n },\n { canCreate: [], canRead: [], canUpdate: [], canDelete: [], canPublish: [] }\n );\n }, [params.slug, userPermissions]);\n\n // TODO: use specific hook to get schema only\n const { schema } = useDocument(\n {\n // We can non-null assert these because below we skip the query if they are not present\n collectionType: params.collectionType!,\n model: params.slug!,\n },\n {\n skip: true,\n }\n );\n\n if (doesPluginOptionsHaveI18nLocalized(schema?.pluginOptions)) {\n return {\n hasI18n: schema.pluginOptions.i18n.localized,\n ...actions,\n };\n }\n\n return {\n hasI18n: false,\n ...actions,\n };\n};\n\nexport { useI18n };\n"],"names":["useI18n","params","useParams","userPermissions","useAuth","state","permissions","actions","React","useMemo","filter","permission","subject","slug","reduce","acc","actionShorthand","action","split","slice","capitalize","properties","locales","canCreate","canRead","canUpdate","canDelete","canPublish","schema","useDocument","collectionType","model","skip","doesPluginOptionsHaveI18nLocalized","pluginOptions","hasI18n","i18n","localized"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBA;;;;;AAKC,UACKA,OAAmB,GAAA,IAAA;;AAEvB,IAAA,MAAMC,MAASC,GAAAA,wBAAAA,EAAAA;AAEf,IAAA,MAAMC,kBAAkBC,mBAAQ,CAAA,SAAA,EAAW,CAACC,KAAAA,GAAUA,MAAMC,WAAW,CAAA;IACvE,MAAMC,OAAAA,GAAUC,gBAAMC,CAAAA,OAAO,CAAC,IAAA;QAC5B,MAAMH,WAAAA,GAAcH,eAAgBO,CAAAA,MAAM,CAAC,CAACC,aAAeA,UAAWC,CAAAA,OAAO,KAAKX,MAAAA,CAAOY,IAAI,CAAA;AAE7F,QAAA,OAAOP,WAAYQ,CAAAA,MAAM,CACvB,CAACC,GAAKJ,EAAAA,UAAAA,GAAAA;YACJ,MAAM,CAACK,eAAgB,CAAA,GAAGL,UAAWM,CAAAA,MAAM,CAACC,KAAK,CAAC,GAAA,CAAA,CAAKC,KAAK,CAAC,CAAC,CAAA,CAAA;YAE9D,OAAO;AACL,gBAAA,GAAGJ,GAAG;AACN,gBAAA,CAAC,CAAC,GAAG,EAAEK,kBAAAA,CAAWJ,eAAiB,CAAA,CAAA,CAAC,GAAGL,UAAWU,CAAAA,UAAU,EAAEC,OAAAA,IAAW;AAC3E,aAAA;SAEF,EAAA;AAAEC,YAAAA,SAAAA,EAAW,EAAE;AAAEC,YAAAA,OAAAA,EAAS,EAAE;AAAEC,YAAAA,SAAAA,EAAW,EAAE;AAAEC,YAAAA,SAAAA,EAAW,EAAE;AAAEC,YAAAA,UAAAA,EAAY;AAAG,SAAA,CAAA;KAE5E,EAAA;AAAC1B,QAAAA,MAAAA,CAAOY,IAAI;AAAEV,QAAAA;AAAgB,KAAA,CAAA;;AAGjC,IAAA,MAAM,EAAEyB,MAAM,EAAE,GAAGC,kCACjB,CAAA;;AAEEC,QAAAA,cAAAA,EAAgB7B,OAAO6B,cAAc;AACrCC,QAAAA,KAAAA,EAAO9B,OAAOY;KAEhB,EAAA;QACEmB,IAAM,EAAA;AACR,KAAA,CAAA;IAGF,IAAIC,yCAAAA,CAAmCL,QAAQM,aAAgB,CAAA,EAAA;QAC7D,OAAO;AACLC,YAAAA,OAAAA,EAASP,MAAOM,CAAAA,aAAa,CAACE,IAAI,CAACC,SAAS;AAC5C,YAAA,GAAG9B;AACL,SAAA;AACF;IAEA,OAAO;QACL4B,OAAS,EAAA,KAAA;AACT,QAAA,GAAG5B;AACL,KAAA;AACF;;;;"}
1
+ {"version":3,"file":"useI18n.js","sources":["../../../admin/src/hooks/useI18n.ts"],"sourcesContent":["import * as React from 'react';\n\nimport { useAuth } from '@strapi/admin/strapi-admin';\nimport { unstable_useDocument as useDocument } from '@strapi/content-manager/strapi-admin';\nimport union from 'lodash/union';\nimport { useParams } from 'react-router-dom';\n\nimport { doesPluginOptionsHaveI18nLocalized } from '../utils/fields';\nimport { capitalize } from '../utils/strings';\n\ntype UseI18n = () => {\n hasI18n: boolean;\n canCreate: string[];\n canRead: string[];\n canUpdate: string[];\n canDelete: string[];\n canPublish: string[];\n};\n\ntype I18nPermissionKeys = keyof Omit<ReturnType<UseI18n>, 'hasI18n'>;\n\n/**\n * @alpha\n * @description This hook is used to get the i18n status of a content type.\n * Also returns the CRUDP permission locale properties for the content type\n * so we know which locales the user can perform actions on.\n */\nconst useI18n: UseI18n = () => {\n // Extract the params from the URL to pass to our useDocument hook\n const params = useParams<{ collectionType: string; slug: string; model: string }>();\n\n const userPermissions = useAuth('useI18n', (state) => state.permissions);\n const actions = React.useMemo(() => {\n const permissions = userPermissions.filter((permission) => permission.subject === params.slug);\n\n return permissions.reduce<Record<I18nPermissionKeys, string[]>>(\n (acc, permission) => {\n const [actionShorthand] = permission.action.split('.').slice(-1);\n const permissionKey = `can${capitalize(actionShorthand)}` as I18nPermissionKeys;\n\n acc[permissionKey] = union(acc[permissionKey] ?? [], permission.properties?.locales ?? []);\n\n return acc;\n },\n { canCreate: [], canRead: [], canUpdate: [], canDelete: [], canPublish: [] }\n );\n }, [params.slug, userPermissions]);\n\n // TODO: use specific hook to get schema only\n const { schema } = useDocument(\n {\n // We can non-null assert these because below we skip the query if they are not present\n collectionType: params.collectionType!,\n model: params.slug!,\n },\n {\n skip: true,\n }\n );\n\n if (doesPluginOptionsHaveI18nLocalized(schema?.pluginOptions)) {\n return {\n hasI18n: schema.pluginOptions.i18n.localized,\n ...actions,\n };\n }\n\n return {\n hasI18n: false,\n ...actions,\n };\n};\n\nexport { useI18n };\n"],"names":["useI18n","params","useParams","userPermissions","useAuth","state","permissions","actions","React","useMemo","filter","permission","subject","slug","reduce","acc","actionShorthand","action","split","slice","permissionKey","capitalize","union","properties","locales","canCreate","canRead","canUpdate","canDelete","canPublish","schema","useDocument","collectionType","model","skip","doesPluginO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AAM,EAAE,GAAGC,kCACjB,CAAA;;AAEEC,QAAAA,cAAAA,EAAgB/B,OAAO+B,cAAc;AACrCC,QAAAA,KAAAA,EAAOhC,OAAOY;KAEhB,EAAA;QACEqB,IAAM,EAAA;AACR,KAAA,CAAA;IAGF,IAAIC,yCAAAA,CAAmCL,QAAQM,aAAgB,CAAA,EAAA;QAC7D,OAAO;AACLC,YAAAA,OAAAA,EAASP,MAAOM,CAAAA,aAAa,CAACE,IAAI,CAACC,SAAS;AAC5C,YAAA,GAAGhC;AACL,SAAA;AACF;IAEA,OAAO;QACL8B,OAAS,EAAA,KAAA;AACT,QAAA,GAAG9B;AACL,KAAA;AACF;;;;"}
@@ -1,6 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { useAuth } from '@strapi/admin/strapi-admin';
3
3
  import { unstable_useDocument } from '@strapi/content-manager/strapi-admin';
4
+ import union from 'lodash/union';
4
5
  import { useParams } from 'react-router-dom';
5
6
  import { doesPluginOptionsHaveI18nLocalized } from '../utils/fields.mjs';
6
7
  import { capitalize } from '../utils/strings.mjs';
@@ -18,10 +19,9 @@ import { capitalize } from '../utils/strings.mjs';
18
19
  const permissions = userPermissions.filter((permission)=>permission.subject === params.slug);
19
20
  return permissions.reduce((acc, permission)=>{
20
21
  const [actionShorthand] = permission.action.split('.').slice(-1);
21
- return {
22
- ...acc,
23
- [`can${capitalize(actionShorthand)}`]: permission.properties?.locales ?? []
24
- };
22
+ const permissionKey = `can${capitalize(actionShorthand)}`;
23
+ acc[permissionKey] = union(acc[permissionKey] ?? [], permission.properties?.locales ?? []);
24
+ return acc;
25
25
  }, {
26
26
  canCreate: [],
27
27
  canRead: [],
@@ -1 +1 @@
1
- {"version":3,"file":"useI18n.mjs","sources":["../../../admin/src/hooks/useI18n.ts"],"sourcesContent":["import * as React from 'react';\n\nimport { useAuth } from '@strapi/admin/strapi-admin';\nimport { unstable_useDocument as useDocument } from '@strapi/content-manager/strapi-admin';\nimport { useParams } from 'react-router-dom';\n\nimport { doesPluginOptionsHaveI18nLocalized } from '../utils/fields';\nimport { capitalize } from '../utils/strings';\n\ntype UseI18n = () => {\n hasI18n: boolean;\n canCreate: string[];\n canRead: string[];\n canUpdate: string[];\n canDelete: string[];\n canPublish: string[];\n};\n\n/**\n * @alpha\n * @description This hook is used to get the i18n status of a content type.\n * Also returns the CRUDP permission locale properties for the content type\n * so we know which locales the user can perform actions on.\n */\nconst useI18n: UseI18n = () => {\n // Extract the params from the URL to pass to our useDocument hook\n const params = useParams<{ collectionType: string; slug: string; model: string }>();\n\n const userPermissions = useAuth('useI18n', (state) => state.permissions);\n const actions = React.useMemo(() => {\n const permissions = userPermissions.filter((permission) => permission.subject === params.slug);\n\n return permissions.reduce<Omit<ReturnType<UseI18n>, 'hasI18n'>>(\n (acc, permission) => {\n const [actionShorthand] = permission.action.split('.').slice(-1);\n\n return {\n ...acc,\n [`can${capitalize(actionShorthand)}`]: permission.properties?.locales ?? [],\n };\n },\n { canCreate: [], canRead: [], canUpdate: [], canDelete: [], canPublish: [] }\n );\n }, [params.slug, userPermissions]);\n\n // TODO: use specific hook to get schema only\n const { schema } = useDocument(\n {\n // We can non-null assert these because below we skip the query if they are not present\n collectionType: params.collectionType!,\n model: params.slug!,\n },\n {\n skip: true,\n }\n );\n\n if (doesPluginOptionsHaveI18nLocalized(schema?.pluginOptions)) {\n return {\n hasI18n: schema.pluginOptions.i18n.localized,\n ...actions,\n };\n }\n\n return {\n hasI18n: false,\n ...actions,\n };\n};\n\nexport { useI18n };\n"],"names":["useI18n","params","useParams","userPermissions","useAuth","state","permissions","actions","React","useMemo","filter","permission","subject","slug","reduce","acc","actionShorthand","action","split","slice","capitalize","properties","locales","canCreate","canRead","canUpdate","canDelete","canPublish","schema","useDocument","collectionType","model","skip","doesPluginOptionsHaveI18nLocalized","pluginOptions","hasI18n","i18n","localized"],"mappings":";;;;;;;AAkBA;;;;;AAKC,UACKA,OAAmB,GAAA,IAAA;;AAEvB,IAAA,MAAMC,MAASC,GAAAA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AAA,OAAAA,EAASP,MAAOM,CAAAA,aAAa,CAACE,IAAI,CAACC,SAAS;AAC5C,YAAA,GAAG9B;AACL,SAAA;AACF;IAEA,OAAO;QACL4B,OAAS,EAAA,KAAA;AACT,QAAA,GAAG5B;AACL,KAAA;AACF;;;;"}
1
+ {"version":3,"file":"useI18n.mjs","sources":["../../../admin/src/hooks/useI18n.ts"],"sourcesContent":["import * as React from 'react';\n\nimport { useAuth } from '@strapi/admin/strapi-admin';\nimport { unstable_useDocument as useDocument } from '@strapi/content-manager/strapi-admin';\nimport union from 'lodash/union';\nimport { useParams } from 'react-router-dom';\n\nimport { doesPluginOptionsHaveI18nLocalized } from '../utils/fields';\nimport { capitalize } from '../utils/strings';\n\ntype UseI18n = () => {\n hasI18n: boolean;\n canCreate: string[];\n canRead: string[];\n canUpdate: string[];\n canDelete: string[];\n canPublish: string[];\n};\n\ntype I18nPermissionKeys = keyof Omit<ReturnType<UseI18n>, 'hasI18n'>;\n\n/**\n * @alpha\n * @description This hook is used to get the i18n status of a content type.\n * Also returns the CRUDP permission locale properties for the content type\n * so we know which locales the user can perform actions on.\n */\nconst useI18n: UseI18n = () => {\n // Extract the params from the URL to pass to our useDocument hook\n const params = useParams<{ collectionType: string; slug: string; model: string }>();\n\n const userPermissions = useAuth('useI18n', (state) => state.permissions);\n const actions = React.useMemo(() => {\n const permissions = userPermissions.filter((permission) => permission.subject === params.slug);\n\n return permissions.reduce<Record<I18nPermissionKeys, string[]>>(\n (acc, permission) => {\n const [actionShorthand] = permission.action.split('.').slice(-1);\n const permissionKey = `can${capitalize(actionShorthand)}` as I18nPermissionKeys;\n\n acc[permissionKey] = union(acc[permissionKey] ?? [], permission.properties?.locales ?? []);\n\n return acc;\n },\n { canCreate: [], canRead: [], canUpdate: [], canDelete: [], canPublish: [] }\n );\n }, [params.slug, userPermissions]);\n\n // TODO: use specific hook to get schema only\n const { schema } = useDocument(\n {\n // We can non-null assert these because below we skip the query if they are not present\n collectionType: params.collectionType!,\n model: params.slug!,\n },\n {\n skip: true,\n }\n );\n\n if (doesPluginOptionsHaveI18nLocalized(schema?.pluginOptions)) {\n return {\n hasI18n: schema.pluginOptions.i18n.localized,\n ...actions,\n };\n }\n\n return {\n hasI18n: false,\n ...actions,\n };\n};\n\nexport { useI18n };\n"],"names":["useI18n","params","useParams","userPermissions","useAuth","state","permissions","actions","React","useMemo","filter","permission","subject","slug","reduce","acc","actionShorthand","action","split","slice","permissionKey","capitalize","union","properties","locales","canCreate","canRead","canUpdate","canDelete","canPublish","schema","useDocument","collectionType","model","skip","doesPluginOptionsHaveI18nLocalized","pluginOptions","hasI18n","i18n","localized"],"mappings":";;;;;;;;AAqBA;;;;;AAKC,UACKA,OAAmB,GAAA,IAAA;;AAEvB,IAAA,MAAMC,MAASC,GAAAA,SAAAA,EAAAA;AAEf,IAAA,MAAMC,kBAAkBC,OAAQ,CAAA,SAAA,EAAW,CAACC,KAAAA,GAAUA,MAAMC,WAAW,CAAA;IACvE,MAAMC,OAAAA,GAAUC,KAAMC,CAAAA,OAAO,CAAC,IAAA;QAC5B,MAAMH,WAAAA,GAAcH,eAAgBO,CAAAA,MAAM,CAAC,CAACC,aAAeA,UAAWC,CAAAA,OAAO,KAAKX,MAAAA,CAAOY,IAAI,CAAA;AAE7F,QAAA,OAAOP,WAAYQ,CAAAA,MAAM,CACvB,CAACC,GAAKJ,EAAAA,UAAAA,GAAAA;YACJ,MAAM,CAACK,eAAgB,CAAA,GAAGL,UAAWM,CAAAA,MAAM,CAACC,KAAK,CAAC,GAAA,CAAA,CAAKC,KAAK,CAAC,CAAC,CAAA,CAAA;AAC9D,YAAA,MAAMC,aAAgB,GAAA,CAAC,GAAG,EAAEC,WAAWL,eAAkB,CAAA,CAAA,CAAA;AAEzDD,YAAAA,GAAG,CAACK,aAAAA,CAAc,GAAGE,KAAAA,CAAMP,GAAG,CAACK,aAAAA,CAAc,IAAI,EAAE,EAAET,UAAAA,CAAWY,UAAU,EAAEC,WAAW,EAAE,CAAA;YAEzF,OAAOT,GAAAA;SAET,EAAA;AAAEU,YAAAA,SAAAA,EAAW,EAAE;AAAEC,YAAAA,OAAAA,EAAS,EAAE;AAAEC,YAAAA,SAAAA,EAAW,EAAE;AAAEC,YAAAA,SAAAA,EAAW,EAAE;AAAEC,YAAAA,UAAAA,EAAY;AAAG,SAAA,CAAA;KAE5E,EAAA;AAAC5B,QAAAA,MAAAA,CAAOY,IAAI;AAAEV,QAAAA;AAAgB,KAAA,CAAA;;AAGjC,IAAA,MAAM,EAAE2B,MAAM,EAAE,GAAGC,oBACjB,CAAA;;AAEEC,QAAAA,cAAAA,EAAgB/B,OAAO+B,cAAc;AACrCC,QAAAA,KAAAA,EAAOhC,OAAOY;KAEhB,EAAA;QACEqB,IAAM,EAAA;AACR,KAAA,CAAA;IAGF,IAAIC,kCAAAA,CAAmCL,QAAQM,aAAgB,CAAA,EAAA;QAC7D,OAAO;AACLC,YAAAA,OAAAA,EAASP,MAAOM,CAAAA,aAAa,CAACE,IAAI,CAACC,SAAS;AAC5C,YAAA,GAAGhC;AACL,SAAA;AACF;IAEA,OAAO;QACL8B,OAAS,EAAA,KAAA;AACT,QAAA,GAAG9B;AACL,KAAA;AACF;;;;"}
@@ -104,6 +104,7 @@ var index = {
104
104
  });
105
105
  const contentManager = app.getPlugin('content-manager');
106
106
  contentManager.apis.addDocumentHeaderAction([
107
+ CMHeaderActions.AITranslationStatusAction,
107
108
  CMHeaderActions.LocalePickerAction,
108
109
  CMHeaderActions.FillFromAnotherLocaleAction
109
110
  ]);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../admin/src/index.ts"],"sourcesContent":["import get from 'lodash/get';\nimport * as yup from 'yup';\n\nimport { CheckboxConfirmation } from './components/CheckboxConfirmation';\nimport {\n BulkLocalePublishAction,\n BulkLocaleUnpublishAction,\n DeleteLocaleAction,\n LocalePickerAction,\n FillFromAnotherLocaleAction,\n} from './components/CMHeaderActions';\nimport {\n DeleteModalAdditionalInfo,\n PublishModalAdditionalInfo,\n UnpublishModalAdditionalInfo,\n} from './components/CMListViewModalsAdditionalInformation';\nimport { LocalePicker } from './components/LocalePicker';\nimport { PERMISSIONS } from './constants';\nimport { mutateEditViewHook } from './contentManagerHooks/editView';\nimport { addColumnToTableHook } from './contentManagerHooks/listView';\nimport { addLocaleToReleasesHook } from './contentReleasesHooks/releaseDetailsView';\nimport { extendCTBAttributeInitialDataMiddleware } from './middlewares/extendCTBAttributeInitialData';\nimport { extendCTBInitialDataMiddleware } from './middlewares/extendCTBInitialData';\nimport { localeMiddleware } from './middlewares/rbac-middleware';\nimport { pluginId } from './pluginId';\nimport { i18nApi } from './services/api';\nimport { LOCALIZED_FIELDS } from './utils/fields';\nimport { getTranslation } from './utils/getTranslation';\nimport { prefixPluginTranslations } from './utils/prefixPluginTranslations';\nimport { mutateCTBContentTypeSchema } from './utils/schemas';\n\nimport type { DocumentActionComponent } from '@strapi/content-manager/strapi-admin';\n\n// eslint-disable-next-line import/no-default-export\nexport default {\n register(app: any) {\n app.addMiddlewares([extendCTBAttributeInitialDataMiddleware, extendCTBInitialDataMiddleware]);\n app.addMiddlewares([() => i18nApi.middleware]);\n app.addReducers({\n [i18nApi.reducerPath]: i18nApi.reducer,\n });\n app.addRBACMiddleware([localeMiddleware]);\n app.registerPlugin({\n id: pluginId,\n name: pluginId,\n });\n },\n bootstrap(app: any) {\n // // Hook that adds a column into the CM's LV table\n app.registerHook('Admin/CM/pages/ListView/inject-column-in-table', addColumnToTableHook);\n app.registerHook('Admin/CM/pages/EditView/mutate-edit-view-layout', mutateEditViewHook);\n // Hooks that checks if the locale is present in the release\n app.registerHook(\n 'ContentReleases/pages/ReleaseDetails/add-locale-in-releases',\n addLocaleToReleasesHook\n );\n\n // Add the settings link\n app.addSettingsLink('global', {\n intlLabel: {\n id: getTranslation('plugin.name'),\n defaultMessage: 'Internationalization',\n },\n id: 'internationalization',\n to: 'internationalization',\n Component: () =>\n import('./pages/SettingsPage').then((mod) => ({ default: mod.ProtectedSettingsPage })),\n permissions: PERMISSIONS.accessMain,\n });\n\n const contentManager = app.getPlugin('content-manager');\n\n contentManager.apis.addDocumentHeaderAction([LocalePickerAction, FillFromAnotherLocaleAction]);\n contentManager.apis.addDocumentAction((actions: DocumentActionComponent[]) => {\n const indexOfDeleteAction = actions.findIndex((action) => action.type === 'delete');\n actions.splice(indexOfDeleteAction, 0, DeleteLocaleAction);\n return actions;\n });\n\n contentManager.apis.addDocumentAction((actions: DocumentActionComponent[]) => {\n // When enabled the bulk locale publish action should be the first action\n // in 'More Document Actions' and therefore the third action in the array\n actions.splice(2, 0, BulkLocalePublishAction);\n actions.splice(5, 0, BulkLocaleUnpublishAction);\n return actions;\n });\n\n contentManager.injectComponent('listView', 'actions', {\n name: 'i18n-locale-filter',\n Component: LocalePicker,\n });\n\n contentManager.injectComponent('listView', 'publishModalAdditionalInfos', {\n name: 'i18n-publish-bullets-in-modal',\n Component: PublishModalAdditionalInfo,\n });\n\n contentManager.injectComponent('listView', 'unpublishModalAdditionalInfos', {\n name: 'i18n-unpublish-bullets-in-modal',\n Component: UnpublishModalAdditionalInfo,\n });\n\n contentManager.injectComponent('listView', 'deleteModalAdditionalInfos', {\n name: 'i18n-delete-bullets-in-modal',\n Component: DeleteModalAdditionalInfo,\n });\n\n const ctbPlugin = app.getPlugin('content-type-builder');\n\n if (ctbPlugin) {\n const ctbFormsAPI = ctbPlugin.apis.forms;\n ctbFormsAPI.addContentTypeSchemaMutation(mutateCTBContentTypeSchema);\n ctbFormsAPI.components.add({ id: 'checkboxConfirmation', component: CheckboxConfirmation });\n\n ctbFormsAPI.extendContentType({\n validator: () => ({\n i18n: yup.object().shape({\n localized: yup.bool(),\n }),\n }),\n form: {\n advanced() {\n return [\n {\n name: 'pluginOptions.i18n.localized',\n description: {\n id: getTranslation('plugin.schema.i18n.localized.description-content-type'),\n defaultMessage: 'Allows translating an entry into different languages',\n },\n type: 'checkboxConfirmation',\n intlLabel: {\n id: getTranslation('plugin.schema.i18n.localized.label-content-type'),\n defaultMessage: 'Localization',\n },\n },\n ];\n },\n },\n });\n\n ctbFormsAPI.extendFields(LOCALIZED_FIELDS, {\n form: {\n advanced({ contentTypeSchema, forTarget, type, step }: any) {\n if (forTarget !== 'contentType') {\n return [];\n }\n\n const hasI18nEnabled = get(\n contentTypeSchema,\n ['pluginOptions', 'i18n', 'localized'],\n false\n );\n\n if (!hasI18nEnabled) {\n return [];\n }\n\n if (type === 'component' && step === '1') {\n return [];\n }\n\n return [\n {\n name: 'pluginOptions.i18n.localized',\n description: {\n id: getTranslation('plugin.schema.i18n.localized.description-field'),\n defaultMessage: 'The field can have different values in each locale',\n },\n type: 'checkbox',\n intlLabel: {\n id: getTranslation('plugin.schema.i18n.localized.label-field'),\n defaultMessage: 'Enable localization for this field',\n },\n },\n ];\n },\n },\n });\n }\n },\n async registerTrads({ locales }: { locales: string[] }) {\n const importedTrads = await Promise.all(\n locales.map((locale) => {\n return import(`./translations/${locale}.json`)\n .then(({ default: data }) => {\n return {\n data: prefixPluginTranslations(data, pluginId),\n locale,\n };\n })\n .catch(() => {\n return {\n data: {},\n locale,\n };\n });\n })\n );\n\n return Promise.resolve(importedTrads);\n },\n};\n"],"names":["register","app","addMiddlewares","extendCTBAttributeInitialDataMiddleware","extendCTBInitialDataMiddleware","i18nApi","middleware","addReducers","reducerPath","reducer","addRBACMiddleware","localeMiddleware","registerPlugin","id","pluginId","name","bootstrap","registerHook","addColumnToTableHook","mutateEditViewHook","addLocaleToReleasesHook","addSettingsLink","intlLabel","getTranslation","defaultMessage","to","Component","then","mod","default","ProtectedSettingsPage","permissions","PERMISSIONS","accessMain","contentManager","getPlugin","apis","addDocumentHeaderAction","LocalePickerAction","FillFromAnotherLocaleAction","addDocumentAction","actions","indexOfDeleteAction","findIndex","action","type","splice","DeleteLocaleAction","BulkLocalePublishAction","BulkLocaleUnpublishAction","injectComponent","LocalePicker","PublishModalAdditionalInfo","UnpublishModalAdditionalInfo","DeleteModalAdditionalInfo","ctbPlugin","ctbFormsAPI","forms","addContentTypeSchemaMutation","mutateCTBContentTypeSchema","components","add","component","CheckboxConfirmation","extendContentType","validator","i18n","yup","object","shape","localized","bool","form","advanced","description","extendFields","LOCALIZED_FIELDS","contentTypeSchema","forTarget","step","hasI18nEnabled","get","registerTrads","locales","importedTrads","Promise","all","map","locale","data","prefixPluginTranslations","catch","resolve"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA;AACA,YAAe;AACbA,IAAAA,QAAAA,CAAAA,CAASC,GAAQ,EAAA;AACfA,QAAAA,GAAAA,CAAIC,cAAc,CAAC;AAACC,YAAAA,qEAAAA;AAAyCC,YAAAA;AAA+B,SAAA,CAAA;AAC5FH,QAAAA,GAAAA,CAAIC,cAAc,CAAC;AAAC,YAAA,IAAMG,YAAQC;AAAW,SAAA,CAAA;AAC7CL,QAAAA,GAAAA,CAAIM,WAAW,CAAC;AACd,YAAA,CAACF,WAAQG,CAAAA,WAAW,GAAGH,YAAQI;AACjC,SAAA,CAAA;AACAR,QAAAA,GAAAA,CAAIS,iBAAiB,CAAC;AAACC,YAAAA;AAAiB,SAAA,CAAA;AACxCV,QAAAA,GAAAA,CAAIW,cAAc,CAAC;YACjBC,EAAIC,EAAAA,iBAAAA;YACJC,IAAMD,EAAAA;AACR,SAAA,CAAA;AACF,KAAA;AACAE,IAAAA,SAAAA,CAAAA,CAAUf,GAAQ,EAAA;;QAEhBA,GAAIgB,CAAAA,YAAY,CAAC,gDAAkDC,EAAAA,6BAAAA,CAAAA;QACnEjB,GAAIgB,CAAAA,YAAY,CAAC,iDAAmDE,EAAAA,2BAAAA,CAAAA;;QAEpElB,GAAIgB,CAAAA,YAAY,CACd,6DACAG,EAAAA,0CAAAA,CAAAA;;QAIFnB,GAAIoB,CAAAA,eAAe,CAAC,QAAU,EAAA;YAC5BC,SAAW,EAAA;AACTT,gBAAAA,EAAAA,EAAIU,6BAAe,CAAA,aAAA,CAA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GAAA;gBACtB,OAAO;AACLA,oBAAAA,IAAAA,EAAMC,kDAAyBD,IAAM3E,EAAAA,iBAAAA,CAAAA;AACrC0E,oBAAAA;AACF,iBAAA;AACF,aAAA,CAAA,CACCG,KAAK,CAAC,IAAA;gBACL,OAAO;AACLF,oBAAAA,IAAAA,EAAM,EAAC;AACPD,oBAAAA;AACF,iBAAA;AACF,aAAA,CAAA;AACJ,SAAA,CAAA,CAAA;QAGF,OAAOH,OAAAA,CAAQO,OAAO,CAACR,aAAAA,CAAAA;AACzB;AACF,CAAE;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../admin/src/index.ts"],"sourcesContent":["import get from 'lodash/get';\nimport * as yup from 'yup';\n\nimport { CheckboxConfirmation } from './components/CheckboxConfirmation';\nimport {\n BulkLocalePublishAction,\n BulkLocaleUnpublishAction,\n DeleteLocaleAction,\n LocalePickerAction,\n FillFromAnotherLocaleAction,\n AITranslationStatusAction,\n} from './components/CMHeaderActions';\nimport {\n DeleteModalAdditionalInfo,\n PublishModalAdditionalInfo,\n UnpublishModalAdditionalInfo,\n} from './components/CMListViewModalsAdditionalInformation';\nimport { LocalePicker } from './components/LocalePicker';\nimport { PERMISSIONS } from './constants';\nimport { mutateEditViewHook } from './contentManagerHooks/editView';\nimport { addColumnToTableHook } from './contentManagerHooks/listView';\nimport { addLocaleToReleasesHook } from './contentReleasesHooks/releaseDetailsView';\nimport { extendCTBAttributeInitialDataMiddleware } from './middlewares/extendCTBAttributeInitialData';\nimport { extendCTBInitialDataMiddleware } from './middlewares/extendCTBInitialData';\nimport { localeMiddleware } from './middlewares/rbac-middleware';\nimport { pluginId } from './pluginId';\nimport { i18nApi } from './services/api';\nimport { LOCALIZED_FIELDS } from './utils/fields';\nimport { getTranslation } from './utils/getTranslation';\nimport { prefixPluginTranslations } from './utils/prefixPluginTranslations';\nimport { mutateCTBContentTypeSchema } from './utils/schemas';\n\nimport type { DocumentActionComponent } from '@strapi/content-manager/strapi-admin';\n\n// eslint-disable-next-line import/no-default-export\nexport default {\n register(app: any) {\n app.addMiddlewares([extendCTBAttributeInitialDataMiddleware, extendCTBInitialDataMiddleware]);\n app.addMiddlewares([() => i18nApi.middleware]);\n app.addReducers({\n [i18nApi.reducerPath]: i18nApi.reducer,\n });\n app.addRBACMiddleware([localeMiddleware]);\n app.registerPlugin({\n id: pluginId,\n name: pluginId,\n });\n },\n bootstrap(app: any) {\n // // Hook that adds a column into the CM's LV table\n app.registerHook('Admin/CM/pages/ListView/inject-column-in-table', addColumnToTableHook);\n app.registerHook('Admin/CM/pages/EditView/mutate-edit-view-layout', mutateEditViewHook);\n // Hooks that checks if the locale is present in the release\n app.registerHook(\n 'ContentReleases/pages/ReleaseDetails/add-locale-in-releases',\n addLocaleToReleasesHook\n );\n\n // Add the settings link\n app.addSettingsLink('global', {\n intlLabel: {\n id: getTranslation('plugin.name'),\n defaultMessage: 'Internationalization',\n },\n id: 'internationalization',\n to: 'internationalization',\n Component: () =>\n import('./pages/SettingsPage').then((mod) => ({ default: mod.ProtectedSettingsPage })),\n permissions: PERMISSIONS.accessMain,\n });\n\n const contentManager = app.getPlugin('content-manager');\n\n contentManager.apis.addDocumentHeaderAction([\n AITranslationStatusAction,\n LocalePickerAction,\n FillFromAnotherLocaleAction,\n ]);\n contentManager.apis.addDocumentAction((actions: DocumentActionComponent[]) => {\n const indexOfDeleteAction = actions.findIndex((action) => action.type === 'delete');\n actions.splice(indexOfDeleteAction, 0, DeleteLocaleAction);\n return actions;\n });\n\n contentManager.apis.addDocumentAction((actions: DocumentActionComponent[]) => {\n // When enabled the bulk locale publish action should be the first action\n // in 'More Document Actions' and therefore the third action in the array\n actions.splice(2, 0, BulkLocalePublishAction);\n actions.splice(5, 0, BulkLocaleUnpublishAction);\n return actions;\n });\n\n contentManager.injectComponent('listView', 'actions', {\n name: 'i18n-locale-filter',\n Component: LocalePicker,\n });\n\n contentManager.injectComponent('listView', 'publishModalAdditionalInfos', {\n name: 'i18n-publish-bullets-in-modal',\n Component: PublishModalAdditionalInfo,\n });\n\n contentManager.injectComponent('listView', 'unpublishModalAdditionalInfos', {\n name: 'i18n-unpublish-bullets-in-modal',\n Component: UnpublishModalAdditionalInfo,\n });\n\n contentManager.injectComponent('listView', 'deleteModalAdditionalInfos', {\n name: 'i18n-delete-bullets-in-modal',\n Component: DeleteModalAdditionalInfo,\n });\n\n const ctbPlugin = app.getPlugin('content-type-builder');\n\n if (ctbPlugin) {\n const ctbFormsAPI = ctbPlugin.apis.forms;\n ctbFormsAPI.addContentTypeSchemaMutation(mutateCTBContentTypeSchema);\n ctbFormsAPI.components.add({ id: 'checkboxConfirmation', component: CheckboxConfirmation });\n\n ctbFormsAPI.extendContentType({\n validator: () => ({\n i18n: yup.object().shape({\n localized: yup.bool(),\n }),\n }),\n form: {\n advanced() {\n return [\n {\n name: 'pluginOptions.i18n.localized',\n description: {\n id: getTranslation('plugin.schema.i18n.localized.description-content-type'),\n defaultMessage: 'Allows translating an entry into different languages',\n },\n type: 'checkboxConfirmation',\n intlLabel: {\n id: getTranslation('plugin.schema.i18n.localized.label-content-type'),\n defaultMessage: 'Localization',\n },\n },\n ];\n },\n },\n });\n\n ctbFormsAPI.extendFields(LOCALIZED_FIELDS, {\n form: {\n advanced({ contentTypeSchema, forTarget, type, step }: any) {\n if (forTarget !== 'contentType') {\n return [];\n }\n\n const hasI18nEnabled = get(\n contentTypeSchema,\n ['pluginOptions', 'i18n', 'localized'],\n false\n );\n\n if (!hasI18nEnabled) {\n return [];\n }\n\n if (type === 'component' && step === '1') {\n return [];\n }\n\n return [\n {\n name: 'pluginOptions.i18n.localized',\n description: {\n id: getTranslation('plugin.schema.i18n.localized.description-field'),\n defaultMessage: 'The field can have different values in each locale',\n },\n type: 'checkbox',\n intlLabel: {\n id: getTranslation('plugin.schema.i18n.localized.label-field'),\n defaultMessage: 'Enable localization for this field',\n },\n },\n ];\n },\n },\n });\n }\n },\n async registerTrads({ locales }: { locales: string[] }) {\n const importedTrads = await Promise.all(\n locales.map((locale) => {\n return import(`./translations/${locale}.json`)\n .then(({ default: data }) => {\n return {\n data: prefixPluginTranslations(data, pluginId),\n locale,\n };\n })\n .catch(() => {\n return {\n data: {},\n locale,\n };\n });\n })\n );\n\n return Promise.resolve(importedTrads);\n },\n};\n"],"names":["register","app","addMiddlewares","extendCTBAttributeInitialDataMiddleware","extendCTBInitialDataMiddleware","i18nApi","middleware","addReducers","reducerPath","reducer","addRBACMiddleware","localeMiddleware","registerPlugin","id","pluginId","name","bootstrap","registerHook","addColumnToTableHook","mutateEditViewHook","addLocaleToReleasesHook","addSettingsLink","intlLabel","getTranslation","defaultMessage","to","Component","then","mod","default","ProtectedSettingsPage","permissions","PERMISSIONS","accessMain","contentManager","getPlugin","apis","addDocumentHeaderAction","AITranslationStatusAction","LocalePickerAction","FillFromAnotherLocaleAction","addDocumentAction","actions","indexOfDeleteAction","findIndex","action","type","splice","DeleteLocaleAction","BulkLocalePublishAction","BulkLocaleUnpublishAction","injectComponent","LocalePicker","PublishModalAdditionalInfo","UnpublishModalAdditionalInfo","DeleteModalAdditionalInfo","ctbPlugin","ctbFormsAPI","forms","addContentTypeSchemaMutation","mutateCTBContentTypeSchema","components","add","component","CheckboxConfirmation","extendContentType","validator","i18n","yup","object","shape","localized","bool","form","advanced","description","extendFields","LOCALIZED_FIELDS","contentTypeSchema","forTarget","step","hasI18nEnabled","get","registerTrads","locales","importedTrads","Promise","all","map","locale","data","prefixPluginTranslations","catch","resolve"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA;AACA,YAAe;AACbA,IAAAA,QAAAA,CAAAA,CAASC,GAAQ,EAAA;AACfA,QAAAA,GAAAA,CAAIC,cAAc,CAAC;AAACC,YAAAA,qEAAAA;AAAyCC,YAAAA;AAA+B,SAAA,CAAA;AAC5FH,QAAAA,GAAAA,CAAIC,cAAc,CAAC;AAAC,YAAA,IAAMG,YAAQC;AAAW,SAAA,CAAA;AA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A;AACxC,4BAAA,OAAO,EAAE;AACX;wBAEA,OAAO;AACL,4BAAA;gCACEjE,IAAM,EAAA,8BAAA;gCACN4D,WAAa,EAAA;AACX9D,oCAAAA,EAAAA,EAAIU,6BAAe,CAAA,gDAAA,CAAA;oCACnBC,cAAgB,EAAA;AAClB,iCAAA;gCACAsB,IAAM,EAAA,UAAA;gCACNxB,SAAW,EAAA;AACTT,oCAAAA,EAAAA,EAAIU,6BAAe,CAAA,0CAAA,CAAA;oCACnBC,cAAgB,EAAA;AAClB;AACF;AACD,yBAAA;AACH;AACF;AACF,aAAA,CAAA;AACF;AACF,KAAA;IACA,MAAM2D,aAAAA,CAAAA,CAAc,EAAEC,OAAO,EAAyB,EAAA;QACpD,MAAMC,aAAAA,GAAgB,MAAMC,OAAQC,CAAAA,GAAG,CACrCH,OAAQI,CAAAA,GAAG,CAAC,CAACC,MAAAA,GAAAA;AACX,YAAA,OAAO,iCAAM,CAAC,CAAC,eAAe,EAAEA,MAAO,CAAA,KAAK,CAAC,CAAA,CAC1C9D,IAAI,CAAC,CAAC,EAAEE,OAAAA,EAAS6D,IAAI,EAAE,GAAA;gBACtB,OAAO;AACLA,oBAAAA,IAAAA,EAAMC,kDAAyBD,IAAM5E,EAAAA,iBAAAA,CAAAA;AACrC2E,oBAAAA;AACF,iBAAA;AACF,aAAA,CAAA,CACCG,KAAK,CAAC,IAAA;gBACL,OAAO;AACLF,oBAAAA,IAAAA,EAAM,EAAC;AACPD,oBAAAA;AACF,iBAAA;AACF,aAAA,CAAA;AACJ,SAAA,CAAA,CAAA;QAGF,OAAOH,OAAAA,CAAQO,OAAO,CAACR,aAAAA,CAAAA;AACzB;AACF,CAAE;;;;"}
@@ -1,7 +1,7 @@
1
1
  import get from 'lodash/get';
2
2
  import * as yup from 'yup';
3
3
  import { CheckboxConfirmation } from './components/CheckboxConfirmation.mjs';
4
- import { LocalePickerAction, FillFromAnotherLocaleAction, DeleteLocaleAction, BulkLocalePublishAction, BulkLocaleUnpublishAction } from './components/CMHeaderActions.mjs';
4
+ import { AITranslationStatusAction, LocalePickerAction, FillFromAnotherLocaleAction, DeleteLocaleAction, BulkLocalePublishAction, BulkLocaleUnpublishAction } from './components/CMHeaderActions.mjs';
5
5
  import { PublishModalAdditionalInfo, UnpublishModalAdditionalInfo, DeleteModalAdditionalInfo } from './components/CMListViewModalsAdditionalInformation.mjs';
6
6
  import { LocalePicker } from './components/LocalePicker.mjs';
7
7
  import { PERMISSIONS } from './constants.mjs';
@@ -81,6 +81,7 @@ var index = {
81
81
  });
82
82
  const contentManager = app.getPlugin('content-manager');
83
83
  contentManager.apis.addDocumentHeaderAction([
84
+ AITranslationStatusAction,
84
85
  LocalePickerAction,
85
86
  FillFromAnotherLocaleAction
86
87
  ]);
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../../admin/src/index.ts"],"sourcesContent":["import get from 'lodash/get';\nimport * as yup from 'yup';\n\nimport { CheckboxConfirmation } from './components/CheckboxConfirmation';\nimport {\n BulkLocalePublishAction,\n BulkLocaleUnpublishAction,\n DeleteLocaleAction,\n LocalePickerAction,\n FillFromAnotherLocaleAction,\n} from './components/CMHeaderActions';\nimport {\n DeleteModalAdditionalInfo,\n PublishModalAdditionalInfo,\n UnpublishModalAdditionalInfo,\n} from './components/CMListViewModalsAdditionalInformation';\nimport { LocalePicker } from './components/LocalePicker';\nimport { PERMISSIONS } from './constants';\nimport { mutateEditViewHook } from './contentManagerHooks/editView';\nimport { addColumnToTableHook } from './contentManagerHooks/listView';\nimport { addLocaleToReleasesHook } from './contentReleasesHooks/releaseDetailsView';\nimport { extendCTBAttributeInitialDataMiddleware } from './middlewares/extendCTBAttributeInitialData';\nimport { extendCTBInitialDataMiddleware } from './middlewares/extendCTBInitialData';\nimport { localeMiddleware } from './middlewares/rbac-middleware';\nimport { pluginId } from './pluginId';\nimport { i18nApi } from './services/api';\nimport { LOCALIZED_FIELDS } from './utils/fields';\nimport { getTranslation } from './utils/getTranslation';\nimport { prefixPluginTranslations } from './utils/prefixPluginTranslations';\nimport { mutateCTBContentTypeSchema } from './utils/schemas';\n\nimport type { DocumentActionComponent } from '@strapi/content-manager/strapi-admin';\n\n// eslint-disable-next-line import/no-default-export\nexport default {\n register(app: any) {\n app.addMiddlewares([extendCTBAttributeInitialDataMiddleware, extendCTBInitialDataMiddleware]);\n app.addMiddlewares([() => i18nApi.middleware]);\n app.addReducers({\n [i18nApi.reducerPath]: i18nApi.reducer,\n });\n app.addRBACMiddleware([localeMiddleware]);\n app.registerPlugin({\n id: pluginId,\n name: pluginId,\n });\n },\n bootstrap(app: any) {\n // // Hook that adds a column into the CM's LV table\n app.registerHook('Admin/CM/pages/ListView/inject-column-in-table', addColumnToTableHook);\n app.registerHook('Admin/CM/pages/EditView/mutate-edit-view-layout', mutateEditViewHook);\n // Hooks that checks if the locale is present in the release\n app.registerHook(\n 'ContentReleases/pages/ReleaseDetails/add-locale-in-releases',\n addLocaleToReleasesHook\n );\n\n // Add the settings link\n app.addSettingsLink('global', {\n intlLabel: {\n id: getTranslation('plugin.name'),\n defaultMessage: 'Internationalization',\n },\n id: 'internationalization',\n to: 'internationalization',\n Component: () =>\n import('./pages/SettingsPage').then((mod) => ({ default: mod.ProtectedSettingsPage })),\n permissions: PERMISSIONS.accessMain,\n });\n\n const contentManager = app.getPlugin('content-manager');\n\n contentManager.apis.addDocumentHeaderAction([LocalePickerAction, FillFromAnotherLocaleAction]);\n contentManager.apis.addDocumentAction((actions: DocumentActionComponent[]) => {\n const indexOfDeleteAction = actions.findIndex((action) => action.type === 'delete');\n actions.splice(indexOfDeleteAction, 0, DeleteLocaleAction);\n return actions;\n });\n\n contentManager.apis.addDocumentAction((actions: DocumentActionComponent[]) => {\n // When enabled the bulk locale publish action should be the first action\n // in 'More Document Actions' and therefore the third action in the array\n actions.splice(2, 0, BulkLocalePublishAction);\n actions.splice(5, 0, BulkLocaleUnpublishAction);\n return actions;\n });\n\n contentManager.injectComponent('listView', 'actions', {\n name: 'i18n-locale-filter',\n Component: LocalePicker,\n });\n\n contentManager.injectComponent('listView', 'publishModalAdditionalInfos', {\n name: 'i18n-publish-bullets-in-modal',\n Component: PublishModalAdditionalInfo,\n });\n\n contentManager.injectComponent('listView', 'unpublishModalAdditionalInfos', {\n name: 'i18n-unpublish-bullets-in-modal',\n Component: UnpublishModalAdditionalInfo,\n });\n\n contentManager.injectComponent('listView', 'deleteModalAdditionalInfos', {\n name: 'i18n-delete-bullets-in-modal',\n Component: DeleteModalAdditionalInfo,\n });\n\n const ctbPlugin = app.getPlugin('content-type-builder');\n\n if (ctbPlugin) {\n const ctbFormsAPI = ctbPlugin.apis.forms;\n ctbFormsAPI.addContentTypeSchemaMutation(mutateCTBContentTypeSchema);\n ctbFormsAPI.components.add({ id: 'checkboxConfirmation', component: CheckboxConfirmation });\n\n ctbFormsAPI.extendContentType({\n validator: () => ({\n i18n: yup.object().shape({\n localized: yup.bool(),\n }),\n }),\n form: {\n advanced() {\n return [\n {\n name: 'pluginOptions.i18n.localized',\n description: {\n id: getTranslation('plugin.schema.i18n.localized.description-content-type'),\n defaultMessage: 'Allows translating an entry into different languages',\n },\n type: 'checkboxConfirmation',\n intlLabel: {\n id: getTranslation('plugin.schema.i18n.localized.label-content-type'),\n defaultMessage: 'Localization',\n },\n },\n ];\n },\n },\n });\n\n ctbFormsAPI.extendFields(LOCALIZED_FIELDS, {\n form: {\n advanced({ contentTypeSchema, forTarget, type, step }: any) {\n if (forTarget !== 'contentType') {\n return [];\n }\n\n const hasI18nEnabled = get(\n contentTypeSchema,\n ['pluginOptions', 'i18n', 'localized'],\n false\n );\n\n if (!hasI18nEnabled) {\n return [];\n }\n\n if (type === 'component' && step === '1') {\n return [];\n }\n\n return [\n {\n name: 'pluginOptions.i18n.localized',\n description: {\n id: getTranslation('plugin.schema.i18n.localized.description-field'),\n defaultMessage: 'The field can have different values in each locale',\n },\n type: 'checkbox',\n intlLabel: {\n id: getTranslation('plugin.schema.i18n.localized.label-field'),\n defaultMessage: 'Enable localization for this field',\n },\n },\n ];\n },\n },\n });\n }\n },\n async registerTrads({ locales }: { locales: string[] }) {\n const importedTrads = await Promise.all(\n locales.map((locale) => {\n return import(`./translations/${locale}.json`)\n .then(({ default: data }) => {\n return {\n data: prefixPluginTranslations(data, pluginId),\n locale,\n };\n })\n .catch(() => {\n return {\n data: {},\n locale,\n };\n });\n })\n );\n\n return Promise.resolve(importedTrads);\n },\n};\n"],"names":["register","app","addMiddlewares","extendCTBAttributeInitialDataMiddleware","extendCTBInitialDataMiddleware","i18nApi","middleware","addReducers","reducerPath","reducer","addRBACMiddleware","localeMiddleware","registerPlugin","id","pluginId","name","bootstrap","registerHook","addColumnToTableHook","mutateEditViewHook","addLocaleToReleasesHook","addSettingsLink","intlLabel","getTranslation","defaultMessage","to","Component","then","mod","default","ProtectedSettingsPage","permissions","PERMISSIONS","accessMain","contentManager","getPlugin","apis","addDocumentHeaderAction","LocalePickerAction","FillFromAnotherLocaleAction","addDocumentAction","actions","indexOfDeleteAction","findIndex","action","type","splice","DeleteLocaleAction","BulkLocalePublishAction","BulkLocaleUnpublishAction","injectComponent","LocalePicker","PublishModalAdditionalInfo","UnpublishModalAdditionalInfo","DeleteModalAdditionalInfo","ctbPlugin","ctbFormsAPI","forms","addContentTypeSchemaMutation","mutateCTBContentTypeSchema","components","add","component","CheckboxConfirmation","extendContentType","validator","i18n","yup","object","shape","localized","bool","form","advanced","description","extendFields","LOCALIZED_FIELDS","contentTypeSchema","forTarget","step","hasI18nEnabled","get","registerTrads","locales","importedTrads","Promise","all","map","locale","data","prefixPluginTranslations","catch","resolve"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA;AACA,YAAe;AACbA,IAAAA,QAAAA,CAAAA,CAASC,GAAQ,EAAA;AACfA,QAAAA,GAAAA,CAAIC,cAAc,CAAC;AAACC,YAAAA,uCAAAA;AAAyCC,YAAAA;AAA+B,SAAA,CAAA;AAC5FH,QAAAA,GAAAA,CAAIC,cAAc,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A,IAAAA,KAAS,GAAK,EAAA;AACxC,4BAAA,OAAO,EAAE;AACX;wBAEA,OAAO;AACL,4BAAA;gCACEhE,IAAM,EAAA,8BAAA;gCACN2D,WAAa,EAAA;AACX7D,oCAAAA,EAAAA,EAAIU,cAAe,CAAA,gDAAA,CAAA;oCACnBC,cAAgB,EAAA;AAClB,iCAAA;gCACAqB,IAAM,EAAA,UAAA;gCACNvB,SAAW,EAAA;AACTT,oCAAAA,EAAAA,EAAIU,cAAe,CAAA,0CAAA,CAAA;oCACnBC,cAAgB,EAAA;AAClB;AACF;AACD,yBAAA;AACH;AACF;AACF,aAAA,CAAA;AACF;AACF,KAAA;IACA,MAAM0D,aAAAA,CAAAA,CAAc,EAAEC,OAAO,EAAyB,EAAA;QACpD,MAAMC,aAAAA,GAAgB,MAAMC,OAAQC,CAAAA,GAAG,CACrCH,OAAQI,CAAAA,GAAG,CAAC,CAACC,MAAAA,GAAAA;AACX,YAAA,OAAO,iCAAM,CAAC,CAAC,eAAe,EAAEA,MAAO,CAAA,KAAK,CAAC,CAAA,CAC1C7D,IAAI,CAAC,CAAC,EAAEE,OAAAA,EAAS4D,IAAI,EAAE,GAAA;gBACtB,OAAO;AACLA,oBAAAA,IAAAA,EAAMC,yBAAyBD,IAAM3E,EAAAA,QAAAA,CAAAA;AACrC0E,oBAAAA;AACF,iBAAA;AACF,aAAA,CAAA,CACCG,KAAK,CAAC,IAAA;gBACL,OAAO;AACLF,oBAAAA,IAAAA,EAAM,EAAC;AACPD,oBAAAA;AACF,iBAAA;AACF,aAAA,CAAA;AACJ,SAAA,CAAA,CAAA;QAGF,OAAOH,OAAAA,CAAQO,OAAO,CAACR,aAAAA,CAAAA;AACzB;AACF,CAAE;;;;"}
1
+ {"version":3,"file":"index.mjs","sources":["../../admin/src/index.ts"],"sourcesContent":["import get from 'lodash/get';\nimport * as yup from 'yup';\n\nimport { CheckboxConfirmation } from './components/CheckboxConfirmation';\nimport {\n BulkLocalePublishAction,\n BulkLocaleUnpublishAction,\n DeleteLocaleAction,\n LocalePickerAction,\n FillFromAnotherLocaleAction,\n AITranslationStatusAction,\n} from './components/CMHeaderActions';\nimport {\n DeleteModalAdditionalInfo,\n PublishModalAdditionalInfo,\n UnpublishModalAdditionalInfo,\n} from './components/CMListViewModalsAdditionalInformation';\nimport { LocalePicker } from './components/LocalePicker';\nimport { PERMISSIONS } from './constants';\nimport { mutateEditViewHook } from './contentManagerHooks/editView';\nimport { addColumnToTableHook } from './contentManagerHooks/listView';\nimport { addLocaleToReleasesHook } from './contentReleasesHooks/releaseDetailsView';\nimport { extendCTBAttributeInitialDataMiddleware } from './middlewares/extendCTBAttributeInitialData';\nimport { extendCTBInitialDataMiddleware } from './middlewares/extendCTBInitialData';\nimport { localeMiddleware } from './middlewares/rbac-middleware';\nimport { pluginId } from './pluginId';\nimport { i18nApi } from './services/api';\nimport { LOCALIZED_FIELDS } from './utils/fields';\nimport { getTranslation } from './utils/getTranslation';\nimport { prefixPluginTranslations } from './utils/prefixPluginTranslations';\nimport { mutateCTBContentTypeSchema } from './utils/schemas';\n\nimport type { DocumentActionComponent } from '@strapi/content-manager/strapi-admin';\n\n// eslint-disable-next-line import/no-default-export\nexport default {\n register(app: any) {\n app.addMiddlewares([extendCTBAttributeInitialDataMiddleware, extendCTBInitialDataMiddleware]);\n app.addMiddlewares([() => i18nApi.middleware]);\n app.addReducers({\n [i18nApi.reducerPath]: i18nApi.reducer,\n });\n app.addRBACMiddleware([localeMiddleware]);\n app.registerPlugin({\n id: pluginId,\n name: pluginId,\n });\n },\n bootstrap(app: any) {\n // // Hook that adds a column into the CM's LV table\n app.registerHook('Admin/CM/pages/ListView/inject-column-in-table', addColumnToTableHook);\n app.registerHook('Admin/CM/pages/EditView/mutate-edit-view-layout', mutateEditViewHook);\n // Hooks that checks if the locale is present in the release\n app.registerHook(\n 'ContentReleases/pages/ReleaseDetails/add-locale-in-releases',\n addLocaleToReleasesHook\n );\n\n // Add the settings link\n app.addSettingsLink('global', {\n intlLabel: {\n id: getTranslation('plugin.name'),\n defaultMessage: 'Internationalization',\n },\n id: 'internationalization',\n to: 'internationalization',\n Component: () =>\n import('./pages/SettingsPage').then((mod) => ({ default: mod.ProtectedSettingsPage })),\n permissions: PERMISSIONS.accessMain,\n });\n\n const contentManager = app.getPlugin('content-manager');\n\n contentManager.apis.addDocumentHeaderAction([\n AITranslationStatusAction,\n LocalePickerAction,\n FillFromAnotherLocaleAction,\n ]);\n contentManager.apis.addDocumentAction((actions: DocumentActionComponent[]) => {\n const indexOfDeleteAction = actions.findIndex((action) => action.type === 'delete');\n actions.splice(indexOfDeleteAction, 0, DeleteLocaleAction);\n return actions;\n });\n\n contentManager.apis.addDocumentAction((actions: DocumentActionComponent[]) => {\n // When enabled the bulk locale publish action should be the first action\n // in 'More Document Actions' and therefore the third action in the array\n actions.splice(2, 0, BulkLocalePublishAction);\n actions.splice(5, 0, BulkLocaleUnpublishAction);\n return actions;\n });\n\n contentManager.injectComponent('listView', 'actions', {\n name: 'i18n-locale-filter',\n Component: LocalePicker,\n });\n\n contentManager.injectComponent('listView', 'publishModalAdditionalInfos', {\n name: 'i18n-publish-bullets-in-modal',\n Component: PublishModalAdditionalInfo,\n });\n\n contentManager.injectComponent('listView', 'unpublishModalAdditionalInfos', {\n name: 'i18n-unpublish-bullets-in-modal',\n Component: UnpublishModalAdditionalInfo,\n });\n\n contentManager.injectComponent('listView', 'deleteModalAdditionalInfos', {\n name: 'i18n-delete-bullets-in-modal',\n Component: DeleteModalAdditionalInfo,\n });\n\n const ctbPlugin = app.getPlugin('content-type-builder');\n\n if (ctbPlugin) {\n const ctbFormsAPI = ctbPlugin.apis.forms;\n ctbFormsAPI.addContentTypeSchemaMutation(mutateCTBContentTypeSchema);\n ctbFormsAPI.components.add({ id: 'checkboxConfirmation', component: CheckboxConfirmation });\n\n ctbFormsAPI.extendContentType({\n validator: () => ({\n i18n: yup.object().shape({\n localized: yup.bool(),\n }),\n }),\n form: {\n advanced() {\n return [\n {\n name: 'pluginOptions.i18n.localized',\n description: {\n id: getTranslation('plugin.schema.i18n.localized.description-content-type'),\n defaultMessage: 'Allows translating an entry into different languages',\n },\n type: 'checkboxConfirmation',\n intlLabel: {\n id: getTranslation('plugin.schema.i18n.localized.label-content-type'),\n defaultMessage: 'Localization',\n },\n },\n ];\n },\n },\n });\n\n ctbFormsAPI.extendFields(LOCALIZED_FIELDS, {\n form: {\n advanced({ contentTypeSchema, forTarget, type, step }: any) {\n if (forTarget !== 'contentType') {\n return [];\n }\n\n const hasI18nEnabled = get(\n contentTypeSchema,\n ['pluginOptions', 'i18n', 'localized'],\n false\n );\n\n if (!hasI18nEnabled) {\n return [];\n }\n\n if (type === 'component' && step === '1') {\n return [];\n }\n\n return [\n {\n name: 'pluginOptions.i18n.localized',\n description: {\n id: getTranslation('plugin.schema.i18n.localized.description-field'),\n defaultMessage: 'The field can have different values in each locale',\n },\n type: 'checkbox',\n intlLabel: {\n id: getTranslation('plugin.schema.i18n.localized.label-field'),\n defaultMessage: 'Enable localization for this field',\n },\n },\n ];\n },\n },\n });\n }\n },\n async registerTrads({ locales }: { locales: string[] }) {\n const importedTrads = await Promise.all(\n locales.map((locale) => {\n return import(`./translations/${locale}.json`)\n .then(({ default: data }) => {\n return {\n data: prefixPluginTranslations(data, pluginId),\n locale,\n };\n })\n .catch(() => {\n return {\n data: {},\n locale,\n };\n });\n })\n );\n\n return Promise.resolve(importedTrads);\n },\n};\n"],"names":["register","app","addMiddlewares","extendCTBAttributeInitialDataMiddleware","extendCTBInitialDataMiddleware","i18nApi","middleware","addReducers","reducerPath","reducer","addRBACMiddleware","localeMiddleware","registerPlugin","id","pluginId","name","bootstrap","registerHook","addColumnToTableHook","mutateEditViewHook","addLocaleToReleasesHook","addSettingsLink","intlLabel","getTranslation","defaultMessage","to","Component","then","mod","default","ProtectedSettingsPage","permissions","PERMISSIONS","accessMain","contentManager","getPlugin","apis","addDocumentHeaderAction","AITranslationStatusAction","LocalePickerAction","FillFromAnotherLocaleAction","addDocumentAction","actions","indexOfDeleteAction","findIndex","action","type","splice","DeleteLocaleAction","BulkLocalePublishAction","BulkLocaleUnpublishAction","injectComponent","LocalePicker","PublishModalAdditionalInfo","UnpublishModalAdditionalInfo","DeleteModalAdditionalInfo","ctbPlugin","ctbFormsAPI","forms","addContentTypeSchemaMutation","mutateCTBContentTypeSchema","components","add","component","CheckboxConfirmation","extendContentType","validator","i18n","yup","object","shape","localized","bool","form","advanced","description","extendFields","LOCALIZED_FIELDS","contentTypeSchema","forTarget","step","hasI18nEnabled","get","registerTrads","locales","importedTrads","Promise","all","map","locale","data","prefixPluginTranslations","catch","resolve"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA;AACA,YAAe;AACbA,IAAAA,QAAAA,CAAAA,CAASC,GAAQ,EAAA;AACfA,QAAAA,GAAAA,CAAIC,cAAc,CAAC;AAACC,YAAAA,uCAAAA;AAAyCC,YAAAA;AAA+B,SAAA,CAAA;AAC5FH,QAAAA,GAAAA,CAAIC,cAAc,CAAC;AAAC,YAAA,IAAMG,QAAQC;AAAW,SAAA,CAAA;AAC7CL,QAAAA,GAAAA,CAAIM,WAAW,CAAC;AACd,YAAA,CAACF,OAAQG,CAAAA,WAAW,GAAGH,QAAQI;AACjC,SAAA,CAAA;AACAR,QAAAA,GAAAA,CAAIS,iBAAiB,CAAC;AAACC,YAAAA;AAAiB,SAAA,CAAA;AACxCV,QAAAA,GAAAA,CAAIW,cAAc,CAAC;YACjBC,EAAIC,EAAAA,QAAAA;YACJC,IAAMD,EAAAA;AACR,SAAA,CAAA;AACF,KAAA;AACAE,IAAAA,SAAAA,CAAAA,CAAUf,GAAQ,EAAA;;QAEhBA,GAAIgB,CAAAA,YAAY,CAAC,gDAAkDC,EAAAA,oBAAAA,CAAAA;QACnEjB,GAAIgB,CAAAA,YAAY,CAAC,iDAAmDE,EAAAA,kBAAAA,CAAAA;;QAEpElB,GAAIgB,CAAAA,YAAY,CACd,6DACAG,EAAAA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,GAAAA;AACX,YAAA,OAAO,iCAAM,CAAC,CAAC,eAAe,EAAEA,MAAO,CAAA,KAAK,CAAC,CAAA,CAC1C9D,IAAI,CAAC,CAAC,EAAEE,OAAAA,EAAS6D,IAAI,EAAE,GAAA;gBACtB,OAAO;AACLA,oBAAAA,IAAAA,EAAMC,yBAAyBD,IAAM5E,EAAAA,QAAAA,CAAAA;AACrC2E,oBAAAA;AACF,iBAAA;AACF,aAAA,CAAA,CACCG,KAAK,CAAC,IAAA;gBACL,OAAO;AACLF,oBAAAA,IAAAA,EAAM,EAAC;AACPD,oBAAAA;AACF,iBAAA;AACF,aAAA,CAAA;AACJ,SAAA,CAAA,CAAA;QAGF,OAAOH,OAAAA,CAAQO,OAAO,CAACR,aAAAA,CAAAA;AACzB;AACF,CAAE;;;;"}
@@ -1,55 +1,65 @@
1
1
  'use strict';
2
2
 
3
3
  var jsxRuntime = require('react/jsx-runtime');
4
- var React = require('react');
4
+ require('react');
5
5
  var strapiAdmin = require('@strapi/admin/strapi-admin');
6
+ var ee = require('@strapi/admin/strapi-admin/ee');
6
7
  var designSystem = require('@strapi/design-system');
8
+ var icons = require('@strapi/icons');
7
9
  var symbols = require('@strapi/icons/symbols');
8
10
  var reactIntl = require('react-intl');
9
11
  var CreateLocale = require('../components/CreateLocale.js');
10
12
  var LocaleTable = require('../components/LocaleTable.js');
11
13
  var constants = require('../constants.js');
12
14
  var locales = require('../services/locales.js');
15
+ var settings = require('../services/settings.js');
13
16
  var getTranslation = require('../utils/getTranslation.js');
14
17
 
15
- function _interopNamespaceDefault(e) {
16
- var n = Object.create(null);
17
- if (e) {
18
- Object.keys(e).forEach(function (k) {
19
- if (k !== 'default') {
20
- var d = Object.getOwnPropertyDescriptor(e, k);
21
- Object.defineProperty(n, k, d.get ? d : {
22
- enumerable: true,
23
- get: function () { return e[k]; }
18
+ const SettingsErrrorTooltip = ({ children, error })=>{
19
+ const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
20
+ if (error) {
21
+ return /*#__PURE__*/ jsxRuntime.jsx(designSystem.Tooltip, {
22
+ label: formatAPIError(error),
23
+ style: {
24
+ maxWidth: '200px'
25
+ },
26
+ children: children
24
27
  });
25
- }
26
- });
27
- }
28
- n.default = e;
29
- return Object.freeze(n);
30
- }
31
-
32
- var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
33
-
28
+ }
29
+ return children;
30
+ };
34
31
  const SettingsPage = ()=>{
35
32
  const { formatMessage } = reactIntl.useIntl();
36
33
  const { toggleNotification } = strapiAdmin.useNotification();
37
- const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
38
34
  const { data: locales$1, isLoading: isLoadingLocales, error } = locales.useGetLocalesQuery();
39
35
  const { isLoading: isLoadingRBAC, allowedActions: { canUpdate, canCreate, canDelete } } = strapiAdmin.useRBAC(constants.PERMISSIONS);
40
- React__namespace.useEffect(()=>{
41
- if (error) {
36
+ const isAIAvailable = ee.useAIAvailability();
37
+ // Settings state management
38
+ const { data: settings$1, isLoading: isLoadingSettings, error: settingsError } = settings.useGetSettingsQuery();
39
+ const [updateSettings] = settings.useUpdatei18nSettingsMutation();
40
+ const handleToggleChange = async (checked)=>{
41
+ try {
42
+ await updateSettings({
43
+ aiLocalizations: checked
44
+ }).unwrap();
45
+ toggleNotification({
46
+ type: 'success',
47
+ message: formatMessage({
48
+ id: 'notification.form.success.fields'
49
+ })
50
+ });
51
+ } catch (err) {
52
+ console.error(err);
42
53
  toggleNotification({
43
54
  type: 'danger',
44
- message: formatAPIError(error)
55
+ message: formatMessage({
56
+ id: 'notification.error',
57
+ defaultMessage: 'An error occurred'
58
+ })
45
59
  });
46
60
  }
47
- }, [
48
- error,
49
- formatAPIError,
50
- toggleNotification
51
- ]);
52
- const isLoading = isLoadingLocales || isLoadingRBAC;
61
+ };
62
+ const isLoading = isLoadingLocales || isLoadingRBAC || isLoadingSettings;
53
63
  if (isLoading) {
54
64
  return /*#__PURE__*/ jsxRuntime.jsx(strapiAdmin.Page.Loading, {});
55
65
  }
@@ -72,25 +82,90 @@ const SettingsPage = ()=>{
72
82
  defaultMessage: 'Configure the settings'
73
83
  })
74
84
  }),
75
- /*#__PURE__*/ jsxRuntime.jsx(strapiAdmin.Layouts.Content, {
76
- children: locales$1.length > 0 ? /*#__PURE__*/ jsxRuntime.jsx(LocaleTable.LocaleTable, {
77
- locales: locales$1,
78
- canDelete: canDelete,
79
- canUpdate: canUpdate
80
- }) : /*#__PURE__*/ jsxRuntime.jsx(designSystem.EmptyStateLayout, {
81
- icon: /*#__PURE__*/ jsxRuntime.jsx(symbols.EmptyDocuments, {
82
- width: undefined,
83
- height: undefined
84
- }),
85
- content: formatMessage({
86
- id: getTranslation.getTranslation('Settings.list.empty.title'),
87
- defaultMessage: 'There are no locales'
85
+ /*#__PURE__*/ jsxRuntime.jsxs(strapiAdmin.Layouts.Content, {
86
+ children: [
87
+ isAIAvailable && /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
88
+ background: "neutral0",
89
+ padding: 6,
90
+ marginBottom: 6,
91
+ shadow: "filterShadow",
92
+ hasRadius: true,
93
+ children: [
94
+ /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
95
+ direction: "column",
96
+ alignItems: "stretch",
97
+ gap: 1,
98
+ flex: 1,
99
+ children: [
100
+ /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
101
+ gap: 1,
102
+ children: [
103
+ /*#__PURE__*/ jsxRuntime.jsx(designSystem.Box, {
104
+ color: "alternative700",
105
+ children: /*#__PURE__*/ jsxRuntime.jsx(icons.Sparkle, {})
106
+ }),
107
+ /*#__PURE__*/ jsxRuntime.jsx(designSystem.Typography, {
108
+ variant: "delta",
109
+ tag: "h2",
110
+ children: formatMessage({
111
+ id: getTranslation.getTranslation('Settings.aiLocalizations.label'),
112
+ defaultMessage: 'AI Translations'
113
+ })
114
+ })
115
+ ]
116
+ }),
117
+ /*#__PURE__*/ jsxRuntime.jsx(designSystem.Typography, {
118
+ variant: "pi",
119
+ textColor: "neutral600",
120
+ fontSize: "14px",
121
+ children: formatMessage({
122
+ id: getTranslation.getTranslation('Settings.aiLocalizations.description'),
123
+ defaultMessage: 'Everytime you save in the Content Manager, our AI will use your default locale to translate all other locales automatically.'
124
+ })
125
+ })
126
+ ]
127
+ }),
128
+ /*#__PURE__*/ jsxRuntime.jsx(designSystem.Field.Root, {
129
+ name: "aiLocalizations",
130
+ minWidth: "200px",
131
+ children: /*#__PURE__*/ jsxRuntime.jsx(SettingsErrrorTooltip, {
132
+ error: settingsError,
133
+ children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Toggle, {
134
+ disabled: Boolean(settingsError),
135
+ checked: settings$1?.data?.aiLocalizations ?? false,
136
+ offLabel: formatMessage({
137
+ id: 'app.components.ToggleCheckbox.disabled-label',
138
+ defaultMessage: 'Disabled'
139
+ }),
140
+ onLabel: formatMessage({
141
+ id: 'app.components.ToggleCheckbox.enabled-label',
142
+ defaultMessage: 'Enabled'
143
+ }),
144
+ onChange: (e)=>handleToggleChange(e.target.checked)
145
+ })
146
+ })
147
+ })
148
+ ]
88
149
  }),
89
- action: /*#__PURE__*/ jsxRuntime.jsx(CreateLocale.CreateLocale, {
90
- disabled: !canCreate,
91
- variant: "secondary"
150
+ locales$1.length > 0 ? /*#__PURE__*/ jsxRuntime.jsx(LocaleTable.LocaleTable, {
151
+ locales: locales$1,
152
+ canDelete: canDelete,
153
+ canUpdate: canUpdate
154
+ }) : /*#__PURE__*/ jsxRuntime.jsx(designSystem.EmptyStateLayout, {
155
+ icon: /*#__PURE__*/ jsxRuntime.jsx(symbols.EmptyDocuments, {
156
+ width: undefined,
157
+ height: undefined
158
+ }),
159
+ content: formatMessage({
160
+ id: getTranslation.getTranslation('Settings.list.empty.title'),
161
+ defaultMessage: 'There are no locales'
162
+ }),
163
+ action: /*#__PURE__*/ jsxRuntime.jsx(CreateLocale.CreateLocale, {
164
+ disabled: !canCreate,
165
+ variant: "secondary"
166
+ })
92
167
  })
93
- })
168
+ ]
94
169
  })
95
170
  ]
96
171
  });
@@ -1 +1 @@
1
- {"version":3,"file":"SettingsPage.js","sources":["../../../admin/src/pages/SettingsPage.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport {\n Page,\n useAPIErrorHandler,\n useNotification,\n useRBAC,\n Layouts,\n} from '@strapi/admin/strapi-admin';\nimport { EmptyStateLayout } from '@strapi/design-system';\nimport { EmptyDocuments } from '@strapi/icons/symbols';\nimport { useIntl } from 'react-intl';\n\nimport { CreateLocale } from '../components/CreateLocale';\nimport { LocaleTable } from '../components/LocaleTable';\nimport { PERMISSIONS } from '../constants';\nimport { useGetLocalesQuery } from '../services/locales';\nimport { getTranslation } from '../utils/getTranslation';\n\nconst SettingsPage = () => {\n const { formatMessage } = useIntl();\n const { toggleNotification } = useNotification();\n const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();\n const { data: locales, isLoading: isLoadingLocales, error } = useGetLocalesQuery();\n const {\n isLoading: isLoadingRBAC,\n allowedActions: { canUpdate, canCreate, canDelete },\n } = useRBAC(PERMISSIONS);\n\n React.useEffect(() => {\n if (error) {\n toggleNotification({\n type: 'danger',\n message: formatAPIError(error),\n });\n }\n }, [error, formatAPIError, toggleNotification]);\n\n const isLoading = isLoadingLocales || isLoadingRBAC;\n\n if (isLoading) {\n return <Page.Loading />;\n }\n\n if (error || !Array.isArray(locales)) {\n return <Page.Error />;\n }\n\n return (\n <Page.Main tabIndex={-1}>\n <Layouts.Header\n primaryAction={<CreateLocale disabled={!canCreate} />}\n title={formatMessage({\n id: getTranslation('plugin.name'),\n defaultMessage: 'Internationalization',\n })}\n subtitle={formatMessage({\n id: getTranslation('Settings.list.description'),\n defaultMessage: 'Configure the settings',\n })}\n />\n <Layouts.Content>\n {locales.length > 0 ? (\n <LocaleTable locales={locales} canDelete={canDelete} canUpdate={canUpdate} />\n ) : (\n <EmptyStateLayout\n icon={<EmptyDocuments width={undefined} height={undefined} />}\n content={formatMessage({\n id: getTranslation('Settings.list.empty.title'),\n defaultMessage: 'There are no locales',\n })}\n action={<CreateLocale disabled={!canCreate} variant=\"secondary\" />}\n />\n )}\n </Layouts.Content>\n </Page.Main>\n );\n};\n\nconst ProtectedSettingsPage = () => {\n return (\n <Page.Protect permissions={PERMISSIONS.read}>\n <SettingsPage />\n </Page.Protect>\n );\n};\n\nexport { ProtectedSettingsPage, SettingsPage };\n"],"names":["SettingsPage","formatMessage","useIntl","toggleNotification","useNotification","_unstableFormatAPIError","formatAPIError","useAPIErrorHandler","data","locales","isLoading","isLoadingLocales","error","useGetLocalesQuery","isLoadingRBAC","allowedActions","canUpdate","canCreate","canDelete","useRBAC","PERMISSIONS","React","useEffect","type","message","_jsx","Page","Loading","Array","isArray","Error","_jsxs","Main","tabIndex","Layouts","Header","primaryAction","CreateLocale","disabled","title","id","getTranslation","defaultMessage","subtitle","Content","length","LocaleTable","EmptyStateLayout","icon","EmptyDocuments","width","undefined","height","content","action","variant","ProtectedSettingsPage","Protect","permissions","read"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBA,MAAMA,YAAe,GAAA,IAAA;IACnB,MAAM,EAAEC,aAAa,EAAE,GAAGC,iBAAAA,EAAAA;IAC1B,MAAM,EAAEC,kBAAkB,EAAE,GAAGC,2BAAAA,EAAAA;AAC/B,IAAA,MAAM,EAAEC,uBAAAA,EAAyBC,cAAc,EAAE,GAAGC,8BAAAA,EAAAA;IACpD,MAAM,EAAEC,MAAMC,SAAO,EAAEC,WAAWC,gBAAgB,EAAEC,KAAK,EAAE,GAAGC,0BAAAA,EAAAA;AAC9D,IAAA,MAAM,EACJH,SAAAA,EAAWI,aAAa,EACxBC,gBAAgB,EAAEC,SAAS,EAAEC,SAAS,EAAEC,SAAS,EAAE,EACpD,GAAGC,mBAAQC,CAAAA,qBAAAA,CAAAA;AAEZC,IAAAA,gBAAAA,CAAMC,SAAS,CAAC,IAAA;AACd,QAAA,IAAIV,KAAO,EAAA;YACTT,k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sB,CAAAA,6BAAAA,EAAAA;AACCC,oBAAAA,IAAAA,gBAAMvB,cAACwB,CAAAA,sBAAAA,EAAAA;wBAAeC,KAAOC,EAAAA,SAAAA;wBAAWC,MAAQD,EAAAA;;AAChDE,oBAAAA,OAAAA,EAASpD,aAAc,CAAA;AACrBuC,wBAAAA,EAAAA,EAAIC,6BAAe,CAAA,2BAAA,CAAA;wBACnBC,cAAgB,EAAA;AAClB,qBAAA,CAAA;AACAY,oBAAAA,MAAAA,gBAAQ7B,cAACY,CAAAA,yBAAAA,EAAAA;AAAaC,wBAAAA,QAAAA,EAAU,CAACrB,SAAAA;wBAAWsC,OAAQ,EAAA;;;;;;AAMhE;AAEA,MAAMC,qBAAwB,GAAA,IAAA;IAC5B,qBACE/B,cAAA,CAACC,iBAAK+B,OAAO,EAAA;AAACC,QAAAA,WAAAA,EAAatC,sBAAYuC,IAAI;AACzC,QAAA,QAAA,gBAAAlC,cAACzB,CAAAA,YAAAA,EAAAA,EAAAA;;AAGP;;;;;"}
1
+ {"version":3,"file":"SettingsPage.js","sources":["../../../admin/src/pages/SettingsPage.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { SerializedError } from '@reduxjs/toolkit';\nimport {\n Page,\n useAPIErrorHandler,\n useNotification,\n useRBAC,\n Layouts,\n BaseQueryError,\n} from '@strapi/admin/strapi-admin';\nimport { useAIAvailability } from '@strapi/admin/strapi-admin/ee';\nimport {\n Box,\n EmptyStateLayout,\n Field,\n Flex,\n Tooltip,\n Toggle,\n Typography,\n} from '@strapi/design-system';\nimport { Sparkle } from '@strapi/icons';\nimport { EmptyDocuments } from '@strapi/icons/symbols';\nimport { useIntl } from 'react-intl';\n\nimport { CreateLocale } from '../components/CreateLocale';\nimport { LocaleTable } from '../components/LocaleTable';\nimport { PERMISSIONS } from '../constants';\nimport { useGetLocalesQuery } from '../services/locales';\nimport { useGetSettingsQuery, useUpdatei18nSettingsMutation } from '../services/settings';\nimport { getTranslation } from '../utils/getTranslation';\n\nconst SettingsErrrorTooltip = ({\n children,\n error,\n}: {\n children: React.ReactNode;\n error: BaseQueryError | SerializedError | undefined;\n}) => {\n const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();\n\n if (error) {\n return (\n <Tooltip label={formatAPIError(error)} style={{ maxWidth: '200px' }}>\n {children}\n </Tooltip>\n );\n }\n\n return children;\n};\n\nconst SettingsPage = () => {\n const { formatMessage } = useIntl();\n const { toggleNotification } = useNotification();\n const { data: locales, isLoading: isLoadingLocales, error } = useGetLocalesQuery();\n const {\n isLoading: isLoadingRBAC,\n allowedActions: { canUpdate, canCreate, canDelete },\n } = useRBAC(PERMISSIONS);\n const isAIAvailable = useAIAvailability();\n\n // Settings state management\n const {\n data: settings,\n isLoading: isLoadingSettings,\n error: settingsError,\n } = useGetSettingsQuery();\n const [updateSettings] = useUpdatei18nSettingsMutation();\n\n const handleToggleChange = async (checked: boolean) => {\n try {\n await updateSettings({ aiLocalizations: checked }).unwrap();\n\n toggleNotification({\n type: 'success',\n message: formatMessage({ id: 'notification.form.success.fields' }),\n });\n } catch (err) {\n console.error(err);\n toggleNotification({\n type: 'danger',\n message: formatMessage({\n id: 'notification.error',\n defaultMessage: 'An error occurred',\n }),\n });\n }\n };\n\n const isLoading = isLoadingLocales || isLoadingRBAC || isLoadingSettings;\n\n if (isLoading) {\n return <Page.Loading />;\n }\n\n if (error || !Array.isArray(locales)) {\n return <Page.Error />;\n }\n\n return (\n <Page.Main tabIndex={-1}>\n <Layouts.Header\n primaryAction={<CreateLocale disabled={!canCreate} />}\n title={formatMessage({\n id: getTranslation('plugin.name'),\n defaultMessage: 'Internationalization',\n })}\n subtitle={formatMessage({\n id: getTranslation('Settings.list.description'),\n defaultMessage: 'Configure the settings',\n })}\n />\n <Layouts.Content>\n {isAIAvailable && (\n <Flex background=\"neutral0\" padding={6} marginBottom={6} shadow=\"filterShadow\" hasRadius>\n <Flex direction=\"column\" alignItems=\"stretch\" gap={1} flex={1}>\n <Flex gap={1}>\n <Box color=\"alternative700\">\n <Sparkle />\n </Box>\n <Typography variant=\"delta\" tag=\"h2\">\n {formatMessage({\n id: getTranslation('Settings.aiLocalizations.label'),\n defaultMessage: 'AI Translations',\n })}\n </Typography>\n </Flex>\n <Typography variant=\"pi\" textColor=\"neutral600\" fontSize=\"14px\">\n {formatMessage({\n id: getTranslation('Settings.aiLocalizations.description'),\n defaultMessage:\n 'Everytime you save in the Content Manager, our AI will use your default locale to translate all other locales automatically.',\n })}\n </Typography>\n </Flex>\n <Field.Root name=\"aiLocalizations\" minWidth=\"200px\">\n <SettingsErrrorTooltip error={settingsError}>\n <Toggle\n disabled={Boolean(settingsError)}\n checked={settings?.data?.aiLocalizations ?? false}\n offLabel={formatMessage({\n id: 'app.components.ToggleCheckbox.disabled-label',\n defaultMessage: 'Disabled',\n })}\n onLabel={formatMessage({\n id: 'app.components.ToggleCheckbox.enabled-label',\n defaultMessage: 'Enabled',\n })}\n onChange={(e) => handleToggleChange(e.target.checked)}\n />\n </SettingsErrrorTooltip>\n </Field.Root>\n </Flex>\n )}\n {locales.length > 0 ? (\n <LocaleTable locales={locales} canDelete={canDelete} canUpdate={canUpdate} />\n ) : (\n <EmptyStateLayout\n icon={<EmptyDocuments width={undefined} height={undefined} />}\n content={formatMessage({\n id: getTranslation('Settings.list.empty.title'),\n defaultMessage: 'There are no locales',\n })}\n action={<CreateLocale disabled={!canCreate} variant=\"secondary\" />}\n />\n )}\n </Layouts.Content>\n </Page.Main>\n );\n};\n\nconst ProtectedSettingsPage = () => {\n return (\n <Page.Protect permissions={PERMISSIONS.read}>\n <SettingsPage />\n </Page.Protect>\n );\n};\n\nexport { ProtectedSettingsPage, SettingsPage };\n"],"names":["SettingsErrrorTooltip","children","error","_unstableFormatAPIError","formatAPIError","useAPIErrorHandler","_jsx","Tooltip","label","style","maxWidth","SettingsPage","formatMessage","useIntl","toggleNotification","useNotification","data","locales","isLoading","isLoadingLocales","useGetLocalesQuery","isLoadingRBAC","allowedActions","canUpdate","canCreate","canDelete","useRBAC","PERMISSIONS","isAIAvailable","useAIAvailability","settings","isLoadingSettings","settingsError","useGetSettingsQuery","updateSettings","useUpdatei18nSettingsMutation","handleToggleChange","checked","aiLocalizations","unwrap","type","message","id","err","console","defaultMessage","Page","Loading","Array","isArray","Error","_jsxs","Main","tabIndex","Layouts","Header","primaryAction","CreateLocale","disabled","title","getTranslation","subtitle","Content","Flex","background","padding","marginBottom","shadow","hasRadius","direction","alignItems","gap","flex","Box","color","Sparkle","Typography","variant","tag","textColor","fontSize","Field","Root","name","minWidth","Toggle","Boolean","offLabel","onLabel","onChange","e","target","length","LocaleTable","EmptyStateLayout","icon","EmptyDocuments","width","undefined","height","content","action","ProtectedSettingsPage","Protect","permissions","read"],"mappings":";;;;;;;;;;;;;;;;;AAgCA,MAAMA,wBAAwB,CAAC,EAC7BC,QAAQ,EACRC,KAAK,EAIN,GAAA;AACC,IAAA,MAAM,EAAEC,uBAAAA,EAAyBC,cAAc,EAAE,GAAGC,8BAAAA,EAAAA;AAEpD,IAAA,IAAIH,KAAO,EAAA;AACT,QAAA,qBACEI,cAACC,CAAAA,oBAAAA,EAAAA;AAAQC,YAAAA,KAAAA,EAAOJ,cAAeF,CAAAA,KAAAA,CAAAA;YAAQO,KAAO,EAAA;gBAAEC,QAAU,EAAA;AAAQ,aAAA;AAC/DT,YAAAA,QAAAA,EAAAA;;AAGP;IAEA,OAAOA,QAAAA;AACT,CAAA;AAEA,MAAMU,YAAe,GAAA,IAAA;IACnB,MAAM,EAAEC,aAAa,EAAE,GAAGC,iBAAAA,EAAAA;IAC1B,MAAM,EAAEC,kBAAkB,EAAE,GAAGC,2BAAAA,EAAAA;IAC/B,MAAM,EAAEC,MAAMC,SAAO,EAAEC,WAAWC,gBAAgB,EAAEjB,KAAK,EAAE,GAAGkB,0BAAAA,EAAAA;AAC9D,IAAA,MAAM,EACJF,SAAAA,EAAWG,aAAa,EACxBC,gBAAgB,EAAEC,SAAS,EAAEC,SAAS,EAAEC,SAAS,EAAE,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