Skip to content

feat: Add dedicated labels to agent status and OS #3759

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 30, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 36 additions & 23 deletions site/src/components/Resources/Resources.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import TableHead from "@material-ui/core/TableHead"
import TableRow from "@material-ui/core/TableRow"
import useTheme from "@material-ui/styles/useTheme"
import { ErrorSummary } from "components/ErrorSummary/ErrorSummary"
import { TableCellDataPrimary } from "components/TableCellData/TableCellData"
import { FC } from "react"
import { getDisplayAgentStatus, getWorkspaceStatus, WorkspaceStateEnum } from "util/workspace"
import { getDisplayAgentStatus } from "util/workspace"
import { Workspace, WorkspaceResource } from "../../api/typesGenerated"
import { AppLink } from "../AppLink/AppLink"
import { SSHButton } from "../SSHButton/SSHButton"
Expand All @@ -24,6 +25,8 @@ const Language = {
resourceLabel: "Resource",
agentsLabel: "Agents",
agentLabel: "Agent",
statusLabel: "status: ",
osLabel: "os: ",
}

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

const workspaceStatus: keyof typeof WorkspaceStateEnum = getWorkspaceStatus(
workspace.latest_build,
)

return (
<div aria-label={Language.resources} className={styles.wrapper}>
{getResourcesError ? (
Expand Down Expand Up @@ -103,21 +102,24 @@ export const Resources: FC<React.PropsWithChildren<ResourcesProps>> = ({
)}

<TableCell className={styles.agentColumn}>
{agent.name}
<div className={styles.agentInfo}>
<span className={styles.operatingSystem}>{agent.operating_system}</span>
{WorkspaceStateEnum[workspaceStatus] !==
WorkspaceStateEnum["stopped"] && (
<TableCellDataPrimary highlight>{agent.name}</TableCellDataPrimary>
<div className={styles.data}>
<div className={styles.dataRow}>
<strong>{Language.statusLabel}</strong>
<span style={{ color: agentStatus.color }} className={styles.status}>
{agentStatus.status}
</span>
)}
</div>
<div className={styles.dataRow}>
<strong>{Language.osLabel}</strong>
<span className={styles.operatingSystem}>{agent.operating_system}</span>
</div>
</div>
</TableCell>
<TableCell>
<>
<div className={styles.accessLinks}>
{canUpdateWorkspace && agent.status === "connected" && (
<div className={styles.accessLinks}>
<>
<SSHButton workspaceName={workspace.name} agentName={agent.name} />
<TerminalLink
workspaceName={workspace.name}
Expand All @@ -134,9 +136,9 @@ export const Resources: FC<React.PropsWithChildren<ResourcesProps>> = ({
agentName={agent.name}
/>
))}
</div>
</>
)}
</>
</div>
</TableCell>
</TableRow>
)
Expand Down Expand Up @@ -181,14 +183,6 @@ const useStyles = makeStyles((theme) => ({
paddingLeft: `${theme.spacing(4)}px !important`,
},

agentInfo: {
display: "flex",
gap: theme.spacing(1.5),
fontSize: 14,
color: theme.palette.text.secondary,
marginTop: theme.spacing(0.5),
},

operatingSystem: {
display: "block",
textTransform: "capitalize",
Expand All @@ -204,4 +198,23 @@ const useStyles = makeStyles((theme) => ({
status: {
whiteSpace: "nowrap",
},

data: {
color: theme.palette.text.secondary,
fontSize: 14,
marginTop: theme.spacing(0.75),
display: "grid",
gridAutoFlow: "row",
whiteSpace: "nowrap",
gap: theme.spacing(0.75),
},

dataRow: {
display: "flex",
alignItems: "center",

"& strong": {
marginRight: theme.spacing(1),
},
},
}))