@@ -10,6 +10,11 @@ import {
10
10
} from 'Components'
11
11
import { useDispatch , useSelector } from 'react-redux'
12
12
import { DeleteOutlined } from '@material-ui/icons'
13
+ import {
14
+ hasPermission ,
15
+ MAPPING_WRITE ,
16
+ MAPPING_DELETE
17
+ } from 'Utils/PermChecker'
13
18
import {
14
19
updateMapping ,
15
20
addPermissionsToRole ,
@@ -27,6 +32,7 @@ function MappingItem({ candidate, roles }) {
27
32
const dispatch = useDispatch ( )
28
33
const autocompleteRef = useRef ( null )
29
34
const permissions = useSelector ( ( state ) => state . apiPermissionReducer . items )
35
+ const authPermissions = useSelector ( ( state ) => state . authReducer . permissions )
30
36
const [ searchablePermissions , setSearchAblePermissions ] = useState ( [ ] )
31
37
const [ serverPermissions , setServerPermissions ] = useState ( null )
32
38
const [ isDeleteable , setIsDeleteable ] = useState ( false )
@@ -136,6 +142,7 @@ function MappingItem({ candidate, roles }) {
136
142
</ Accordion . Header >
137
143
< Accordion . Body >
138
144
< div style = { { marginTop : 10 } } > </ div >
145
+ { hasPermission ( authPermissions , MAPPING_WRITE ) ?
139
146
< Formik
140
147
initialValues = { initialValues }
141
148
onSubmit = { handleAddPermission }
@@ -170,10 +177,11 @@ function MappingItem({ candidate, roles }) {
170
177
</ Form >
171
178
</ >
172
179
) }
173
- </ Formik >
180
+ </ Formik > : null }
174
181
{ candidate . permissions . map ( ( permission , id ) => (
175
182
< Row key = { id } >
176
183
< Col sm = { 10 } > { permission } </ Col >
184
+ { hasPermission ( authPermissions , MAPPING_DELETE ) ?
177
185
< Col sm = { 2 } >
178
186
< Button
179
187
type = "button"
@@ -188,11 +196,13 @@ function MappingItem({ candidate, roles }) {
188
196
< i className = "fa fa-trash mr-2" > </ i >
189
197
{ t ( 'actions.remove' ) }
190
198
</ Button >
191
- </ Col >
199
+ </ Col > :null
200
+ }
192
201
</ Row >
193
202
) ) }
194
203
{ /* Bottom Buttons */ }
195
204
< FormGroup row />
205
+ { hasPermission ( authPermissions , MAPPING_WRITE ) ?
196
206
< Row >
197
207
< Col sm = { 6 } >
198
208
< Button
@@ -205,6 +215,7 @@ function MappingItem({ candidate, roles }) {
205
215
{ t ( 'actions.revert' ) }
206
216
</ Button >
207
217
</ Col >
218
+
208
219
< Col sm = { 6 } className = "text-right" >
209
220
< Button
210
221
type = "button"
@@ -219,7 +230,7 @@ function MappingItem({ candidate, roles }) {
219
230
{ t ( 'actions.save' ) }
220
231
</ Button >
221
232
</ Col >
222
- </ Row >
233
+ </ Row > : null }
223
234
{ /* Bottom Buttons */ }
224
235
</ Accordion . Body >
225
236
</ Accordion >
0 commit comments