Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(admin-ui): message not correct while creating duplicate role #1964

Merged
merged 1 commit into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading