Skip to content

feat(site): add tooltip showing the error in the failure badge #9029

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 1 commit into from
Aug 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions site/src/components/WorkspaceStatusBadge/WorkspaceStatusBadge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import {
ImpendingDeletionText,
} from "components/WorkspaceDeletion"
import { getDisplayWorkspaceStatus } from "utils/workspace"
import Tooltip, { TooltipProps, tooltipClasses } from "@mui/material/Tooltip"
import { styled } from "@mui/material/styles"
import Box from "@mui/material/Box"
import ErrorOutline from "@mui/icons-material/ErrorOutline"

export type WorkspaceStatusBadgeProps = {
workspace: Workspace
Expand All @@ -28,6 +32,27 @@ export const WorkspaceStatusBadge: FC<
<Cond condition={Boolean(LockedBadge({ workspace }))}>
<LockedBadge workspace={workspace} />
</Cond>
<Cond condition={workspace.latest_build.status === "failed"}>
<FailureTooltip
title={
<Box sx={{ display: "flex", alignItems: "center", gap: 1.25 }}>
<ErrorOutline
sx={{
width: 14,
height: 14,
color: (theme) => theme.palette.error.light,
}}
/>
<Box>{workspace.latest_build.job.error}</Box>
</Box>
}
placement="top"
>
<div>
<Pill className={className} icon={icon} text={text} type={type} />
</div>
</FailureTooltip>
</Cond>
<Cond>
<Pill className={className} icon={icon} text={text} type={type} />
</Cond>
Expand Down Expand Up @@ -66,6 +91,17 @@ export const WorkspaceStatusText: FC<
)
}

const FailureTooltip = styled(({ className, ...props }: TooltipProps) => (
<Tooltip {...props} classes={{ popper: className }} />
))(({ theme }) => ({
[`& .${tooltipClasses.tooltip}`]: {
backgroundColor: theme.palette.background.paperLight,
border: `1px solid ${theme.palette.divider}`,
fontSize: 12,
padding: theme.spacing(1, 1.25),
},
}))

const useStyles = makeStyles((theme) => ({
root: { fontWeight: 600 },
"type-error": {
Expand Down