Skip to content

Commit adb120e

Browse files
committed
refactor: support unhealthy on workspace status indicator
1 parent 3e7ff9d commit adb120e

File tree

3 files changed

+47
-13
lines changed

3 files changed

+47
-13
lines changed

site/src/modules/workspaces/WorkspaceStatusIndicator/WorkspaceStatusIndicator.stories.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,18 @@ export const Running: Story = {
2727
},
2828
};
2929

30+
export const Unhealthy: Story = {
31+
args: {
32+
workspace: {
33+
...createWorkspaceWithStatus("running"),
34+
health: {
35+
healthy: false,
36+
failing_agents: [],
37+
},
38+
},
39+
},
40+
};
41+
3042
export const Stopped: Story = {
3143
args: {
3244
workspace: createWorkspaceWithStatus("stopped"),

site/src/modules/workspaces/WorkspaceStatusIndicator/WorkspaceStatusIndicator.tsx

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ import {
44
StatusIndicatorDot,
55
type StatusIndicatorProps,
66
} from "components/StatusIndicator/StatusIndicator";
7+
import {
8+
Tooltip,
9+
TooltipContent,
10+
TooltipProvider,
11+
TooltipTrigger,
12+
} from "components/Tooltip/Tooltip";
713
import type { FC } from "react";
814
import type React from "react";
915
import {
@@ -32,18 +38,41 @@ export const WorkspaceStatusIndicator: FC<WorkspaceStatusIndicatorProps> = ({
3238
workspace,
3339
children,
3440
}) => {
35-
const { text, type } = getDisplayWorkspaceStatus(
41+
let { text, type } = getDisplayWorkspaceStatus(
3642
workspace.latest_build.status,
3743
workspace.latest_build.job,
3844
);
3945

40-
return (
46+
if (!workspace.health.healthy) {
47+
type = "warning";
48+
}
49+
50+
const statusIndicator = (
4151
<StatusIndicator variant={variantByStatusType[type]}>
4252
<StatusIndicatorDot />
43-
<span>
44-
<span className="sr-only">Workspace status:</span> {text}
45-
</span>
53+
<span className="sr-only">Workspace status:</span> {text}
4654
{children}
4755
</StatusIndicator>
4856
);
57+
58+
if (workspace.health.healthy) {
59+
return statusIndicator;
60+
}
61+
62+
return (
63+
<TooltipProvider>
64+
<Tooltip>
65+
<TooltipTrigger asChild>
66+
<StatusIndicator variant={variantByStatusType[type]}>
67+
<StatusIndicatorDot />
68+
<span className="sr-only">Workspace status:</span> {text}
69+
{children}
70+
</StatusIndicator>
71+
</TooltipTrigger>
72+
<TooltipContent>
73+
Your workspace is running but some agents are unhealthy.
74+
</TooltipContent>
75+
</Tooltip>
76+
</TooltipProvider>
77+
);
4978
};

site/src/pages/WorkspacesPage/WorkspacesTable.tsx

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ export const WorkspacesTable: FC<WorkspacesTableProps> = ({
290290
</TableCell>
291291

292292
<WorkspaceStatusCell workspace={workspace} />
293+
293294
<WorkspaceActionsCell
294295
workspace={workspace}
295296
onActionSuccess={onActionSuccess}
@@ -395,14 +396,6 @@ const WorkspaceStatusCell: FC<WorkspaceStatusCellProps> = ({ workspace }) => {
395396
<TableCell>
396397
<div className="flex flex-col">
397398
<WorkspaceStatusIndicator workspace={workspace}>
398-
{workspace.latest_build.status === "running" &&
399-
!workspace.health.healthy && (
400-
<InfoTooltip
401-
type="warning"
402-
title="Workspace is unhealthy"
403-
message="Your workspace is running but some agents are unhealthy."
404-
/>
405-
)}
406399
{workspace.dormant_at && (
407400
<WorkspaceDormantBadge workspace={workspace} />
408401
)}

0 commit comments

Comments
 (0)