Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 42f6b71

Browse files
authored
fix: add link to troubleshooting (#16592)
Fixes: #14933
1 parent e39f39e commit 42f6b71

File tree

2 files changed

+43
-6
lines changed

2 files changed

+43
-6
lines changed

site/src/pages/WorkspacePage/WorkspaceNotifications/Notifications.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,10 @@ export const NotificationActionButton: FC<ButtonProps> = (props) => {
100100
variant="text"
101101
css={{
102102
textDecoration: "underline",
103-
padding: 0,
103+
paddingLeft: 0,
104+
paddingRight: 8,
105+
paddingTop: 0,
106+
paddingBottom: 0,
104107
height: "auto",
105108
minWidth: "auto",
106109
"&:hover": { background: "none", textDecoration: "underline" },

site/src/pages/WorkspacePage/WorkspaceNotifications/WorkspaceNotifications.tsx

+39-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@ import type { Interpolation, Theme } from "@emotion/react";
22
import InfoOutlined from "@mui/icons-material/InfoOutlined";
33
import WarningRounded from "@mui/icons-material/WarningRounded";
44
import { workspaceResolveAutostart } from "api/queries/workspaceQuota";
5-
import type { Template, TemplateVersion, Workspace } from "api/typesGenerated";
5+
import type {
6+
Template,
7+
TemplateVersion,
8+
Workspace,
9+
WorkspaceBuild,
10+
} from "api/typesGenerated";
611
import { MemoizedInlineMarkdown } from "components/Markdown/Markdown";
712
import formatDistanceToNow from "date-fns/formatDistanceToNow";
813
import dayjs from "dayjs";
@@ -82,6 +87,9 @@ export const WorkspaceNotifications: FC<WorkspaceNotificationsProps> = ({
8287
workspace.latest_build.status === "running" &&
8388
!workspace.health.healthy
8489
) {
90+
const troubleshootingURL = findTroubleshootingURL(workspace.latest_build);
91+
const hasActions = permissions.updateWorkspace || troubleshootingURL;
92+
8593
notifications.push({
8694
title: "Workspace is unhealthy",
8795
severity: "warning",
@@ -94,10 +102,21 @@ export const WorkspaceNotifications: FC<WorkspaceNotificationsProps> = ({
94102
.
95103
</>
96104
),
97-
actions: permissions.updateWorkspace ? (
98-
<NotificationActionButton onClick={onRestartWorkspace}>
99-
Restart
100-
</NotificationActionButton>
105+
actions: hasActions ? (
106+
<>
107+
{permissions.updateWorkspace && (
108+
<NotificationActionButton onClick={onRestartWorkspace}>
109+
Restart
110+
</NotificationActionButton>
111+
)}
112+
{troubleshootingURL && (
113+
<NotificationActionButton
114+
onClick={() => window.open(troubleshootingURL, "_blank")}
115+
>
116+
Troubleshooting
117+
</NotificationActionButton>
118+
)}
119+
</>
101120
) : undefined,
102121
});
103122
}
@@ -254,3 +273,18 @@ const styles = {
254273
gap: 12,
255274
},
256275
} satisfies Record<string, Interpolation<Theme>>;
276+
277+
const findTroubleshootingURL = (
278+
workspaceBuild: WorkspaceBuild,
279+
): string | undefined => {
280+
for (const resource of workspaceBuild.resources) {
281+
if (resource.agents) {
282+
for (const agent of resource.agents) {
283+
if (agent.troubleshooting_url) {
284+
return agent.troubleshooting_url;
285+
}
286+
}
287+
}
288+
}
289+
return undefined;
290+
};

0 commit comments

Comments
 (0)