diff --git a/admin-ui/app/locales/en/translation.json b/admin-ui/app/locales/en/translation.json index 5be1180d2..1581038be 100644 --- a/admin-ui/app/locales/en/translation.json +++ b/admin-ui/app/locales/en/translation.json @@ -754,7 +754,8 @@ "see_project_details": "See project details", "add_ssa": "Add SSA", "copied": "Copied", - "no_data_found": "No data found" + "no_data_found": "No data found", + "role_already_exists": "Role already exists" }, "tooltips": { "add_attribute": "Add attribute", diff --git a/admin-ui/app/locales/fr/translation.json b/admin-ui/app/locales/fr/translation.json index 9c4584793..b01ffd125 100644 --- a/admin-ui/app/locales/fr/translation.json +++ b/admin-ui/app/locales/fr/translation.json @@ -689,7 +689,8 @@ "add_ssa": "Ajouter SSA", "copied": "Copié", "edit_acr": "Modifier ACR", - "no_data_found": "Aucune donnée trouvée" + "no_data_found": "Aucune donnée trouvée", + "role_already_exists": "Le rôle existe déjà" }, "tooltips": { "add_attribute": "Ajouter un attribut", diff --git a/admin-ui/app/locales/pt/translation.json b/admin-ui/app/locales/pt/translation.json index e08ce76d5..b67092c41 100644 --- a/admin-ui/app/locales/pt/translation.json +++ b/admin-ui/app/locales/pt/translation.json @@ -684,7 +684,8 @@ "add_ssa": "Adicionar SSA", "copied": "Copiado", "edit_acr": "Editar ACR", - "no_data_found": "Nenhum dado encontrado" + "no_data_found": "Nenhum dado encontrado", + "role_already_exists": "Função já existe" }, "tooltips": { "add_attribute": "Adicionar atributo", diff --git a/admin-ui/plugins/admin/components/Roles/UiRoleListPage.js b/admin-ui/plugins/admin/components/Roles/UiRoleListPage.js index 2be7f140a..44d0badbd 100644 --- a/admin-ui/plugins/admin/components/Roles/UiRoleListPage.js +++ b/admin-ui/plugins/admin/components/Roles/UiRoleListPage.js @@ -25,6 +25,7 @@ import SetTitle from 'Utils/SetTitle' import { ThemeContext } from 'Context/theme/themeContext' import getThemeColor from 'Context/theme/config' import { ROLE_DELETE } from '../../../../app/utils/PermChecker' +import { toast } from 'react-toastify' function UiRoleListPage() { const apiRoles = useSelector((state) => state.apiRoleReducer.items) @@ -69,8 +70,15 @@ function UiRoleListPage() { } function onAddConfirmed(roleData) { buildPayload(userAction, 'message', roleData) - dispatch(addRole({ action: userAction })) - toggle() + + const fetchRoles = apiRoles.filter((role) => role.role === roleData.role) + if (fetchRoles.length > 0) { + toast.error(`${t('messages.role_already_exists')}`) + } + else{ + dispatch(addRole({ action: userAction })) + toggle() + } } return (