mirror of
https://github.com/strapi/strapi.git
synced 2025-09-25 08:19:07 +00:00
Show all locales in the listview content-available cell (#9877)
This commit is contained in:
parent
f30895b588
commit
ba1f493c8c
@ -5,8 +5,9 @@ import { Tooltip } from '@buffetjs/styles';
|
||||
const mapToLocaleName = (locales, localeCode) =>
|
||||
locales.find(({ code }) => code === localeCode).name;
|
||||
|
||||
const LocaleListCell = ({ locales, localizations, id }) => {
|
||||
const localizationNames = localizations.map(locale => locale.locale);
|
||||
const LocaleListCell = ({ locales, localizations, locale: currentLocaleCode, id }) => {
|
||||
const allLocalizations = [{ locale: currentLocaleCode }, ...localizations];
|
||||
const localizationNames = allLocalizations.map(locale => locale.locale);
|
||||
const defaultLocale = locales.find(locale => locale.isDefault);
|
||||
const hasDefaultLocale = localizationNames.includes(defaultLocale.code);
|
||||
|
||||
@ -61,6 +62,7 @@ LocaleListCell.propTypes = {
|
||||
isDefault: PropTypes.bool,
|
||||
})
|
||||
).isRequired,
|
||||
locale: PropTypes.string.isRequired,
|
||||
};
|
||||
|
||||
export default LocaleListCell;
|
||||
|
@ -42,7 +42,7 @@ describe('LocaleListCell', () => {
|
||||
<LocaleListCell id={12} locales={locales} locale={locale} localizations={localizations} />
|
||||
);
|
||||
|
||||
expect(screen.getByText('French (default), Arabic')).toBeVisible();
|
||||
expect(screen.getByText('French (default), Arabic, English')).toBeVisible();
|
||||
});
|
||||
|
||||
it('returns the "ar" when there s 2 locales available', () => {
|
||||
@ -80,7 +80,7 @@ describe('LocaleListCell', () => {
|
||||
<LocaleListCell id={12} locales={locales} locale={locale} localizations={localizations} />
|
||||
);
|
||||
|
||||
expect(screen.getByText('Arabic')).toBeVisible();
|
||||
expect(screen.getByText('Arabic, English')).toBeVisible();
|
||||
});
|
||||
|
||||
it('returns the "ar" and "en" locales alphabetically sorted', () => {
|
||||
@ -118,6 +118,6 @@ describe('LocaleListCell', () => {
|
||||
<LocaleListCell id={12} locales={locales} locale={locale} localizations={localizations} />
|
||||
);
|
||||
|
||||
expect(screen.getByText('Arabic, English')).toBeVisible();
|
||||
expect(screen.getByText('French (default), Arabic, English')).toBeVisible();
|
||||
});
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user