- Notifications
You must be signed in to change notification settings - Fork1k
fix: display health alert inDeploymentBannerView
#10193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
3893821
5682238
f59d467
8cca491
bee5ecb
9600c49
78f701c
626f4f6
5785c4d
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1516,14 +1516,17 @@ export const getInsightsTemplate = async ( | ||
return response.data; | ||
}; | ||
export interface Health { | ||
Parkreiner marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
healthy: boolean; | ||
time: string; | ||
coder_version: string; | ||
access_url: { healthy: boolean }; | ||
database: { healthy: boolean }; | ||
derp: { healthy: boolean }; | ||
websocket: { healthy: boolean }; | ||
} | ||
export const getHealth = async () => { | ||
const response = await axios.get<Health>("/api/v2/debug/health"); | ||
return response.data; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -17,6 +17,13 @@ export const deploymentDAUs = () => { | ||
export const deploymentStats = () => { | ||
return { | ||
queryKey: ["deployment", "stats"], | ||
queryFn: API.getDeploymentStats, | ||
}; | ||
}; | ||
export const health = () => { | ||
return { | ||
queryKey: ["deployment", "health"], | ||
Parkreiner marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
queryFn: API.getHealth, | ||
}; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,14 @@ | ||
import type { Health } from "api/api"; | ||
import type { DeploymentStats, WorkspaceStatus } from "api/typesGenerated"; | ||
import { | ||
type FC, | ||
useMemo, | ||
useEffect, | ||
useState, | ||
PropsWithChildren, | ||
} from "react"; | ||
import prettyBytes from "pretty-bytes"; | ||
import BuildingIcon from "@mui/icons-material/Build"; | ||
import Tooltip from "@mui/material/Tooltip"; | ||
import { Link as RouterLink } from "react-router-dom"; | ||
import Link from "@mui/material/Link"; | ||
@@ -12,13 +17,26 @@ import DownloadIcon from "@mui/icons-material/CloudDownload"; | ||
import UploadIcon from "@mui/icons-material/CloudUpload"; | ||
import LatencyIcon from "@mui/icons-material/SettingsEthernet"; | ||
import WebTerminalIcon from "@mui/icons-material/WebAsset"; | ||
import CollectedIcon from "@mui/icons-material/Compare"; | ||
import RefreshIcon from "@mui/icons-material/Refresh"; | ||
import Button from "@mui/material/Button"; | ||
import { css as className } from "@emotion/css"; | ||
import { | ||
css, | ||
type CSSObject, | ||
type Theme, | ||
type Interpolation, | ||
useTheme, | ||
} from "@emotion/react"; | ||
import dayjs from "dayjs"; | ||
import { TerminalIcon } from "components/Icons/TerminalIcon"; | ||
import { RocketIcon } from "components/Icons/RocketIcon"; | ||
import ErrorIcon from "@mui/icons-material/ErrorOutline"; | ||
import { MONOSPACE_FONT_FAMILY } from "theme/constants"; | ||
import { getDisplayWorkspaceStatus } from "utils/workspace"; | ||
import { colors } from "theme/colors"; | ||
import { HelpTooltipTitle } from "components/HelpTooltip/HelpTooltip"; | ||
import { Stack } from "components/Stack/Stack"; | ||
export const bannerHeight = 36; | ||
@@ -49,14 +67,13 @@ const styles = { | ||
} satisfies Record<string, Interpolation<Theme>>; | ||
export interface DeploymentBannerViewProps { | ||
health?:Health; | ||
stats?: DeploymentStats; | ||
fetchStats?: () => void; | ||
} | ||
export const DeploymentBannerView: FC<DeploymentBannerViewProps> = (props) => { | ||
const { health, stats, fetchStats } = props; | ||
const theme = useTheme(); | ||
const aggregatedMinutes = useMemo(() => { | ||
if (!stats) { | ||
@@ -105,14 +122,43 @@ export const DeploymentBannerView: FC<DeploymentBannerViewProps> = ({ | ||
// eslint-disable-next-line react-hooks/exhaustive-deps -- We want this to periodically update! | ||
}, [timeUntilRefresh, stats]); | ||
const unhealthy = health && !health.healthy; | ||
aslilac marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
const statusBadgeStyle = css` | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
background-color: ${unhealthy ? colors.red[10] : undefined}; | ||
padding: ${theme.spacing(0, 1.5)}; | ||
height: ${bannerHeight}px; | ||
color: #fff; | ||
& svg { | ||
width: 16px; | ||
height: 16px; | ||
} | ||
`; | ||
const statusSummaryStyle = className` | ||
aslilac marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
${theme.typography.body2 as CSSObject} | ||
margin: ${theme.spacing(0, 0, 0.5, 1.5)}; | ||
width: ${theme.spacing(50)}; | ||
padding: ${theme.spacing(2)}; | ||
color: ${theme.palette.text.primary}; | ||
background-color: ${theme.palette.background.paper}; | ||
border: 1px solid ${theme.palette.divider}; | ||
pointer-events: none; | ||
`; | ||
return ( | ||
<div | ||
css={{ | ||
position: "sticky", | ||
height: bannerHeight, | ||
bottom: 0, | ||
zIndex: 1, | ||
paddingRight: theme.spacing(2), | ||
backgroundColor: theme.palette.background.paper, | ||
display: "flex", | ||
alignItems: "center", | ||
@@ -124,24 +170,51 @@ export const DeploymentBannerView: FC<DeploymentBannerViewProps> = ({ | ||
whiteSpace: "nowrap", | ||
}} | ||
> | ||
<Tooltip | ||
classes={{ tooltip: statusSummaryStyle }} | ||
title={ | ||
unhealthy ? ( | ||
<> | ||
<HelpTooltipTitle> | ||
We have detected problems with your Coder deployment. | ||
</HelpTooltipTitle> | ||
<Stack spacing={1}> | ||
{health.access_url && ( | ||
<HealthIssue> | ||
Your access URL may be configured incorrectly. | ||
</HealthIssue> | ||
)} | ||
{health.database && ( | ||
<HealthIssue>Your database is unhealthy.</HealthIssue> | ||
)} | ||
{health.derp && ( | ||
<HealthIssue> | ||
We're noticing DERP proxy issues. | ||
</HealthIssue> | ||
)} | ||
{health.websocket && ( | ||
<HealthIssue> | ||
We're noticing websocket issues. | ||
</HealthIssue> | ||
)} | ||
</Stack> | ||
</> | ||
) : ( | ||
<>Status of your Coder deployment. Only visible for admins!</> | ||
) | ||
} | ||
open={process.env.STORYBOOK === "true" ? true : undefined} | ||
css={{ marginRight: theme.spacing(-2) }} | ||
> | ||
{unhealthy ? ( | ||
<Link component={RouterLink} to="/health" css={statusBadgeStyle}> | ||
<ErrorIcon /> | ||
</Link> | ||
) : ( | ||
<div css={statusBadgeStyle}> | ||
<RocketIcon /> | ||
</div> | ||
)} | ||
</Tooltip> | ||
<div css={styles.group}> | ||
<div css={styles.category}>Workspaces</div> | ||
@@ -330,3 +403,12 @@ const WorkspaceBuildValue: FC<{ | ||
</Tooltip> | ||
); | ||
}; | ||
const HealthIssue: FC<PropsWithChildren> = ({ children }) => { | ||
return ( | ||
<Stack direction="row" spacing={1}> | ||
<ErrorIcon fontSize="small" htmlColor={colors.red[10]} /> | ||
{children} | ||
</Stack> | ||
); | ||
}; |
This file was deleted.
Uh oh!
There was an error while loading.Please reload this page.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -159,9 +159,7 @@ export const HelpTooltip: FC<PropsWithChildren<HelpTooltipProps>> = ({ | ||
); | ||
}; | ||
export const HelpTooltipTitle: FC<PropsWithChildren> = ({ children }) => { | ||
return <h4 css={styles.title}>{children}</h4>; | ||
}; | ||
@@ -242,7 +240,7 @@ const styles = { | ||
marginBottom: theme.spacing(1), | ||
color: theme.palette.text.primary, | ||
fontSize: 14, | ||
lineHeight: "150%", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. I'm wondering if this could be changed to just There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Not sure what you mean by "work better with CSS inheritance". There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. I wish they were the same, butthey aren't There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. why is CSS like this 😭 | ||
fontWeight: 600, | ||
}), | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -2,11 +2,6 @@ import { Meta, StoryObj } from "@storybook/react"; | ||
import { PopoverContainer } from "./PopoverContainer"; | ||
import Button from "@mui/material/Button"; | ||
aslilac marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
const meta: Meta<typeof PopoverContainer> = { | ||
title: "components/PopoverContainer", | ||
component: PopoverContainer, | ||
Uh oh!
There was an error while loading.Please reload this page.