Skip to content

Commit 01a06e1

Browse files
authored
feat: Add dedicated labels to agent status and OS (coder#3759)
1 parent a410ac4 commit 01a06e1

File tree

1 file changed

+36
-23
lines changed

1 file changed

+36
-23
lines changed

site/src/components/Resources/Resources.tsx

Lines changed: 36 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ import TableHead from "@material-ui/core/TableHead"
77
import TableRow from "@material-ui/core/TableRow"
88
import useTheme from "@material-ui/styles/useTheme"
99
import { ErrorSummary } from "components/ErrorSummary/ErrorSummary"
10+
import { TableCellDataPrimary } from "components/TableCellData/TableCellData"
1011
import { FC } from "react"
11-
import { getDisplayAgentStatus, getWorkspaceStatus, WorkspaceStateEnum } from "util/workspace"
12+
import { getDisplayAgentStatus } from "util/workspace"
1213
import { Workspace, WorkspaceResource } from "../../api/typesGenerated"
1314
import { AppLink } from "../AppLink/AppLink"
1415
import { SSHButton } from "../SSHButton/SSHButton"
@@ -24,6 +25,8 @@ const Language = {
2425
resourceLabel: "Resource",
2526
agentsLabel: "Agents",
2627
agentLabel: "Agent",
28+
statusLabel: "status: ",
29+
osLabel: "os: ",
2730
}
2831

2932
interface ResourcesProps {
@@ -42,10 +45,6 @@ export const Resources: FC<React.PropsWithChildren<ResourcesProps>> = ({
4245
const styles = useStyles()
4346
const theme: Theme = useTheme()
4447

45-
const workspaceStatus: keyof typeof WorkspaceStateEnum = getWorkspaceStatus(
46-
workspace.latest_build,
47-
)
48-
4948
return (
5049
<div aria-label={Language.resources} className={styles.wrapper}>
5150
{getResourcesError ? (
@@ -103,21 +102,24 @@ export const Resources: FC<React.PropsWithChildren<ResourcesProps>> = ({
103102
)}
104103

105104
<TableCell className={styles.agentColumn}>
106-
{agent.name}
107-
<div className={styles.agentInfo}>
108-
<span className={styles.operatingSystem}>{agent.operating_system}</span>
109-
{WorkspaceStateEnum[workspaceStatus] !==
110-
WorkspaceStateEnum["stopped"] && (
105+
<TableCellDataPrimary highlight>{agent.name}</TableCellDataPrimary>
106+
<div className={styles.data}>
107+
<div className={styles.dataRow}>
108+
<strong>{Language.statusLabel}</strong>
111109
<span style={{ color: agentStatus.color }} className={styles.status}>
112110
{agentStatus.status}
113111
</span>
114-
)}
112+
</div>
113+
<div className={styles.dataRow}>
114+
<strong>{Language.osLabel}</strong>
115+
<span className={styles.operatingSystem}>{agent.operating_system}</span>
116+
</div>
115117
</div>
116118
</TableCell>
117119
<TableCell>
118-
<>
120+
<div className={styles.accessLinks}>
119121
{canUpdateWorkspace && agent.status === "connected" && (
120-
<div className={styles.accessLinks}>
122+
<>
121123
<SSHButton workspaceName={workspace.name} agentName={agent.name} />
122124
<TerminalLink
123125
workspaceName={workspace.name}
@@ -134,9 +136,9 @@ export const Resources: FC<React.PropsWithChildren<ResourcesProps>> = ({
134136
agentName={agent.name}
135137
/>
136138
))}
137-
</div>
139+
</>
138140
)}
139-
</>
141+
</div>
140142
</TableCell>
141143
</TableRow>
142144
)
@@ -181,14 +183,6 @@ const useStyles = makeStyles((theme) => ({
181183
paddingLeft: `${theme.spacing(4)}px !important`,
182184
},
183185

184-
agentInfo: {
185-
display: "flex",
186-
gap: theme.spacing(1.5),
187-
fontSize: 14,
188-
color: theme.palette.text.secondary,
189-
marginTop: theme.spacing(0.5),
190-
},
191-
192186
operatingSystem: {
193187
display: "block",
194188
textTransform: "capitalize",
@@ -204,4 +198,23 @@ const useStyles = makeStyles((theme) => ({
204198
status: {
205199
whiteSpace: "nowrap",
206200
},
201+
202+
data: {
203+
color: theme.palette.text.secondary,
204+
fontSize: 14,
205+
marginTop: theme.spacing(0.75),
206+
display: "grid",
207+
gridAutoFlow: "row",
208+
whiteSpace: "nowrap",
209+
gap: theme.spacing(0.75),
210+
},
211+
212+
dataRow: {
213+
display: "flex",
214+
alignItems: "center",
215+
216+
"& strong": {
217+
marginRight: theme.spacing(1),
218+
},
219+
},
207220
}))

0 commit comments

Comments
 (0)