mirror of
https://github.com/block/buzz.git
synced 2026-10-27 12:40:30 +00:00
## Summary Part 1 of 4 stacked PRs continuing the Projects work from #6003. - The Projects overview now follows the selected section: the right-hand context pod stays visible across the Projects / Repositories / Reviews / Tasks / Channels tabs and shows section-specific people, stats, and contribution graphs, so it reads as live context rather than a detached summary. - Entity list rows are consolidated onto one compact line (title first, icons after, aligned dates/counts), shared across projects, repositories, PRs, issues, and channel lists via `ProjectEntityListRow`. - New `projectRelatedChannels` helper resolves the channels a project is discussed in for the overview. Follow-ups in this stack: part 2 (selectable workspaces), part 3 (context-aware collaboration), part 4 (navigation & detail-page polish). ## Test plan - [x] Desktop unit tests (`pnpm test`) — pass - [x] TypeScript (`tsc --noEmit`), Biome, clippy — clean via pre-push gate - [x] Playwright specs updated for the new overview behavior (`projects-v3-screenshots.spec.ts`, `sidebar.spec.ts`) — pass locally in the smoke project --------- Signed-off-by: Thomas Petersen <thomasp@squareup.com>
128 lines
3.5 KiB
TypeScript
128 lines
3.5 KiB
TypeScript
import { CircleDot, FolderGit2, GitPullRequest, Plus } from "lucide-react";
|
|
import * as React from "react";
|
|
|
|
import { Button } from "@/shared/ui/button";
|
|
import {
|
|
POPOVER_SHADOW_STYLE,
|
|
POPOVER_SURFACE_CLASS,
|
|
} from "@/shared/ui/popoverSurface";
|
|
|
|
const MENU_ITEM_CLASS =
|
|
"flex min-h-9 w-full items-center gap-2 rounded-lg py-2 pl-2 pr-4 text-left text-sm outline-hidden transition-colors hover:bg-muted/50 focus:bg-muted/50 focus:text-foreground focus-visible:ring-1 focus-visible:ring-ring [&_svg]:size-4 [&_svg]:shrink-0";
|
|
|
|
export function ProjectsCreateMenu({
|
|
compact = false,
|
|
onCreateIssue,
|
|
onCreateProject,
|
|
onCreatePullRequest,
|
|
}: {
|
|
compact?: boolean;
|
|
onCreateIssue: () => void;
|
|
onCreateProject: () => void;
|
|
onCreatePullRequest: () => void;
|
|
}) {
|
|
const [open, setOpen] = React.useState(false);
|
|
const containerRef = React.useRef<HTMLElement>(null);
|
|
|
|
React.useEffect(() => {
|
|
if (!open) return;
|
|
function handlePointerDown(event: PointerEvent) {
|
|
if (!containerRef.current?.contains(event.target as Node)) {
|
|
setOpen(false);
|
|
}
|
|
}
|
|
globalThis.document.addEventListener(
|
|
"pointerdown",
|
|
handlePointerDown,
|
|
true,
|
|
);
|
|
return () =>
|
|
globalThis.document.removeEventListener(
|
|
"pointerdown",
|
|
handlePointerDown,
|
|
true,
|
|
);
|
|
}, [open]);
|
|
|
|
function select(action: () => void) {
|
|
setOpen(false);
|
|
action();
|
|
}
|
|
|
|
return (
|
|
<nav
|
|
aria-label="Create project item"
|
|
className="relative shrink-0"
|
|
onBlurCapture={(event) => {
|
|
if (!event.currentTarget.contains(event.relatedTarget)) {
|
|
setOpen(false);
|
|
}
|
|
}}
|
|
onKeyDown={(event) => {
|
|
if (event.key === "Escape") {
|
|
setOpen(false);
|
|
containerRef.current?.querySelector<HTMLElement>("button")?.focus();
|
|
}
|
|
}}
|
|
onMouseEnter={() => setOpen(true)}
|
|
onMouseLeave={() => setOpen(false)}
|
|
ref={containerRef}
|
|
>
|
|
<Button
|
|
aria-expanded={open}
|
|
aria-haspopup="menu"
|
|
aria-label="Create"
|
|
className={
|
|
compact
|
|
? "h-6 w-6 shrink-0 rounded-md text-muted-foreground hover:bg-muted/70 hover:text-foreground"
|
|
: "h-8 w-8 rounded-full"
|
|
}
|
|
data-testid="projects-create-menu"
|
|
onClick={() => setOpen(true)}
|
|
size="icon"
|
|
type="button"
|
|
variant={compact ? "ghost" : "default"}
|
|
>
|
|
<Plus className="h-4 w-4" />
|
|
</Button>
|
|
{open ? (
|
|
<div className="absolute right-0 top-full z-50 min-w-48 pt-1">
|
|
<div
|
|
className={`rounded-xl p-1 ${POPOVER_SURFACE_CLASS}`}
|
|
role="menu"
|
|
style={POPOVER_SHADOW_STYLE}
|
|
>
|
|
<button
|
|
className={MENU_ITEM_CLASS}
|
|
onClick={() => select(onCreateProject)}
|
|
role="menuitem"
|
|
type="button"
|
|
>
|
|
<FolderGit2 />
|
|
Project
|
|
</button>
|
|
<button
|
|
className={MENU_ITEM_CLASS}
|
|
onClick={() => select(onCreateIssue)}
|
|
role="menuitem"
|
|
type="button"
|
|
>
|
|
<CircleDot />
|
|
Task
|
|
</button>
|
|
<button
|
|
className={MENU_ITEM_CLASS}
|
|
onClick={() => select(onCreatePullRequest)}
|
|
role="menuitem"
|
|
type="button"
|
|
>
|
|
<GitPullRequest />
|
|
Review
|
|
</button>
|
|
</div>
|
|
</div>
|
|
) : null}
|
|
</nav>
|
|
);
|
|
}
|