Skip to content

Commit afb66eb

Browse files
committed
refactor: Update workspace status to be the latest job status
1 parent 3be3bc2 commit afb66eb

File tree

3 files changed

+41
-6
lines changed

3 files changed

+41
-6
lines changed

site/src/components/WorkspaceStats/WorkspaceStats.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ import { Link as RouterLink } from "react-router-dom"
66
import { Workspace } from "../../api/typesGenerated"
77
import { CardRadius, MONOSPACE_FONT_FAMILY } from "../../theme/constants"
88
import { combineClasses } from "../../util/combineClasses"
9-
import { getDisplayStatus } from "../../util/workspace"
9+
import { displayBuildStatus } from "../../util/workspace"
1010

1111
const Language = {
1212
templateLabel: "Template",
13-
statusLabel: "Status",
13+
statusLabel: "Last job status",
1414
versionLabel: "Version",
1515
lastBuiltLabel: "Last Built",
1616
outdated: "Outdated",
@@ -24,7 +24,7 @@ export interface WorkspaceStatsProps {
2424
export const WorkspaceStats: FC<WorkspaceStatsProps> = ({ workspace }) => {
2525
const styles = useStyles()
2626
const theme = useTheme()
27-
const status = getDisplayStatus(theme, workspace.latest_build)
27+
const status = displayBuildStatus(theme, workspace.latest_build)
2828

2929
return (
3030
<div className={styles.stats}>

site/src/pages/WorkspacesPage/WorkspacesPageView.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { AvatarData } from "../../components/AvatarData/AvatarData"
1717
import { EmptyState } from "../../components/EmptyState/EmptyState"
1818
import { Stack } from "../../components/Stack/Stack"
1919
import { TableLoader } from "../../components/TableLoader/TableLoader"
20-
import { getDisplayStatus } from "../../util/workspace"
20+
import { displayBuildStatus } from "../../util/workspace"
2121

2222
dayjs.extend(relativeTime)
2323

@@ -45,7 +45,7 @@ export const WorkspacesPageView: FC<WorkspacesPageViewProps> = ({ loading, works
4545
<TableCell>Template</TableCell>
4646
<TableCell>Version</TableCell>
4747
<TableCell>Last Built</TableCell>
48-
<TableCell>Status</TableCell>
48+
<TableCell>Last Job Status</TableCell>
4949
</TableRow>
5050
</TableHead>
5151
<TableBody>
@@ -67,7 +67,7 @@ export const WorkspacesPageView: FC<WorkspacesPageViewProps> = ({ loading, works
6767
)}
6868
{workspaces &&
6969
workspaces.map((workspace) => {
70-
const status = getDisplayStatus(theme, workspace.latest_build)
70+
const status = displayBuildStatus(theme, workspace.latest_build)
7171
return (
7272
<TableRow key={workspace.id}>
7373
<TableCell>

site/src/util/workspace.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,41 @@ export const displayWorkspaceBuildDuration = (
156156
return duration ? `${duration} seconds` : inProgressLabel
157157
}
158158

159+
export const displayBuildStatus = (theme: Theme, build: TypesGen.WorkspaceBuild): { color: string; status: string } => {
160+
switch (build.job.status) {
161+
case "canceled":
162+
return {
163+
color: theme.palette.text.secondary,
164+
status: "ⓧ Canceled",
165+
}
166+
case "canceling":
167+
return {
168+
color: theme.palette.text.secondary,
169+
status: "◍ Canceling",
170+
}
171+
case "failed":
172+
return {
173+
color: theme.palette.error.main,
174+
status: "ⓧ Failed",
175+
}
176+
case "pending":
177+
return {
178+
color: theme.palette.text.secondary,
179+
status: "⦿ Pending",
180+
}
181+
case "running":
182+
return {
183+
color: theme.palette.primary.main,
184+
status: "⦿ Running",
185+
}
186+
case "succeeded":
187+
return {
188+
color: theme.palette.success.main,
189+
status: "⦿ Succeeded",
190+
}
191+
}
192+
}
193+
159194
export const DisplayAgentStatusLanguage = {
160195
connected: "⦿ Connected",
161196
connecting: "⦿ Connecting",

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy