From c37c0e7d1b2540c253b3a704cda481f68d865148 Mon Sep 17 00:00:00 2001 From: Bruno Quaresma Date: Tue, 2 Jan 2024 15:17:42 -0300 Subject: [PATCH] refactor(site): simplify workspace topbar (#11370) --- site/src/components/AvatarData/AvatarData.tsx | 6 +- .../WorkspaceTopbar/WorkspaceTopbar.tsx | 124 ++++++++++-------- 2 files changed, 72 insertions(+), 58 deletions(-) diff --git a/site/src/components/AvatarData/AvatarData.tsx b/site/src/components/AvatarData/AvatarData.tsx index 2f8b59a30a..9ed11ebc0b 100644 --- a/site/src/components/AvatarData/AvatarData.tsx +++ b/site/src/components/AvatarData/AvatarData.tsx @@ -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; } diff --git a/site/src/pages/WorkspacePage/WorkspaceTopbar/WorkspaceTopbar.tsx b/site/src/pages/WorkspacePage/WorkspaceTopbar/WorkspaceTopbar.tsx index 6c2f708495..d2a40ae49e 100644 --- a/site/src/pages/WorkspacePage/WorkspaceTopbar/WorkspaceTopbar.tsx +++ b/site/src/pages/WorkspacePage/WorkspaceTopbar/WorkspaceTopbar.tsx @@ -11,12 +11,8 @@ import { } from "components/FullPageLayout/Topbar"; import Tooltip from "@mui/material/Tooltip"; import ArrowBackOutlined from "@mui/icons-material/ArrowBackOutlined"; -import PersonOutlineOutlined from "@mui/icons-material/PersonOutlineOutlined"; -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, @@ -25,11 +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" @@ -120,58 +120,72 @@ export const WorkspaceTopbar = (props: WorkspaceProps) => { }} > - - {workspace.name} - - - {workspace.template_display_name ?? workspace.template_name} - - - {workspace.outdated ? ( - - - {/* Added to give some bottom space from the popover content */} -
- - } - > - - {workspace.latest_build.template_version_name} - - -
-
- -
- ) : ( - {workspace.latest_build.template_version_name} - )} -
- - + + + - - - + {workspace.owner_name} - {workspace.owner_name} + + + + + + {workspace.name} + + + + + + {workspace.template_display_name.length > 0 + ? workspace.template_display_name + : workspace.template_name} + + } + subtitle={ + + {workspace.latest_build.template_version_name} + + } + avatar={ + workspace.template_icon !== "" && ( + + ) + } + /> + + {shouldDisplayDormantData && (