Skip to content

Commit ecb9971

Browse files
refactor(site) re-design proxies table (#8410)
1 parent 3c2ce4f commit ecb9971

File tree

1 file changed

+58
-40
lines changed

1 file changed

+58
-40
lines changed

site/src/pages/UserSettingsPage/WorkspaceProxyPage/WorkspaceProxyRow.tsx

Lines changed: 58 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { AvatarData } from "components/AvatarData/AvatarData"
33
import { Avatar } from "components/Avatar/Avatar"
44
import TableCell from "@mui/material/TableCell"
55
import TableRow from "@mui/material/TableRow"
6-
import { FC, useState } from "react"
6+
import { FC, ReactNode, useState } from "react"
77
import {
88
HealthyBadge,
99
NotHealthyBadge,
@@ -13,19 +13,14 @@ import {
1313
import { ProxyLatencyReport } from "contexts/useProxyLatency"
1414
import { getLatencyColor } from "utils/latency"
1515
import Collapse from "@mui/material/Collapse"
16-
import { makeStyles } from "@mui/styles"
17-
import { combineClasses } from "utils/combineClasses"
18-
import ListItem from "@mui/material/ListItem"
19-
import List from "@mui/material/List"
20-
import ListSubheader from "@mui/material/ListSubheader"
2116
import { Maybe } from "components/Conditionals/Maybe"
22-
import { CodeExample } from "components/CodeExample/CodeExample"
17+
import { useClickableTableRow } from "hooks"
18+
import Box from "@mui/material/Box"
2319

2420
export const ProxyRow: FC<{
2521
latency?: ProxyLatencyReport
2622
proxy: Region
2723
}> = ({ proxy, latency }) => {
28-
const styles = useStyles()
2924
// If we have a more specific proxy status, use that.
3025
// All users can see healthy/unhealthy, some can see more.
3126
let statusBadge = <ProxyStatus proxy={proxy} />
@@ -47,16 +42,13 @@ export const ProxyRow: FC<{
4742
setIsMsgsOpen((v) => !v)
4843
}
4944
}
45+
const clickableProps = useClickableTableRow(toggle)
46+
const rowProps = shouldShowMessages ? clickableProps : undefined
47+
5048
return (
5149
<>
52-
<TableRow
53-
className={combineClasses({
54-
[styles.clickable]: shouldShowMessages,
55-
})}
56-
key={proxy.name}
57-
data-testid={`${proxy.name}`}
58-
>
59-
<TableCell onClick={toggle}>
50+
<TableRow key={proxy.name} data-testid={proxy.name} {...rowProps}>
51+
<TableCell>
6052
<AvatarData
6153
title={
6254
proxy.display_name && proxy.display_name.length > 0
@@ -94,7 +86,10 @@ export const ProxyRow: FC<{
9486
</TableRow>
9587
<Maybe condition={shouldShowMessages}>
9688
<TableRow>
97-
<TableCell colSpan={4} sx={{ padding: "0px !important" }}>
89+
<TableCell
90+
colSpan={4}
91+
sx={{ padding: "0px !important", borderBottom: 0 }}
92+
>
9893
<Collapse in={isMsgsOpen}>
9994
<ProxyMessagesRow proxy={proxy as WorkspaceProxy} />
10095
</Collapse>
@@ -111,38 +106,71 @@ const ProxyMessagesRow: FC<{
111106
return (
112107
<>
113108
<ProxyMessagesList
114-
title="Errors"
109+
title={
110+
<Box
111+
component="span"
112+
sx={{ color: (theme) => theme.palette.error.light }}
113+
>
114+
Errors
115+
</Box>
116+
}
115117
messages={proxy.status?.report?.errors}
116118
/>
117119
<ProxyMessagesList
118-
title="Warnings"
120+
title={
121+
<Box
122+
component="span"
123+
sx={{ color: (theme) => theme.palette.warning.light }}
124+
>
125+
Warnings
126+
</Box>
127+
}
119128
messages={proxy.status?.report?.warnings}
120129
/>
121130
</>
122131
)
123132
}
124133

125134
const ProxyMessagesList: FC<{
126-
title: string
135+
title: ReactNode
127136
messages?: string[]
128137
}> = ({ title, messages }) => {
129138
if (!messages) {
130139
return <></>
131140
}
141+
132142
return (
133-
<List
134-
subheader={
135-
<ListSubheader component="div" id="nested-list-subheader">
136-
{title}
137-
</ListSubheader>
138-
}
143+
<Box
144+
sx={{
145+
borderBottom: (theme) => `1px solid ${theme.palette.divider}`,
146+
backgroundColor: (theme) => theme.palette.background.default,
147+
p: (theme) => theme.spacing(2, 3),
148+
}}
139149
>
150+
<Box
151+
id="nested-list-subheader"
152+
sx={{
153+
mb: 0.5,
154+
fontSize: 13,
155+
fontWeight: 600,
156+
}}
157+
>
158+
{title}
159+
</Box>
140160
{messages.map((error, index) => (
141-
<ListItem key={"message" + index}>
142-
<CodeExample code={error} />
143-
</ListItem>
161+
<Box
162+
component="pre"
163+
key={"message" + index}
164+
sx={{
165+
margin: (theme) => theme.spacing(0, 0, 1),
166+
fontSize: 14,
167+
whiteSpace: "pre-wrap",
168+
}}
169+
>
170+
{error}
171+
</Box>
144172
))}
145-
</List>
173+
</Box>
146174
)
147175
}
148176

@@ -180,13 +208,3 @@ const ProxyStatus: FC<{
180208

181209
return icon
182210
}
183-
184-
const useStyles = makeStyles((theme) => ({
185-
clickable: {
186-
cursor: "pointer",
187-
188-
"&:hover": {
189-
backgroundColor: theme.palette.action.hover,
190-
},
191-
},
192-
}))

0 commit comments

Comments
 (0)