Skip to content

Commit 175aed1

Browse files
feat(site): add tooltip showing the error in the failure badge (#9029)
1 parent 83061be commit 175aed1

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

site/src/components/WorkspaceStatusBadge/WorkspaceStatusBadge.tsx

+36
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ import {
99
ImpendingDeletionText,
1010
} from "components/WorkspaceDeletion"
1111
import { getDisplayWorkspaceStatus } from "utils/workspace"
12+
import Tooltip, { TooltipProps, tooltipClasses } from "@mui/material/Tooltip"
13+
import { styled } from "@mui/material/styles"
14+
import Box from "@mui/material/Box"
15+
import ErrorOutline from "@mui/icons-material/ErrorOutline"
1216

1317
export type WorkspaceStatusBadgeProps = {
1418
workspace: Workspace
@@ -28,6 +32,27 @@ export const WorkspaceStatusBadge: FC<
2832
<Cond condition={Boolean(LockedBadge({ workspace }))}>
2933
<LockedBadge workspace={workspace} />
3034
</Cond>
35+
<Cond condition={workspace.latest_build.status === "failed"}>
36+
<FailureTooltip
37+
title={
38+
<Box sx={{ display: "flex", alignItems: "center", gap: 1.25 }}>
39+
<ErrorOutline
40+
sx={{
41+
width: 14,
42+
height: 14,
43+
color: (theme) => theme.palette.error.light,
44+
}}
45+
/>
46+
<Box>{workspace.latest_build.job.error}</Box>
47+
</Box>
48+
}
49+
placement="top"
50+
>
51+
<div>
52+
<Pill className={className} icon={icon} text={text} type={type} />
53+
</div>
54+
</FailureTooltip>
55+
</Cond>
3156
<Cond>
3257
<Pill className={className} icon={icon} text={text} type={type} />
3358
</Cond>
@@ -66,6 +91,17 @@ export const WorkspaceStatusText: FC<
6691
)
6792
}
6893

94+
const FailureTooltip = styled(({ className, ...props }: TooltipProps) => (
95+
<Tooltip {...props} classes={{ popper: className }} />
96+
))(({ theme }) => ({
97+
[`& .${tooltipClasses.tooltip}`]: {
98+
backgroundColor: theme.palette.background.paperLight,
99+
border: `1px solid ${theme.palette.divider}`,
100+
fontSize: 12,
101+
padding: theme.spacing(1, 1.25),
102+
},
103+
}))
104+
69105
const useStyles = makeStyles((theme) => ({
70106
root: { fontWeight: 600 },
71107
"type-error": {

0 commit comments

Comments
 (0)