@akemona-org/strapi-plugin-i18n 3.12.4 → 3.13.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.
@@ -17,15 +17,15 @@ import {
17
17
  import { getTrad } from '../../utils';
18
18
  import { cleanData, generateOptions } from './utils';
19
19
 
20
- const CMEditViewCopyLocale = (props) => {
20
+ function CMEditViewCopyLocale(props) {
21
21
  if (!props.localizations.length) {
22
22
  return null;
23
23
  }
24
24
 
25
25
  return <Content {...props} />;
26
- };
26
+ }
27
27
 
28
- const Content = ({ appLocales, currentLocale, localizations, readPermissions }) => {
28
+ function Content({ appLocales, currentLocale, localizations, readPermissions }) {
29
29
  const options = generateOptions(appLocales, currentLocale, localizations, readPermissions);
30
30
 
31
31
  const { formatMessage } = useIntl();
@@ -162,7 +162,7 @@ const Content = ({ appLocales, currentLocale, localizations, readPermissions })
162
162
  </ModalConfirm>
163
163
  </>
164
164
  );
165
- };
165
+ }
166
166
 
167
167
  CMEditViewCopyLocale.propTypes = {
168
168
  localizations: PropTypes.array.isRequired,
@@ -10,7 +10,7 @@ import selectI18NLocales from '../../selectors/selectI18nLocales';
10
10
  import useContentTypePermissions from '../../hooks/useContentTypePermissions';
11
11
  import CMEditViewLocalePicker from '../CMEditViewLocalePicker';
12
12
 
13
- const CMEditViewInjectedComponents = () => {
13
+ function CMEditViewInjectedComponents() {
14
14
  const { layout, modifiedData, slug, isSingleType } = useContentManagerEditViewDataManager();
15
15
  const { createPermissions, readPermissions } = useContentTypePermissions(slug);
16
16
  const locales = useSelector(selectI18NLocales);
@@ -56,6 +56,6 @@ const CMEditViewInjectedComponents = () => {
56
56
  slug={slug}
57
57
  />
58
58
  );
59
- };
59
+ }
60
60
 
61
61
  export default CMEditViewInjectedComponents;
@@ -18,7 +18,7 @@ const statusToTitleMap = {
18
18
  'did-not-create-locale': getTrad('components.Select.locales.not-available'),
19
19
  };
20
20
 
21
- const Option = (props) => {
21
+ function Option(props) {
22
22
  const { formatMessage } = useIntl();
23
23
  const Component = components.Option;
24
24
  const options = get(props, ['selectProps', 'options'], {});
@@ -45,7 +45,7 @@ const Option = (props) => {
45
45
  </Flex>
46
46
  </Component>
47
47
  );
48
- };
48
+ }
49
49
 
50
50
  Option.defaultProps = {};
51
51
 
@@ -18,7 +18,7 @@ import CMEditViewCopyLocale from '../CMEditViewCopyLocale';
18
18
  import OptionComponent from './Option';
19
19
  import Wrapper from './Wrapper';
20
20
 
21
- const CMEditViewLocalePicker = ({
21
+ function CMEditViewLocalePicker({
22
22
  appLocales,
23
23
  createPermissions,
24
24
  currentEntityId,
@@ -29,7 +29,7 @@ const CMEditViewLocalePicker = ({
29
29
  readPermissions,
30
30
  setQuery,
31
31
  slug,
32
- }) => {
32
+ }) {
33
33
  const { formatMessage } = useIntl();
34
34
  const theme = useTheme();
35
35
  const currentLocale = get(query, 'plugins.i18n.locale', false);
@@ -137,7 +137,7 @@ const CMEditViewLocalePicker = ({
137
137
  </Padded>
138
138
  </Wrapper>
139
139
  );
140
- };
140
+ }
141
141
 
142
142
  CMEditViewLocalePicker.defaultProps = {
143
143
  createPermissions: [],
@@ -6,7 +6,7 @@ import { ModalConfirm } from '@akemona-org/strapi-helper-plugin';
6
6
  import { getTrad } from '../../utils';
7
7
  import Wrapper from './Wrapper';
8
8
 
9
- const CheckboxConfirmation = ({ description, isCreating, label, name, onChange, ...rest }) => {
9
+ function CheckboxConfirmation({ description, isCreating, label, name, onChange, ...rest }) {
10
10
  const { formatMessage } = useIntl();
11
11
  const [isOpen, setIsOpen] = useState(false);
12
12
 
@@ -52,7 +52,7 @@ const CheckboxConfirmation = ({ description, isCreating, label, name, onChange,
52
52
  </ModalConfirm>
53
53
  </>
54
54
  );
55
- };
55
+ }
56
56
 
57
57
  CheckboxConfirmation.defaultProps = {
58
58
  description: null,
@@ -3,7 +3,7 @@ import { FormattedMessage } from 'react-intl';
3
3
  import { getTrad } from '../../utils';
4
4
  import useHasI18n from '../../hooks/useHasI18n';
5
5
 
6
- const DeleteModalAdditionalInfos = () => {
6
+ function DeleteModalAdditionalInfos() {
7
7
  const hasI18nEnabled = useHasI18n();
8
8
 
9
9
  if (!hasI18nEnabled) {
@@ -20,6 +20,6 @@ const DeleteModalAdditionalInfos = () => {
20
20
  />
21
21
  </span>
22
22
  );
23
- };
23
+ }
24
24
 
25
25
  export default DeleteModalAdditionalInfos;
@@ -12,7 +12,7 @@ import ModalEdit from '../ModalEdit';
12
12
  import ModalDelete from '../ModalDelete';
13
13
  import ModalCreate from '../ModalCreate';
14
14
 
15
- const LocaleList = ({ canUpdateLocale, canDeleteLocale, onToggleCreateModal, isCreating }) => {
15
+ function LocaleList({ canUpdateLocale, canDeleteLocale, onToggleCreateModal, isCreating }) {
16
16
  const [localeToDelete, setLocaleToDelete] = useState();
17
17
  const [localeToEdit, setLocaleToEdit] = useState();
18
18
  const { locales, isLoading } = useLocales();
@@ -85,7 +85,7 @@ const LocaleList = ({ canUpdateLocale, canDeleteLocale, onToggleCreateModal, isC
85
85
  <ModalCreate isOpened={isCreating} onClose={onToggleCreateModal} />
86
86
  </>
87
87
  );
88
- };
88
+ }
89
89
 
90
90
  LocaleList.defaultProps = {
91
91
  onToggleCreateModal: undefined,
@@ -18,7 +18,7 @@ const LocaleName = styled.div`
18
18
  white-space: nowrap;
19
19
  `;
20
20
 
21
- const LocaleListCell = ({ locales, localizations, locale: currentLocaleCode, id }) => {
21
+ function LocaleListCell({ locales, localizations, locale: currentLocaleCode, id }) {
22
22
  const allLocalizations = [{ locale: currentLocaleCode }, ...localizations];
23
23
  const localizationNames = allLocalizations.map((locale) => locale.locale);
24
24
  const defaultLocale = locales.find((locale) => locale.isDefault);
@@ -68,7 +68,7 @@ const LocaleListCell = ({ locales, localizations, locale: currentLocaleCode, id
68
68
  </Tooltip>
69
69
  </div>
70
70
  );
71
- };
71
+ }
72
72
 
73
73
  LocaleListCell.propTypes = {
74
74
  id: PropTypes.number.isRequired,
@@ -40,7 +40,7 @@ const EllipsisParagraph = styled(Text)`
40
40
  text-align: left;
41
41
  `;
42
42
 
43
- const LocalePicker = () => {
43
+ function LocalePicker() {
44
44
  const dispatch = useDispatch();
45
45
  const locales = useSelector(selectI18NLocales);
46
46
  const [{ query }, setQuery] = useQueryParams();
@@ -121,6 +121,6 @@ const LocalePicker = () => {
121
121
  }}
122
122
  />
123
123
  );
124
- };
124
+ }
125
125
 
126
126
  export default LocalePicker;
@@ -7,7 +7,7 @@ import { CustomRow } from '@buffetjs/styles';
7
7
  import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
8
8
  import { getTrad } from '../../utils';
9
9
 
10
- const LocaleSettingsPage = ({ locale, onDelete, onEdit }) => {
10
+ function LocaleSettingsPage({ locale, onDelete, onEdit }) {
11
11
  const { formatMessage } = useIntl();
12
12
 
13
13
  const links = [];
@@ -57,7 +57,7 @@ const LocaleSettingsPage = ({ locale, onDelete, onEdit }) => {
57
57
  </td>
58
58
  </CustomRow>
59
59
  );
60
- };
60
+ }
61
61
 
62
62
  LocaleSettingsPage.defaultProps = {
63
63
  onDelete: undefined,
@@ -5,7 +5,7 @@ import { useIntl } from 'react-intl';
5
5
  import { BaselineAlignment } from '@akemona-org/strapi-helper-plugin';
6
6
  import { getTrad } from '../../utils';
7
7
 
8
- const AdvancedForm = () => {
8
+ function AdvancedForm() {
9
9
  const { values, setFieldValue } = useFormikContext();
10
10
  const { formatMessage } = useIntl();
11
11
 
@@ -40,6 +40,6 @@ const AdvancedForm = () => {
40
40
  </Text>
41
41
  </div>
42
42
  );
43
- };
43
+ }
44
44
 
45
45
  export default AdvancedForm;
@@ -20,7 +20,7 @@ const reactSelectLocaleFilter = createFilter({
20
20
  matchFrom: 'start',
21
21
  });
22
22
 
23
- const BaseForm = ({ options, defaultOption }) => {
23
+ function BaseForm({ options, defaultOption }) {
24
24
  const theme = useTheme();
25
25
  const { formatMessage } = useIntl();
26
26
  const { values, handleChange, setFieldValue } = useFormikContext();
@@ -88,7 +88,7 @@ const BaseForm = ({ options, defaultOption }) => {
88
88
  </Col>
89
89
  </Row>
90
90
  );
91
- };
91
+ }
92
92
 
93
93
  BaseForm.defaultProps = {
94
94
  defaultOption: undefined,
@@ -12,7 +12,7 @@ import useAddLocale from '../../hooks/useAddLocale';
12
12
  import BaseForm from './BaseForm';
13
13
  import AdvancedForm from './AdvancedForm';
14
14
 
15
- const ModalCreate = ({ alreadyUsedLocales, onClose, isOpened }) => {
15
+ function ModalCreate({ alreadyUsedLocales, onClose, isOpened }) {
16
16
  const { defaultLocales, isLoading } = useDefaultLocales();
17
17
  const { isAdding, addLocale } = useAddLocale();
18
18
  const { formatMessage } = useIntl();
@@ -74,7 +74,8 @@ const ModalCreate = ({ alreadyUsedLocales, onClose, isOpened }) => {
74
74
  })
75
75
  .then(() => {
76
76
  onClose();
77
- })}
77
+ })
78
+ }
78
79
  validationSchema={localeFormSchema}
79
80
  >
80
81
  {({ handleSubmit, errors }) => (
@@ -121,7 +122,7 @@ const ModalCreate = ({ alreadyUsedLocales, onClose, isOpened }) => {
121
122
  </Formik>
122
123
  </Modal>
123
124
  );
124
- };
125
+ }
125
126
 
126
127
  ModalCreate.defaultProps = {
127
128
  alreadyUsedLocales: [],
@@ -6,7 +6,7 @@ import { useIntl } from 'react-intl';
6
6
  import useDeleteLocale from '../../hooks/useDeleteLocale';
7
7
  import { getTrad } from '../../utils';
8
8
 
9
- const ModalDelete = ({ localeToDelete, onClose }) => {
9
+ function ModalDelete({ localeToDelete, onClose }) {
10
10
  const { isDeleting, deleteLocale } = useDeleteLocale();
11
11
  const { formatMessage } = useIntl();
12
12
  const isOpened = Boolean(localeToDelete);
@@ -33,7 +33,7 @@ const ModalDelete = ({ localeToDelete, onClose }) => {
33
33
  </Text>
34
34
  </ModalConfirm>
35
35
  );
36
- };
36
+ }
37
37
 
38
38
  ModalDelete.defaultProps = {
39
39
  localeToDelete: undefined,
@@ -6,7 +6,7 @@ import { useIntl } from 'react-intl';
6
6
  import { BaselineAlignment } from '@akemona-org/strapi-helper-plugin';
7
7
  import { getTrad } from '../../utils';
8
8
 
9
- const AdvancedForm = ({ isDefaultLocale }) => {
9
+ function AdvancedForm({ isDefaultLocale }) {
10
10
  const { values, setFieldValue } = useFormikContext();
11
11
  const { formatMessage } = useIntl();
12
12
 
@@ -42,7 +42,7 @@ const AdvancedForm = ({ isDefaultLocale }) => {
42
42
  </Text>
43
43
  </div>
44
44
  );
45
- };
45
+ }
46
46
 
47
47
  AdvancedForm.propTypes = {
48
48
  isDefaultLocale: PropTypes.bool.isRequired,
@@ -14,7 +14,7 @@ import {
14
14
  import { useFormikContext } from 'formik';
15
15
  import { getTrad } from '../../utils';
16
16
 
17
- const BaseForm = ({ options, defaultOption }) => {
17
+ function BaseForm({ options, defaultOption }) {
18
18
  const { formatMessage } = useIntl();
19
19
  const { values, handleChange } = useFormikContext();
20
20
  const theme = useTheme();
@@ -76,7 +76,7 @@ const BaseForm = ({ options, defaultOption }) => {
76
76
  </Col>
77
77
  </Row>
78
78
  );
79
- };
79
+ }
80
80
 
81
81
  BaseForm.defaultProps = {
82
82
  defaultOption: undefined,
@@ -11,7 +11,7 @@ import BaseForm from './BaseForm';
11
11
  import AdvancedForm from './AdvancedForm';
12
12
  import SettingsModal from '../SettingsModal';
13
13
 
14
- const ModalEdit = ({ localeToEdit, onClose, locales }) => {
14
+ function ModalEdit({ localeToEdit, onClose, locales }) {
15
15
  const { isEditing, editLocale } = useEditLocale();
16
16
  const shouldUpdateMenu = useRef(false);
17
17
  const { updateMenu } = useGlobalContext();
@@ -95,7 +95,7 @@ const ModalEdit = ({ localeToEdit, onClose, locales }) => {
95
95
  </Formik>
96
96
  </Modal>
97
97
  );
98
- };
98
+ }
99
99
 
100
100
  ModalEdit.defaultProps = {
101
101
  localeToEdit: undefined,
@@ -13,7 +13,7 @@ import {
13
13
  import { useIntl } from 'react-intl';
14
14
  import { getTrad } from '../utils';
15
15
 
16
- const SettingsModal = ({ children, title, breadCrumb, tabsAriaLabel, tabsId }) => {
16
+ function SettingsModal({ children, title, breadCrumb, tabsAriaLabel, tabsId }) {
17
17
  const { formatMessage } = useIntl();
18
18
 
19
19
  return (
@@ -53,7 +53,7 @@ const SettingsModal = ({ children, title, breadCrumb, tabsAriaLabel, tabsId }) =
53
53
  </div>
54
54
  </>
55
55
  );
56
- };
56
+ }
57
57
 
58
58
  SettingsModal.propTypes = {
59
59
  children: PropTypes.node.isRequired,
@@ -9,7 +9,7 @@ import PropTypes from 'prop-types';
9
9
  import pluginId from '../pluginId';
10
10
  import useLocales from '../hooks/useLocales';
11
11
 
12
- const Initializer = ({ updatePlugin }) => {
12
+ function Initializer({ updatePlugin }) {
13
13
  const { isLoading, locales } = useLocales();
14
14
  const ref = useRef();
15
15
 
@@ -22,7 +22,7 @@ const Initializer = ({ updatePlugin }) => {
22
22
  }, [isLoading, locales]);
23
23
 
24
24
  return null;
25
- };
25
+ }
26
26
 
27
27
  Initializer.propTypes = {
28
28
  updatePlugin: PropTypes.func.isRequired,
@@ -7,12 +7,12 @@ import { Button } from '@buffetjs/core';
7
7
  import { getTrad } from '../../utils';
8
8
  import LocaleList from '../../components/LocaleList';
9
9
 
10
- const LocaleSettingsPage = ({
10
+ function LocaleSettingsPage({
11
11
  canReadLocale,
12
12
  canCreateLocale,
13
13
  canDeleteLocale,
14
14
  canUpdateLocale,
15
- }) => {
15
+ }) {
16
16
  const { formatMessage } = useIntl();
17
17
  const [isOpenedCreateModal, setIsOpenedCreateModal] = useState(false);
18
18
 
@@ -57,7 +57,7 @@ const LocaleSettingsPage = ({
57
57
  ) : null}
58
58
  </>
59
59
  );
60
- };
60
+ }
61
61
 
62
62
  LocaleSettingsPage.propTypes = {
63
63
  canReadLocale: PropTypes.bool.isRequired,
@@ -5,7 +5,7 @@ import LocaleSettingsPage from './LocaleSettingsPage';
5
5
  import i18nPermissions from '../../permissions';
6
6
  import { getTrad } from '../../utils';
7
7
 
8
- const ProtectedLocaleSettingsPage = () => {
8
+ function ProtectedLocaleSettingsPage() {
9
9
  const { formatMessage } = useIntl();
10
10
  const {
11
11
  isLoading,
@@ -28,6 +28,6 @@ const ProtectedLocaleSettingsPage = () => {
28
28
  canDeleteLocale={canDelete}
29
29
  />
30
30
  );
31
- };
31
+ }
32
32
 
33
33
  export default ProtectedLocaleSettingsPage;
@@ -10,11 +10,11 @@ import { request, useUserPermissions } from '@akemona-org/strapi-helper-plugin';
10
10
  import { fireEvent, render, screen, within, waitFor } from '@testing-library/react';
11
11
  import { ThemeProvider } from 'styled-components';
12
12
  import { QueryClient, QueryClientProvider } from 'react-query';
13
+ import themes from '@akemona-org/strapi-admin/admin/src/themes';
13
14
  import LocaleSettingsPage from '..';
14
- import themes from '../../../../../../strapi-admin/admin/src/themes';
15
15
  import i18nReducers, { initialState } from '../../../hooks/reducers';
16
16
 
17
- const TestWrapper = ({ children }) => {
17
+ function TestWrapper({ children }) {
18
18
  const queryClient = new QueryClient();
19
19
 
20
20
  const initialStoreState = fromJS(initialState);
@@ -28,7 +28,7 @@ const TestWrapper = ({ children }) => {
28
28
  </QueryClientProvider>
29
29
  </Provider>
30
30
  );
31
- };
31
+ }
32
32
 
33
33
  // TODO: we should not be forced to mock this module
34
34
  // but it bugs somehow when run with jest
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "3.12.4",
6
+ "version": "3.13.0",
7
7
  "description": "This plugin enables to create, to read and to update content in different languages, both from the Admin Panel and from the API",
8
8
  "strapi": {
9
9
  "name": "Internationalization",
@@ -12,7 +12,7 @@
12
12
  "required": false
13
13
  },
14
14
  "dependencies": {
15
- "@akemona-org/strapi-utils": "3.12.4",
15
+ "@akemona-org/strapi-utils": "3.13.0",
16
16
  "lodash": "4.17.21",
17
17
  "p-map": "4.0.0",
18
18
  "pluralize": "8.0.0"
@@ -27,5 +27,5 @@
27
27
  "npm": ">=6.0.0"
28
28
  },
29
29
  "license": "SEE LICENSE IN LICENSE",
30
- "gitHead": "edf7db826c8babebcfa519e136874ba729667f8b"
30
+ "gitHead": "8bb7b41ae9cc2110f94b9338f0ec2df437e49161"
31
31
  }
@@ -23,7 +23,7 @@ const assignDefaultLocale = async (data) => {
23
23
  * @param {Object} options.model corresponding model
24
24
  */
25
25
  const syncLocalizations = async (entry, { model }) => {
26
- if (Array.isArray(entry.localizations)) {
26
+ if (Array.isArray(entry?.localizations)) {
27
27
  const newLocalizations = [entry.id, ...entry.localizations.map(prop('id'))];
28
28
 
29
29
  const updateLocalization = (id) => {
@@ -45,7 +45,7 @@ const syncLocalizations = async (entry, { model }) => {
45
45
  const syncNonLocalizedAttributes = async (entry, { model }) => {
46
46
  const { copyNonLocalizedAttributes } = getService('content-types');
47
47
 
48
- if (Array.isArray(entry.localizations)) {
48
+ if (Array.isArray(entry?.localizations)) {
49
49
  const nonLocalizedAttributes = copyNonLocalizedAttributes(model, entry);
50
50
 
51
51
  if (isEmpty(nonLocalizedAttributes)) {