@strapi/i18n 5.61.1 → 5.62.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/dist/admin/components/CMHeaderActions.js +153 -0
  2. package/dist/admin/components/CMHeaderActions.js.map +1 -1
  3. package/dist/admin/components/CMHeaderActions.mjs +155 -3
  4. package/dist/admin/components/CMHeaderActions.mjs.map +1 -1
  5. package/dist/admin/components/CreateLocale.js +1 -1
  6. package/dist/admin/components/CreateLocale.js.map +1 -1
  7. package/dist/admin/components/CreateLocale.mjs +2 -2
  8. package/dist/admin/components/CreateLocale.mjs.map +1 -1
  9. package/dist/admin/components/EditLocale.js +1 -1
  10. package/dist/admin/components/EditLocale.js.map +1 -1
  11. package/dist/admin/components/EditLocale.mjs +2 -2
  12. package/dist/admin/components/EditLocale.mjs.map +1 -1
  13. package/dist/admin/contentManagerHooks/editView.js +82 -16
  14. package/dist/admin/contentManagerHooks/editView.js.map +1 -1
  15. package/dist/admin/contentManagerHooks/editView.mjs +83 -18
  16. package/dist/admin/contentManagerHooks/editView.mjs.map +1 -1
  17. package/dist/admin/index.js +2 -1
  18. package/dist/admin/index.js.map +1 -1
  19. package/dist/admin/index.mjs +3 -2
  20. package/dist/admin/index.mjs.map +1 -1
  21. package/dist/admin/src/components/CMHeaderActions.d.ts +20 -1
  22. package/dist/admin/src/components/tests/UnlockSharedFieldsAction.test.d.ts +1 -0
  23. package/dist/admin/src/contentManagerHooks/editView.d.ts +9 -2
  24. package/dist/admin/translations/en.json.js +9 -0
  25. package/dist/admin/translations/en.json.js.map +1 -1
  26. package/dist/admin/translations/en.json.mjs +9 -0
  27. package/dist/admin/translations/en.json.mjs.map +1 -1
  28. package/dist/server/bootstrap.js +16 -5
  29. package/dist/server/bootstrap.js.map +1 -1
  30. package/dist/server/bootstrap.mjs +16 -5
  31. package/dist/server/bootstrap.mjs.map +1 -1
  32. package/dist/server/services/ai-localizations.js +6 -1
  33. package/dist/server/services/ai-localizations.js.map +1 -1
  34. package/dist/server/services/ai-localizations.mjs +6 -1
  35. package/dist/server/services/ai-localizations.mjs.map +1 -1
  36. package/dist/server/services/content-types.js +21 -2
  37. package/dist/server/services/content-types.js.map +1 -1
  38. package/dist/server/services/content-types.mjs +21 -2
  39. package/dist/server/services/content-types.mjs.map +1 -1
  40. package/dist/server/src/bootstrap.d.ts.map +1 -1
  41. package/dist/server/src/index.d.ts +1 -1
  42. package/dist/server/src/services/ai-localizations.d.ts.map +1 -1
  43. package/dist/server/src/services/content-types.d.ts.map +1 -1
  44. package/dist/server/src/services/index.d.ts +1 -1
  45. package/dist/server/src/services/sanitize/index.d.ts +1 -1
  46. package/dist/server/src/utils/non-localized-original-data.d.ts +23 -0
  47. package/dist/server/src/utils/non-localized-original-data.d.ts.map +1 -0
  48. package/dist/server/utils/non-localized-original-data.js +29 -0
  49. package/dist/server/utils/non-localized-original-data.js.map +1 -0
  50. package/dist/server/utils/non-localized-original-data.mjs +27 -0
  51. package/dist/server/utils/non-localized-original-data.mjs.map +1 -0
  52. package/package.json +11 -11
