@@ -3,7 +3,7 @@ import { AvatarData } from "components/AvatarData/AvatarData"
3
3
import { Avatar } from "components/Avatar/Avatar"
4
4
import TableCell from "@mui/material/TableCell"
5
5
import TableRow from "@mui/material/TableRow"
6
- import { FC , useState } from "react"
6
+ import { FC , ReactNode , useState } from "react"
7
7
import {
8
8
HealthyBadge ,
9
9
NotHealthyBadge ,
@@ -13,19 +13,14 @@ import {
13
13
import { ProxyLatencyReport } from "contexts/useProxyLatency"
14
14
import { getLatencyColor } from "utils/latency"
15
15
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"
21
16
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"
23
19
24
20
export const ProxyRow : FC < {
25
21
latency ?: ProxyLatencyReport
26
22
proxy : Region
27
23
} > = ( { proxy, latency } ) => {
28
- const styles = useStyles ( )
29
24
// If we have a more specific proxy status, use that.
30
25
// All users can see healthy/unhealthy, some can see more.
31
26
let statusBadge = < ProxyStatus proxy = { proxy } />
@@ -47,16 +42,13 @@ export const ProxyRow: FC<{
47
42
setIsMsgsOpen ( ( v ) => ! v )
48
43
}
49
44
}
45
+ const clickableProps = useClickableTableRow ( toggle )
46
+ const rowProps = shouldShowMessages ? clickableProps : undefined
47
+
50
48
return (
51
49
< >
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 >
60
52
< AvatarData
61
53
title = {
62
54
proxy . display_name && proxy . display_name . length > 0
@@ -94,7 +86,10 @@ export const ProxyRow: FC<{
94
86
</ TableRow >
95
87
< Maybe condition = { shouldShowMessages } >
96
88
< TableRow >
97
- < TableCell colSpan = { 4 } sx = { { padding : "0px !important" } } >
89
+ < TableCell
90
+ colSpan = { 4 }
91
+ sx = { { padding : "0px !important" , borderBottom : 0 } }
92
+ >
98
93
< Collapse in = { isMsgsOpen } >
99
94
< ProxyMessagesRow proxy = { proxy as WorkspaceProxy } />
100
95
</ Collapse >
@@ -111,38 +106,71 @@ const ProxyMessagesRow: FC<{
111
106
return (
112
107
< >
113
108
< 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
+ }
115
117
messages = { proxy . status ?. report ?. errors }
116
118
/>
117
119
< 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
+ }
119
128
messages = { proxy . status ?. report ?. warnings }
120
129
/>
121
130
</ >
122
131
)
123
132
}
124
133
125
134
const ProxyMessagesList : FC < {
126
- title : string
135
+ title : ReactNode
127
136
messages ?: string [ ]
128
137
} > = ( { title, messages } ) => {
129
138
if ( ! messages ) {
130
139
return < > </ >
131
140
}
141
+
132
142
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
+ } }
139
149
>
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 >
140
160
{ 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 >
144
172
) ) }
145
- </ List >
173
+ </ Box >
146
174
)
147
175
}
148
176
@@ -180,13 +208,3 @@ const ProxyStatus: FC<{
180
208
181
209
return icon
182
210
}
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