Skip to content

Commit 8a6bfc9

Browse files
feat(site): do not show health warning when the warning is dismissed (#11068)
1 parent 2947b82 commit 8a6bfc9

File tree

2 files changed

+44
-21
lines changed

2 files changed

+44
-21
lines changed

site/src/components/Dashboard/DeploymentBanner/DeploymentBannerView.stories.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,15 @@ export const WithHealthIssues: Story = {
2323
health: DeploymentHealthUnhealthy,
2424
},
2525
};
26+
27+
export const WithDismissedHealthIssues: Story = {
28+
args: {
29+
health: {
30+
...DeploymentHealthUnhealthy,
31+
workspace_proxy: {
32+
...DeploymentHealthUnhealthy.workspace_proxy,
33+
dismissed: true,
34+
},
35+
},
36+
},
37+
};

site/src/components/Dashboard/DeploymentBanner/DeploymentBannerView.tsx

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ export const DeploymentBannerView: FC<DeploymentBannerViewProps> = ({
105105
// eslint-disable-next-line react-hooks/exhaustive-deps -- We want this to periodically update!
106106
}, [timeUntilRefresh, stats]);
107107

108-
const unhealthy = health && !health.healthy;
108+
const healthErrors = health ? getHealthErrors(health) : [];
109109
const displayLatency = stats?.workspaces.connection_latency_ms.P50 || -1;
110110

111111
return (
@@ -131,30 +131,15 @@ export const DeploymentBannerView: FC<DeploymentBannerViewProps> = ({
131131
<Tooltip
132132
classes={{ tooltip: summaryTooltip }}
133133
title={
134-
unhealthy ? (
134+
healthErrors.length > 0 ? (
135135
<>
136136
<HelpTooltipTitle>
137137
We have detected problems with your Coder deployment.
138138
</HelpTooltipTitle>
139139
<Stack spacing={1}>
140-
{!health.access_url.healthy && (
141-
<HealthIssue>
142-
Your access URL may be configured incorrectly.
143-
</HealthIssue>
144-
)}
145-
{!health.database.healthy && (
146-
<HealthIssue>Your database is unhealthy.</HealthIssue>
147-
)}
148-
{!health.derp.healthy && (
149-
<HealthIssue>
150-
We&apos;re noticing DERP proxy issues.
151-
</HealthIssue>
152-
)}
153-
{!health.websocket.healthy && (
154-
<HealthIssue>
155-
We&apos;re noticing websocket issues.
156-
</HealthIssue>
157-
)}
140+
{healthErrors.map((error) => (
141+
<HealthIssue key={error}>{error}</HealthIssue>
142+
))}
158143
</Stack>
159144
</>
160145
) : (
@@ -164,7 +149,7 @@ export const DeploymentBannerView: FC<DeploymentBannerViewProps> = ({
164149
open={process.env.STORYBOOK === "true" ? true : undefined}
165150
css={{ marginRight: -16 }}
166151
>
167-
{unhealthy ? (
152+
{healthErrors.length > 0 ? (
168153
<Link
169154
component={RouterLink}
170155
to="/health"
@@ -380,6 +365,32 @@ const HealthIssue: FC<PropsWithChildren> = ({ children }) => {
380365
);
381366
};
382367

368+
const getHealthErrors = (health: HealthcheckReport) => {
369+
const warnings: string[] = [];
370+
const sections = [
371+
"access_url",
372+
"database",
373+
"derp",
374+
"websocket",
375+
"workspace_proxy",
376+
] as const;
377+
const messages: Record<(typeof sections)[number], string> = {
378+
access_url: "Your access URL may be configured incorrectly.",
379+
database: "Your database is unhealthy.",
380+
derp: "We're noticing DERP proxy issues.",
381+
websocket: "We're noticing websocket issues.",
382+
workspace_proxy: "We're noticing workspace proxy issues.",
383+
} as const;
384+
385+
sections.forEach((section) => {
386+
if (health[section].severity === "error" && !health[section].dismissed) {
387+
warnings.push(messages[section]);
388+
}
389+
});
390+
391+
return warnings;
392+
};
393+
383394
const classNames = {
384395
summaryTooltip: (css, theme) => css`
385396
${theme.typography.body2 as CSSObject}

0 commit comments

Comments
 (0)