1- import { Button , Select } from '@linode/ui' ;
1+ import { Button , Select , Typography } from '@linode/ui' ;
22import { capitalizeAllWords } from '@linode/utilities' ;
33import Grid from '@mui/material/Grid2' ;
44import Paper from '@mui/material/Paper' ;
55import {
6+ sortRows ,
67 Table ,
78 TableBody ,
89 TableCell ,
910 TableHead ,
1011 TableHeaderCell ,
1112 TableRow ,
1213 TableRowExpanded ,
13- sortRows ,
1414} from 'akamai-cds-react-components/Table' ;
1515import React , { useState } from 'react' ;
1616
1717import { DebouncedSearchTextField } from 'src/components/DebouncedSearchTextField' ;
18- import { StyledTextTooltip } from 'src/features/ components/PlansPanel/PlansAvailabilityNotice.styles ' ;
18+ import { Link } from 'src/components/Link ' ;
1919import { RolesTableActionMenu } from 'src/features/IAM/Roles/RolesTable/RolesTableActionMenu' ;
2020import { RolesTableExpandedRow } from 'src/features/IAM/Roles/RolesTable/RolesTableExpandedRow' ;
21- import { mapEntityTypesForSelect } from 'src/features/IAM/Shared/utilities' ;
21+ import {
22+ getFacadeRoleDescription ,
23+ mapEntityTypesForSelect ,
24+ } from 'src/features/IAM/Shared/utilities' ;
2225
2326import type { SelectOption } from '@linode/ui' ;
2427import type { Order } from 'akamai-cds-react-components/Table' ;
@@ -45,16 +48,20 @@ export const RolesTable = ({ roles }: Props) => {
4548 } , [ roles ] ) ;
4649
4750 const [ filterableEntityType , setFilterableEntityType ] =
48- useState < SelectOption | null > ( ALL_ROLES_OPTION ) ;
51+ useState < null | SelectOption > ( ALL_ROLES_OPTION ) ;
4952
5053 const [ sort , setSort ] = useState <
51- { column : string ; order : Order } | undefined
54+ undefined | { column : string ; order : Order }
5255 > ( undefined ) ;
5356
5457 const [ selectedRows , setSelectedRows ] = useState < RoleMap [ ] > ( [ ] ) ;
5558
5659 const areAllSelected = React . useMemo ( ( ) => {
57- return ! ! rows ?. length && ! ! selectedRows ?. length && rows ?. length === selectedRows ?. length ;
60+ return (
61+ ! ! rows ?. length &&
62+ ! ! selectedRows ?. length &&
63+ rows ?. length === selectedRows ?. length
64+ ) ;
5865 } , [ rows , selectedRows ] ) ;
5966
6067 const handleSort = ( event : CustomEvent , column : string ) => {
@@ -107,20 +114,18 @@ export const RolesTable = ({ roles }: Props) => {
107114 return (
108115 < Paper sx = { ( theme ) => ( { marginTop : theme . spacing ( 2 ) } ) } >
109116 < Grid
110- sx = { ( ) => ( {
111- justifyContent : 'space-between' ,
112- } ) }
113117 container
114118 direction = "row"
115119 spacing = { 2 }
120+ sx = { { justifyContent : 'space-between' } }
116121 >
117122 < Grid
118- sx = { ( ) => ( {
119- alignItems : 'center' ,
120- justifyContent : 'flex-start' ,
121- } ) }
122123 container
123124 direction = "row"
125+ sx = { {
126+ alignItems : 'center' ,
127+ justifyContent : 'flex-start' ,
128+ } }
124129 >
125130 < DebouncedSearchTextField
126131 clearable
@@ -143,14 +148,14 @@ export const RolesTable = ({ roles }: Props) => {
143148 />
144149 </ Grid >
145150 < Button
151+ buttonType = "primary"
152+ disabled = { selectedRows . length === 0 }
153+ onClick = { ( ) => handleAssignSelectedRoles ( ) }
146154 tooltipText = {
147155 selectedRows . length === 0
148156 ? 'You must select some roles to assign them.'
149157 : undefined
150158 }
151- buttonType = "primary"
152- disabled = { selectedRows . length === 0 }
153- onClick = { ( ) => handleAssignSelectedRoles ( ) }
154159 >
155160 Assign Selected Roles
156161 </ Button >
@@ -176,19 +181,19 @@ export const RolesTable = ({ roles }: Props) => {
176181 sort = { ( event ) => handleSort ( event , 'access' ) }
177182 sortable
178183 sorted = { sort ?. column === 'access' ? sort . order : undefined }
179- style = { { minWidth : '18 %' } }
184+ style = { { minWidth : '14 %' } }
180185 >
181186 Role Type
182187 </ TableHeaderCell >
183188 < TableHeaderCell
184189 sort = { ( event ) => handleSort ( event , 'description' ) }
185190 sortable
186191 sorted = { sort ?. column === 'description' ? sort . order : undefined }
187- style = { { minWidth : '30 %' } }
192+ style = { { minWidth : '38 %' } }
188193 >
189194 Description
190195 </ TableHeaderCell >
191- < TableHeaderCell style = { { minWidth : '14 %' } } />
196+ < TableHeaderCell style = { { minWidth : '10 %' } } />
192197 </ TableRow >
193198 </ TableHead >
194199 < TableBody >
@@ -210,20 +215,21 @@ export const RolesTable = ({ roles }: Props) => {
210215 < TableCell style = { { minWidth : '26%' } } >
211216 { roleRow . name }
212217 </ TableCell >
213- < TableCell style = { { minWidth : '18 %' } } >
218+ < TableCell style = { { minWidth : '14 %' } } >
214219 { capitalizeAllWords ( roleRow . access , '_' ) }
215220 </ TableCell >
216- < TableCell style = { { minWidth : '30 %' } } >
217- { roleRow . description . length <= 80 ? (
218- < > { roleRow . description } </ >
221+ < TableCell style = { { minWidth : '38 %' } } >
222+ { roleRow . permissions . length ? (
223+ roleRow . description
219224 ) : (
220- < span >
221- { roleRow . description . substring ( 0 , 80 ) } { '... ' }
222- < StyledTextTooltip tooltipText = { roleRow . description } displayText = { 'Show more' } />
223- </ span >
225+ // TODO: update the link for the description when it's ready - UIE-8534
226+ < Typography >
227+ { getFacadeRoleDescription ( roleRow ) } { ' ' }
228+ < Link to = "#" > Learn more.</ Link >
229+ </ Typography >
224230 ) }
225231 </ TableCell >
226- < TableCell style = { { minWidth : '14 %' } } >
232+ < TableCell style = { { minWidth : '10 %' } } >
227233 < RolesTableActionMenu />
228234 </ TableCell >
229235 < TableRowExpanded
0 commit comments