Skip to content

Commit

Permalink
fix(admin-ui): message not correct while creating duplicate role (#1964)
Browse files Browse the repository at this point in the history
fix: message not correct while creating duplicate role
  • Loading branch information
mjatin-dev authored Jan 14, 2025
1 parent 981ac1b commit 35fe996
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
3 changes: 2 additions & 1 deletion admin-ui/app/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion admin-ui/app/locales/fr/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion admin-ui/app/locales/pt/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
12 changes: 10 additions & 2 deletions admin-ui/plugins/admin/components/Roles/UiRoleListPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 (
<Card style={applicationStyle.mainCard}>
Expand Down

0 comments on commit 35fe996

Please sign in to comment.