mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
fix: add link to troubleshooting (#16592)
Fixes: https://github.com/coder/coder/issues/14933
This commit is contained in:
@@ -100,7 +100,10 @@ export const NotificationActionButton: FC<ButtonProps> = (props) => {
|
||||
variant="text"
|
||||
css={{
|
||||
textDecoration: "underline",
|
||||
padding: 0,
|
||||
paddingLeft: 0,
|
||||
paddingRight: 8,
|
||||
paddingTop: 0,
|
||||
paddingBottom: 0,
|
||||
height: "auto",
|
||||
minWidth: "auto",
|
||||
"&:hover": { background: "none", textDecoration: "underline" },
|
||||
|
||||
@@ -2,7 +2,12 @@ import type { Interpolation, Theme } from "@emotion/react";
|
||||
import InfoOutlined from "@mui/icons-material/InfoOutlined";
|
||||
import WarningRounded from "@mui/icons-material/WarningRounded";
|
||||
import { workspaceResolveAutostart } from "api/queries/workspaceQuota";
|
||||
import type { Template, TemplateVersion, Workspace } from "api/typesGenerated";
|
||||
import type {
|
||||
Template,
|
||||
TemplateVersion,
|
||||
Workspace,
|
||||
WorkspaceBuild,
|
||||
} from "api/typesGenerated";
|
||||
import { MemoizedInlineMarkdown } from "components/Markdown/Markdown";
|
||||
import formatDistanceToNow from "date-fns/formatDistanceToNow";
|
||||
import dayjs from "dayjs";
|
||||
@@ -82,6 +87,9 @@ export const WorkspaceNotifications: FC<WorkspaceNotificationsProps> = ({
|
||||
workspace.latest_build.status === "running" &&
|
||||
!workspace.health.healthy
|
||||
) {
|
||||
const troubleshootingURL = findTroubleshootingURL(workspace.latest_build);
|
||||
const hasActions = permissions.updateWorkspace || troubleshootingURL;
|
||||
|
||||
notifications.push({
|
||||
title: "Workspace is unhealthy",
|
||||
severity: "warning",
|
||||
@@ -94,10 +102,21 @@ export const WorkspaceNotifications: FC<WorkspaceNotificationsProps> = ({
|
||||
.
|
||||
</>
|
||||
),
|
||||
actions: permissions.updateWorkspace ? (
|
||||
<NotificationActionButton onClick={onRestartWorkspace}>
|
||||
Restart
|
||||
</NotificationActionButton>
|
||||
actions: hasActions ? (
|
||||
<>
|
||||
{permissions.updateWorkspace && (
|
||||
<NotificationActionButton onClick={onRestartWorkspace}>
|
||||
Restart
|
||||
</NotificationActionButton>
|
||||
)}
|
||||
{troubleshootingURL && (
|
||||
<NotificationActionButton
|
||||
onClick={() => window.open(troubleshootingURL, "_blank")}
|
||||
>
|
||||
Troubleshooting
|
||||
</NotificationActionButton>
|
||||
)}
|
||||
</>
|
||||
) : undefined,
|
||||
});
|
||||
}
|
||||
@@ -254,3 +273,18 @@ const styles = {
|
||||
gap: 12,
|
||||
},
|
||||
} satisfies Record<string, Interpolation<Theme>>;
|
||||
|
||||
const findTroubleshootingURL = (
|
||||
workspaceBuild: WorkspaceBuild,
|
||||
): string | undefined => {
|
||||
for (const resource of workspaceBuild.resources) {
|
||||
if (resource.agents) {
|
||||
for (const agent of resource.agents) {
|
||||
if (agent.troubleshooting_url) {
|
||||
return agent.troubleshooting_url;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user