@@ -8,6 +8,7 @@ import Table from "@mui/material/Table";
8
8
import TableBody from "@mui/material/TableBody" ;
9
9
import TableCell from "@mui/material/TableCell" ;
10
10
import TableContainer from "@mui/material/TableContainer" ;
11
+ import TableFooter from "@mui/material/TableFooter" ;
11
12
import TableHead from "@mui/material/TableHead" ;
12
13
import TableRow from "@mui/material/TableRow" ;
13
14
import TextField from "@mui/material/TextField" ;
@@ -219,80 +220,102 @@ const ActionCheckboxes: FC<ActionCheckboxesProps> = ({
219
220
: filteredRBACResourceActions ;
220
221
221
222
return (
222
- < >
223
- < TableContainer >
224
- < Table >
225
- < TableHead >
226
- < TableRow >
227
- < TableCell > Permission</ TableCell >
228
- < TableCell
229
- align = "right"
230
- sx = { { paddingTop : 0.4 , paddingBottom : 0.4 } }
231
- >
232
- < FormControlLabel
233
- sx = { { marginRight : 1 } }
234
- control = {
235
- < Checkbox
236
- size = "small"
237
- id = "show_all_permissions"
238
- name = "show_all_permissions"
239
- checked = { showAllResources }
240
- onChange = { ( e ) =>
241
- setShowAllResources ( e . currentTarget . checked )
242
- }
243
- checkedIcon = { < VisibilityOutlinedIcon /> }
244
- icon = { < VisibilityOffOutlinedIcon /> }
245
- />
246
- }
247
- label = {
248
- < span style = { { fontSize : 12 } } > Show all permissions</ span >
249
- }
250
- />
251
- </ TableCell >
252
- </ TableRow >
253
- </ TableHead >
254
- < TableBody >
255
- { Object . entries ( resourceActions ) . map ( ( [ resourceKey , value ] ) => {
256
- return (
257
- < TableRow key = { resourceKey } >
258
- < TableCell sx = { { paddingLeft : 2 } } >
259
- < li key = { resourceKey } css = { styles . checkBoxes } >
260
- { resourceKey }
261
- < ul css = { styles . checkBoxes } >
262
- { Object . entries ( value ) . map ( ( [ actionKey , value ] ) => (
263
- < li key = { actionKey } >
264
- < span css = { styles . actionText } >
265
- < Checkbox
266
- size = "small"
267
- name = { `${ resourceKey } :${ actionKey } ` }
268
- checked = { checkedActions ?. some ( ( p ) =>
269
- ResourceActionComparator (
270
- p ,
271
- resourceKey ,
272
- actionKey ,
273
- ) ,
274
- ) }
275
- onChange = { ( e ) =>
276
- handleActionCheckChange ( e , form )
277
- }
278
- />
279
- { actionKey }
280
- </ span > { " " }
281
- –{ " " }
282
- < span css = { styles . actionDescription } > { value } </ span >
283
- </ li >
284
- ) ) }
285
- </ ul >
286
- </ li >
287
- </ TableCell >
288
- < TableCell />
289
- </ TableRow >
290
- ) ;
291
- } ) }
292
- </ TableBody >
293
- </ Table >
294
- </ TableContainer >
295
- </ >
223
+ < TableContainer >
224
+ < Table >
225
+ < TableHead >
226
+ < TableRow >
227
+ < TableCell > Permission</ TableCell >
228
+ < TableCell
229
+ align = "right"
230
+ sx = { { paddingTop : 0.4 , paddingBottom : 0.4 } }
231
+ >
232
+ < ShowAllResourcesCheckbox
233
+ showAllResources = { showAllResources }
234
+ setShowAllResources = { setShowAllResources }
235
+ />
236
+ </ TableCell >
237
+ </ TableRow >
238
+ </ TableHead >
239
+ < TableBody >
240
+ { Object . entries ( resourceActions ) . map ( ( [ resourceKey , value ] ) => {
241
+ return (
242
+ < TableRow key = { resourceKey } >
243
+ < TableCell sx = { { paddingLeft : 2 } } colSpan = { 2 } >
244
+ < li key = { resourceKey } css = { styles . checkBoxes } >
245
+ { resourceKey }
246
+ < ul css = { styles . checkBoxes } >
247
+ { Object . entries ( value ) . map ( ( [ actionKey , value ] ) => (
248
+ < li key = { actionKey } >
249
+ < span css = { styles . actionText } >
250
+ < Checkbox
251
+ size = "small"
252
+ name = { `${ resourceKey } :${ actionKey } ` }
253
+ checked = { checkedActions ?. some ( ( p ) =>
254
+ ResourceActionComparator (
255
+ p ,
256
+ resourceKey ,
257
+ actionKey ,
258
+ ) ,
259
+ ) }
260
+ onChange = { ( e ) => handleActionCheckChange ( e , form ) }
261
+ />
262
+ { actionKey }
263
+ </ span > { " " }
264
+ –{ " " }
265
+ < span css = { styles . actionDescription } > { value } </ span >
266
+ </ li >
267
+ ) ) }
268
+ </ ul >
269
+ </ li >
270
+ </ TableCell >
271
+ </ TableRow >
272
+ ) ;
273
+ } ) }
274
+ </ TableBody >
275
+ < TableFooter >
276
+ < TableRow >
277
+ < TableCell
278
+ align = "right"
279
+ colSpan = { 2 }
280
+ sx = { { paddingTop : 0.4 , paddingBottom : 0.4 , paddingRight : 4 } }
281
+ >
282
+ < ShowAllResourcesCheckbox
283
+ showAllResources = { showAllResources }
284
+ setShowAllResources = { setShowAllResources }
285
+ />
286
+ </ TableCell >
287
+ </ TableRow >
288
+ </ TableFooter >
289
+ </ Table >
290
+ </ TableContainer >
291
+ ) ;
292
+ } ;
293
+
294
+ interface ShowAllResourcesCheckboxProps {
295
+ showAllResources : boolean ;
296
+ setShowAllResources : React . Dispatch < React . SetStateAction < boolean > > ;
297
+ }
298
+
299
+ const ShowAllResourcesCheckbox : FC < ShowAllResourcesCheckboxProps > = ( {
300
+ showAllResources,
301
+ setShowAllResources,
302
+ } ) => {
303
+ return (
304
+ < FormControlLabel
305
+ sx = { { marginRight : 1 } }
306
+ control = {
307
+ < Checkbox
308
+ size = "small"
309
+ id = "show_all_permissions"
310
+ name = "show_all_permissions"
311
+ checked = { showAllResources }
312
+ onChange = { ( e ) => setShowAllResources ( e . currentTarget . checked ) }
313
+ checkedIcon = { < VisibilityOutlinedIcon /> }
314
+ icon = { < VisibilityOffOutlinedIcon /> }
315
+ />
316
+ }
317
+ label = { < span style = { { fontSize : 12 } } > Show all permissions</ span > }
318
+ />
296
319
) ;
297
320
} ;
298
321
0 commit comments