Skip to content

refactor(site): simplify workspace topbar #11370

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 4 commits into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
use popover instead of tooltip for template info
  • Loading branch information
BrunoQuaresma committed Jan 2, 2024
commit 7d875b86692ecf399e2d701ac2597d4ad488498f
6 changes: 3 additions & 3 deletions site/src/components/AvatarData/AvatarData.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { FC } from "react";
import type { FC, ReactNode } from "react";
import { useTheme } from "@emotion/react";
import { Avatar } from "components/Avatar/Avatar";
import { Stack } from "components/Stack/Stack";

export interface AvatarDataProps {
title: string | JSX.Element;
subtitle?: string;
title: ReactNode;
subtitle?: ReactNode;
src?: string;
avatar?: React.ReactNode;
}
Expand Down
110 changes: 64 additions & 46 deletions site/src/pages/WorkspacePage/WorkspaceTopbar/WorkspaceTopbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,8 @@ import {
} from "components/FullPageLayout/Topbar";
import Tooltip from "@mui/material/Tooltip";
import ArrowBackOutlined from "@mui/icons-material/ArrowBackOutlined";
import { WorkspaceOutdatedTooltipContent } from "components/WorkspaceOutdatedTooltip/WorkspaceOutdatedTooltip";
import { Popover, PopoverTrigger } from "components/Popover/Popover";
import ScheduleOutlined from "@mui/icons-material/ScheduleOutlined";
import { WorkspaceStatusBadge } from "components/WorkspaceStatusBadge/WorkspaceStatusBadge";
import { Pill } from "components/Pill/Pill";
import {
WorkspaceScheduleControls,
shouldDisplayScheduleControls,
Expand All @@ -24,12 +21,15 @@ import { workspaceQuota } from "api/queries/workspaceQuota";
import { useQuery } from "react-query";
import MonetizationOnOutlined from "@mui/icons-material/MonetizationOnOutlined";
import { useTheme } from "@mui/material/styles";
import InfoOutlined from "@mui/icons-material/InfoOutlined";
import Link from "@mui/material/Link";
import { useDashboard } from "components/Dashboard/DashboardProvider";
import { displayDormantDeletion } from "utils/dormant";
import DeleteOutline from "@mui/icons-material/DeleteOutline";
import PersonOutline from "@mui/icons-material/PersonOutline";
import { Popover, PopoverTrigger } from "components/Popover/Popover";
import { HelpTooltipContent } from "components/HelpTooltip/HelpTooltip";
import { AvatarData } from "components/AvatarData/AvatarData";
import { Avatar } from "components/Avatar/Avatar";

export type WorkspaceError =
| "getBuildsError"
Expand Down Expand Up @@ -127,52 +127,70 @@ export const WorkspaceTopbar = (props: WorkspaceProps) => {
<span>{workspace.owner_name}</span>
</Tooltip>
<TopbarDivider />
<Tooltip
title={workspace.template_display_name ?? workspace.template_name}
<Popover
mode="hover"
// title={`${
// workspace.template_display_name ?? workspace.template_name
// } on version ${workspace.latest_build.template_version_name}`}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the commented code intentional? Will it be used later?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, ty!

>
<Link
component={RouterLink}
to={`/templates/${workspace.template_name}`}
css={{ color: "inherit" }}
>
<TopbarAvatar src={workspace.template_icon} />
</Link>
</Tooltip>

<span css={{ fontWeight: 500 }}>{workspace.name}</span>
<PopoverTrigger>
<span
css={{
display: "flex",
alignItems: "center",
gap: 8,
cursor: "default",
padding: "4px 0",
}}
>
<TopbarAvatar src={workspace.template_icon} />
<span css={{ fontWeight: 500 }}>{workspace.name}</span>
</span>
</PopoverTrigger>

{workspace.outdated ? (
<Popover mode="hover">
<PopoverTrigger>
{/* Added to give some bottom space from the popover content */}
<div css={{ padding: "4px 0", margin: "-4px 0" }}>
<Pill
icon={
<InfoOutlined
css={{
width: "12px !important",
height: "12px !important",
color: theme.palette.warning.light,
}}
/>
}
<HelpTooltipContent
anchorOrigin={{
vertical: "bottom",
horizontal: "center",
}}
transformOrigin={{
vertical: "top",
horizontal: "center",
}}
>
<AvatarData
title={
<Link
component={RouterLink}
to={`/templates/${workspace.template_name}`}
css={{ color: "inherit" }}
>
{workspace.template_display_name.length > 0
? workspace.template_display_name
: workspace.template_name}
</Link>
}
subtitle={
<Link
component={RouterLink}
to={`/templates/${workspace.template_name}/versions/${workspace.latest_build.template_version_name}`}
css={{ color: "inherit" }}
>
<span css={{ color: theme.palette.warning.light }}>
{workspace.latest_build.template_version_name}
</span>
</Pill>
</div>
</PopoverTrigger>
<WorkspaceOutdatedTooltipContent
templateName={workspace.template_name}
latestVersionId={workspace.template_active_version_id}
onUpdateVersion={handleUpdate}
ariaLabel="update version"
{workspace.latest_build.template_version_name}
</Link>
}
avatar={
workspace.template_icon !== "" && (
<Avatar
src={workspace.template_icon}
variant="square"
fitImage
/>
)
}
/>
</Popover>
) : (
<Pill>{workspace.latest_build.template_version_name}</Pill>
)}
</HelpTooltipContent>
</Popover>
</TopbarData>

{shouldDisplayDormantData && (
Expand Down