-
Notifications
You must be signed in to change notification settings - Fork 929
feat(site): add healthcheck page for provisioner daemons #11494
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
site/src/pages/HealthPage/ProvisionerDaemonsPage.stories.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { StoryObj, Meta } from "@storybook/react"; | ||
import { ProvisionerDaemonsPage } from "./ProvisionerDaemonsPage"; | ||
import { generateMeta } from "./storybook"; | ||
|
||
const meta: Meta = { | ||
title: "pages/Health/ProvisionerDaemons", | ||
...generateMeta({ | ||
path: "/health/provisioner-daemons", | ||
element: <ProvisionerDaemonsPage />, | ||
}), | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj; | ||
|
||
export const Default: Story = {}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,166 @@ | ||
import { Header, HeaderTitle, HealthyDot, Main, Pill } from "./Content"; | ||
import { Helmet } from "react-helmet-async"; | ||
import { pageTitle } from "utils/page"; | ||
import { useTheme } from "@mui/material/styles"; | ||
import { DismissWarningButton } from "./DismissWarningButton"; | ||
import { Alert } from "components/Alert/Alert"; | ||
import { HealthcheckReport } from "api/typesGenerated"; | ||
import { createDayString } from "utils/createDayString"; | ||
|
||
import { useOutletContext } from "react-router-dom"; | ||
import Business from "@mui/icons-material/Business"; | ||
import Person from "@mui/icons-material/Person"; | ||
import SwapHoriz from "@mui/icons-material/SwapHoriz"; | ||
import Tooltip from "@mui/material/Tooltip"; | ||
import Sell from "@mui/icons-material/Sell"; | ||
|
||
export const ProvisionerDaemonsPage = () => { | ||
const healthStatus = useOutletContext<HealthcheckReport>(); | ||
const { provisioner_daemons: daemons } = healthStatus; | ||
const theme = useTheme(); | ||
return ( | ||
<> | ||
<Helmet> | ||
<title>{pageTitle("Provisioner Daemons - Health")}</title> | ||
</Helmet> | ||
|
||
<Header> | ||
<HeaderTitle> | ||
<HealthyDot severity={daemons.severity} /> | ||
Provisioner Daemons | ||
</HeaderTitle> | ||
<DismissWarningButton healthcheck="ProvisionerDaemons" /> | ||
</Header> | ||
|
||
<Main> | ||
{daemons.warnings.map((warning) => { | ||
return ( | ||
<Alert key={warning.code} severity="warning"> | ||
{warning.message} | ||
</Alert> | ||
); | ||
})} | ||
|
||
{daemons.items.map(({ provisioner_daemon: daemon, warnings }) => { | ||
const daemonScope = daemon.tags["scope"] || "organization"; | ||
const iconScope = | ||
daemonScope === "organization" ? <Business /> : <Person />; | ||
const extraTags = Object.keys(daemon.tags) | ||
.filter((key) => key !== "scope" && key !== "owner") | ||
.reduce( | ||
(acc, key) => { | ||
acc[key] = daemon.tags[key]; | ||
return acc; | ||
}, | ||
{} as Record<string, string>, | ||
); | ||
const isWarning = warnings.length > 0; | ||
return ( | ||
<div | ||
key={daemon.name} | ||
css={{ | ||
borderRadius: 8, | ||
border: `1px solid ${ | ||
isWarning | ||
? theme.palette.warning.light | ||
: theme.palette.divider | ||
}`, | ||
fontSize: 14, | ||
}} | ||
> | ||
<header | ||
css={{ | ||
padding: 24, | ||
display: "flex", | ||
alignItems: "center", | ||
justifyContenxt: "space-between", | ||
gap: 24, | ||
}} | ||
> | ||
<div | ||
css={{ | ||
display: "flex", | ||
alignItems: "center", | ||
gap: 24, | ||
objectFit: "fill", | ||
}} | ||
> | ||
<div css={{ lineHeight: "160%" }}> | ||
<h4 css={{ fontWeight: 500, margin: 0 }}>{daemon.name}</h4> | ||
<span css={{ color: theme.palette.text.secondary }}> | ||
<code>{daemon.version}</code> | ||
</span> | ||
</div> | ||
</div> | ||
<div | ||
css={{ | ||
marginLeft: "auto", | ||
display: "flex", | ||
flexWrap: "wrap", | ||
gap: 12, | ||
}} | ||
> | ||
<Tooltip title="API Version"> | ||
<Pill icon={<SwapHoriz />}> | ||
<code>{daemon.api_version}</code> | ||
</Pill> | ||
</Tooltip> | ||
<Tooltip title="Scope"> | ||
<Pill icon={iconScope}> | ||
<span | ||
css={{ | ||
":first-letter": { textTransform: "uppercase" }, | ||
}} | ||
> | ||
{daemonScope} | ||
</span> | ||
</Pill> | ||
</Tooltip> | ||
{Object.keys(extraTags).map((k) => ( | ||
<Tooltip key={k} title={k}> | ||
<Pill key={k} icon={<Sell />}> | ||
{extraTags[k]} | ||
</Pill> | ||
</Tooltip> | ||
))} | ||
</div> | ||
</header> | ||
|
||
<div | ||
css={{ | ||
borderTop: `1px solid ${theme.palette.divider}`, | ||
display: "flex", | ||
alignItems: "center", | ||
justifyContent: "space-between", | ||
padding: "8px 24px", | ||
fontSize: 12, | ||
color: theme.palette.text.secondary, | ||
}} | ||
> | ||
{warnings.length > 0 ? ( | ||
<div css={{ display: "flex", flexDirection: "column" }}> | ||
{warnings.map((warning, i) => ( | ||
<span key={i}>{warning.message}</span> | ||
))} | ||
</div> | ||
) : ( | ||
<span>No warnings</span> | ||
)} | ||
{daemon.last_seen_at && ( | ||
<span | ||
css={{ color: theme.palette.text.secondary }} | ||
data-chromatic="ignore" | ||
> | ||
Last seen {createDayString(daemon.last_seen_at)} | ||
</span> | ||
)} | ||
</div> | ||
</div> | ||
); | ||
})} | ||
</Main> | ||
</> | ||
); | ||
}; | ||
|
||
export default ProvisionerDaemonsPage; |
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also add other stories to cover different conditions of this UI view?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, we need to do this for essentially all of the provisionerd healthchecks. I think this can be resolved in #10785