@@ -1 +1 @@
1
- {"version":3,"file":"editView.js","sources":["../../../admin/src/contentManagerHooks/editView.tsx"],"sourcesContent":["/* eslint-disable check-file/filename-naming-convention */\nimport { Flex, Tooltip, VisuallyHidden } from '@strapi/design-system';\nimport { Earth } from '@strapi/icons';\nimport { MessageDescriptor, useIntl } from 'react-intl';\nimport { styled } from 'styled-components';\n\nimport { getTranslation } from '../utils/getTranslation';\n\nimport type { EditFieldLayout, EditLayout } from '@strapi/content-manager/strapi-admin';\ninterface MutateEditViewArgs {\n layout: EditLayout;\n}\n\ntype I18nLayoutOptions = EditLayout['options'] & {\n i18n?: {\n localized?: boolean;\n };\n};\n\nconst hasI18nLayoutOptions = (options: EditLayout['options']): options is I18nLayoutOptions =>\n 'i18n' in options && typeof options.i18n === 'object' && options.i18n !== null;\n\nconst mutateEditViewHook = ({ layout }: MutateEditViewArgs): MutateEditViewArgs => {\n // If i18n isn't explicitly enabled on the content type, then no field can be localized\n if (\n !('i18n' in layout.options) ||\n (typeof layout.options.i18n === 'object' &&\n layout.options.i18n !== null &&\n 'localized' in layout.options.i18n &&\n !layout.options.i18n.localized)\n ) {\n return { layout };\n }\n\n const decorateField = (field: EditFieldLayout) => addLabelActionToField(field, layout);\n\n const components = Object.entries(layout.components).reduce<EditLayout['components']>(\n (acc, [key, componentLayout]) => {\n return {\n ...acc,\n [key]: {\n ...componentLayout,\n layout: componentLayout.layout.map((row) => row.map(decorateField)),\n },\n };\n },\n {}\n );\n\n return {\n layout: {\n ...layout,\n components,\n layout: layout.layout.map((panel) => panel.map((row) => row.map(decorateField))),\n },\n } satisfies Pick<MutateEditViewArgs, 'layout'>;\n};\n\nconst isFieldLocalized = (attribute: EditFieldLayout['attribute'], layout: EditLayout) => {\n const contentTypeLocalized =\n hasI18nLayoutOptions(layout.options) && layout.options.i18n?.localized === true;\n\n if (!contentTypeLocalized) {\n return false;\n }\n\n const pluginOptions =\n attribute && typeof attribute === 'object' && 'pluginOptions' in (attribute as object)\n ? (attribute as { pluginOptions?: { i18n?: { localized?: boolean } } }).pluginOptions\n : undefined;\n\n return pluginOptions?.i18n?.localized === true;\n};\n\nconst addLabelActionToField = (field: EditFieldLayout, layout: EditLayout) => {\n const localized = isFieldLocalized(field.attribute, layout);\n\n if (!localized) {\n return field;\n }\n\n const title: MessageDescriptor = {\n id: getTranslation('Field.localized'),\n defaultMessage: 'This value is unique for the selected locale',\n };\n\n return {\n ...field,\n labelAction: <LabelAction title={title} />,\n };\n};\n\n/* -------------------------------------------------------------------------------------------------\n * LabelAction\n * -----------------------------------------------------------------------------------------------*/\n\ninterface LabelActionProps {\n title: MessageDescriptor;\n}\n\nconst LabelAction = ({ title }: LabelActionProps) => {\n const { formatMessage } = useIntl();\n\n return (\n <Span tag=\"span\">\n <VisuallyHidden tag=\"span\">{formatMessage(title)}</VisuallyHidden>\n <Tooltip label={formatMessage(title)}>\n <Earth aria-hidden focusable={false} />\n </Tooltip>\n </Span>\n );\n};\n\nconst Span = styled(Flex)`\n svg {\n width: 12px;\n height: 12px;\n\n fill: ${({ theme }) => theme.colors.neutral500};\n\n path {\n fill: ${({ theme }) => theme.colors.neutral500};\n }\n }\n`;\n\nexport { mutateEditViewHook };\n"],"names":["hasI18nLayoutOptions","options","i18n","mutateEditViewHook","layout","localized","decorateField","field","addLabelActionToField","components","Object","entries","reduce","acc","key","componentLayout","map","row","panel","isFieldLocalized","attribute","contentTypeLocalized","pluginOptions","undefined","title","id","getTranslation","defaultMessage","labelAction","_jsx","LabelAction","formatMessage","useIntl","_jsxs","Span","tag","VisuallyHidden","Tooltip","label","Earth","aria-hidden","focusable","styled","Flex","theme","colors","neutral500"],"mappings":";;;;;;;;;AAmBA,MAAMA,oBAAAA,GAAuB,CAACC,OAAAA,GAC5B,MAAA,IAAUA,OAAAA,IAAW,OAAOA,OAAAA,CAAQC,IAAI,KAAK,QAAA,IAAYD,OAAAA,CAAQC,IAAI,KAAK,IAAA;AAE5E,MAAMC,kBAAAA,GAAqB,CAAC,EAAEC,MAAM,EAAsB,GAAA;;AAExD,IAAA,IACE,EAAE,MAAA,IAAUA,MAAAA,CAAOH,OAAO,CAAD,IACxB,OAAOG,MAAAA,CAAOH,OAAO,CAACC,IAAI,KAAK,YAC9BE,MAAAA,CAAOH,OAAO,CAACC,IAAI,KAAK,IAAA,IACxB,WAAA,IAAeE,MAAAA,CAAOH,OAAO,CAACC,IAAI,IAClC,CAACE,OAAOH,OAAO,CAACC,IAAI,CAACG,SAAS,EAChC;QACA,OAAO;AAAED,YAAAA;AAAO,SAAA;AAClB,IAAA;AAEA,IAAA,MAAME,aAAAA,GAAgB,CAACC,KAAAA,GAA2BC,qBAAAA,CAAsBD,KAAAA,EAAOH,MAAAA,CAAAA;AAE/E,IAAA,MAAMK,UAAAA,GAAaC,MAAAA,CAAOC,OAAO,CAACP,MAAAA,CAAOK,UAAU,CAAA,CAAEG,MAAM,CACzD,CAACC,GAA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ACC,SAAAA,EAAW;QACd,OAAOE,KAAAA;AACT,IAAA;AAEA,IAAA,MAAMiB,KAAAA,GAA2B;AAC/BC,QAAAA,EAAAA,EAAIC,6BAAAA,CAAe,iBAAA,CAAA;QACnBC,cAAAA,EAAgB;AAClB,KAAA;IAEA,OAAO;AACL,QAAA,GAAGpB,KAAK;AACRqB,QAAAA,WAAAA,gBAAaC,cAAA,CAACC,WAAAA,EAAAA;YAAYN,KAAAA,EAAOA;;AACnC,KAAA;AACF,CAAA;AAUA,MAAMM,WAAAA,GAAc,CAAC,EAAEN,KAAK,EAAoB,GAAA;IAC9C,MAAM,EAAEO,aAAa,EAAE,GAAGC,iBAAAA,EAAAA;AAE1B,IAAA,qBACEC,eAAA,CAACC,IAAAA,EAAAA;QAAKC,GAAAA,EAAI,MAAA;;0BACRN,cAAA,CAACO,2BAAAA,EAAAA;gBAAeD,GAAAA,EAAI,MAAA;0BAAQJ,aAAAA,CAAcP,KAAAA;;0BAC1CK,cAAA,CAACQ,oBAAAA,EAAAA;AAAQC,gBAAAA,KAAAA,EAAOP,aAAAA,CAAcP,KAAAA,CAAAA;AAC5B,gBAAA,QAAA,gBAAAK,cAAA,CAACU,WAAAA,EAAAA;oBAAMC,aAAW,EAAA,IAAA;oBAACC,SAAAA,EAAW;;;;;AAItC,CAAA;AAEA,MAAMP,IAAAA,GAAOQ,uBAAAA,CAAOC,iBAAAA,CAAK;;;;;UAKf,EAAE,CAAC,EAAEC,KAAK,EAAE,GAAKA,KAAAA,CAAMC,MAAM,CAACC,UAAU,CAAC;;;YAGvC,EAAE,CAAC,EAAEF,KAAK,EAAE,GAAKA,KAAAA,CAAMC,MAAM,CAACC,UAAU,CAAC;;;AAGrD,CAAC;;;;"}
1
+ {"version":3,"file":"editView.js","sources":["../../../admin/src/contentManagerHooks/editView.tsx"],"sourcesContent":["/* eslint-disable check-file/filename-naming-convention */\nimport { useQueryParams } from '@strapi/admin/strapi-admin';\nimport {\n unstable_useHasDefaultLocaleEntry as useHasDefaultLocaleEntry,\n unstable_useI18nSharedFieldsLock as useI18nSharedFieldsLock,\n} from '@strapi/content-manager/strapi-admin';\nimport { Flex, Tooltip, VisuallyHidden } from '@strapi/design-system';\nimport { Earth, Lock } from '@strapi/icons';\nimport { MessageDescriptor, useIntl } from 'react-intl';\nimport { styled } from 'styled-components';\n\nimport { useGetLocalesQuery } from '../services/locales';\nimport { getTranslation } from '../utils/getTranslation';\n\nimport type { I18nBaseQuery } from '../types';\nimport type { EditFieldLayout, EditLayout } from '@strapi/content-manager/strapi-admin';\n\ninterface MutateEditViewArgs {\n layout: EditLayout;\n query?: unknown;\n}\n\ntype I18nLayoutOptions = EditLayout['options'] & {\n i18n?: {\n localized?: boolean;\n };\n};\n\nconst hasI18nLayoutOptions = (options: EditLayout['options']): options is I18nLayoutOptions =>\n 'i18n' in options && typeof options.i18n === 'object' && options.i18n !== null;\n\nconst mutateEditViewHook = ({ layout, query }: MutateEditViewArgs): MutateEditViewArgs => {\n // If i18n isn't explicitly enabled on the content type, then no field can be localized\n if (\n !('i18n' in layout.options) ||\n (typeof layout.options.i18n === 'object' &&\n layout.options.i18n !== null &&\n 'localized' in layout.options.i18n &&\n !layout.options.i18n.localized)\n ) {\n return { layout, query };\n }\n\n // Root fields: localized → Earth; shared → Lock on secondary locales only.\n // Component fields: only Earth when explicitly localized — nested fields inherit\n // shared/locked state from their parent attribute (see #24890).\n const decorateRootField = (field: EditFieldLayout) =>\n addLabelActionToField(field, layout, { isComponentField: false });\n const decorateComponentField = (field: EditFieldLayout) =>\n addLabelActionToField(field, layout, { isComponentField: true });\n\n const components = Object.entries(layout.components).reduce<EditLayout['components']>(\n (acc, [key, componentLayout]) => {\n return {\n ...acc,\n [key]: {\n ...componentLayout,\n layout: componentLayout.layout.map((row) => row.map(decorateComponentField)),\n },\n };\n },\n {}\n );\n\n return {\n layout: {\n ...layout,\n components,\n layout: layout.layout.map((panel) => panel.map((row) => row.map(decorateRootField))),\n },\n query,\n } satisfies MutateEditViewArgs;\n};\n\nconst isFieldLocalized = (attribute: EditFieldLayout['attribute'], layout: EditLayout) => {\n const contentTypeLocalized =\n hasI18nLayoutOptions(layout.options) && layout.options.i18n?.localized === true;\n\n if (!contentTypeLocalized) {\n return false;\n }\n\n // Match server `isLocalizedAttribute`: relations and uids are always locale-specific.\n if (\n attribute &&\n typeof attribute === 'object' &&\n 'type' in attribute &&\n (attribute.type === 'relation' || attribute.type === 'uid')\n ) {\n return true;\n }\n\n const pluginOptions =\n attribute && typeof attribute === 'object' && 'pluginOptions' in (attribute as object)\n ? (attribute as { pluginOptions?: { i18n?: { localized?: boolean } } }).pluginOptions\n : undefined;\n\n return pluginOptions?.i18n?.localized === true;\n};\n\nconst addLabelActionToField = (\n field: EditFieldLayout,\n layout: EditLayout,\n { isComponentField }: { isComponentField: boolean }\n) => {\n const localized = isFieldLocalized(field.attribute, layout);\n\n if (localized) {\n const title: MessageDescriptor = {\n id: getTranslation('Field.localized'),\n defaultMessage: 'This value is unique for the selected locale',\n };\n\n return {\n ...field,\n labelAction: <LabelAction title={title} icon=\"earth\" />,\n };\n }\n\n // Nested fields: no shared-field icon — parent component/DZ owns that signal (#24890).\n if (isComponentField) {\n return field;\n }\n\n return {\n ...field,\n labelAction: (\n <NonLocalizedLabelAction\n title={{\n id: getTranslation('Field.not-localized'),\n defaultMessage: 'This value is common to all locales',\n }}\n />\n ),\n };\n};\n\n/* -------------------------------------------------------------------------------------------------\n * LabelAction\n * -----------------------------------------------------------------------------------------------*/\n\ninterface LabelActionProps {\n title: MessageDescriptor;\n icon?: 'earth' | 'lock';\n}\n\nconst LabelAction = ({ title, icon = 'earth' }: LabelActionProps) => {\n const { formatMessage } = useIntl();\n const Icon = icon === 'lock' ? Lock : Earth;\n\n return (\n <Span tag=\"span\">\n <VisuallyHidden tag=\"span\">{formatMessage(title)}</VisuallyHidden>\n <Tooltip label={formatMessage(title)}>\n <Icon aria-hidden focusable={false} />\n </Tooltip>\n </Span>\n );\n};\n\nconst NonLocalizedLabelAction = ({ title }: Pick<LabelActionProps, 'title'>) => {\n const [{ query }] = useQueryParams<I18nBaseQuery>();\n const { data: locales = [] } = useGetLocalesQuery();\n const isUnlocked = useI18nSharedFieldsLock(\n 'NonLocalizedLabelAction',\n (state) => state.isUnlocked\n );\n const hasDefaultLocaleEntry = useHasDefaultLocaleEntry();\n\n // History rewrites this title via cloneElement. Honor that copy so the\n // restore-replaces-all-locales warning renders instead of the edit-view lock tooltip.\n if (title?.id && title.id !== getTranslation('Field.not-localized')) {\n return <LabelAction title={title} icon=\"lock\" />;\n }\n\n const currentLocale = query?.plugins?.i18n?.locale;\n const defaultLocale = Array.isArray(locales)\n ? locales.find((locale) => locale.isDefault)?.code\n : undefined;\n // No Lock when this document has no default-locale entry. The tooltip would\n // point at an entry that does not exist, and the field stays editable.\n const locked = Boolean(\n currentLocale && defaultLocale && currentLocale !== defaultLocale && hasDefaultLocaleEntry\n );\n\n // Default locale: no icon on shared fields (regression of #24890 if we show Earth).\n if (!locked) {\n return null;\n }\n\n const sharedFieldTitle: MessageDescriptor = isUnlocked\n ? {\n id: getTranslation('Field.not-localized-unlocked'),\n defaultMessage: 'This value is common to all locales. Saving will update every locale.',\n }\n : {\n id: getTranslation('Field.not-localized-locked'),\n defaultMessage: 'This value is common to all locales. Edit it in the default locale.',\n };\n\n return <LabelAction title={sharedFieldTitle} icon=\"lock\" />;\n};\n\nconst Span = styled(Flex)`\n svg {\n width: 12px;\n height: 12px;\n\n fill: ${({ theme }) => theme.colors.neutral500};\n\n path {\n fill: ${({ theme }) => theme.colors.neutral500};\n }\n }\n`;\n\nexport { mutateEditViewHook, LabelAction };\n"],"names":["hasI18nLayoutOptions","options","i18n","mutateEditViewHook","layout","query","localized","decorateRootField","field","addLabelActionToField","isComponentField","decorateComponentField","components","Object","entries","reduce","acc","key","componentLayout","map","row","panel","isFieldLocalized","attribute","contentTypeLocalized","type","pluginOptions","undefined","title","id","getTranslation","defaultMessage","labelAction","_jsx","LabelAction","icon","NonLocalizedLabelAction","formatMessage","useIntl","Icon","Lock","Earth","_jsxs","Span","tag","VisuallyHidden","Tooltip","label","aria-hidden","focusable","useQueryParams","data","locales","useGetLocalesQuery","isUnlocked","useI18nSharedFieldsLock","state","hasDefaultLocaleEntry","useHasDefaultLocaleEntry","currentLocale","plugins","locale","defaultLocale","Array","isArray","find","isDefault","code","locked","Boolean","sharedFieldTitle","styled","Flex","theme","colors","neutral500"],"mappings":";;;;;;;;;;;;AA4BA,MAAMA,oBAAAA,GAAuB,CAACC,OAAAA,GAC5B,MAAA,IAAUA,OAAAA,IAAW,OAAOA,OAAAA,CAAQC,IAAI,KAAK,QAAA,IAAYD,OAAAA,CAAQC,IAAI,KAAK,IAAA;AAE5E,MAAMC,qBAAqB,CAAC,EAAEC,MAAM,EAAEC,KAAK,EAAsB,GAAA;;AAE/D,IAAA,IACE,EAAE,MAAA,IAAUD,MAAAA,CAAOH,OAAO,CAAD,IACxB,OAAOG,MAAAA,CAAOH,OAAO,CAACC,IAAI,KAAK,YAC9BE,MAAAA,CAAOH,OAAO,CAACC,IAAI,KAAK,IAAA,IACxB,WAAA,IAAeE,MAAAA,CAAOH,OAAO,CAACC,IAAI,IAClC,CAACE,OAAOH,OAAO,CAACC,IAAI,CAACI,SAAS,EAChC;QACA,OAAO;AAAEF,YAAAA,MAAAA;AAAQC,YAAAA;AAAM,SAAA;AACzB,IAAA;;;;AAKA,IAAA,MAAME,iBAAAA,GAAoB,CAACC,KAAAA,GACzBC,qBAAAA,CAAsBD,OAAOJ,MAAAA,EAAQ;YAAEM,gBAAAA,EAAkB;AAAM,SAAA,CAAA;AACjE,IAAA,MAAMC,sBAAAA,GAAyB,CAACH,KAAAA,GAC9BC,qBAAAA,CAAsBD,OAAOJ,MAAAA,EAAQ;YAAEM,gBAAAA,EAAkB;AAAK,SAAA,CAAA;AAEhE,IAAA,MAAME,UAAAA,GAAaC,MAAAA,CAAOC,OAAO,CAACV,MAAAA,CAAOQ,UAAU,CAAA,CAAEG,MAAM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ACX,OAAO,IAAA;AACT,IAAA;AAEA,IAAA,MAAME,mBAAsChB,UAAAA,GACxC;AACEzB,QAAAA,EAAAA,EAAIC,6BAAAA,CAAe,8BAAA,CAAA;QACnBC,cAAAA,EAAgB;KAClB,GACA;AACEF,QAAAA,EAAAA,EAAIC,6BAAAA,CAAe,4BAAA,CAAA;QACnBC,cAAAA,EAAgB;AAClB,KAAA;AAEJ,IAAA,qBAAOE,cAAA,CAACC,WAAAA,EAAAA;QAAYN,KAAAA,EAAO0C,gBAAAA;QAAkBnC,IAAAA,EAAK;;AACpD,CAAA;AAEA,MAAMQ,IAAAA,GAAO4B,uBAAAA,CAAOC,iBAAAA,CAAK;;;;;UAKf,EAAE,CAAC,EAAEC,KAAK,EAAE,GAAKA,KAAAA,CAAMC,MAAM,CAACC,UAAU,CAAC;;;YAGvC,EAAE,CAAC,EAAEF,KAAK,EAAE,GAAKA,KAAAA,CAAMC,MAAM,CAACC,UAAU,CAAC;;;AAGrD,CAAC;;;;;"}
@@ -1,25 +1,37 @@
1
1
  import { jsx, jsxs } from 'react/jsx-runtime';
2
+ import { useQueryParams } from '@strapi/admin/strapi-admin';
3
+ import { unstable_useI18nSharedFieldsLock, unstable_useHasDefaultLocaleEntry } from '@strapi/content-manager/strapi-admin';
2
4
  import { Flex, VisuallyHidden, Tooltip } from '@strapi/design-system';
3
- import { Earth } from '@strapi/icons';
5
+ import { Lock, Earth } from '@strapi/icons';
4
6
  import { useIntl } from 'react-intl';
5
7
  import { styled } from 'styled-components';
8
+ import { useGetLocalesQuery } from '../services/locales.mjs';
6
9
  import { getTranslation } from '../utils/getTranslation.mjs';
7
10
 
8
11
  const hasI18nLayoutOptions = (options)=>'i18n' in options && typeof options.i18n === 'object' && options.i18n !== null;
9
- const mutateEditViewHook = ({ layout })=>{
12
+ const mutateEditViewHook = ({ layout, query })=>{
10
13
  // If i18n isn't explicitly enabled on the content type, then no field can be localized
11
14
  if (!('i18n' in layout.options) || typeof layout.options.i18n === 'object' && layout.options.i18n !== null && 'localized' in layout.options.i18n && !layout.options.i18n.localized) {
12
15
  return {
13
- layout
16
+ layout,
17
+ query
14
18
  };
15
19
  }
16
- const decorateField = (field)=>addLabelActionToField(field, layout);
20
+ // Root fields: localized → Earth; shared → Lock on secondary locales only.
21
+ // Component fields: only Earth when explicitly localized — nested fields inherit
22
+ // shared/locked state from their parent attribute (see #24890).
23
+ const decorateRootField = (field)=>addLabelActionToField(field, layout, {
24
+ isComponentField: false
25
+ });
26
+ const decorateComponentField = (field)=>addLabelActionToField(field, layout, {
27
+ isComponentField: true
28
+ });
17
29
  const components = Object.entries(layout.components).reduce((acc, [key, componentLayout])=>{
18
30
  return {
19
31
  ...acc,
20
32
  [key]: {
21
33
  ...componentLayout,
22
- layout: componentLayout.layout.map((row)=>row.map(decorateField))
34
+ layout: componentLayout.layout.map((row)=>row.map(decorateComponentField))
23
35
  }
24
36
  };
25
37
  }, {});
@@ -27,8 +39,9 @@ const mutateEditViewHook = ({ layout })=>{
27
39
  layout: {
28
40
  ...layout,
29
41
  components,
30
- layout: layout.layout.map((panel)=>panel.map((row)=>row.map(decorateField)))
31
- }
42
+ layout: layout.layout.map((panel)=>panel.map((row)=>row.map(decorateRootField)))
43
+ },
44
+ query
32
45
  };
33
46
  };
