@strapi/i18n 0.0.0-next.965570e6e12a33ad098ddb3174a9750fddb03be2 → 0.0.0-next.96a532b33a712f19b498ed0a82a84752247cd899
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.
- package/dist/admin/components/CMHeaderActions.js +116 -1
- package/dist/admin/components/CMHeaderActions.js.map +1 -1
- package/dist/admin/components/CMHeaderActions.mjs +119 -5
- package/dist/admin/components/CMHeaderActions.mjs.map +1 -1
- package/dist/admin/components/CreateLocale.js +1 -1
- package/dist/admin/components/CreateLocale.js.map +1 -1
- package/dist/admin/components/CreateLocale.mjs +1 -1
- package/dist/admin/components/CreateLocale.mjs.map +1 -1
- package/dist/admin/components/EditLocale.js +1 -1
- package/dist/admin/components/EditLocale.js.map +1 -1
- package/dist/admin/components/EditLocale.mjs +1 -1
- package/dist/admin/components/EditLocale.mjs.map +1 -1
- package/dist/admin/components/LocaleListCell.js +65 -45
- package/dist/admin/components/LocaleListCell.js.map +1 -1
- package/dist/admin/components/LocaleListCell.mjs +66 -46
- package/dist/admin/components/LocaleListCell.mjs.map +1 -1
- package/dist/admin/components/LocalePicker.js +18 -11
- package/dist/admin/components/LocalePicker.js.map +1 -1
- package/dist/admin/components/LocalePicker.mjs +19 -12
- package/dist/admin/components/LocalePicker.mjs.map +1 -1
- package/dist/admin/contentManagerHooks/editView.js +6 -3
- package/dist/admin/contentManagerHooks/editView.js.map +1 -1
- package/dist/admin/contentManagerHooks/editView.mjs +7 -4
- package/dist/admin/contentManagerHooks/editView.mjs.map +1 -1
- package/dist/admin/contentManagerHooks/listView.js +2 -1
- package/dist/admin/contentManagerHooks/listView.js.map +1 -1
- package/dist/admin/contentManagerHooks/listView.mjs +2 -1
- package/dist/admin/contentManagerHooks/listView.mjs.map +1 -1
- package/dist/admin/index.js +1 -0
- package/dist/admin/index.js.map +1 -1
- package/dist/admin/index.mjs +2 -1
- package/dist/admin/index.mjs.map +1 -1
- package/dist/admin/pages/SettingsPage.js +121 -46
- package/dist/admin/pages/SettingsPage.js.map +1 -1
- package/dist/admin/pages/SettingsPage.mjs +124 -30
- package/dist/admin/pages/SettingsPage.mjs.map +1 -1
- package/dist/admin/services/api.js +2 -1
- package/dist/admin/services/api.js.map +1 -1
- package/dist/admin/services/api.mjs +2 -1
- package/dist/admin/services/api.mjs.map +1 -1
- package/dist/admin/services/settings.js +29 -0
- package/dist/admin/services/settings.js.map +1 -0
- package/dist/admin/services/settings.mjs +26 -0
- package/dist/admin/services/settings.mjs.map +1 -0
- package/dist/admin/src/components/CMHeaderActions.d.ts +7 -1
- package/dist/admin/src/components/LocaleListCell.d.ts +2 -1
- package/dist/admin/src/services/api.d.ts +1 -1
- package/dist/admin/src/services/locales.d.ts +1 -1
- package/dist/admin/src/services/relations.d.ts +1 -1
- package/dist/admin/src/services/settings.d.ts +5 -0
- package/dist/admin/translations/en.json.js +7 -0
- package/dist/admin/translations/en.json.js.map +1 -1
- package/dist/admin/translations/en.json.mjs +7 -0
- package/dist/admin/translations/en.json.mjs.map +1 -1
- package/dist/admin/utils/clean.js +2 -2
- package/dist/admin/utils/clean.js.map +1 -1
- package/dist/admin/utils/clean.mjs +2 -2
- package/dist/admin/utils/clean.mjs.map +1 -1
- package/dist/server/constants/iso-locales.json.js +4 -0
- package/dist/server/constants/iso-locales.json.js.map +1 -1
- package/dist/server/constants/iso-locales.json.mjs +4 -0
- package/dist/server/constants/iso-locales.json.mjs.map +1 -1
- package/dist/server/controllers/index.js +3 -1
- package/dist/server/controllers/index.js.map +1 -1
- package/dist/server/controllers/index.mjs +3 -1
- package/dist/server/controllers/index.mjs.map +1 -1
- package/dist/server/controllers/settings.js +24 -0
- package/dist/server/controllers/settings.js.map +1 -0
- package/dist/server/controllers/settings.mjs +22 -0
- package/dist/server/controllers/settings.mjs.map +1 -0
- package/dist/server/routes/admin.js +20 -0
- package/dist/server/routes/admin.js.map +1 -1
- package/dist/server/routes/admin.mjs +20 -0
- package/dist/server/routes/admin.mjs.map +1 -1
- package/dist/server/services/ai-localizations.js +143 -0
- package/dist/server/services/ai-localizations.js.map +1 -0
- package/dist/server/services/ai-localizations.mjs +141 -0
- package/dist/server/services/ai-localizations.mjs.map +1 -0
- package/dist/server/services/index.js +5 -1
- package/dist/server/services/index.js.map +1 -1
- package/dist/server/services/index.mjs +5 -1
- package/dist/server/services/index.mjs.map +1 -1
- package/dist/server/services/settings.js +25 -0
- package/dist/server/services/settings.js.map +1 -0
- package/dist/server/services/settings.mjs +23 -0
- package/dist/server/services/settings.mjs.map +1 -0
- package/dist/server/src/controllers/index.d.ts +4 -0
- package/dist/server/src/controllers/index.d.ts.map +1 -1
- package/dist/server/src/controllers/settings.d.ts +7 -0
- package/dist/server/src/controllers/settings.d.ts.map +1 -0
- package/dist/server/src/index.d.ts +23 -0
- package/dist/server/src/index.d.ts.map +1 -1
- package/dist/server/src/routes/admin.d.ts.map +1 -1
- package/dist/server/src/services/ai-localizations.d.ts +17 -0
- package/dist/server/src/services/ai-localizations.d.ts.map +1 -0
- package/dist/server/src/services/index.d.ts +19 -0
- package/dist/server/src/services/index.d.ts.map +1 -1
- package/dist/server/src/services/settings.d.ts +13 -0
- package/dist/server/src/services/settings.d.ts.map +1 -0
- package/dist/server/src/utils/index.d.ts +5 -1
- package/dist/server/src/utils/index.d.ts.map +1 -1
- package/dist/server/src/validation/settings.d.ts +12 -0
- package/dist/server/src/validation/settings.d.ts.map +1 -0
- package/dist/server/utils/index.js.map +1 -1
- package/dist/server/utils/index.mjs.map +1 -1
- package/dist/server/validation/settings.js +11 -0
- package/dist/server/validation/settings.js.map +1 -0
- package/dist/server/validation/settings.mjs +9 -0
- package/dist/server/validation/settings.mjs.map +1 -0
- package/dist/shared/contracts/settings.d.ts +40 -0
- package/package.json +9 -8
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { useQueryParams } from '@strapi/admin/strapi-admin';
|
|
4
|
-
import {
|
|
4
|
+
import { SingleSelectOption, SingleSelect } from '@strapi/design-system';
|
|
5
5
|
import { useIntl } from 'react-intl';
|
|
6
6
|
import { useI18n } from '../hooks/useI18n.mjs';
|
|
7
7
|
import { useGetLocalesQuery } from '../services/locales.mjs';
|
|
@@ -47,16 +47,26 @@ const LocalePicker = ()=>{
|
|
|
47
47
|
locales,
|
|
48
48
|
query.plugins?.i18n?.locale
|
|
49
49
|
]);
|
|
50
|
+
const sortedLocaleOptions = React.useMemo(()=>{
|
|
51
|
+
const displayedLocales = Array.isArray(locales) ? locales.filter((locale)=>{
|
|
52
|
+
/**
|
|
53
|
+
* If you can create or read we allow you to see the locale exists
|
|
54
|
+
* this is because in the ListView, you may be able to create a new entry
|
|
55
|
+
* in a locale you can't read.
|
|
56
|
+
*/ return canCreate.includes(locale.code) || canRead.includes(locale.code);
|
|
57
|
+
}) : [];
|
|
58
|
+
return displayedLocales.sort((a, b)=>a.name.localeCompare(b.name)).map((locale)=>/*#__PURE__*/ jsx(SingleSelectOption, {
|
|
59
|
+
value: locale.code,
|
|
60
|
+
children: locale.name
|
|
61
|
+
}, locale.id));
|
|
62
|
+
}, [
|
|
63
|
+
locales,
|
|
64
|
+
canCreate,
|
|
65
|
+
canRead
|
|
66
|
+
]);
|
|
50
67
|
if (!hasI18n || !Array.isArray(locales) || locales.length === 0) {
|
|
51
68
|
return null;
|
|
52
69
|
}
|
|
53
|
-
const displayedLocales = locales.filter((locale)=>{
|
|
54
|
-
/**
|
|
55
|
-
* If you can create or read we allow you to see the locale exists
|
|
56
|
-
* this is because in the ListView, you may be able to create a new entry
|
|
57
|
-
* in a locale you can't read.
|
|
58
|
-
*/ return canCreate.includes(locale.code) || canRead.includes(locale.code);
|
|
59
|
-
});
|
|
60
70
|
return /*#__PURE__*/ jsx(SingleSelect, {
|
|
61
71
|
size: "S",
|
|
62
72
|
"aria-label": formatMessage({
|
|
@@ -66,10 +76,7 @@ const LocalePicker = ()=>{
|
|
|
66
76
|
value: query.plugins?.i18n?.locale || locales.find((locale)=>locale.isDefault)?.code,
|
|
67
77
|
// @ts-expect-error – This can be removed in V2 of the DS.
|
|
68
78
|
onChange: handleChange,
|
|
69
|
-
children:
|
|
70
|
-
value: locale.code,
|
|
71
|
-
children: locale.name
|
|
72
|
-
}, locale.id))
|
|
79
|
+
children: sortedLocaleOptions
|
|
73
80
|
});
|
|
74
81
|
};
|
|
75
82
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LocalePicker.mjs","sources":["../../../admin/src/components/LocalePicker.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { useQueryParams } from '@strapi/admin/strapi-admin';\nimport { SingleSelect, SingleSelectOption } from '@strapi/design-system';\nimport { useIntl } from 'react-intl';\n\nimport { useI18n } from '../hooks/useI18n';\nimport { useGetLocalesQuery } from '../services/locales';\nimport { getTranslation } from '../utils/getTranslation';\n\nimport type { I18nBaseQuery } from '../types';\n\ninterface Query extends I18nBaseQuery {\n page?: number;\n}\n\nconst LocalePicker = () => {\n const { formatMessage } = useIntl();\n const [{ query }, setQuery] = useQueryParams<Query>();\n\n const { hasI18n, canRead, canCreate } = useI18n();\n const { data: locales = [] } = useGetLocalesQuery(undefined, {\n skip: !hasI18n,\n });\n\n const handleChange = React.useCallback(\n (code: string, replace = false) => {\n setQuery(\n {\n page: 1,\n plugins: { ...query.plugins, i18n: { locale: code } },\n },\n 'push',\n replace\n );\n },\n [query.plugins, setQuery]\n );\n\n React.useEffect(() => {\n if (!Array.isArray(locales) || !hasI18n) {\n return;\n }\n /**\n * Handle the case where the current locale query param doesn't exist\n * in the list of available locales, so we redirect to the default locale.\n */\n const currentDesiredLocale = query.plugins?.i18n?.locale;\n const doesLocaleExist = locales.find((loc) => loc.code === currentDesiredLocale);\n const defaultLocale = locales.find((locale) => locale.isDefault);\n if (!doesLocaleExist && defaultLocale?.code) {\n handleChange(defaultLocale.code, true);\n }\n }, [hasI18n, handleChange, locales, query.plugins?.i18n?.locale]);\n\n
|
|
1
|
+
{"version":3,"file":"LocalePicker.mjs","sources":["../../../admin/src/components/LocalePicker.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { useQueryParams } from '@strapi/admin/strapi-admin';\nimport { SingleSelect, SingleSelectOption } from '@strapi/design-system';\nimport { useIntl } from 'react-intl';\n\nimport { useI18n } from '../hooks/useI18n';\nimport { useGetLocalesQuery } from '../services/locales';\nimport { getTranslation } from '../utils/getTranslation';\n\nimport type { I18nBaseQuery } from '../types';\n\ninterface Query extends I18nBaseQuery {\n page?: number;\n}\n\nconst LocalePicker = () => {\n const { formatMessage } = useIntl();\n const [{ query }, setQuery] = useQueryParams<Query>();\n\n const { hasI18n, canRead, canCreate } = useI18n();\n const { data: locales = [] } = useGetLocalesQuery(undefined, {\n skip: !hasI18n,\n });\n\n const handleChange = React.useCallback(\n (code: string, replace = false) => {\n setQuery(\n {\n page: 1,\n plugins: { ...query.plugins, i18n: { locale: code } },\n },\n 'push',\n replace\n );\n },\n [query.plugins, setQuery]\n );\n\n React.useEffect(() => {\n if (!Array.isArray(locales) || !hasI18n) {\n return;\n }\n /**\n * Handle the case where the current locale query param doesn't exist\n * in the list of available locales, so we redirect to the default locale.\n */\n const currentDesiredLocale = query.plugins?.i18n?.locale;\n const doesLocaleExist = locales.find((loc) => loc.code === currentDesiredLocale);\n const defaultLocale = locales.find((locale) => locale.isDefault);\n if (!doesLocaleExist && defaultLocale?.code) {\n handleChange(defaultLocale.code, true);\n }\n }, [hasI18n, handleChange, locales, query.plugins?.i18n?.locale]);\n\n const sortedLocaleOptions = React.useMemo(() => {\n const displayedLocales = Array.isArray(locales)\n ? locales.filter((locale) => {\n /**\n * If you can create or read we allow you to see the locale exists\n * this is because in the ListView, you may be able to create a new entry\n * in a locale you can't read.\n */\n return canCreate.includes(locale.code) || canRead.includes(locale.code);\n })\n : [];\n\n return displayedLocales\n .sort((a, b) => a.name.localeCompare(b.name))\n .map((locale) => (\n <SingleSelectOption key={locale.id} value={locale.code}>\n {locale.name}\n </SingleSelectOption>\n ));\n }, [locales, canCreate, canRead]);\n\n if (!hasI18n || !Array.isArray(locales) || locales.length === 0) {\n return null;\n }\n\n return (\n <SingleSelect\n size=\"S\"\n aria-label={formatMessage({\n id: getTranslation('actions.select-locale'),\n defaultMessage: 'Select locale',\n })}\n value={query.plugins?.i18n?.locale || locales.find((locale) => locale.isDefault)?.code}\n // @ts-expect-error – This can be removed in V2 of the DS.\n onChange={handleChange}\n >\n {sortedLocaleOptions}\n </SingleSelect>\n );\n};\n\nexport { LocalePicker };\n"],"names":["LocalePicker","formatMessage","useIntl","query","setQuery","useQueryParams","hasI18n","canRead","canCreate","useI18n","data","locales","useGetLocalesQuery","undefined","skip","handleChange","React","useCallback","code","replace","page","plugins","i18n","locale","useEffect","Array","isArray","currentDesiredLocale","doesLocaleExist","find","loc","defaultLocale","isDefault","sortedLocaleOptions","useMemo","displayedLocales","filter","includes","sort","a","b","name","localeCompare","map","_jsx","SingleSelectOption","value","id","length","SingleSelect","size","aria-label","getTranslation","defaultMessage","onChange"],"mappings":";;;;;;;;;AAgBA,MAAMA,YAAe,GAAA,IAAA;IACnB,MAAM,EAAEC,aAAa,EAAE,GAAGC,OAAAA,EAAAA;AAC1B,IAAA,MAAM,CAAC,EAAEC,KAAK,EAAE,EAAEC,SAAS,GAAGC,cAAAA,EAAAA;AAE9B,IAAA,MAAM,EAAEC,OAAO,EAAEC,OAAO,EAAEC,SAAS,EAAE,GAAGC,OAAAA,EAAAA;AACxC,IAAA,MAAM,EAAEC,IAAMC,EAAAA,OAAAA,GAAU,EAAE,EAAE,GAAGC,mBAAmBC,SAAW,EAAA;AAC3DC,QAAAA,IAAAA,EAAM,CAACR;AACT,KAAA,CAAA;AAEA,IAAA,MAAMS,eAAeC,KAAMC,CAAAA,WAAW,CACpC,CAACC,IAAAA,EAAcC,UAAU,KAAK,GAAA;QAC5Bf,QACE,CAAA;YACEgB,IAAM,EAAA,CAAA;YACNC,OAAS,EAAA;AAAE,g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/
|
|
86
|
-
|
|
87
|
-
|
|
85
|
+
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Tooltip, {
|
|
86
|
+
label: formatMessage(title),
|
|
87
|
+
children: /*#__PURE__*/ React__namespace.cloneElement(icon, {
|
|
88
|
+
'aria-hidden': true,
|
|
89
|
+
focusable: false
|
|
90
|
+
})
|
|
88
91
|
})
|
|
89
92
|
]
|
|
90
93
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editView.js","sources":["../../../admin/src/contentManagerHooks/editView.tsx"],"sourcesContent":["/* eslint-disable check-file/filename-naming-convention */\nimport * as React from 'react';\n\nimport { Flex, VisuallyHidden } from '@strapi/design-system';\nimport { Earth, EarthStriked } 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';\n\ninterface MutateEditViewArgs {\n layout: EditLayout;\n}\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 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(addLabelActionToField)),\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(addLabelActionToField))),\n },\n } satisfies Pick<MutateEditViewArgs, 'layout'>;\n};\n\nconst addLabelActionToField = (field: EditFieldLayout) => {\n const isFieldLocalized = doesFieldHaveI18nPluginOpt(field.attribute.pluginOptions)\n ? field.attribute.pluginOptions.i18n.localized\n : true || ['uid', 'relation'].includes(field.attribute.type);\n\n const labelActionProps = {\n title: {\n id: isFieldLocalized\n ? getTranslation('Field.localized')\n : getTranslation('Field.not-localized'),\n defaultMessage: isFieldLocalized\n ? 'This value is unique for the selected locale'\n : 'This value is the same across all locales',\n },\n icon: isFieldLocalized ? <Earth /> : null,\n };\n\n return {\n ...field,\n labelAction: isFieldLocalized ? <LabelAction {...labelActionProps} /> : null,\n };\n};\n\nconst doesFieldHaveI18nPluginOpt = (\n pluginOpts?: object\n): pluginOpts is { i18n: { localized: boolean } } => {\n if (!pluginOpts) {\n return false;\n }\n\n return (\n 'i18n' in pluginOpts &&\n typeof pluginOpts.i18n === 'object' &&\n pluginOpts.i18n !== null &&\n 'localized' in pluginOpts.i18n\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * LabelAction\n * -----------------------------------------------------------------------------------------------*/\n\ninterface LabelActionProps {\n title: MessageDescriptor;\n icon: React.ReactNode;\n}\n\nconst LabelAction = ({ title, icon }: LabelActionProps) => {\n const { formatMessage } = useIntl();\n\n return (\n <Span tag=\"span\">\n <VisuallyHidden tag=\"span\">{formatMessage(title)}</VisuallyHidden>\n {React.cloneElement(icon as React.ReactElement, {\n
|
|
1
|
+
{"version":3,"file":"editView.js","sources":["../../../admin/src/contentManagerHooks/editView.tsx"],"sourcesContent":["/* eslint-disable check-file/filename-naming-convention */\nimport * as React from 'react';\n\nimport { Flex, Tooltip, VisuallyHidden } from '@strapi/design-system';\nimport { Earth, EarthStriked } 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';\n\ninterface MutateEditViewArgs {\n layout: EditLayout;\n}\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 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(addLabelActionToField)),\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(addLabelActionToField))),\n },\n } satisfies Pick<MutateEditViewArgs, 'layout'>;\n};\n\nconst addLabelActionToField = (field: EditFieldLayout) => {\n const isFieldLocalized = doesFieldHaveI18nPluginOpt(field.attribute.pluginOptions)\n ? field.attribute.pluginOptions.i18n.localized\n : true || ['uid', 'relation'].includes(field.attribute.type);\n\n const labelActionProps = {\n title: {\n id: isFieldLocalized\n ? getTranslation('Field.localized')\n : getTranslation('Field.not-localized'),\n defaultMessage: isFieldLocalized\n ? 'This value is unique for the selected locale'\n : 'This value is the same across all locales',\n },\n icon: isFieldLocalized ? <Earth /> : null,\n };\n\n return {\n ...field,\n labelAction: isFieldLocalized ? <LabelAction {...labelActionProps} /> : null,\n };\n};\n\nconst doesFieldHaveI18nPluginOpt = (\n pluginOpts?: object\n): pluginOpts is { i18n: { localized: boolean } } => {\n if (!pluginOpts) {\n return false;\n }\n\n return (\n 'i18n' in pluginOpts &&\n typeof pluginOpts.i18n === 'object' &&\n pluginOpts.i18n !== null &&\n 'localized' in pluginOpts.i18n\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * LabelAction\n * -----------------------------------------------------------------------------------------------*/\n\ninterface LabelActionProps {\n title: MessageDescriptor;\n icon: React.ReactNode;\n}\n\nconst LabelAction = ({ title, icon }: 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 {React.cloneElement(icon as React.ReactElement, {\n 'aria-hidden': true,\n focusable: false, // See: https://allyjs.io/tutorials/focusing-in-svg.html#making-svg-elements-focusable\n })}\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":["mutateEditViewHook","layout","options","i18n","localized","components","Object","entries","reduce","acc","key","componentLayout","map","row","addLabelActionToField","panel","field","isFieldLocalized","doesFieldHaveI18nPluginOpt","attribute","pluginOptions","labelActionProps","title","id","getTranslation","defaultMessage","icon","_jsx","Earth","labelAction","LabelAction","pluginOpts","formatMessage","useIntl","_jsxs","Span","tag","VisuallyHidden","Tooltip","label","React","cloneElement","focusable","styled","Flex","theme","colors","neutral500"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBA,MAAMA,kBAAqB,GAAA,CAAC,EAAEC,MAAM,EAAsB,GAAA;;AAExD,IAAA,IACE,EAAE,MAAUA,IAAAA,MAAAA,CAAOC,OAAO,CAAD,IACxB,OAAOD,MAAAA,CAAOC,OAAO,CAACC,IAAI,KAAK,YAC9BF,MAAOC,CAAAA,OAAO,CAACC,IAAI,KAAK,IAAA,IACxB,WAAeF,IAAAA,MAAAA,CAAOC,OAAO,CAACC,IAAI,IAClC,CAACF,OAAOC,OAAO,CAACC,IAAI,CAACC,SAAS,EAChC;QACA,OAAO;AAAEH,YAAAA;AAAO,SAAA;AAClB;AAEA,IAAA,MAAMI,UAAaC,GAAAA,MAAAA,CAAOC,OAAO,CAACN,MAAOI,CAAAA,UAAU,CAAEG,CAAAA,MAAM,CACzD,CAACC,GAAK,EAAA,CAACC,KAAKC,eAAgB,CAAA,GAAA;QAC1B,OAAO;AACL,YAAA,GAAGF,GAAG;AACN,YAAA,CAACC,MAAM;AACL,gBAAA,GAAGC,eAAe;gBAClBV,MAAQU,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AUA,IAAAA,UAAAA,IACV,OAAOA,UAAAA,CAAW5B,IAAI,KAAK,QAC3B4B,IAAAA,UAAAA,CAAW5B,IAAI,KAAK,IACpB,IAAA,WAAA,IAAe4B,WAAW5B,IAAI;AAElC,CAAA;AAWA,MAAM2B,cAAc,CAAC,EAAER,KAAK,EAAEI,IAAI,EAAoB,GAAA;IACpD,MAAM,EAAEM,aAAa,EAAE,GAAGC,iBAAAA,EAAAA;AAE1B,IAAA,qBACEC,eAACC,CAAAA,IAAAA,EAAAA;QAAKC,GAAI,EAAA,MAAA;;0BACRT,cAACU,CAAAA,2BAAAA,EAAAA;gBAAeD,GAAI,EAAA,MAAA;0BAAQJ,aAAcV,CAAAA,KAAAA;;0BAC1CK,cAACW,CAAAA,oBAAAA,EAAAA;AAAQC,gBAAAA,KAAAA,EAAOP,aAAcV,CAAAA,KAAAA,CAAAA;wCAC3BkB,gBAAAA,CAAMC,YAAY,CAACf,IAA4B,EAAA;oBAC9C,aAAe,EAAA,IAAA;oBACfgB,SAAW,EAAA;AACb,iBAAA;;;;AAIR,CAAA;AAEA,MAAMP,IAAAA,GAAOQ,uBAAOC,CAAAA,iBAAAA,CAAK;;;;;UAKf,EAAE,CAAC,EAAEC,KAAK,EAAE,GAAKA,KAAMC,CAAAA,MAAM,CAACC,UAAU,CAAC;;;YAGvC,EAAE,CAAC,EAAEF,KAAK,EAAE,GAAKA,KAAMC,CAAAA,MAAM,CAACC,UAAU,CAAC;;;AAGrD,CAAC;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import { Flex, VisuallyHidden } from '@strapi/design-system';
|
|
3
|
+
import { Flex, VisuallyHidden, Tooltip } from '@strapi/design-system';
|
|
4
4
|
import { Earth } from '@strapi/icons';
|
|
5
5
|
import { useIntl } from 'react-intl';
|
|
6
6
|
import { styled } from 'styled-components';
|
|
@@ -61,9 +61,12 @@ const LabelAction = ({ title, icon })=>{
|
|
|
61
61
|
tag: "span",
|
|
62
62
|
children: formatMessage(title)
|
|
63
63
|
}),
|
|
64
|
-
/*#__PURE__*/
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
/*#__PURE__*/ jsx(Tooltip, {
|
|
65
|
+
label: formatMessage(title),
|
|
66
|
+
children: /*#__PURE__*/ React.cloneElement(icon, {
|
|
67
|
+
'aria-hidden': true,
|
|
68
|
+
focusable: false
|
|
69
|
+
})
|
|
67
70
|
})
|
|
68
71
|
]
|
|
69
72
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editView.mjs","sources":["../../../admin/src/contentManagerHooks/editView.tsx"],"sourcesContent":["/* eslint-disable check-file/filename-naming-convention */\nimport * as React from 'react';\n\nimport { Flex, VisuallyHidden } from '@strapi/design-system';\nimport { Earth, EarthStriked } 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';\n\ninterface MutateEditViewArgs {\n layout: EditLayout;\n}\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 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(addLabelActionToField)),\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(addLabelActionToField))),\n },\n } satisfies Pick<MutateEditViewArgs, 'layout'>;\n};\n\nconst addLabelActionToField = (field: EditFieldLayout) => {\n const isFieldLocalized = doesFieldHaveI18nPluginOpt(field.attribute.pluginOptions)\n ? field.attribute.pluginOptions.i18n.localized\n : true || ['uid', 'relation'].includes(field.attribute.type);\n\n const labelActionProps = {\n title: {\n id: isFieldLocalized\n ? getTranslation('Field.localized')\n : getTranslation('Field.not-localized'),\n defaultMessage: isFieldLocalized\n ? 'This value is unique for the selected locale'\n : 'This value is the same across all locales',\n },\n icon: isFieldLocalized ? <Earth /> : null,\n };\n\n return {\n ...field,\n labelAction: isFieldLocalized ? <LabelAction {...labelActionProps} /> : null,\n };\n};\n\nconst doesFieldHaveI18nPluginOpt = (\n pluginOpts?: object\n): pluginOpts is { i18n: { localized: boolean } } => {\n if (!pluginOpts) {\n return false;\n }\n\n return (\n 'i18n' in pluginOpts &&\n typeof pluginOpts.i18n === 'object' &&\n pluginOpts.i18n !== null &&\n 'localized' in pluginOpts.i18n\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * LabelAction\n * -----------------------------------------------------------------------------------------------*/\n\ninterface LabelActionProps {\n title: MessageDescriptor;\n icon: React.ReactNode;\n}\n\nconst LabelAction = ({ title, icon }: LabelActionProps) => {\n const { formatMessage } = useIntl();\n\n return (\n <Span tag=\"span\">\n <VisuallyHidden tag=\"span\">{formatMessage(title)}</VisuallyHidden>\n {React.cloneElement(icon as React.ReactElement, {\n
|
|
1
|
+
{"version":3,"file":"editView.mjs","sources":["../../../admin/src/contentManagerHooks/editView.tsx"],"sourcesContent":["/* eslint-disable check-file/filename-naming-convention */\nimport * as React from 'react';\n\nimport { Flex, Tooltip, VisuallyHidden } from '@strapi/design-system';\nimport { Earth, EarthStriked } 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';\n\ninterface MutateEditViewArgs {\n layout: EditLayout;\n}\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 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(addLabelActionToField)),\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(addLabelActionToField))),\n },\n } satisfies Pick<MutateEditViewArgs, 'layout'>;\n};\n\nconst addLabelActionToField = (field: EditFieldLayout) => {\n const isFieldLocalized = doesFieldHaveI18nPluginOpt(field.attribute.pluginOptions)\n ? field.attribute.pluginOptions.i18n.localized\n : true || ['uid', 'relation'].includes(field.attribute.type);\n\n const labelActionProps = {\n title: {\n id: isFieldLocalized\n ? getTranslation('Field.localized')\n : getTranslation('Field.not-localized'),\n defaultMessage: isFieldLocalized\n ? 'This value is unique for the selected locale'\n : 'This value is the same across all locales',\n },\n icon: isFieldLocalized ? <Earth /> : null,\n };\n\n return {\n ...field,\n labelAction: isFieldLocalized ? <LabelAction {...labelActionProps} /> : null,\n };\n};\n\nconst doesFieldHaveI18nPluginOpt = (\n pluginOpts?: object\n): pluginOpts is { i18n: { localized: boolean } } => {\n if (!pluginOpts) {\n return false;\n }\n\n return (\n 'i18n' in pluginOpts &&\n typeof pluginOpts.i18n === 'object' &&\n pluginOpts.i18n !== null &&\n 'localized' in pluginOpts.i18n\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * LabelAction\n * -----------------------------------------------------------------------------------------------*/\n\ninterface LabelActionProps {\n title: MessageDescriptor;\n icon: React.ReactNode;\n}\n\nconst LabelAction = ({ title, icon }: 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 {React.cloneElement(icon as React.ReactElement, {\n 'aria-hidden': true,\n focusable: false, // See: https://allyjs.io/tutorials/focusing-in-svg.html#making-svg-elements-focusable\n })}\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":["mutateEditViewHook","layout","options","i18n","localized","components","Object","entries","reduce","acc","key","componentLayout","map","row","addLabelActionToField","panel","field","isFieldLocalized","doesFieldHaveI18nPluginOpt","attribute","pluginOptions","labelActionProps","title","id","getTranslation","defaultMessage","icon","_jsx","Earth","labelAction","LabelAction","pluginOpts","formatMessage","useIntl","_jsxs","Span","tag","VisuallyHidden","Tooltip","label","React","cloneElement","focusable","styled","Flex","theme","colors","neutral500"],"mappings":";;;;;;;;AAgBA,MAAMA,kBAAqB,GAAA,CAAC,EAAEC,MAAM,EAAsB,GAAA;;AAExD,IAAA,IACE,EAAE,MAAUA,IAAAA,MAAAA,CAAOC,OAAO,CAAD,IACxB,OAAOD,MAAAA,CAAOC,OAAO,CAACC,IAAI,KAAK,YAC9BF,MAAOC,CAAAA,OAAO,CAACC,IAAI,KAAK,IAAA,IACxB,WAAeF,IAAAA,MAAAA,CAAOC,OAAO,CAACC,IAAI,IAClC,CAACF,OAAOC,OAAO,CAACC,IAAI,CAACC,SAAS,EAChC;QACA,OAAO;AAAEH,YAAAA;AAAO,SAAA;AAClB;AAEA,IAAA,MAAMI,UAAaC,GAAAA,MAAAA,CAAOC,OAAO,CAACN,MAAOI,CAAAA,UAAU,CAAEG,CAAAA,MAAM,CACzD,CAACC,GAAK,EAAA,CAACC,KAAKC,eAAgB,CAAA,GAAA;QAC1B,OAAO;AACL,YAAA,GAAGF,GA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IAAI,CAACA,UAAY,EAAA;QACf,OAAO,KAAA;AACT;AAEA,IAAA,OACE,MAAUA,IAAAA,UAAAA,IACV,OAAOA,UAAAA,CAAW5B,IAAI,KAAK,QAC3B4B,IAAAA,UAAAA,CAAW5B,IAAI,KAAK,IACpB,IAAA,WAAA,IAAe4B,WAAW5B,IAAI;AAElC,CAAA;AAWA,MAAM2B,cAAc,CAAC,EAAER,KAAK,EAAEI,IAAI,EAAoB,GAAA;IACpD,MAAM,EAAEM,aAAa,EAAE,GAAGC,OAAAA,EAAAA;AAE1B,IAAA,qBACEC,IAACC,CAAAA,IAAAA,EAAAA;QAAKC,GAAI,EAAA,MAAA;;0BACRT,GAACU,CAAAA,cAAAA,EAAAA;gBAAeD,GAAI,EAAA,MAAA;0BAAQJ,aAAcV,CAAAA,KAAAA;;0BAC1CK,GAACW,CAAAA,OAAAA,EAAAA;AAAQC,gBAAAA,KAAAA,EAAOP,aAAcV,CAAAA,KAAAA,CAAAA;wCAC3BkB,KAAAA,CAAMC,YAAY,CAACf,IAA4B,EAAA;oBAC9C,aAAe,EAAA,IAAA;oBACfgB,SAAW,EAAA;AACb,iBAAA;;;;AAIR,CAAA;AAEA,MAAMP,IAAAA,GAAOQ,MAAOC,CAAAA,IAAAA,CAAK;;;;;UAKf,EAAE,CAAC,EAAEC,KAAK,EAAE,GAAKA,KAAMC,CAAAA,MAAM,CAACC,UAAU,CAAC;;;YAGvC,EAAE,CAAC,EAAEF,KAAK,EAAE,GAAKA,KAAMC,CAAAA,MAAM,CAACC,UAAU,CAAC;;;AAGrD,CAAC;;;;"}
|
|
@@ -31,7 +31,8 @@ const addColumnToTableHook = ({ displayedHeaders, layout })=>{
|
|
|
31
31
|
// @ts-expect-error – ID is seen as number | string; this will change when we move the type over.
|
|
32
32
|
cellFormatter: (props, _header, meta)=>/*#__PURE__*/ jsxRuntime.jsx(LocaleListCell.LocaleListCell, {
|
|
33
33
|
...props,
|
|
34
|
-
...meta
|
|
34
|
+
...meta,
|
|
35
|
+
documentId: props.documentId
|
|
35
36
|
})
|
|
36
37
|
}
|
|
37
38
|
],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listView.js","sources":["../../../admin/src/contentManagerHooks/listView.tsx"],"sourcesContent":["/* eslint-disable check-file/filename-naming-convention */\nimport { LocaleListCell } from '../components/LocaleListCell';\nimport { doesPluginOptionsHaveI18nLocalized } from '../utils/fields';\nimport { getTranslation } from '../utils/getTranslation';\n\nimport type { ListFieldLayout, ListLayout } from '@strapi/content-manager/strapi-admin';\n\n/* -------------------------------------------------------------------------------------------------\n * addColumnToTableHook\n * -----------------------------------------------------------------------------------------------*/\ninterface AddColumnToTableHookArgs {\n layout: ListLayout;\n displayedHeaders: ListFieldLayout[];\n}\n\nconst addColumnToTableHook = ({ displayedHeaders, layout }: AddColumnToTableHookArgs) => {\n const { options } = layout;\n\n const isFieldLocalized = doesPluginOptionsHaveI18nLocalized(options)\n ? options.i18n.localized\n : false;\n\n if (!isFieldLocalized) {\n return { displayedHeaders, layout };\n }\n\n return {\n displayedHeaders: [\n ...displayedHeaders,\n {\n attribute: { type: 'string' },\n label: {\n id: getTranslation('list-view.table.header.label'),\n defaultMessage: 'Available in',\n },\n searchable: false,\n sortable: false,\n name: 'locales',\n // @ts-expect-error – ID is seen as number | string; this will change when we move the type over.\n cellFormatter: (props, _header, meta) => <LocaleListCell {...props} {...meta}
|
|
1
|
+
{"version":3,"file":"listView.js","sources":["../../../admin/src/contentManagerHooks/listView.tsx"],"sourcesContent":["/* eslint-disable check-file/filename-naming-convention */\nimport { LocaleListCell } from '../components/LocaleListCell';\nimport { doesPluginOptionsHaveI18nLocalized } from '../utils/fields';\nimport { getTranslation } from '../utils/getTranslation';\n\nimport type { ListFieldLayout, ListLayout } from '@strapi/content-manager/strapi-admin';\n\n/* -------------------------------------------------------------------------------------------------\n * addColumnToTableHook\n * -----------------------------------------------------------------------------------------------*/\ninterface AddColumnToTableHookArgs {\n layout: ListLayout;\n displayedHeaders: ListFieldLayout[];\n}\n\nconst addColumnToTableHook = ({ displayedHeaders, layout }: AddColumnToTableHookArgs) => {\n const { options } = layout;\n\n const isFieldLocalized = doesPluginOptionsHaveI18nLocalized(options)\n ? options.i18n.localized\n : false;\n\n if (!isFieldLocalized) {\n return { displayedHeaders, layout };\n }\n\n return {\n displayedHeaders: [\n ...displayedHeaders,\n {\n attribute: { type: 'string' },\n label: {\n id: getTranslation('list-view.table.header.label'),\n defaultMessage: 'Available in',\n },\n searchable: false,\n sortable: false,\n name: 'locales',\n // @ts-expect-error – ID is seen as number | string; this will change when we move the type over.\n cellFormatter: (props, _header, meta) => (\n <LocaleListCell {...props} {...meta} documentId={props.documentId} />\n ),\n },\n ],\n layout,\n };\n};\n\nexport { addColumnToTableHook };\n"],"names":["addColumnToTableHook","displayedHeaders","layout","options","isFieldLocalized","doesPluginOptionsHaveI18nLocalized","i18n","localized","attribute","type","label","id","getTranslation","defaultMessage","searchable","sortable","name","cellFormatter","props","_header","meta","_jsx","LocaleListCell","documentId"],"mappings":";;;;;;;AAeA,MAAMA,uBAAuB,CAAC,EAAEC,gBAAgB,EAAEC,MAAM,EAA4B,GAAA;IAClF,MAAM,EAAEC,OAAO,EAAE,GAAGD,MAAAA;AAEpB,IAAA,MAAME,mBAAmBC,yCAAmCF,CAAAA,OAAAA,CAAAA,GACxDA,QAAQG,IAAI,CAACC,SAAS,GACtB,KAAA;AAEJ,IAAA,IAAI,CAACH,gBAAkB,EAAA;QACrB,OAAO;AAAEH,YAAAA,gBAAAA;AAAkBC,YAAAA;AAAO,SAAA;AACpC;IAEA,OAAO;QACLD,gBAAkB,EAAA;AACbA,YAAAA,GAAAA,gBAAAA;AACH,YAAA;gBACEO,SAAW,EAAA;oBAAEC,IAAM,EAAA;AAAS,iBAAA;gBAC5BC,KAAO,EAAA;AACLC,oBAAAA,EAAAA,EAAIC,6BAAe,CAAA,8BAAA,CAAA;oBACnBC,cAAgB,EAAA;AAClB,iBAAA;gBACAC,UAAY,EAAA,KAAA;gBACZC,QAAU,EAAA,KAAA;gBACVC,IAAM,EAAA,SAAA;;AAENC,gBAAAA,aAAAA,EAAe,CAACC,KAAAA,EAAOC,OAASC,EAAAA,IAAAA,iBAC9BC,cAACC,CAAAA,6BAAAA,EAAAA;AAAgB,wBAAA,GAAGJ,KAAK;AAAG,wBAAA,GAAGE,IAAI;AAAEG,wBAAAA,UAAAA,EAAYL,MAAMK;;AAE3D;AACD,SAAA;AACDrB,QAAAA;AACF,KAAA;AACF;;;;"}
|
|
@@ -29,7 +29,8 @@ const addColumnToTableHook = ({ displayedHeaders, layout })=>{
|
|
|
29
29
|
// @ts-expect-error – ID is seen as number | string; this will change when we move the type over.
|
|
30
30
|
cellFormatter: (props, _header, meta)=>/*#__PURE__*/ jsx(LocaleListCell, {
|
|
31
31
|
...props,
|
|
32
|
-
...meta
|
|
32
|
+
...meta,
|
|
33
|
+
documentId: props.documentId
|
|
33
34
|
})
|
|
34
35
|
}
|
|
35
36
|
],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listView.mjs","sources":["../../../admin/src/contentManagerHooks/listView.tsx"],"sourcesContent":["/* eslint-disable check-file/filename-naming-convention */\nimport { LocaleListCell } from '../components/LocaleListCell';\nimport { doesPluginOptionsHaveI18nLocalized } from '../utils/fields';\nimport { getTranslation } from '../utils/getTranslation';\n\nimport type { ListFieldLayout, ListLayout } from '@strapi/content-manager/strapi-admin';\n\n/* -------------------------------------------------------------------------------------------------\n * addColumnToTableHook\n * -----------------------------------------------------------------------------------------------*/\ninterface AddColumnToTableHookArgs {\n layout: ListLayout;\n displayedHeaders: ListFieldLayout[];\n}\n\nconst addColumnToTableHook = ({ displayedHeaders, layout }: AddColumnToTableHookArgs) => {\n const { options } = layout;\n\n const isFieldLocalized = doesPluginOptionsHaveI18nLocalized(options)\n ? options.i18n.localized\n : false;\n\n if (!isFieldLocalized) {\n return { displayedHeaders, layout };\n }\n\n return {\n displayedHeaders: [\n ...displayedHeaders,\n {\n attribute: { type: 'string' },\n label: {\n id: getTranslation('list-view.table.header.label'),\n defaultMessage: 'Available in',\n },\n searchable: false,\n sortable: false,\n name: 'locales',\n // @ts-expect-error – ID is seen as number | string; this will change when we move the type over.\n cellFormatter: (props, _header, meta) => <LocaleListCell {...props} {...meta}
|
|
1
|
+
{"version":3,"file":"listView.mjs","sources":["../../../admin/src/contentManagerHooks/listView.tsx"],"sourcesContent":["/* eslint-disable check-file/filename-naming-convention */\nimport { LocaleListCell } from '../components/LocaleListCell';\nimport { doesPluginOptionsHaveI18nLocalized } from '../utils/fields';\nimport { getTranslation } from '../utils/getTranslation';\n\nimport type { ListFieldLayout, ListLayout } from '@strapi/content-manager/strapi-admin';\n\n/* -------------------------------------------------------------------------------------------------\n * addColumnToTableHook\n * -----------------------------------------------------------------------------------------------*/\ninterface AddColumnToTableHookArgs {\n layout: ListLayout;\n displayedHeaders: ListFieldLayout[];\n}\n\nconst addColumnToTableHook = ({ displayedHeaders, layout }: AddColumnToTableHookArgs) => {\n const { options } = layout;\n\n const isFieldLocalized = doesPluginOptionsHaveI18nLocalized(options)\n ? options.i18n.localized\n : false;\n\n if (!isFieldLocalized) {\n return { displayedHeaders, layout };\n }\n\n return {\n displayedHeaders: [\n ...displayedHeaders,\n {\n attribute: { type: 'string' },\n label: {\n id: getTranslation('list-view.table.header.label'),\n defaultMessage: 'Available in',\n },\n searchable: false,\n sortable: false,\n name: 'locales',\n // @ts-expect-error – ID is seen as number | string; this will change when we move the type over.\n cellFormatter: (props, _header, meta) => (\n <LocaleListCell {...props} {...meta} documentId={props.documentId} />\n ),\n },\n ],\n layout,\n };\n};\n\nexport { addColumnToTableHook };\n"],"names":["addColumnToTableHook","displayedHeaders","layout","options","isFieldLocalized","doesPluginOptionsHaveI18nLocalized","i18n","localized","attribute","type","label","id","getTranslation","defaultMessage","searchable","sortable","name","cellFormatter","props","_header","meta","_jsx","LocaleListCell","documentId"],"mappings":";;;;;AAeA,MAAMA,uBAAuB,CAAC,EAAEC,gBAAgB,EAAEC,MAAM,EAA4B,GAAA;IAClF,MAAM,EAAEC,OAAO,EAAE,GAAGD,MAAAA;AAEpB,IAAA,MAAME,mBAAmBC,kCAAmCF,CAAAA,OAAAA,CAAAA,GACxDA,QAAQG,IAAI,CAACC,SAAS,GACtB,KAAA;AAEJ,IAAA,IAAI,CAACH,gBAAkB,EAAA;QACrB,OAAO;AAAEH,YAAAA,gBAAAA;AAAkBC,YAAAA;AAAO,SAAA;AACpC;IAEA,OAAO;QACLD,gBAAkB,EAAA;AACbA,YAAAA,GAAAA,gBAAAA;AACH,YAAA;gBACEO,SAAW,EAAA;oBAAEC,IAAM,EAAA;AAAS,iBAAA;gBAC5BC,KAAO,EAAA;AACLC,oBAAAA,EAAAA,EAAIC,cAAe,CAAA,8BAAA,CAAA;oBACnBC,cAAgB,EAAA;AAClB,iBAAA;gBACAC,UAAY,EAAA,KAAA;gBACZC,QAAU,EAAA,KAAA;gBACVC,IAAM,EAAA,SAAA;;AAENC,gBAAAA,aAAAA,EAAe,CAACC,KAAAA,EAAOC,OAASC,EAAAA,IAAAA,iBAC9BC,GAACC,CAAAA,cAAAA,EAAAA;AAAgB,wBAAA,GAAGJ,KAAK;AAAG,wBAAA,GAAGE,IAAI;AAAEG,wBAAAA,UAAAA,EAAYL,MAAMK;;AAE3D;AACD,SAAA;AACDrB,QAAAA;AACF,KAAA;AACF;;;;"}
|
package/dist/admin/index.js
CHANGED
|
@@ -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
|
]);
|
package/dist/admin/index.js.map
CHANGED
|
@@ -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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gB,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,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,YAA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OAAO,CAACR,aAAAA,CAAAA;AACzB;AACF,CAAE;;;;"}
|
package/dist/admin/index.mjs
CHANGED
|
@@ -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
|
]);
|
package/dist/admin/index.mjs.map
CHANGED
|
@@ -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,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,uBAAAA,CAAAA;;QAIFnB,GAAIoB,CAAAA,eAAe,CAAC,QAAU,EAAA;YAC5BC,SAAW,EAAA;AACTT,gBAAAA,EAAAA,EAAIU,cAAe,CAAA,aAAA,CAAA;gBACnBC,cAAgB,EAAA;AAClB,aAAA;YACAX,EAAI,EAAA,sBAAA;YACJY,EAAI,EAAA,sBAAA;YACJC,SA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A;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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