fix: hide the locale option in the Edit view dropdown if you don't have permission to read it (#22229)

* fix: hide the locale option in the edit view if you don't have permission

* fix: change the permission condition

* fix: show the option if you have read permission
This commit is contained in:
Simone 2024-11-25 09:54:32 +01:00 committed by GitHub
parent 3827154d28
commit c196a9d2b8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -168,12 +168,20 @@ const LocalePickerAction = ({
return null;
}
const displayedLocales = locales.filter((locale) => {
/**
* If you can read we allow you to see the locale exists
* otherwise the locale is hidden.
*/
return canRead.includes(locale.code);
});
return {
label: formatMessage({
id: getTranslation('Settings.locales.modal.locales.label'),
defaultMessage: 'Locales',
}),
options: locales.map((locale) => {
options: displayedLocales.map((locale) => {
const entryWithLocaleExists = allCurrentLocales.some((doc) => doc.locale === locale.code);
const currentLocaleDoc = allCurrentLocales.find((doc) =>