File tree Expand file tree Collapse file tree 4 files changed +16
-5
lines changed
plugins/admin/components/Roles Expand file tree Collapse file tree 4 files changed +16
-5
lines changed Original file line number Diff line number Diff line change 754
754
"see_project_details" : " See project details" ,
755
755
"add_ssa" : " Add SSA" ,
756
756
"copied" : " Copied" ,
757
- "no_data_found" : " No data found"
757
+ "no_data_found" : " No data found" ,
758
+ "role_already_exists" : " Role already exists"
758
759
},
759
760
"tooltips" : {
760
761
"add_attribute" : " Add attribute" ,
Original file line number Diff line number Diff line change 689
689
"add_ssa" : " Ajouter SSA" ,
690
690
"copied" : " Copié" ,
691
691
"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à"
693
694
},
694
695
"tooltips" : {
695
696
"add_attribute" : " Ajouter un attribut" ,
Original file line number Diff line number Diff line change 684
684
"add_ssa" : " Adicionar SSA" ,
685
685
"copied" : " Copiado" ,
686
686
"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"
688
689
},
689
690
"tooltips" : {
690
691
"add_attribute" : " Adicionar atributo" ,
Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ import SetTitle from 'Utils/SetTitle'
25
25
import { ThemeContext } from 'Context/theme/themeContext'
26
26
import getThemeColor from 'Context/theme/config'
27
27
import { ROLE_DELETE } from '../../../../app/utils/PermChecker'
28
+ import { toast } from 'react-toastify'
28
29
29
30
function UiRoleListPage ( ) {
30
31
const apiRoles = useSelector ( ( state ) => state . apiRoleReducer . items )
@@ -69,8 +70,15 @@ function UiRoleListPage() {
69
70
}
70
71
function onAddConfirmed ( roleData ) {
71
72
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
+ }
74
82
}
75
83
return (
76
84
< Card style = { applicationStyle . mainCard } >
You can’t perform that action at this time.
0 commit comments