Skip to content

Commit 35fe996

Browse files
authored
fix(admin-ui): message not correct while creating duplicate role (#1964)
fix: message not correct while creating duplicate role
1 parent 981ac1b commit 35fe996

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

admin-ui/app/locales/en/translation.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,8 @@
754754
"see_project_details": "See project details",
755755
"add_ssa": "Add SSA",
756756
"copied": "Copied",
757-
"no_data_found": "No data found"
757+
"no_data_found": "No data found",
758+
"role_already_exists": "Role already exists"
758759
},
759760
"tooltips": {
760761
"add_attribute": "Add attribute",

admin-ui/app/locales/fr/translation.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,8 @@
689689
"add_ssa": "Ajouter SSA",
690690
"copied": "Copié",
691691
"edit_acr": "Modifier ACR",
692-
"no_data_found": "Aucune donnée trouvée"
692+
"no_data_found": "Aucune donnée trouvée",
693+
"role_already_exists": "Le rôle existe déjà"
693694
},
694695
"tooltips": {
695696
"add_attribute": "Ajouter un attribut",

admin-ui/app/locales/pt/translation.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,8 @@
684684
"add_ssa": "Adicionar SSA",
685685
"copied": "Copiado",
686686
"edit_acr": "Editar ACR",
687-
"no_data_found": "Nenhum dado encontrado"
687+
"no_data_found": "Nenhum dado encontrado",
688+
"role_already_exists": "Função já existe"
688689
},
689690
"tooltips": {
690691
"add_attribute": "Adicionar atributo",

admin-ui/plugins/admin/components/Roles/UiRoleListPage.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import SetTitle from 'Utils/SetTitle'
2525
import { ThemeContext } from 'Context/theme/themeContext'
2626
import getThemeColor from 'Context/theme/config'
2727
import { ROLE_DELETE } from '../../../../app/utils/PermChecker'
28+
import { toast } from 'react-toastify'
2829

2930
function UiRoleListPage() {
3031
const apiRoles = useSelector((state) => state.apiRoleReducer.items)
@@ -69,8 +70,15 @@ function UiRoleListPage() {
6970
}
7071
function onAddConfirmed(roleData) {
7172
buildPayload(userAction, 'message', roleData)
72-
dispatch(addRole({ action: userAction }))
73-
toggle()
73+
74+
const fetchRoles = apiRoles.filter((role) => role.role === roleData.role)
75+
if (fetchRoles.length > 0) {
76+
toast.error(`${t('messages.role_already_exists')}`)
77+
}
78+
else{
79+
dispatch(addRole({ action: userAction }))
80+
toggle()
81+
}
7482
}
7583
return (
7684
<Card style={applicationStyle.mainCard}>

0 commit comments

Comments
 (0)