Skip to content

feat(site): refactor workspace header to be more slim #11327

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 21 commits into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
84f1bc4
Extract a few components to topbar module
BrunoQuaresma Dec 14, 2023
4ed5550
Extract and refactor a few more topbar componetns
BrunoQuaresma Dec 14, 2023
ffacb9f
WIP: Refactor workspace header
BrunoQuaresma Dec 15, 2023
a9ac963
Merge branch 'main' of https://github.com/coder/coder into bq/impleme…
BrunoQuaresma Dec 19, 2023
68c13ae
Improve outdated spacing
BrunoQuaresma Dec 19, 2023
ba88521
Merge branch 'main' of https://github.com/coder/coder into bq/impleme…
BrunoQuaresma Dec 20, 2023
3796085
Add schedule controls
BrunoQuaresma Dec 20, 2023
e0dd30d
Use topbar buttons
BrunoQuaresma Dec 20, 2023
c56d2f5
Add dormant to topbar
BrunoQuaresma Dec 20, 2023
90c3fc9
Add quota and minor accessibility improvements
BrunoQuaresma Dec 21, 2023
fdda1ba
Make template navigable
BrunoQuaresma Dec 21, 2023
f37a88d
Make visual adjustments
BrunoQuaresma Dec 21, 2023
26d6c09
Refactor icon colors
BrunoQuaresma Dec 22, 2023
5fa1f8f
Merge branch 'main' of https://github.com/coder/coder into bq/impleme…
BrunoQuaresma Dec 22, 2023
651b800
Add storybook
BrunoQuaresma Dec 22, 2023
d5510b2
Refactor storybook names
BrunoQuaresma Dec 22, 2023
d48c501
Merge branch 'main' of https://github.com/coder/coder into bq/impleme…
BrunoQuaresma Jan 2, 2024
19832ee
fix pill usage
BrunoQuaresma Jan 2, 2024
b8e80d0
add data-testid to workspace badge
BrunoQuaresma Jan 2, 2024
30f2a8c
Fix workspace status helper
BrunoQuaresma Jan 2, 2024
446bb76
remove span depedency from build-status
BrunoQuaresma Jan 2, 2024
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
WIP: Refactor workspace header
  • Loading branch information
BrunoQuaresma committed Dec 15, 2023
commit ffacb9f77fd90ac9c59aa6475596cb839eec7b72
27 changes: 25 additions & 2 deletions site/src/components/FullPageLayout/Topbar.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
import { css } from "@emotion/css";
import Button, { ButtonProps } from "@mui/material/Button";
import IconButton, { IconButtonProps } from "@mui/material/IconButton";
import { useTheme } from "@mui/material/styles";
import { Avatar, AvatarProps } from "components/Avatar/Avatar";
import { HTMLAttributes, forwardRef } from "react";
import {
HTMLAttributes,
PropsWithChildren,
ReactElement,
cloneElement,
forwardRef,
} from "react";

