mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat(site): add tooltip showing the error in the failure badge (#9029)
This commit is contained in:
@@ -9,6 +9,10 @@ import {
|
|||||||
ImpendingDeletionText,
|
ImpendingDeletionText,
|
||||||
} from "components/WorkspaceDeletion"
|
} from "components/WorkspaceDeletion"
|
||||||
import { getDisplayWorkspaceStatus } from "utils/workspace"
|
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 = {
|
export type WorkspaceStatusBadgeProps = {
|
||||||
workspace: Workspace
|
workspace: Workspace
|
||||||
@@ -28,6 +32,27 @@ export const WorkspaceStatusBadge: FC<
|
|||||||
<Cond condition={Boolean(LockedBadge({ workspace }))}>
|
<Cond condition={Boolean(LockedBadge({ workspace }))}>
|
||||||
<LockedBadge workspace={workspace} />
|
<LockedBadge workspace={workspace} />
|
||||||
</Cond>
|
</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>
|
<Cond>
|
||||||
<Pill className={className} icon={icon} text={text} type={type} />
|
<Pill className={className} icon={icon} text={text} type={type} />
|
||||||
</Cond>
|
</Cond>
|
||||||
@@ -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) => ({
|
const useStyles = makeStyles((theme) => ({
|
||||||
root: { fontWeight: 600 },
|
root: { fontWeight: 600 },
|
||||||
"type-error": {
|
"type-error": {
|
||||||
|
|||||||
Reference in New Issue
Block a user