Skip to content

Commit fb88fa8

Browse files
feat(site): display error messages on ws and access url health pages (#12430)
Close #12408
1 parent 4343998 commit fb88fa8

File tree

6 files changed

+90
-8
lines changed

6 files changed

+90
-8
lines changed

site/src/pages/HealthPage/AccessURLPage.stories.tsx

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
import { StoryObj, Meta } from "@storybook/react";
1+
import { StoryObj } from "@storybook/react";
22
import { AccessURLPage } from "./AccessURLPage";
33
import { generateMeta } from "./storybook";
4+
import { HEALTH_QUERY_KEY } from "api/queries/debug";
5+
import { MockHealth } from "testHelpers/entities";
6+
import { HealthcheckReport } from "api/typesGenerated";
47

5-
const meta: Meta = {
8+
const meta = {
69
title: "pages/Health/AccessURL",
710
...generateMeta({
811
path: "/health/access-url",
@@ -15,4 +18,27 @@ type Story = StoryObj;
1518

1619
const Example: Story = {};
1720

21+
const settingsWithError: HealthcheckReport = {
22+
...MockHealth,
23+
severity: "error",
24+
access_url: {
25+
...MockHealth.access_url,
26+
severity: "error",
27+
error:
28+
'EACS03: get healthz endpoint: Get "https://localhost:7080/healthz": http: server gave HTTP response to HTTPS client',
29+
},
30+
};
31+
32+
export const WithError: Story = {
33+
parameters: {
34+
queries: [
35+
...meta.parameters.queries,
36+
{
37+
key: HEALTH_QUERY_KEY,
38+
data: settingsWithError,
39+
},
40+
],
41+
},
42+
};
43+
1844
export { Example as AccessURL };

site/src/pages/HealthPage/AccessURLPage.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ export const AccessURLPage = () => {
3434
</Header>
3535

3636
<Main>
37+
{accessUrl.error && <Alert severity="error">{accessUrl.error}</Alert>}
38+
3739
{accessUrl.warnings.map((warning) => {
3840
return (
3941
<Alert

site/src/pages/HealthPage/WebsocketPage.stories.tsx

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
import { StoryObj, Meta } from "@storybook/react";
1+
import { StoryObj } from "@storybook/react";
22
import { WebsocketPage } from "./WebsocketPage";
33
import { generateMeta } from "./storybook";
4+
import { HEALTH_QUERY_KEY } from "api/queries/debug";
5+
import { HealthcheckReport } from "api/typesGenerated";
6+
import { MockHealth } from "testHelpers/entities";
47

5-
const meta: Meta = {
8+
const meta = {
69
title: "pages/Health/Websocket",
710
...generateMeta({
811
path: "/health/websocket",
@@ -15,4 +18,27 @@ type Story = StoryObj;
1518

1619
const Example: Story = {};
1720

21+
const settingsWithError: HealthcheckReport = {
22+
...MockHealth,
23+
severity: "error",
24+
websocket: {
25+
...MockHealth.websocket,
26+
severity: "error",
27+
error:
28+
'EACS03: get healthz endpoint: Get "https://localhost:7080/healthz": http: server gave HTTP response to HTTPS client',
29+
},
30+
};
31+
32+
export const WithError: Story = {
33+
parameters: {
34+
queries: [
35+
...meta.parameters.queries,
36+
{
37+
key: HEALTH_QUERY_KEY,
38+
data: settingsWithError,
39+
},
40+
],
41+
},
42+
};
43+
1844
export { Example as Websocket };

site/src/pages/HealthPage/WebsocketPage.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ export const WebsocketPage = () => {
3737
</Header>
3838

3939
<Main>
40+
{websocket.error && <Alert severity="error">{websocket.error}</Alert>}
41+
4042
{websocket.warnings.map((warning) => {
4143
return (
4244
<Alert key={warning} severity="warning">

site/src/pages/HealthPage/WorkspaceProxyPage.stories.tsx

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
import { StoryObj, Meta } from "@storybook/react";
1+
import { StoryObj } from "@storybook/react";
22
import { WorkspaceProxyPage } from "./WorkspaceProxyPage";
33
import { generateMeta } from "./storybook";
4+
import { HealthcheckReport } from "api/typesGenerated";
5+
import { HEALTH_QUERY_KEY } from "api/queries/debug";
6+
import { MockHealth } from "testHelpers/entities";
47

5-
const meta: Meta = {
8+
const meta = {
69
title: "pages/Health/WorkspaceProxy",
710
...generateMeta({
811
path: "/health/workspace-proxy",
@@ -15,4 +18,27 @@ type Story = StoryObj;
1518

1619
const Example: Story = {};
1720

21+
const settingsWithError: HealthcheckReport = {
22+
...MockHealth,
23+
severity: "error",
24+
workspace_proxy: {
25+
...MockHealth.workspace_proxy,
26+
severity: "error",
27+
error:
28+
'EACS03: get healthz endpoint: Get "https://localhost:7080/healthz": http: server gave HTTP response to HTTPS client',
29+
},
30+
};
31+
32+
export const WithError: Story = {
33+
parameters: {
34+
queries: [
35+
...meta.parameters.queries,
36+
{
37+
key: HEALTH_QUERY_KEY,
38+
data: settingsWithError,
39+
},
40+
],
41+
},
42+
};
43+
1844
export { Example as WorkspaceProxy };

site/src/pages/HealthPage/storybook.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ type MetaOptions = {
2323
params?: Record<string, string>;
2424
};
2525

26-
export const generateMeta = ({ element, path, params }: MetaOptions): Meta => {
26+
export const generateMeta = ({ element, path, params }: MetaOptions) => {
2727
return {
2828
component: HealthLayout,
2929
parameters: {
@@ -43,5 +43,5 @@ export const generateMeta = ({ element, path, params }: MetaOptions): Meta => {
4343
],
4444
decorators: [withDashboardProvider],
4545
},
46-
};
46+
} satisfies Meta;
4747
};

0 commit comments

Comments
 (0)