34
47
  const isFieldLocalized = (attribute, layout)=>{
@@ -36,27 +49,45 @@ const isFieldLocalized = (attribute, layout)=>{
36
49
  if (!contentTypeLocalized) {
37
50
  return false;
38
51
  }
52
+ // Match server `isLocalizedAttribute`: relations and uids are always locale-specific.
53
+ if (attribute && typeof attribute === 'object' && 'type' in attribute && (attribute.type === 'relation' || attribute.type === 'uid')) {
54
+ return true;
55
+ }
39
56
  const pluginOptions = attribute && typeof attribute === 'object' && 'pluginOptions' in attribute ? attribute.pluginOptions : undefined;
40
57
  return pluginOptions?.i18n?.localized === true;
41
58
  };
42
- const addLabelActionToField = (field, layout)=>{
59
+ const addLabelActionToField = (field, layout, { isComponentField })=>{
43
60
  const localized = isFieldLocalized(field.attribute, layout);
44
- if (!localized) {
61
+ if (localized) {
62
+ const title = {
63
+ id: getTranslation('Field.localized'),
64
+ defaultMessage: 'This value is unique for the selected locale'
65
+ };
66
+ return {
67
+ ...field,
68
+ labelAction: /*#__PURE__*/ jsx(LabelAction, {
69
+ title: title,
70
+ icon: "earth"
71
+ })
72
+ };
73
+ }
74
+ // Nested fields: no shared-field icon — parent component/DZ owns that signal (#24890).
75
+ if (isComponentField) {
45
76
  return field;
46
77
  }
47
- const title = {
48
- id: getTranslation('Field.localized'),
49
- defaultMessage: 'This value is unique for the selected locale'
50
- };
51
78
  return {
52
79
  ...field,
53
- labelAction: /*#__PURE__*/ jsx(LabelAction, {
54
- title: title
80
+ labelAction: /*#__PURE__*/ jsx(NonLocalizedLabelAction, {
81
+ title: {
82
+ id: getTranslation('Field.not-localized'),
83
+ defaultMessage: 'This value is common to all locales'
84
+ }
55
85
  })
56
86
  };
57
87
  };
58
- const LabelAction = ({ title })=>{
88
+ const LabelAction = ({ title, icon = 'earth' })=>{
59
89
  const { formatMessage } = useIntl();
90
+ const Icon = icon === 'lock' ? Lock : Earth;
60
91
  return /*#__PURE__*/ jsxs(Span, {
61
92
  tag: "span",
62
93
  children: [
@@ -66,7 +97,7 @@ const LabelAction = ({ title })=>{
66
97
  }),
67
98
  /*#__PURE__*/ jsx(Tooltip, {
68
99
  label: formatMessage(title),
69
- children: /*#__PURE__*/ jsx(Earth, {
100
+ children: /*#__PURE__*/ jsx(Icon, {
70
101
  "aria-hidden": true,
71
102
  focusable: false
72
103
  })
@@ -74,6 +105,40 @@ const LabelAction = ({ title })=>{
74
105
  ]
75
106
  });
76
107
  };
108
+ const NonLocalizedLabelAction = ({ title })=>{
109
+ const [{ query }] = useQueryParams();
110
+ const { data: locales = [] } = useGetLocalesQuery();
111
+ const isUnlocked = unstable_useI18nSharedFieldsLock('NonLocalizedLabelAction', (state)=>state.isUnlocked);
112
+ const hasDefaultLocaleEntry = unstable_useHasDefaultLocaleEntry();
113
+ // History rewrites this title via cloneElement. Honor that copy so the
114
+ // restore-replaces-all-locales warning renders instead of the edit-view lock tooltip.
115
+ if (title?.id && title.id !== getTranslation('Field.not-localized')) {
116
+ return /*#__PURE__*/ jsx(LabelAction, {
117
+ title: title,
118
+ icon: "lock"
119
+ });
120
+ }
121
+ const currentLocale = query?.plugins?.i18n?.locale;
122
+ const defaultLocale = Array.isArray(locales) ? locales.find((locale)=>locale.isDefault)?.code : undefined;
123
+ // No Lock when this document has no default-locale entry. The tooltip would
124
+ // point at an entry that does not exist, and the field stays editable.
125
+ const locked = Boolean(currentLocale && defaultLocale && currentLocale !== defaultLocale && hasDefaultLocaleEntry);
126
+ // Default locale: no icon on shared fields (regression of #24890 if we show Earth).
127
+ if (!locked) {
128
+ return null;
129
+ }
130
+ const sharedFieldTitle = isUnlocked ? {
131
+ id: getTranslation('Field.not-localized-unlocked'),
132
+ defaultMessage: 'This value is common to all locales. Saving will update every locale.'
133
+ } : {
134
+ id: getTranslation('Field.not-localized-locked'),
135
+ defaultMessage: 'This value is common to all locales. Edit it in the default locale.'
136
+ };
137
+ return /*#__PURE__*/ jsx(LabelAction, {
138
+ title: sharedFieldTitle,
139
+ icon: "lock"
140
+ });
141
+ };
77
142
  const Span = styled(Flex)`
78
143
  svg {
79
144
  width: 12px;
@@ -87,5 +152,5 @@ const Span = styled(Flex)`
87
152
  }
88
153
  `;
89
154
 
90
- export { mutateEditViewHook };
155
+ export { LabelAction, mutateEditViewHook };
91
156
  //# sourceMappingURL=editView.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"editView.mjs","sources":["../../../admin/src/contentManagerHooks/editView.tsx"],"sourcesContent":["/* eslint-disable check-file/filename-naming-convention */\nimport { Flex, Tooltip, VisuallyHidden } from '@strapi/design-system';\nimport { Earth } from '@strapi/icons';\nimport { MessageDescriptor, useIntl } from 'react-intl';\nimport { styled } from 'styled-components';\n\nimport { getTranslation } from '../utils/getTranslation';\n\nimport type { EditFieldLayout, EditLayout } from '@strapi/content-manager/strapi-admin';\ninterface MutateEditViewArgs {\n layout: EditLayout;\n}\n\ntype I18nLayoutOptions = EditLayout['options'] & {\n i18n?: {\n localized?: boolean;\n };\n};\n\nconst hasI18nLayoutOptions = (options: EditLayout['options']): options is I18nLayoutOptions =>\n 'i18n' in options && typeof options.i18n === 'object' && options.i18n !== null;\n\nconst mutateEditViewHook = ({ layout }: MutateEditViewArgs): MutateEditViewArgs => {\n // If i18n isn't explicitly enabled on the content type, then no field can be localized\n if (\n !('i18n' in layout.options) ||\n (typeof layout.options.i18n === 'object' &&\n layout.options.i18n !== null &&\n 'localized' in layout.options.i18n &&\n !layout.options.i18n.localized)\n ) {\n return { layout };\n }\n\n const decorateField = (field: EditFieldLayout) => addLabelActionToField(field, layout);\n\n const components = Object.entries(layout.components).reduce<EditLayout['components']>(\n (acc, [key, componentLayout]) => {\n return {\n ...acc,\n [key]: {\n ...componentLayout,\n layout: componentLayout.layout.map((row) => row.map(decorateField)),\n },\n };\n },\n {}\n );\n\n return {\n layout: {\n ...layout,\n components,\n layout: layout.layout.map((panel) => panel.map((row) => row.map(decorateField))),\n },\n } satisfies Pick<MutateEditViewArgs, 'layout'>;\n};\n\nconst isFieldLocalized = (attribute: EditFieldLayout['attribute'], layout: EditLayout) => {\n const contentTypeLocalized =\n hasI18nLayoutOptions(layout.options) && layout.options.i18n?.localized === true;\n\n if (!contentTypeLocalized) {\n return false;\n }\n\n const pluginOptions =\n attribute && typeof attribute === 'object' && 'pluginOptions' in (attribute as object)\n ? (attribute as { pluginOptions?: { i18n?: { localized?: boolean } } }).pluginOptions\n : undefined;\n\n return pluginOptions?.i18n?.localized === true;\n};\n\nconst addLabelActionToField = (field: EditFieldLayout, layout: EditLayout) => {\n const localized = isFieldLocalized(field.attribute, layout);\n\n if (!localized) {\n return field;\n }\n\n const title: MessageDescriptor = {\n id: getTranslation('Field.localized'),\n defaultMessage: 'This value is unique for the selected locale',\n };\n\n return {\n ...field,\n labelAction: <LabelAction title={title} />,\n };\n};\n\n/* -------------------------------------------------------------------------------------------------\n * LabelAction\n * -----------------------------------------------------------------------------------------------*/\n\ninterface LabelActionProps {\n title: MessageDescriptor;\n}\n\nconst LabelAction = ({ title }: LabelActionProps) => {\n const { formatMessage } = useIntl();\n\n return (\n <Span tag=\"span\">\n <VisuallyHidden tag=\"span\">{formatMessage(title)}</VisuallyHidden>\n <Tooltip label={formatMessage(title)}>\n <Earth aria-hidden focusable={false} />\n </Tooltip>\n </Span>\n );\n};\n\nconst Span = styled(Flex)`\n svg {\n width: 12px;\n height: 12px;\n\n fill: ${({ theme }) => theme.colors.neutral500};\n\n path {\n fill: ${({ theme }) => theme.colors.neutral500};\n }\n }\n`;\n\nexport { mutateEditViewHook };\n"],"names":["hasI18nLayoutOptions","options","i18n","mutateEditViewHook","layout","localized","decorateField","field","addLabelActionToField","components","Object","entries","reduce","acc","key","componentLayout","map","row","panel","isFieldLocalized","attribute","contentTypeLocalized","pluginOptions","undefined","title","id","getTranslation","defaultMessage","labelAction","_jsx","LabelAction","formatMessage","useIntl","_jsxs","Span","tag","VisuallyHidden","Tooltip","label","Earth","aria-hidden","focusable","styled","Flex","theme","colors","neutral500"],"mappings":";;;;;;;AAmBA,MAAMA,oBAAAA,GAAuB,CAACC,OAAAA,GAC5B,MAAA,IAAUA,OAAAA,IAAW,OAAOA,OAAAA,CAAQC,IAAI,KAAK,QAAA,IAAYD,OAAAA,CAAQC,IAAI,KAAK,IAAA;AAE5E,MAAMC,kBAAAA,GAAqB,CAAC,EAAEC,MAAM,EAAsB,GAAA;;AAExD,IAAA,IACE,EAAE,MAAA,IAAUA,MAAAA,CAAOH,OAAO,CAAD,IACxB,OAAOG,MAAAA,CAAOH,OAAO,CAACC,IAAI,KAAK,YAC9BE,MAAAA,CAAOH,OAAO,CAACC,IAAI,KAAK,IAAA,IACxB,WAAA,IAAeE,MAAAA,CAAOH,OAAO,CAACC,IAAI,IAClC,CAACE,OAAOH,OAAO,CAACC,IAAI,CAACG,SAAS,EAChC;QACA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AC,EAAEF,KAAK,EAAE,GAAKA,KAAAA,CAAMC,MAAM,CAACC,UAAU,CAAC;;;AAGrD,CAAC;;;;"}
1
+ {"version":3,"file":"editView.mjs","sources":["../../../admin/src/contentManagerHooks/editView.tsx"],"sourcesContent":["/* eslint-disable check-file/filename-naming-convention */\nimport { useQueryParams } from '@strapi/admin/strapi-admin';\nimport {\n unstable_useHasDefaultLocaleEntry as useHasDefaultLocaleEntry,\n unstable_useI18nSharedFieldsLock as useI18nSharedFieldsLock,\n} from '@strapi/content-manager/strapi-admin';\nimport { Flex, Tooltip, VisuallyHidden } from '@strapi/design-system';\nimport { Earth, Lock } from '@strapi/icons';\nimport { MessageDescriptor, useIntl } from 'react-intl';\nimport { styled } from 'styled-components';\n\nimport { useGetLocalesQuery } from '../services/locales';\nimport { getTranslation } from '../utils/getTranslation';\n\nimport type { I18nBaseQuery } from '../types';\nimport type { EditFieldLayout, EditLayout } from '@strapi/content-manager/strapi-admin';\n\ninterface MutateEditViewArgs {\n layout: EditLayout;\n query?: unknown;\n}\n\ntype I18nLayoutOptions = EditLayout['options'] & {\n i18n?: {\n localized?: boolean;\n };\n};\n\nconst hasI18nLayoutOptions = (options: EditLayout['options']): options is I18nLayoutOptions =>\n 'i18n' in options && typeof options.i18n === 'object' && options.i18n !== null;\n\nconst mutateEditViewHook = ({ layout, query }: MutateEditViewArgs): MutateEditViewArgs => {\n // If i18n isn't explicitly enabled on the content type, then no field can be localized\n if (\n !('i18n' in layout.options) ||\n (typeof layout.options.i18n === 'object' &&\n layout.options.i18n !== null &&\n 'localized' in layout.options.i18n &&\n !layout.options.i18n.localized)\n ) {\n return { layout, query };\n }\n\n // Root fields: localized → Earth; shared → Lock on secondary locales only.\n // Component fields: only Earth when explicitly localized — nested fields inherit\n // shared/locked state from their parent attribute (see #24890).\n const decorateRootField = (field: EditFieldLayout) =>\n addLabelActionToField(field, layout, { isComponentField: false });\n const decorateComponentField = (field: EditFieldLayout) =>\n addLabelActionToField(field, layout, { isComponentField: true });\n\n const components = Object.entries(layout.components).reduce<EditLayout['components']>(\n (acc, [key, componentLayout]) => {\n return {\n ...acc,\n [key]: {\n ...componentLayout,\n layout: componentLayout.layout.map((row) => row.map(decorateComponentField)),\n },\n };\n },\n {}\n );\n\n return {\n layout: {\n ...layout,\n components,\n layout: layout.layout.map((panel) => panel.map((row) => row.map(decorateRootField))),\n },\n query,\n } satisfies MutateEditViewArgs;\n};\n\nconst isFieldLocalized = (attribute: EditFieldLayout['attribute'], layout: EditLayout) => {\n const contentTypeLocalized =\n hasI18nLayoutOptions(layout.options) && layout.options.i18n?.localized === true;\n\n if (!contentTypeLocalized) {\n return false;\n }\n\n // Match server `isLocalizedAttribute`: relations and uids are always locale-specific.\n if (\n attribute &&\n typeof attribute === 'object' &&\n 'type' in attribute &&\n (attribute.type === 'relation' || attribute.type === 'uid')\n ) {\n return true;\n }\n\n const pluginOptions =\n attribute && typeof attribute === 'object' && 'pluginOptions' in (attribute as object)\n ? (attribute as { pluginOptions?: { i18n?: { localized?: boolean } } }).pluginOptions\n : undefined;\n\n return pluginOptions?.i18n?.localized === true;\n};\n\nconst addLabelActionToField = (\n field: EditFieldLayout,\n layout: EditLayout,\n { isComponentField }: { isComponentField: boolean }\n) => {\n const localized = isFieldLocalized(field.attribute, layout);\n\n if (localized) {\n const title: MessageDescriptor = {\n id: getTranslation('Field.localized'),\n defaultMessage: 'This value is unique for the selected locale',\n };\n\n return {\n ...field,\n labelAction: <LabelAction title={title} icon=\"earth\" />,\n };\n }\n\n // Nested fields: no shared-field icon — parent component/DZ owns that signal (#24890).\n if (isComponentField) {\n return field;\n }\n\n return {\n ...field,\n labelAction: (\n <NonLocalizedLabelAction\n title={{\n id: getTranslation('Field.not-localized'),\n defaultMessage: 'This value is common to all locales',\n }}\n />\n ),\n };\n};\n\n/* -------------------------------------------------------------------------------------------------\n * LabelAction\n * -----------------------------------------------------------------------------------------------*/\n\ninterface LabelActionProps {\n title: MessageDescriptor;\n icon?: 'earth' | 'lock';\n}\n\nconst LabelAction = ({ title, icon = 'earth' }: LabelActionProps) => {\n const { formatMessage } = useIntl();\n const Icon = icon === 'lock' ? Lock : Earth;\n\n return (\n <Span tag=\"span\">\n <VisuallyHidden tag=\"span\">{formatMessage(title)}</VisuallyHidden>\n <Tooltip label={formatMessage(title)}>\n <Icon aria-hidden focusable={false} />\n </Tooltip>\n </Span>\n );\n};\n\nconst NonLocalizedLabelAction = ({ title }: Pick<LabelActionProps, 'title'>) => {\n const [{ query }] = useQueryParams<I18nBaseQuery>();\n const { data: locales = [] } = useGetLocalesQuery();\n const isUnlocked = useI18nSharedFieldsLock(\n 'NonLocalizedLabelAction',\n (state) => state.isUnlocked\n );\n const hasDefaultLocaleEntry = useHasDefaultLocaleEntry();\n\n // History rewrites this title via cloneElement. Honor that copy so the\n // restore-replaces-all-locales warning renders instead of the edit-view lock tooltip.\n if (title?.id && title.id !== getTranslation('Field.not-localized')) {\n return <LabelAction title={title} icon=\"lock\" />;\n }\n\n const currentLocale = query?.plugins?.i18n?.locale;\n const defaultLocale = Array.isArray(locales)\n ? locales.find((locale) => locale.isDefault)?.code\n : undefined;\n // No Lock when this document has no default-locale entry. The tooltip would\n // point at an entry that does not exist, and the field stays editable.\n const locked = Boolean(\n currentLocale && defaultLocale && currentLocale !== defaultLocale && hasDefaultLocaleEntry\n );\n\n // Default locale: no icon on shared fields (regression of #24890 if we show Earth).\n if (!locked) {\n return null;\n }\n\n const sharedFieldTitle: MessageDescriptor = isUnlocked\n ? {\n id: getTranslation('Field.not-localized-unlocked'),\n defaultMessage: 'This value is common to all locales. Saving will update every locale.',\n }\n : {\n id: getTranslation('Field.not-localized-locked'),\n defaultMessage: 'This value is common to all locales. Edit it in the default locale.',\n };\n\n return <LabelAction title={sharedFieldTitle} icon=\"lock\" />;\n};\n\nconst Span = styled(Flex)`\n svg {\n width: 12px;\n height: 12px;\n\n fill: ${({ theme }) => theme.colors.neutral500};\n\n path {\n fill: ${({ theme }) => theme.colors.neutral500};\n }\n }\n`;\n\nexport { mutateEditViewHook, LabelAction };\n"],"names":["hasI18nLayoutOptions","options","i18n","mutateEditViewHook","layout","query","localized","decorateRootField","field","addLabelActionToField","isComponentField","decorateComponentField","components","Object","entries","reduce","acc","key","componentLayout","map","row","panel","isFieldLocalized","attribute","contentTypeLocalized","type","pluginOptions","undefined","title","id","getTranslation","defaultMessage","labelAction","_jsx","LabelAction","icon","NonLocalizedLabelAction","formatMessage","useIntl","Icon","Lock","Earth","_jsxs","Span","tag","VisuallyHidden","Tooltip","label","aria-hidden","focusable","useQueryParams","data","locales","useGetLocalesQuery","isUnlocked","useI18nSharedFieldsLock","state","hasDefaultLocaleEntry","useHasDefaultLocaleEntry","currentLocale","plugins","locale","defaultLocale","Array","isArray","find","isDefault","code","locked","Boolean","sharedFieldTitle","styled","Flex","theme","colors","neutral500"],"mappings":";;;;;;;;;;AA4BA,MAAMA,oBAAAA,GAAuB,CAACC,OAAAA,GAC5B,MAAA,IAAUA,OAAAA,IAAW,OAAOA,OAAAA,CAAQC,IAAI,KAAK,QAAA,IAAYD,OAAAA,CAAQC,IAAI,KAAK,IAAA;AAE5E,MAAMC,qBAAqB,CAAC,EAAEC,MAAM,EAAEC,KAAK,EAAsB,GAAA;;AAE/D,IAAA,IACE,EAAE,MAAA,IAAUD,MAAAA,CAAOH,OAAO,CAAD,IACxB,OAAOG,MAAAA,CAAOH,OAAO,CAACC,IAAI,KAAK,YAC9BE,MAAAA,CAAOH,OAAO,CAACC,IAAI,KAAK,IAAA,IACxB,WAAA,IAAeE,MAAAA,CAAOH,OAAO,CAACC,IAAI,IAClC,CAACE,OAAOH,OAAO,CAACC,IAAI,CAACI,SAAS,EAChC;QACA,OAAO;AAAEF,YAAAA,MAAAA;AAAQC,YAAAA;AAAM,SAAA;AACzB,IAAA;;;;AAKA,IAAA,MAAME,iBAAAA,GAAoB,CAACC,KAAAA,GACzBC,qBAAAA,CAAsBD,OAAOJ,MAAAA,EAAQ;YAAEM,gBAAAA,EAAkB;A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,CAAC,CAACJ,MAAAA,GAAWA,MAAAA,CAAOK,SAAS,GAAGC,IAAAA,GAC5CxC,SAAAA;;;AAGJ,IAAA,MAAMyC,MAAAA,GAASC,OAAAA,CACbV,aAAAA,IAAiBG,aAAAA,IAAiBH,kBAAkBG,aAAAA,IAAiBL,qBAAAA,CAAAA;;AAIvE,IAAA,IAAI,CAACW,MAAAA,EAAQ;QACX,OAAO,IAAA;AACT,IAAA;AAEA,IAAA,MAAME,mBAAsChB,UAAAA,GACxC;AACEzB,QAAAA,EAAAA,EAAIC,cAAAA,CAAe,8BAAA,CAAA;QACnBC,cAAAA,EAAgB;KAClB,GACA;AACEF,QAAAA,EAAAA,EAAIC,cAAAA,CAAe,4BAAA,CAAA;QACnBC,cAAAA,EAAgB;AAClB,KAAA;AAEJ,IAAA,qBAAOE,GAAA,CAACC,WAAAA,EAAAA;QAAYN,KAAAA,EAAO0C,gBAAAA;QAAkBnC,IAAAA,EAAK;;AACpD,CAAA;AAEA,MAAMQ,IAAAA,GAAO4B,MAAAA,CAAOC,IAAAA,CAAK;;;;;UAKf,EAAE,CAAC,EAAEC,KAAK,EAAE,GAAKA,KAAAA,CAAMC,MAAM,CAACC,UAAU,CAAC;;;YAGvC,EAAE,CAAC,EAAEF,KAAK,EAAE,GAAKA,KAAAA,CAAMC,MAAM,CAACC,UAAU,CAAC;;;AAGrD,CAAC;;;;"}
@@ -115,7 +115,8 @@ var index = {
115
115
  contentManagerApis.addDocumentHeaderAction([
116
116
  CMHeaderActions.AITranslationStatusAction,
117
117
  CMHeaderActions.LocalePickerAction,
118
- CMHeaderActions.FillFromAnotherLocaleAction
118
+ CMHeaderActions.FillFromAnotherLocaleAction,
119
+ CMHeaderActions.UnlockSharedFieldsAction
119
120
  ]);
120
121
  contentManagerApis.addDocumentAction((actions)=>{
121
122
  const indexOfDeleteAction = actions.findIndex((action)=>action.type === 'delete');
@@ -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 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 { StrapiApp } from '@strapi/admin/strapi-admin';\nimport type {\n ContentManagerPlugin,\n DocumentActionComponent,\n HeaderActionComponent,\n} from '@strapi/content-manager/strapi-admin';\n\ntype ContentTypeBuilderFormsAPI = {\n addContentTypeSchemaMutation: (mutation: typeof mutateCTBContentTypeSchema) => void;\n components: {\n add: (component: { id: string; component: typeof CheckboxConfirmation }) => void;\n };\n extendContentType: (extension: {\n validator: () => Record<string, unknown>;\n form: {\n advanced: () => Array<Record<string, unknown>>;\n };\n }) => void;\n extendFields: (\n fields: typeof LOCALIZED_FIELDS,\n extension: {\n form: {\n advanced: (args: ContentTypeBuilderAdvancedFieldArgs) => Array<Record<string, unknown>>;\n };\n }\n ) => void;\n};\n\ntype ContentTypeBuilderAdvancedFieldArgs = {\n contentTypeSchema?: Record<string, unknown>;\n forTarget: string;\n step?: string;\n type?: string;\n};\n\n// eslint-disable-next-line import/no-default-export\nexport default {\n register(app: StrapiApp) {\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: StrapiApp) {\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 const contentManagerApis = contentManager.apis as ContentManagerPlugin['config']['apis'];\n\n contentManagerApis.addDocumentHeaderAction([\n AITranslationStatusAction,\n LocalePickerAction,\n FillFromAnotherLocaleAction,\n ] as HeaderActionComponent[]);\n contentManagerApis.addDocumentAction((actions: DocumentActionComponent[]) => {\n const indexOfDeleteAction = actions.findIndex((action) => action.type === 'delete');\n actions.splice(indexOfDeleteAction, 0, DeleteLocaleAction);\n return actions;\n });\n\n contentManagerApis.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 as ContentTypeBuilderFormsAPI;\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({\n contentTypeSchema,\n forTarget,\n type,\n step,\n }: ContentTypeBuilderAdvancedFieldArgs) {\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","contentManagerApis","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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmEA;A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AAM,EAAC;AACPD,oBAAAA;AACF,iBAAA;AACF,YAAA,CAAA,CAAA;AACJ,QAAA,CAAA,CAAA,CAAA;QAGF,OAAOH,OAAAA,CAAQO,OAAO,CAACR,aAAAA,CAAAA;AACzB,IAAA;AACF,CAAA;;;;"}
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 UnlockSharedFieldsAction,\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 { StrapiApp } from '@strapi/admin/strapi-admin';\nimport type {\n ContentManagerPlugin,\n DocumentActionComponent,\n HeaderActionComponent,\n} from '@strapi/content-manager/strapi-admin';\n\ntype ContentTypeBuilderFormsAPI = {\n addContentTypeSchemaMutation: (mutation: typeof mutateCTBContentTypeSchema) => void;\n components: {\n add: (component: { id: string; component: typeof CheckboxConfirmation }) => void;\n };\n extendContentType: (extension: {\n validator: () => Record<string, unknown>;\n form: {\n advanced: () => Array<Record<string, unknown>>;\n };\n }) => void;\n extendFields: (\n fields: typeof LOCALIZED_FIELDS,\n extension: {\n form: {\n advanced: (args: ContentTypeBuilderAdvancedFieldArgs) => Array<Record<string, unknown>>;\n };\n }\n ) => void;\n};\n\ntype ContentTypeBuilderAdvancedFieldArgs = {\n contentTypeSchema?: Record<string, unknown>;\n forTarget: string;\n step?: string;\n type?: string;\n};\n\n// eslint-disable-next-line import/no-default-export\nexport default {\n register(app: StrapiApp) {\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: StrapiApp) {\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 const contentManagerApis = contentManager.apis as ContentManagerPlugin['config']['apis'];\n\n contentManagerApis.addDocumentHeaderAction([\n AITranslationStatusAction,\n LocalePickerAction,\n FillFromAnotherLocaleAction,\n UnlockSharedFieldsAction,\n ] as HeaderActionComponent[]);\n contentManagerApis.addDocumentAction((actions: DocumentActionComponent[]) => {\n const indexOfDeleteAction = actions.findIndex((action) => action.type === 'delete');\n actions.splice(indexOfDeleteAction, 0, DeleteLocaleAction);\n return actions;\n });\n\n contentManagerApis.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 as ContentTypeBuilderFormsAPI;\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({\n contentTypeSchema,\n forTarget,\n type,\n step,\n }: ContentTypeBuilderAdvancedFieldArgs) {\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","contentManagerApis","apis","addDocumentHeaderAction","AITranslationStatusAction","LocalePickerAction","FillFromAnotherLocaleAction","UnlockSharedFieldsAction","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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoEA;AACA,YAAe;AACbA,IAAAA,QAAAA,CAAAA,CAASC,GAAc,EAAA;AACrBA,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,WAAAA,CAAQG,WAAW,GAAGH,YAAQI;AACjC,SAAA,CAAA;AACAR,QAAAA,GAAAA,CAAIS,iBAAiB,CAAC;AAACC,YAAAA;AAAiB,SAAA,CAAA;AACxCV,QAAAA,GAAAA,CAAIW,cAAc,CAAC;YACjBC,EAAAA,EAAIC,iBAAAA;YACJC,IAAAA,EAAMD;AACR,SAAA,CAAA;AACF,IAAA,CAAA;AACAE,IAAAA,SAAAA,CAAAA,CAAUf,GAAc,EAAA;;QAEtBA,GAAAA,CAAIgB,YAAY,CAAC,gDAAA,EAAkDC,6BAAAA,CAAAA;QACnEjB,GAAAA,CAAIgB,YAAY,CAAC,iDAAA,EAAmDE,2BAAAA,CAAAA;;QAEpElB,GAAAA,CAAIgB,YAAY,CACd,6DAAA,EACAG,0CAAAA,CAAAA;;QAIFnB,GAAAA,CAAIoB,eAAe,CAAC,QAAA,EAAU;YAC5BC,SAAAA,EAAW;AACTT,gBAAAA,EAAAA,EAAIU,6BAAAA,CAAe,aAAA,CAAA;gBACnBC,cAAAA,EAAgB;AA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,eAAe,EAAEA,MAAAA,CAAO,KAAK,CAAC,CAAA,CAC1ChE,IAAI,CAAC,CAAC,EAAEE,OAAAA,EAAS+D,IAAI,EAAE,GAAA;gBACtB,OAAO;AACLA,oBAAAA,IAAAA,EAAMC,kDAAyBD,IAAAA,EAAM9E,iBAAAA,CAAAA;AACrC6E,oBAAAA;AACF,iBAAA;AACF,YAAA,CAAA,CAAA,CACCG,KAAK,CAAC,IAAA;gBACL,OAAO;AACLF,oBAAAA,IAAAA,EAAM,EAAC;AACPD,oBAAAA;AACF,iBAAA;AACF,YAAA,CAAA,CAAA;AACJ,QAAA,CAAA,CAAA,CAAA;QAGF,OAAOH,OAAAA,CAAQO,OAAO,CAACR,aAAAA,CAAAA;AACzB,IAAA;AACF,CAAA;;;;"}
@@ -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 { AITranslationStatusAction, LocalePickerAction, FillFromAnotherLocaleAction, DeleteLocaleAction, BulkLocalePublishAction, BulkLocaleUnpublishAction } from './components/CMHeaderActions.mjs';
4
+ import { AITranslationStatusAction, LocalePickerAction, FillFromAnotherLocaleAction, UnlockSharedFieldsAction, 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';
@@ -88,7 +88,8 @@ var index = {
88
88
  contentManagerApis.addDocumentHeaderAction([
89
89
  AITranslationStatusAction,
90
90
  LocalePickerAction,
91
- FillFromAnotherLocaleAction
91
+ FillFromAnotherLocaleAction,
92
+ UnlockSharedFieldsAction
92
93
  ]);
93
94
  contentManagerApis.addDocumentAction((actions)=>{
94
95
  const indexOfDeleteAction = actions.findIndex((action)=>action.type === 'delete');
@@ -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 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 { StrapiApp } from '@strapi/admin/strapi-admin';\nimport type {\n ContentManagerPlugin,\n DocumentActionComponent,\n HeaderActionComponent,\n} from '@strapi/content-manager/strapi-admin';\n\ntype ContentTypeBuilderFormsAPI = {\n addContentTypeSchemaMutation: (mutation: typeof mutateCTBContentTypeSchema) => void;\n components: {\n add: (component: { id: string; component: typeof CheckboxConfirmation }) => void;\n };\n extendContentType: (extension: {\n validator: () => Record<string, unknown>;\n form: {\n advanced: () => Array<Record<string, unknown>>;\n };\n }) => void;\n extendFields: (\n fields: typeof LOCALIZED_FIELDS,\n extension: {\n form: {\n advanced: (args: ContentTypeBuilderAdvancedFieldArgs) => Array<Record<string, unknown>>;\n };\n }\n ) => void;\n};\n\ntype ContentTypeBuilderAdvancedFieldArgs = {\n contentTypeSchema?: Record<string, unknown>;\n forTarget: string;\n step?: string;\n type?: string;\n};\n\n// eslint-disable-next-line import/no-default-export\nexport default {\n register(app: StrapiApp) {\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: StrapiApp) {\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 const contentManagerApis = contentManager.apis as ContentManagerPlugin['config']['apis'];\n\n contentManagerApis.addDocumentHeaderAction([\n AITranslationStatusAction,\n LocalePickerAction,\n FillFromAnotherLocaleAction,\n ] as HeaderActionComponent[]);\n contentManagerApis.addDocumentAction((actions: DocumentActionComponent[]) => {\n const indexOfDeleteAction = actions.findIndex((action) => action.type === 'delete');\n actions.splice(indexOfDeleteAction, 0, DeleteLocaleAction);\n return actions;\n });\n\n contentManagerApis.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 as ContentTypeBuilderFormsAPI;\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({\n contentTypeSchema,\n forTarget,\n type,\n step,\n }: ContentTypeBuilderAdvancedFieldArgs) {\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","contentManagerApis","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":";;;;;;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C,IAAA;gBACL,OAAO;AACLF,oBAAAA,IAAAA,EAAM,EAAC;AACPD,oBAAAA;AACF,iBAAA;AACF,YAAA,CAAA,CAAA;AACJ,QAAA,CAAA,CAAA,CAAA;QAGF,OAAOH,OAAAA,CAAQO,OAAO,CAACR,aAAAA,CAAAA;AACzB,IAAA;AACF,CAAA;;;;"}
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 UnlockSharedFieldsAction,\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 { StrapiApp } from '@strapi/admin/strapi-admin';\nimport type {\n ContentManagerPlugin,\n DocumentActionComponent,\n HeaderActionComponent,\n} from '@strapi/content-manager/strapi-admin';\n\ntype ContentTypeBuilderFormsAPI = {\n addContentTypeSchemaMutation: (mutation: typeof mutateCTBContentTypeSchema) => void;\n components: {\n add: (component: { id: string; component: typeof CheckboxConfirmation }) => void;\n };\n extendContentType: (extension: {\n validator: () => Record<string, unknown>;\n form: {\n advanced: () => Array<Record<string, unknown>>;\n };\n }) => void;\n extendFields: (\n fields: typeof LOCALIZED_FIELDS,\n extension: {\n form: {\n advanced: (args: ContentTypeBuilderAdvancedFieldArgs) => Array<Record<string, unknown>>;\n };\n }\n ) => void;\n};\n\ntype ContentTypeBuilderAdvancedFieldArgs = {\n contentTypeSchema?: Record<string, unknown>;\n forTarget: string;\n step?: string;\n type?: string;\n};\n\n// eslint-disable-next-line import/no-default-export\nexport default {\n register(app: StrapiApp) {\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: StrapiApp) {\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 const contentManagerApis = contentManager.apis as ContentManagerPlugin['config']['apis'];\n\n contentManagerApis.addDocumentHeaderAction([\n AITranslationStatusAction,\n LocalePickerAction,\n FillFromAnotherLocaleAction,\n UnlockSharedFieldsAction,\n ] as HeaderActionComponent[]);\n contentManagerApis.addDocumentAction((actions: DocumentActionComponent[]) => {\n const indexOfDeleteAction = actions.findIndex((action) => action.type === 'delete');\n actions.splice(indexOfDeleteAction, 0, DeleteLocaleAction);\n return actions;\n });\n\n contentManagerApis.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 as ContentTypeBuilderFormsAPI;\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({\n contentTypeSchema,\n forTarget,\n type,\n step,\n }: ContentTypeBuilderAdvancedFieldArgs) {\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","contentManagerApis","apis","addDocumentHeaderAction","AITranslationStatusAction","LocalePickerAction","FillFromAnotherLocaleAction","UnlockSharedFieldsAction","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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoEA;AACA,YAAe;AACbA,IAAAA,QAAAA,CAAAA,CAASC,GAAc,EAAA;AACrBA,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,OAAAA,CAAQG,WAAW,GAAGH,QAAQI;AACjC,SAAA,CAAA;AACAR,QAAAA,GAAAA,CAAIS,iBAAiB,CAAC;AAACC,YAAAA;AAAiB,SAAA,CAAA;AACxCV,QAAAA,GAAAA,CAAIW,cAAc,CAAC;YACjBC,EAAAA,EAAIC,QAAAA;YACJC,IAAAA,EAAMD;AACR,SAAA,CAAA;AACF,IAAA,CAAA;AACAE,IAAAA,SAAAA,CAAAA,CAAUf,GAAc,EAAA;;QAEtBA,GAAAA,CAAIgB,YAAY,CAAC,gDAAA,EAAkDC,oBAAAA,CAAAA;QACnEjB,GAAAA,CAAIgB,YAAY,CAAC,iDAAA,EAAmDE,kBAAAA,CAAAA;;QAEpElB,GAAAA,CAAIgB,YAAY,CACd,6DAAA,EACAG,uBAAAA,CAAAA;;QAIFnB,GAAAA,CAAIoB,eAAe,CAAC,QAAA,EAAU;YAC5BC,SAAAA,EAAW;AACTT,gBAAAA,EAAAA,EAAIU,cAAAA,CAAe,aAAA,CAAA;gBACnBC,cAAAA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AC,eAAe,EAAEA,MAAAA,CAAO,KAAK,CAAC,CAAA,CAC1ChE,IAAI,CAAC,CAAC,EAAEE,OAAAA,EAAS+D,IAAI,EAAE,GAAA;gBACtB,OAAO;AACLA,oBAAAA,IAAAA,EAAMC,yBAAyBD,IAAAA,EAAM9E,QAAAA,CAAAA;AACrC6E,oBAAAA;AACF,iBAAA;AACF,YAAA,CAAA,CAAA,CACCG,KAAK,CAAC,IAAA;gBACL,OAAO;AACLF,oBAAAA,IAAAA,EAAM,EAAC;AACPD,oBAAAA;AACF,iBAAA;AACF,YAAA,CAAA,CAAA;AACJ,QAAA,CAAA,CAAA,CAAA;QAGF,OAAOH,OAAAA,CAAQO,OAAO,CAACR,aAAAA,CAAAA;AACzB,IAAA;AACF,CAAA;;;;"}
@@ -39,6 +39,25 @@ declare const FillFromAnotherLocaleAction: ({ documentId, meta, model, collectio
39
39
  }) => import("react/jsx-runtime").JSX.Element;
40
40
  };
41
41
  } | null;
42
+ declare const UnlockSharedFieldsAction: ({ activeTab, model, collectionType, documentId, }: HeaderActionProps) => {
43
+ type: "icon";
44
+ icon: import("react/jsx-runtime").JSX.Element;
45
+ label: string;
46
+ onClick: () => boolean;
47
+ dialog?: undefined;
48
+ } | {
49
+ type: "icon";
50
+ icon: import("react/jsx-runtime").JSX.Element;
51
+ label: string;
52
+ dialog: {
53
+ type: "dialog";
54
+ title: string;
55
+ content: ({ onClose }: {
56
+ onClose: () => void;
57
+ }) => import("react/jsx-runtime").JSX.Element;
58
+ };
59
+ onClick?: undefined;
60
+ } | null;
42
61
  declare const DeleteLocaleAction: DocumentActionComponent;
43
62
  export type LocaleStatus = {
44
63
  locale: string;
@@ -46,4 +65,4 @@ export type LocaleStatus = {
46
65
  };
47
66
  declare const BulkLocalePublishAction: DocumentActionComponent;
48
67
  declare const BulkLocaleUnpublishAction: DocumentActionComponent;
49
- export { BulkLocalePublishAction, BulkLocaleUnpublishAction, DeleteLocaleAction, LocalePickerAction, FillFromAnotherLocaleAction, AITranslationStatusAction, };
68
+ export { BulkLocalePublishAction, BulkLocaleUnpublishAction, DeleteLocaleAction, LocalePickerAction, FillFromAnotherLocaleAction, UnlockSharedFieldsAction, AITranslationStatusAction, };
@@ -1,6 +1,13 @@
1
+ import { MessageDescriptor } from 'react-intl';
1
2
  import type { EditLayout } from '@strapi/content-manager/strapi-admin';
2
3
  interface MutateEditViewArgs {
3
4
  layout: EditLayout;
5
+ query?: unknown;
4
6
  }
5
- declare const mutateEditViewHook: ({ layout }: MutateEditViewArgs) => MutateEditViewArgs;
6
- export { mutateEditViewHook };
7
+ declare const mutateEditViewHook: ({ layout, query }: MutateEditViewArgs) => MutateEditViewArgs;
8
+ interface LabelActionProps {
9
+ title: MessageDescriptor;
10
+ icon?: 'earth' | 'lock';
11
+ }
12
+ declare const LabelAction: ({ title, icon }: LabelActionProps) => import("react/jsx-runtime").JSX.Element;
13
+ export { mutateEditViewHook, LabelAction };
@@ -28,6 +28,13 @@ var en = {
28
28
  "CMEditViewAITranslation.job-failed": "AI translation failed. Please try again.",
29
29
  "CMEditViewLocalePicker.locale.create": "Create <bold>{locale}</bold> locale",
30
30
  "CMEditViewLocalePicker.locale.ai-translations": "AI Translations:",
31
+ "CMEditViewUnlockSharedFields.unlock-text": "Edit shared fields",
32
+ "CMEditViewUnlockSharedFields.lock-text": "Keep shared fields locked",
33
+ "CMEditViewUnlockSharedFields.dialog.title": "Edit fields common to all locales?",
34
+ "CMEditViewUnlockSharedFields.dialog.body": "These values are shared across every locale. Saving changes will update {defaultLocale} and all other translations, not just {currentLocale}.",
35
+ "CMEditViewUnlockSharedFields.default-locale": "the default locale",
36
+ "CMEditViewUnlockSharedFields.cancel-text": "No, cancel",
37
+ "CMEditViewUnlockSharedFields.submit-text": "Yes, edit shared fields",
31
38
  "CMListView.popover.display-locales.label": "Display translated locales",
32
39
  "CMListView.popover.display-locales.more": "{locales} + {count} more",
33
40
  "CheckboxConfirmation.Modal.body": "Do you want to disable it?",
@@ -35,6 +42,8 @@ var en = {
35
42
  "CheckboxConfirmation.Modal.content": "Disabling localization will engender the deletion of all your content but the one associated to your default locale (if existing).",
36
43
  "Field.localized": "This value is unique for the selected locale",
37
44
  "Field.not-localized": "This value is common to all locales",
45
+ "Field.not-localized-locked": "This value is common to all locales. Edit it in the default locale.",
46
+ "Field.not-localized-unlocked": "This value is common to all locales. Saving will update every locale.",
38
47
  "Settings.list.actions.add": "Add new locale",
39
48
  "Settings.list.actions.delete": "Delete {name} locale",
40
49
  "Settings.list.actions.deleteAdditionalInfos": "This will delete the active locale versions <em>(from Internationalization)</em>",
@@ -1 +1 @@
1
- {"version":3,"file":"en.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"en.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -26,6 +26,13 @@ var en = {
26
26
  "CMEditViewAITranslation.job-failed": "AI translation failed. Please try again.",
27
27
  "CMEditViewLocalePicker.locale.create": "Create <bold>{locale}</bold> locale",
28
28
  "CMEditViewLocalePicker.locale.ai-translations": "AI Translations:",
29
+ "CMEditViewUnlockSharedFields.unlock-text": "Edit shared fields",
30
+ "CMEditViewUnlockSharedFields.lock-text": "Keep shared fields locked",
31
+ "CMEditViewUnlockSharedFields.dialog.title": "Edit fields common to all locales?",
32
+ "CMEditViewUnlockSharedFields.dialog.body": "These values are shared across every locale. Saving changes will update {defaultLocale} and all other translations, not just {currentLocale}.",
33
+ "CMEditViewUnlockSharedFields.default-locale": "the default locale",
34
+ "CMEditViewUnlockSharedFields.cancel-text": "No, cancel",
35
+ "CMEditViewUnlockSharedFields.submit-text": "Yes, edit shared fields",
29
36
  "CMListView.popover.display-locales.label": "Display translated locales",
30
37
  "CMListView.popover.display-locales.more": "{locales} + {count} more",
31
38
  "CheckboxConfirmation.Modal.body": "Do you want to disable it?",
@@ -33,6 +40,8 @@ var en = {
33
40
  "CheckboxConfirmation.Modal.content": "Disabling localization will engender the deletion of all your content but the one associated to your default locale (if existing).",
34
41
  "Field.localized": "This value is unique for the selected locale",
35
42
  "Field.not-localized": "This value is common to all locales",
43
+ "Field.not-localized-locked": "This value is common to all locales. Edit it in the default locale.",
44
+ "Field.not-localized-unlocked": "This value is common to all locales. Saving will update every locale.",
36
45
  "Settings.list.actions.add": "Add new locale",
37
46
  "Settings.list.actions.delete": "Delete {name} locale",
38
47
  "Settings.list.actions.deleteAdditionalInfos": "This will delete the active locale versions <em>(from Internationalization)</em>",
@@ -1 +1 @@
1
- {"version":3,"file":"en.json.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"en.json.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,8 +1,10 @@
1
1
  'use strict';
2
2
 
3
3
  var _ = require('lodash');
4
+ var utils = require('@strapi/utils');
4
5
  var auditLogs = require('./audit-logs.js');
5
6
  var index = require('./utils/index.js');
7
+ var nonLocalizedOriginalData = require('./utils/non-localized-original-data.js');
6
8
 
7
9
  const registerModelsHooks = ()=>{
8
10
  strapi.db.lifecycles.subscribe({
@@ -32,11 +34,20 @@ const registerModelsHooks = ()=>{
32
34
  // Build a populate array for all non localized fields within the schema
33
35
  const { getNestedPopulateOfNonLocalizedAttributes, copyNonLocalizedAttributes } = index.getService('content-types');
34
36
  const attributesToPopulate = getNestedPopulateOfNonLocalizedAttributes(schema.uid);
35
- // Get original data before the update to compare what actually changed
36
- const originalData = 'documentId' in context.params && context.params.documentId ? await strapi.db.query(schema.uid).findOne({
37
- where: {
38
- documentId: context.params.documentId
39
- },
37
+ // Compare against this locale + status, not an arbitrary row of the document.
38
+ // Unscoped findOne can pick a published sibling while we write a draft (or
39
+ // the reverse), which makes i18n sync overwrite the other tree.
40
+ const localeParam = 'locale' in context.params ? context.params.locale : undefined;
41
+ const defaultLocale = await index.getService('locales').getDefaultLocale();
42
+ const originalWhere = nonLocalizedOriginalData.getOriginalNonLocalizedLookup({
43
+ documentId: 'documentId' in context.params && typeof context.params.documentId === 'string' ? context.params.documentId : undefined,
44
+ locale: localeParam,
45
+ action: context.action,
46
+ hasDraftAndPublish: utils.contentTypes.hasDraftAndPublish(schema),
47
+ defaultLocale
48
+ });
49
+ const originalData = originalWhere ? await strapi.db.query(schema.uid).findOne({
50
+ where: originalWhere,
40
51
  populate: attributesToPopulate
41
52
  }) : null;
42
53
  // Get the result of the document service action