Skip to content

Commit 7d875b8

Browse files
committed
use popover instead of tooltip for template info
1 parent ea3973f commit 7d875b8

File tree

2 files changed

+67
-49
lines changed

2 files changed

+67
-49
lines changed

site/src/components/AvatarData/AvatarData.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import type { FC } from "react";
1+
import type { FC, ReactNode } from "react";
22
import { useTheme } from "@emotion/react";
33
import { Avatar } from "components/Avatar/Avatar";
44
import { Stack } from "components/Stack/Stack";
55

66
export interface AvatarDataProps {
7-
title: string | JSX.Element;
8-
subtitle?: string;
7+
title: ReactNode;
8+
subtitle?: ReactNode;
99
src?: string;
1010
avatar?: React.ReactNode;
1111
}

site/src/pages/WorkspacePage/WorkspaceTopbar/WorkspaceTopbar.tsx

Lines changed: 64 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,8 @@ import {
1111
} from "components/FullPageLayout/Topbar";
1212
import Tooltip from "@mui/material/Tooltip";
1313
import ArrowBackOutlined from "@mui/icons-material/ArrowBackOutlined";
14-
import { WorkspaceOutdatedTooltipContent } from "components/WorkspaceOutdatedTooltip/WorkspaceOutdatedTooltip";
15-
import { Popover, PopoverTrigger } from "components/Popover/Popover";
1614
import ScheduleOutlined from "@mui/icons-material/ScheduleOutlined";
1715
import { WorkspaceStatusBadge } from "components/WorkspaceStatusBadge/WorkspaceStatusBadge";
18-
import { Pill } from "components/Pill/Pill";
1916
import {
2017
WorkspaceScheduleControls,
2118
shouldDisplayScheduleControls,
@@ -24,12 +21,15 @@ import { workspaceQuota } from "api/queries/workspaceQuota";
2421
import { useQuery } from "react-query";
2522
import MonetizationOnOutlined from "@mui/icons-material/MonetizationOnOutlined";
2623
import { useTheme } from "@mui/material/styles";
27-
import InfoOutlined from "@mui/icons-material/InfoOutlined";
2824
import Link from "@mui/material/Link";
2925
import { useDashboard } from "components/Dashboard/DashboardProvider";
3026
import { displayDormantDeletion } from "utils/dormant";
3127
import DeleteOutline from "@mui/icons-material/DeleteOutline";
3228
import PersonOutline from "@mui/icons-material/PersonOutline";
29+
import { Popover, PopoverTrigger } from "components/Popover/Popover";
30+
import { HelpTooltipContent } from "components/HelpTooltip/HelpTooltip";
31+
import { AvatarData } from "components/AvatarData/AvatarData";
32+
import { Avatar } from "components/Avatar/Avatar";
3333

3434
export type WorkspaceError =
3535
| "getBuildsError"
@@ -127,52 +127,70 @@ export const WorkspaceTopbar = (props: WorkspaceProps) => {
127127
<span>{workspace.owner_name}</span>
128128
</Tooltip>
129129
<TopbarDivider />
130-
<Tooltip
131-
title={workspace.template_display_name ?? workspace.template_name}
130+
<Popover
131+
mode="hover"
132+
// title={`${
133+
// workspace.template_display_name ?? workspace.template_name
134+
// } on version ${workspace.latest_build.template_version_name}`}
132135
>
133-
<Link
134-
component={RouterLink}
135-
to={`/templates/${workspace.template_name}`}
136-
css={{ color: "inherit" }}
137-
>
138-
<TopbarAvatar src={workspace.template_icon} />
139-
</Link>
140-
</Tooltip>
141-
142-
<span css={{ fontWeight: 500 }}>{workspace.name}</span>
136+
<PopoverTrigger>
137+
<span
138+
css={{
139+
display: "flex",
140+
alignItems: "center",
141+
gap: 8,
142+
cursor: "default",
143+
padding: "4px 0",
144+
}}
145+
>
146+
<TopbarAvatar src={workspace.template_icon} />
147+
<span css={{ fontWeight: 500 }}>{workspace.name}</span>
148+
</span>
149+
</PopoverTrigger>
143150

144-
{workspace.outdated ? (
145-
<Popover mode="hover">
146-
<PopoverTrigger>
147-
{/* Added to give some bottom space from the popover content */}
148-
<div css={{ padding: "4px 0", margin: "-4px 0" }}>
149-
<Pill
150-
icon={
151-
<InfoOutlined
152-
css={{
153-
width: "12px !important",
154-
height: "12px !important",
155-
color: theme.palette.warning.light,
156-
}}
157-
/>
158-
}
151+
<HelpTooltipContent
152+
anchorOrigin={{
153+
vertical: "bottom",
154+
horizontal: "center",
155+
}}
156+
transformOrigin={{
157+
vertical: "top",
158+
horizontal: "center",
159+
}}
160+
>
161+
<AvatarData
162+
title={
163+
<Link
164+
component={RouterLink}
165+
to={`/templates/${workspace.template_name}`}
166+
css={{ color: "inherit" }}
167+
>
168+
{workspace.template_display_name.length > 0
169+
? workspace.template_display_name
170+
: workspace.template_name}
171+
</Link>
172+
}
173+
subtitle={
174+
<Link
175+
component={RouterLink}
176+
to={`/templates/${workspace.template_name}/versions/${workspace.latest_build.template_version_name}`}
177+
css={{ color: "inherit" }}
159178
>
160-
<span css={{ color: theme.palette.warning.light }}>
161-
{workspace.latest_build.template_version_name}
162-
</span>
163-
</Pill>
164-
</div>
165-
</PopoverTrigger>
166-
<WorkspaceOutdatedTooltipContent
167-
templateName={workspace.template_name}
168-
latestVersionId={workspace.template_active_version_id}
169-
onUpdateVersion={handleUpdate}
170-
ariaLabel="update version"
179+
{workspace.latest_build.template_version_name}
180+
</Link>
181+
}
182+
avatar={
183+
workspace.template_icon !== "" && (
184+
<Avatar
185+
src={workspace.template_icon}
186+
variant="square"
187+
fitImage
188+
/>
189+
)
190+
}
171191
/>
172-
</Popover>
173-
) : (
174-
<Pill>{workspace.latest_build.template_version_name}</Pill>
175-
)}
192+
</HelpTooltipContent>
193+
</Popover>
176194
</TopbarData>
177195

178196
{shouldDisplayDormantData && (

0 commit comments

Comments
 (0)