export const Topbar = (props: HTMLAttributes<HTMLDivElement>) => {
const theme = useTheme();
Expand Down Expand Up @@ -30,9 +37,10 @@ export const TopbarIconButton = forwardRef<HTMLButtonElement, IconButtonProps>(
{...props}
size="small"
css={{
padding: "0 16px",
padding: 0,
borderRadius: 0,
height: 48,
width: 48,

"& svg": {
fontSize: 20,
Expand Down Expand Up @@ -90,3 +98,18 @@ export const TopbarAvatar = (props: AvatarProps) => {
/>
);
};

export const TopbarIcon = ({
children,
...props
}: PropsWithChildren<HTMLAttributes<HTMLOrSVGElement>>) => {
const theme = useTheme();

return cloneElement(
children as ReactElement<HTMLAttributes<HTMLOrSVGElement>>,
{
...props,
className: css({ fontSize: 16, color: theme.palette.text.secondary }),
},
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,26 @@ interface TooltipProps {
ariaLabel?: string;
}

export const WorkspaceOutdatedTooltip: FC<TooltipProps> = ({
onUpdateVersion,
ariaLabel,
latestVersionId,
templateName,
}) => {
const { data: activeVersion } = useQuery(templateVersion(latestVersionId));
const theme = useTheme();

export const WorkspaceOutdatedTooltip: FC<TooltipProps> = (props) => {
return (
<HelpTooltip
size="small"
icon={InfoIcon}
iconStyles={styles.icon}
buttonStyles={styles.button}
>
<OutdatedTooltipContent {...props} />
</HelpTooltip>
);
};

export const OutdatedTooltipContent = (props: TooltipProps) => {
const theme = useTheme();
const { onUpdateVersion, ariaLabel, latestVersionId, templateName } = props;
const { data: activeVersion } = useQuery(templateVersion(latestVersionId));

return (
<>
<HelpTooltipTitle>{Language.outdatedLabel}</HelpTooltipTitle>
<HelpTooltipText>{Language.versionTooltipText}</HelpTooltipText>

Expand Down Expand Up @@ -81,16 +85,16 @@ export const WorkspaceOutdatedTooltip: FC<TooltipProps> = ({
</div>
</div>

<HelpTooltipLinksGroup>
{/* <HelpTooltipLinksGroup>
<HelpTooltipAction
icon={RefreshIcon}
onClick={onUpdateVersion}
ariaLabel={ariaLabel}
>
{Language.updateVersionLabel}
</HelpTooltipAction>
</HelpTooltipLinksGroup>
</HelpTooltip>
</HelpTooltipLinksGroup> */}
</>
);
};

Expand Down
83 changes: 80 additions & 3 deletions site/src/pages/WorkspacePage/Workspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { type Interpolation, type Theme } from "@emotion/react";
import Button from "@mui/material/Button";
import AlertTitle from "@mui/material/AlertTitle";
import { type FC, useEffect, useState } from "react";
import { useNavigate } from "react-router-dom";
import { useNavigate, Link as RouterLink } from "react-router-dom";
import dayjs from "dayjs";
import type * as TypesGen from "api/typesGenerated";
import { Alert, AlertDetail } from "components/Alert/Alert";
Expand All @@ -28,6 +28,28 @@ import {
import { BuildsTable } from "./BuildsTable";
import { WorkspaceDeletedBanner } from "./WorkspaceDeletedBanner";
import { WorkspaceStats } from "./WorkspaceStats";
import {
Topbar,
TopbarAvatar,
TopbarData,
TopbarDivider,
TopbarIcon,
TopbarIconButton,
} from "components/FullPageLayout/Topbar";
import Tooltip from "@mui/material/Tooltip";
import ArrowBackOutlined from "@mui/icons-material/ArrowBackOutlined";
import { useTheme } from "@mui/material/styles";
import PersonOutlineOutlined from "@mui/icons-material/PersonOutlineOutlined";
import LayersOutlined from "@mui/icons-material/LayersOutlined";
import {
OutdatedTooltipContent,
WorkspaceOutdatedTooltip,
} from "components/WorkspaceOutdatedTooltip/WorkspaceOutdatedTooltip";
import {
Popover,
PopoverContent,
PopoverTrigger,
} from "components/Popover/Popover";

export type WorkspaceError =
| "getBuildsError"
Expand Down Expand Up @@ -114,6 +136,7 @@ export const Workspace: FC<React.PropsWithChildren<WorkspaceProps>> = ({
hasMoreBuilds,
canAutostart,
}) => {
const theme = useTheme();
const navigate = useNavigate();
const { saveLocal, getLocal } = useLocalStorage();

Expand Down Expand Up @@ -166,7 +189,61 @@ export const Workspace: FC<React.PropsWithChildren<WorkspaceProps>> = ({

return (
<>
<FullWidthPageHeader>
<Topbar>
<Tooltip title="Back to workspaces">
<TopbarIconButton component={RouterLink} to="workspaces">
<ArrowBackOutlined />
</TopbarIconButton>
</Tooltip>

<div
css={{
paddingLeft: 16,
display: "flex",
alignItems: "center",
gap: 32,
}}
>
<TopbarData>
<TopbarAvatar src={workspace.template_icon} />
<span css={{ fontWeight: 500 }}>{workspace.name}</span>
<TopbarDivider />
<span>
{workspace.template_display_name ?? workspace.template_name}
</span>
<TopbarDivider />
{workspace.outdated ? (
<Popover mode="hover">
<PopoverTrigger>
<span css={{ color: theme.palette.warning.light }}>
{workspace.latest_build.template_version_name}
</span>
</PopoverTrigger>
<PopoverContent>
<OutdatedTooltipContent
templateName={workspace.template_name}
latestVersionId={workspace.template_active_version_id}
onUpdateVersion={handleUpdate}
ariaLabel="update version"
/>
</PopoverContent>
</Popover>
) : (
<span css={{ color: theme.palette.text.secondary }}>
{workspace.latest_build.template_version_name}
</span>
)}
</TopbarData>

<TopbarData>
<TopbarIcon>
<PersonOutlineOutlined />
</TopbarIcon>
<span>{workspace.owner_name}</span>
</TopbarData>
</div>
</Topbar>
{/* <FullWidthPageHeader>
<Stack direction="row" spacing={3} alignItems="center">
<Avatar
size="md"
Expand Down Expand Up @@ -214,7 +291,7 @@ export const Workspace: FC<React.PropsWithChildren<WorkspaceProps>> = ({
/>
</PageHeaderActions>
)}
</FullWidthPageHeader>
</FullWidthPageHeader> */}

<Margins css={styles.content}>
<Stack direction="column" css={styles.firstColumnSpacer} spacing={4}>
Expand Down