@@ -22,35 +22,55 @@ import UserTableAvatarInfo from './UserTableAvatarInfo';
22
22
interface ActionButtonsProps {
23
23
tableMeta : MUIDataTableMeta ;
24
24
isRemoveFromTeamAllowed : boolean ;
25
+ isEditUserAllowed : boolean ;
25
26
handleRemoveFromTeam : ( data : any [ ] ) => ( ) => void ;
27
+ handleEditUser : ( data : any [ ] ) => ( ) => void ;
26
28
theme ?: Theme ;
27
29
}
28
30
29
31
const ActionButtons : React . FC < ActionButtonsProps > = ( {
30
32
tableMeta,
31
33
handleRemoveFromTeam,
34
+ handleEditUser,
32
35
isRemoveFromTeamAllowed,
36
+ isEditUserAllowed,
33
37
theme
34
38
} ) => {
35
39
return (
36
- < div >
40
+ < TableIconsContainer >
41
+ { isEditUserAllowed ? (
42
+ < TooltipIcon
43
+ id = { `edit_user-${ tableMeta . rowIndex } ` }
44
+ onClick = { handleEditUser ( tableMeta . rowData ) }
45
+ title = "Edit user"
46
+ iconType = "edit"
47
+ >
48
+ < EditIcon fill = { theme ?. palette . text . primary } />
49
+ </ TooltipIcon >
50
+ ) : (
51
+ < EditIcon
52
+ style = { {
53
+ marginRight : '.5rem'
54
+ } }
55
+ fill = { CHARCOAL }
56
+ height = "30"
57
+ width = "30"
58
+ />
59
+ ) }
60
+
37
61
{ isRemoveFromTeamAllowed ? (
38
- < TableIconsContainer >
39
- < TooltipIcon
40
- id = { `delete_user-${ tableMeta . rowIndex } ` }
41
- onClick = { handleRemoveFromTeam ( tableMeta . rowData ) }
42
- title = "Remove user membership from team"
43
- iconType = "delete"
44
- >
45
- < LogoutIcon fill = { theme ?. palette . icon . default } />
46
- </ TooltipIcon >
47
- </ TableIconsContainer >
62
+ < TooltipIcon
63
+ id = { `delete_user-${ tableMeta . rowIndex } ` }
64
+ onClick = { handleRemoveFromTeam ( tableMeta . rowData ) }
65
+ title = "Remove user membership from team"
66
+ iconType = "delete"
67
+ >
68
+ < LogoutIcon fill = { theme ?. palette . text . primary } />
69
+ </ TooltipIcon >
48
70
) : (
49
- < TableIconsDisabledContainer >
50
- < LogoutIcon fill = { theme ?. palette . icon . disabled } secondaryFill = { CHARCOAL } />
51
- </ TableIconsDisabledContainer >
71
+ < LogoutIcon fill = { CHARCOAL } secondaryFill = { CHARCOAL } />
52
72
) }
53
- </ div >
73
+ </ TableIconsContainer >
54
74
) ;
55
75
} ;
56
76
@@ -61,6 +81,8 @@ interface UsersTableProps {
61
81
useRemoveUserFromTeamMutation : any ;
62
82
useNotificationHandlers : any ;
63
83
isRemoveFromTeamAllowed : boolean ;
84
+ isEditUserAllowed : boolean ;
85
+ handleEditUser : ( data : any [ ] ) => ( ) => void ;
64
86
theme ?: Theme ;
65
87
}
66
88
@@ -71,6 +93,8 @@ const UsersTable: React.FC<UsersTableProps> = ({
71
93
useRemoveUserFromTeamMutation,
72
94
useNotificationHandlers,
73
95
isRemoveFromTeamAllowed,
96
+ isEditUserAllowed,
97
+ handleEditUser,
74
98
theme
75
99
} ) => {
76
100
const [ page , setPage ] = useState < number > ( 0 ) ;
@@ -91,9 +115,29 @@ const UsersTable: React.FC<UsersTableProps> = ({
91
115
orgId : org_id
92
116
} ) ;
93
117
118
+ //->calling without teamId filter to get organization roles
119
+ const { data : fullUserData } = useGetUsersForOrgQuery ( {
120
+ page : 0 ,
121
+ pagesize : pageSize ,
122
+ search : search ,
123
+ order : sortOrder ,
124
+ orgId : org_id
125
+ } ) ;
126
+
94
127
const [ removeUserFromTeam ] = useRemoveUserFromTeamMutation ( ) ;
95
128
96
129
const users = userData ?. data || [ ] ;
130
+ const fullUsers = fullUserData ?. data || [ ] ;
131
+
132
+ const enrichedUsers = users . map ( ( teamUser : any ) => {
133
+ const fullUser = fullUsers . find ( ( fu : any ) => fu . user_id === teamUser . user_id ) ;
134
+ const teamRoles = teamUser . role_names || [ ] ;
135
+ const organizationRoles = fullUser ?. organization_with_user_roles ?. role_names || [ ] ;
136
+ return {
137
+ ...teamUser ,
138
+ role_names : [ ...teamRoles , ...organizationRoles ]
139
+ } ;
140
+ } ) ;
97
141
const count = userData ?. total_count || 0 ;
98
142
99
143
const handleRemoveFromTeam = ( data : any [ ] ) => async ( ) => {
@@ -383,7 +427,7 @@ const UsersTable: React.FC<UsersTableProps> = ({
383
427
fullWidth : true
384
428
} ,
385
429
customBodyRender : ( _ : string , tableMeta : MUIDataTableMeta ) => {
386
- const rowData = users [ tableMeta . rowIndex ] ;
430
+ const rowData = enrichedUsers [ tableMeta . rowIndex ] ;
387
431
return parseDeletionTimestamp ( rowData ) ;
388
432
}
389
433
}
@@ -412,7 +456,9 @@ const UsersTable: React.FC<UsersTableProps> = ({
412
456
< ActionButtons
413
457
tableMeta = { tableMeta }
414
458
handleRemoveFromTeam = { handleRemoveFromTeam }
459
+ handleEditUser = { handleEditUser }
415
460
isRemoveFromTeamAllowed = { isRemoveFromTeamAllowed }
461
+ isEditUserAllowed = { isEditUserAllowed }
416
462
theme = { theme }
417
463
/>
418
464
)
@@ -436,7 +482,7 @@ const UsersTable: React.FC<UsersTableProps> = ({
436
482
< div style = { { margin : 'auto' , width : '100%' } } >
437
483
< ResponsiveDataTable
438
484
columns = { columns }
439
- data = { users }
485
+ data = { enrichedUsers }
440
486
options = { options }
441
487
colViews = { colViews }
442
488
tableCols = { tableCols }
0 commit comments