Skip to content

Commit 829cfee

Browse files
refactor: Improve users table view for non admins (#5547)
1 parent 5e36fd5 commit 829cfee

File tree

3 files changed

+24
-8
lines changed

3 files changed

+24
-8
lines changed

site/src/components/RoleSelect/RoleSelect.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ const useStyles = makeStyles((theme: Theme) => ({
6969
margin: 0,
7070
// Set a fixed width for the select. It avoids selects having different sizes
7171
// depending on how many roles they have selected.
72-
width: theme.spacing(25),
72+
width: theme.spacing(32),
7373
"& .MuiSelect-root": {
7474
// Adjusting padding because it does not have label
7575
paddingTop: theme.spacing(1.5),

site/src/components/UsersTable/UsersTable.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ export const UsersTable: FC<React.PropsWithChildren<UsersTableProps>> = ({
5454
<Table>
5555
<TableHead>
5656
<TableRow>
57-
<TableCell width="50%">{Language.usernameLabel}</TableCell>
58-
<TableCell width="25%">{Language.statusLabel}</TableCell>
59-
<TableCell width="50%">{Language.lastSeenLabel}</TableCell>
60-
<TableCell width="25%">
57+
<TableCell width="35%">{Language.usernameLabel}</TableCell>
58+
<TableCell width="15%">{Language.statusLabel}</TableCell>
59+
<TableCell width="15%">{Language.lastSeenLabel}</TableCell>
60+
<TableCell width="35%">
6161
<Stack direction="row" spacing={1} alignItems="center">
6262
<span>{Language.rolesLabel}</span>
6363
<UserRoleHelpTooltip />

site/src/components/UsersTable/UsersTableBody.tsx

+19-3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import TableCell from "@material-ui/core/TableCell"
44
import TableRow from "@material-ui/core/TableRow"
55
import { ChooseOne, Cond } from "components/Conditionals/ChooseOne"
66
import { LastUsed } from "components/LastUsed/LastUsed"
7+
import { Pill } from "components/Pill/Pill"
78
import { FC } from "react"
89
import { useTranslation } from "react-i18next"
910
import * as TypesGen from "../../api/typesGenerated"
@@ -136,9 +137,15 @@ export const UsersTableBody: FC<
136137
}}
137138
/>
138139
) : (
139-
<>
140-
{userRoles.map((role) => role.display_name).join(", ")}
141-
</>
140+
<div className={styles.roles}>
141+
{userRoles.map((role) => (
142+
<Pill
143+
key={role.name}
144+
text={role.display_name}
145+
className={styles.rolePill}
146+
/>
147+
))}
148+
</div>
142149
)}
143150
</TableCell>
144151
{canEditUsers && (
@@ -199,4 +206,13 @@ const useStyles = makeStyles((theme) => ({
199206
height: theme.spacing(4.5),
200207
borderRadius: "100%",
201208
},
209+
roles: {
210+
display: "flex",
211+
gap: theme.spacing(1),
212+
flexWrap: "wrap",
213+
},
214+
rolePill: {
215+
backgroundColor: theme.palette.background.paperLight,
216+
borderColor: theme.palette.divider,
217+
},
202218
}))

0 commit comments

Comments
 (0)