@@ -22,35 +22,55 @@ import UserTableAvatarInfo from './UserTableAvatarInfo';
2222interface ActionButtonsProps {
2323 tableMeta : MUIDataTableMeta ;
2424 isRemoveFromTeamAllowed : boolean ;
25+ isEditUserAllowed : boolean ;
2526 handleRemoveFromTeam : ( data : any [ ] ) => ( ) => void ;
27+ handleEditUser : ( data : any [ ] ) => ( ) => void ;
2628 theme ?: Theme ;
2729}
2830
2931const ActionButtons : React . FC < ActionButtonsProps > = ( {
3032 tableMeta,
3133 handleRemoveFromTeam,
34+ handleEditUser,
3235 isRemoveFromTeamAllowed,
36+ isEditUserAllowed,
3337 theme
3438} ) => {
3539 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+
3761 { 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 >
4870 ) : (
49- < TableIconsDisabledContainer >
50- < LogoutIcon fill = { theme ?. palette . icon . disabled } secondaryFill = { CHARCOAL } />
51- </ TableIconsDisabledContainer >
71+ < LogoutIcon fill = { CHARCOAL } secondaryFill = { CHARCOAL } />
5272 ) }
53- </ div >
73+ </ TableIconsContainer >
5474 ) ;
5575} ;
5676
@@ -61,6 +81,8 @@ interface UsersTableProps {
6181 useRemoveUserFromTeamMutation : any ;
6282 useNotificationHandlers : any ;
6383 isRemoveFromTeamAllowed : boolean ;
84+ isEditUserAllowed : boolean ;
85+ handleEditUser : ( data : any [ ] ) => ( ) => void ;
6486 theme ?: Theme ;
6587}
6688
@@ -71,6 +93,8 @@ const UsersTable: React.FC<UsersTableProps> = ({
7193 useRemoveUserFromTeamMutation,
7294 useNotificationHandlers,
7395 isRemoveFromTeamAllowed,
96+ isEditUserAllowed,
97+ handleEditUser,
7498 theme
7599} ) => {
76100 const [ page , setPage ] = useState < number > ( 0 ) ;
@@ -91,9 +115,29 @@ const UsersTable: React.FC<UsersTableProps> = ({
91115 orgId : org_id
92116 } ) ;
93117
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+
94127 const [ removeUserFromTeam ] = useRemoveUserFromTeamMutation ( ) ;
95128
96129 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+ } ) ;
97141 const count = userData ?. total_count || 0 ;
98142
99143 const handleRemoveFromTeam = ( data : any [ ] ) => async ( ) => {
@@ -383,7 +427,7 @@ const UsersTable: React.FC<UsersTableProps> = ({
383427 fullWidth : true
384428 } ,
385429 customBodyRender : ( _ : string , tableMeta : MUIDataTableMeta ) => {
386- const rowData = users [ tableMeta . rowIndex ] ;
430+ const rowData = enrichedUsers [ tableMeta . rowIndex ] ;
387431 return parseDeletionTimestamp ( rowData ) ;
388432 }
389433 }
@@ -412,7 +456,9 @@ const UsersTable: React.FC<UsersTableProps> = ({
412456 < ActionButtons
413457 tableMeta = { tableMeta }
414458 handleRemoveFromTeam = { handleRemoveFromTeam }
459+ handleEditUser = { handleEditUser }
415460 isRemoveFromTeamAllowed = { isRemoveFromTeamAllowed }
461+ isEditUserAllowed = { isEditUserAllowed }
416462 theme = { theme }
417463 />
418464 )
@@ -436,7 +482,7 @@ const UsersTable: React.FC<UsersTableProps> = ({
436482 < div style = { { margin : 'auto' , width : '100%' } } >
437483 < ResponsiveDataTable
438484 columns = { columns }
439- data = { users }
485+ data = { enrichedUsers }
440486 options = { options }
441487 colViews = { colViews }
442488 tableCols = { tableCols }
0 commit comments