Skip to content

Commit 9dffc37

Browse files
committed
Add a table that shows all role membersips in a group
1 parent d59fc96 commit 9dffc37

File tree

1 file changed

+104
-0
lines changed

1 file changed

+104
-0
lines changed

src/pages/groups/Read.tsx

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,110 @@ export default function ReadGroup() {
644644
</Table>
645645
</TableContainer>
646646
</Grid>
647+
{group.type != 'role_group' && (group.active_role_member_mappings?.length || group.active_role_owner_mappings?.length) ? (
648+
<Grid item xs={12}>
649+
<TableContainer component={Paper}>
650+
<Table sx={{minWidth: 650}} size="small" aria-label="roles with access">
651+
<TableHead>
652+
<TableRow>
653+
<TableCell colSpan={3}>
654+
<Stack direction="row" spacing={1} sx={{display: 'flex', alignItems: 'center'}}>
655+
<Typography variant="h6" color="text.accent">
656+
Roles with Access
657+
</Typography>
658+
<Typography variant="body1" color="text.secondary">
659+
Roles that grant access to this group
660+
</Typography>
661+
</Stack>
662+
</TableCell>
663+
<TableCell>
664+
<Box
665+
sx={{
666+
display: 'flex',
667+
justifyContent: 'flex-end',
668+
alignItems: 'right',
669+
}}>
670+
<Divider sx={{mx: 2}} orientation="vertical" flexItem />
671+
Total: {(group.active_role_member_mappings?.length || 0) + (group.active_role_owner_mappings?.length || 0)}
672+
</Box>
673+
</TableCell>
674+
</TableRow>
675+
<TableRow>
676+
<TableCell>Role Name</TableCell>
677+
<TableCell>Access Type</TableCell>
678+
<TableCell>Ending</TableCell>
679+
<TableCell></TableCell>
680+
</TableRow>
681+
</TableHead>
682+
<TableBody>
683+
{(group.active_role_owner_mappings ?? []).map((roleMapping: RoleGroupMap) => (
684+
<TableRow key={'role-owner-' + roleMapping.active_role_group?.id}>
685+
<TableCell>
686+
<Link
687+
to={`/groups/${roleMapping.active_role_group?.name}`}
688+
sx={{
689+
textDecoration: 'none',
690+
color: 'inherit',
691+
'&:hover': {
692+
color: (theme: any) => theme.palette.primary.main,
693+
},
694+
}}
695+
component={RouterLink}>
696+
{roleMapping.active_role_group?.name}
697+
</Link>
698+
</TableCell>
699+
<TableCell>
700+
<Chip
701+
label="Owner"
702+
color="primary"
703+
variant="filled"
704+
size="small"
705+
/>
706+
</TableCell>
707+
<TableCell>
708+
<Ending memberships={[roleMapping]} />
709+
</TableCell>
710+
<TableCell></TableCell>
711+
</TableRow>
712+
))}
713+
{(group.active_role_member_mappings ?? []).map((roleMapping: RoleGroupMap) => (
714+
<TableRow key={'role-member-' + roleMapping.active_role_group?.id}>
715+
<TableCell>
716+
<Link
717+
to={`/groups/${roleMapping.active_role_group?.name}`}
718+
sx={{
719+
textDecoration: 'none',
720+
color: 'inherit',
721+
'&:hover': {
722+
color: (theme: any) => theme.palette.primary.main,
723+
},
724+
}}
725+
component={RouterLink}>
726+
{roleMapping.active_role_group?.name}
727+
</Link>
728+
</TableCell>
729+
<TableCell>
730+
<Chip
731+
label="Member"
732+
color="secondary"
733+
variant="outlined"
734+
size="small"
735+
/>
736+
</TableCell>
737+
<TableCell>
738+
<Ending memberships={[roleMapping]} />
739+
</TableCell>
740+
<TableCell></TableCell>
741+
</TableRow>
742+
))}
743+
</TableBody>
744+
<TableFooter>
745+
<TableRow />
746+
</TableFooter>
747+
</Table>
748+
</TableContainer>
749+
</Grid>
750+
) : null}
647751
<Grid item xs={12}>
648752
<TableContainer component={Paper}>
649753
<Table sx={{minWidth: 650}} size="small" aria-label="group members">

0 commit comments

Comments
 (0)