11import { useTranslation } from "react-i18next" ;
2- import { User } from "../../../slices/userSlice" ;
2+ import { fetchUsers , User } from "../../../slices/userSlice" ;
3+ import MultiValueCell from "../../shared/MultiValueCell" ;
4+ import { loadUsersIntoTable } from "../../../thunks/tableThunks" ;
35
46/**
57 * This component renders the roles cells of users in the table view
@@ -13,6 +15,7 @@ const UsersRolesCell = ({
1315
1416 const getRoleString = ( ) => {
1517 const displayRoles = [ ] ;
18+ const squashedRoles = [ ] ;
1619 let roleCountUI = 0 ;
1720 let roleCountAPI = 0 ;
1821 let roleCountCaptureAgent = 0 ;
@@ -31,21 +34,36 @@ const UsersRolesCell = ({
3134
3235 if ( roleCountUI > 0 ) {
3336 const desc = t ( "USERS.USERS.TABLE.COLLAPSED.UI" ) ;
34- displayRoles . push ( `${ roleCountUI } ${ desc } ` ) ;
37+ squashedRoles . push ( `${ roleCountUI } ${ desc } ` ) ;
3538 }
3639 if ( roleCountAPI > 0 ) {
3740 const desc = t ( "USERS.USERS.TABLE.COLLAPSED.API" ) ;
38- displayRoles . push ( `${ roleCountAPI } ${ desc } ` ) ;
41+ squashedRoles . push ( `${ roleCountAPI } ${ desc } ` ) ;
3942 }
4043 if ( roleCountCaptureAgent > 0 ) {
4144 const desc = t ( "USERS.USERS.TABLE.COLLAPSED.CAPTURE_AGENT" ) ;
42- displayRoles . push ( `${ roleCountCaptureAgent } ${ desc } ` ) ;
45+ squashedRoles . push ( `${ roleCountCaptureAgent } ${ desc } ` ) ;
4346 }
4447
45- return displayRoles . join ( ", " ) ;
48+ return { displayRoles, squashedRoles } ;
4649 } ;
4750
48- return < span > { getRoleString ( ) } </ span > ;
51+ const { displayRoles, squashedRoles } = getRoleString ( ) ;
52+
53+ return (
54+ < >
55+ < MultiValueCell
56+ resource = "users"
57+ values = { displayRoles }
58+ filterName = "Role"
59+ fetchResource = { fetchUsers }
60+ loadResourceIntoTable = { loadUsersIntoTable }
61+ tooltipText = "USERS.USERS.TABLE.TOOLTIP.ROLES"
62+ />
63+ { displayRoles . length > 0 && squashedRoles . length > 0 && < span > , </ span > }
64+ < span > { squashedRoles . join ( ", " ) } </ span >
65+ </ >
66+ ) ;
4967} ;
5068
5169export default UsersRolesCell ;
0 commit comments