diff --git a/app/javascript/components/users/user/forms/UpdateUserForm.jsx b/app/javascript/components/users/user/forms/UpdateUserForm.jsx index 7d524695b8..2c357eed22 100644 --- a/app/javascript/components/users/user/forms/UpdateUserForm.jsx +++ b/app/javascript/components/users/user/forms/UpdateUserForm.jsx @@ -68,6 +68,12 @@ export default function UpdateUserForm({ user }) { methods.setValue('language', currentLanguage()); }, [currentLanguage()]); + // Check if the current user has a specific role + const hasSpecificRole = currentUser?.role.name === 'Administrator'; + + // Filter roles based on name and/or ID if the current user does not have the specific role + const filteredRoles = hasSpecificRole ? roles : roles?.filter(role => role.name !== 'Administrator'); + return (
@@ -77,10 +83,10 @@ export default function UpdateUserForm({ user }) { Object.keys(locales || {}).map((code) => ) } - {(canUpdateRole && roles) && ( + {(canUpdateRole && filteredRoles) && ( { - roles.map((role) => ) + filteredRoles.map((role) => ) } )}