Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
feat(sidebar): mark private projects with a lock (MUL-9285) (#10619)
Jiayuan Zhang1eb61f25abb8
diff --git a/packages/ui/components/common/__tests__/truncated-tooltip.test.tsx b/packages/ui/components/common/__tests__/truncated-tooltip.test.tsxindex 177f2bb364..7de4aa2f16 100644--- a/packages/ui/components/common/__tests__/truncated-tooltip.test.tsx+++ b/packages/ui/components/common/__tests__/truncated-tooltip.test.tsx@@ -3,7 +3,7 @@ import { act, cleanup, fireEvent, render, screen, waitFor } from "@testing-libraimport userEvent from "@testing-library/user-event";import { afterEach, describe, expect, it, vi } from "vitest";import { isContentTruncated, TruncatedTooltip } from "../truncated-tooltip";-import { TooltipProvider } from "../../ui/tooltip";+import { Tooltip, TooltipProvider, TooltipTrigger } from "../../ui/tooltip";afterEach(() => {cleanup();@@ -165,6 +165,46 @@ describe("TruncatedTooltip", () => {}});+ it("yields to a descendant's own tooltip while the pointer is on it", async () => {+ renderWithTooltips(+ <TruncatedTooltip content="A very long project name">+ <button type="button">+ <span data-testid="label" style={{ overflowX: "hidden", overflowY: "hidden" }}>+ A very long project name+ </span>+ <Tooltip>+ <TooltipTrigger render={<span data-testid="lock" />} />+ </Tooltip>+ </button>+ </TruncatedTooltip>,+ );+ setBox(screen.getByTestId("label"), { scrollWidth: 240, clientWidth: 120 });++ vi.useFakeTimers();+ try {+ // Arriving straight on the lock: React derives the row's enter from this.+ fireEvent.pointerOver(screen.getByTestId("lock"), { pointerType: "mouse" });+ await act(async () => {+ vi.advanceTimersByTime(550);+ });+ expect(tooltipPopup()).toBeNull();++ fireEvent.pointerOver(screen.getByTestId("label"), { pointerType: "mouse" });+ await act(async () => {+ vi.advanceTimersByTime(550);+ });+ expect(tooltipPopup()).toHaveTextContent("A very long project name");++ fireEvent.pointerOver(screen.getByTestId("lock"), { pointerType: "mouse" });+ await act(async () => {+ vi.advanceTimersByTime(550);+ });+ expect(tooltipPopup()).toBeNull();+ } finally {+ vi.useRealTimers();+ }+ });+it("renders the child alone without content", () => {renderWithTooltips(<TruncatedTooltip content="">diff --git a/packages/ui/components/common/deferred-tooltip.tsx b/packages/ui/components/common/deferred-tooltip.tsxindex f1b1458dc0..d99fff97fe 100644--- a/packages/ui/components/common/deferred-tooltip.tsx+++ b/packages/ui/components/common/deferred-tooltip.tsx@@ -80,6 +80,9 @@ export function DeferredTooltip({// hover delay; a Tab under a resting pointer still opens at once.const hoveringRef = useRef(false);const keyPressesAtHoverRef = useRef(0);+ // The pointer is on a descendant with a tooltip of its own (a lock icon+ // inside a row link); that tooltip owns the hover, so this one stays shut.+ const onNestedTriggerRef = useRef(false);const clearTimer = () => {if (timerRef.current !== null) {@@ -93,7 +96,7 @@ export function DeferredTooltip({// A trigger whose own menu/popover is open keeps the tooltip hidden;// plain expand/collapse toggles (aria-expanded without a popup) keep it.const el = anchorRef.current;- if (!el) return false;+ if (!el || onNestedTriggerRef.current) return false;const popupOpen =el.hasAttribute("data-popup-open") ||(el.getAttribute("aria-expanded") === "true" &&@@ -102,6 +105,18 @@ export function DeferredTooltip({return !shouldOpen || shouldOpen(el);};+ // Same delay as every other tooltip, and the same instant hand-off: when+ // a tooltip is showing or just closed, open without waiting.+ const armOpen = () => {+ clearTimer();+ timerRef.current = setTimeout(+ () => {+ if (canOpen()) setOpen(true);+ },+ isTooltipInstantPhase() ? 0 : TOOLTIP_OPEN_DELAY,+ );+ };+const triggerRef = trigger.props.ref as Ref<HTMLElement> | undefined;const element = cloneElement(trigger, {ref: (el: HTMLElement | null) => {@@ -115,19 +130,25 @@ export function DeferredTooltip({hoveringRef.current = true;keyPressesAtHoverRef.current = keyPresses;setWarm(true);- clearTimer();- // Same delay as every other tooltip, and the same instant hand-off: when- // a tooltip is showing or just closed, open without waiting.- timerRef.current = setTimeout(- () => {- if (canOpen()) setOpen(true);- },- isTooltipInstantPhase() ? 0 : TOOLTIP_OPEN_DELAY,- );+ armOpen();+ },+ onPointerOver: (e: React.PointerEvent) => {+ (trigger.props.onPointerOver as ((e: React.PointerEvent) => void) | undefined)?.(e);+ const nested = (e.target as Element).closest?.('[data-slot="tooltip-trigger"]');+ const onNested = !!nested && nested !== anchorRef.current && !!anchorRef.current?.contains(nested);+ if (onNested === onNestedTriggerRef.current) return;+ onNestedTriggerRef.current = onNested;+ if (onNested) {+ clearTimer();+ setOpen(false);+ } else {+ armOpen();+ }},onPointerLeave: (e: React.PointerEvent) => {(trigger.props.onPointerLeave as ((e: React.PointerEvent) => void) | undefined)?.(e);hoveringRef.current = false;+ onNestedTriggerRef.current = false;clearTimer();setOpen(false);},diff --git a/packages/views/layout/panels/pinned-section.test.tsx b/packages/views/layout/panels/pinned-section.test.tsxindex 811da86c83..33de3356e5 100644--- a/packages/views/layout/panels/pinned-section.test.tsx+++ b/packages/views/layout/panels/pinned-section.test.tsx@@ -187,6 +187,20 @@ describe("PinnedSection", () => {expect((await iconSlot())?.matches("svg")).toBe(true);});+ it("marks a pinned private project with a lock", async () => {+ state.pins = [{ ...pin(1), item_type: "project", item_id: "project-1" }];+ state.detail = { isPending: false, isError: false, data: { title: "Fundraise", icon: null, visibility: "private" }, error: null };+ const { unmount } = renderWithI18n(<Harness pathname="/acme/issues" />);+ const lock = await screen.findByRole("img", { name: "Visible to project members and workspace owners and admins" });+ expect(lock.closest("a")).toHaveTextContent("Fundraise");+ unmount();++ state.detail = { isPending: false, isError: false, data: { title: "Fundraise", icon: null, visibility: "workspace" }, error: null };+ renderWithI18n(<Harness pathname="/acme/issues" />);+ await screen.findByText("Fundraise");+ expect(screen.queryByRole("img", { name: "Visible to project members and workspace owners and admins" })).toBeNull();+ });+// dnd-kit stops the release's click at the document without cancelling// it. Where React listens below the document (Desktop), it never sees that// click, so the row must not wait for it before opening on the next one.diff --git a/packages/views/layout/panels/pinned-section.tsx b/packages/views/layout/panels/pinned-section.tsxindex 9ec99836c8..a69ba52f2d 100644--- a/packages/views/layout/panels/pinned-section.tsx+++ b/packages/views/layout/panels/pinned-section.tsx@@ -37,6 +37,7 @@ import {ISSUE_ROW_LINK_CLASS,IssueAgentBadge,IssueUnreadDot,+ PrivateProjectLock,SIDEBAR_SHIMMER_CLASS,SidebarIssueStatus,issueRowMenuOpenClass,@@ -208,6 +209,7 @@ function SortablePinItem({active,running = false,unread = false,+ labelSuffix,trailing,issue,}: {@@ -221,6 +223,8 @@ function SortablePinItem({running?: boolean;/** Brightens the label while the issue has an unread agent result. */unread?: boolean;+ /** Right after the label, which truncates before it. */+ labelSuffix?: React.ReactNode;trailing?: React.ReactNode;/** A pinned issue's row opens the issue context menu on right-click. */issue?: Issue;@@ -248,12 +252,15 @@ function SortablePinItem({aria-current={active ? "page" : undefined}className={cn(ISSUE_ROW_LINK_CLASS, "gap-2.5")}>- <ShimmerText- active={running}- className={cn("min-w-0 flex-1 truncate", SIDEBAR_SHIMMER_CLASS, unread && "text-foreground")}- >- {label}- </ShimmerText>+ <span className="flex min-w-0 flex-1 items-center gap-1.5">+ <ShimmerText+ active={running}+ className={cn("min-w-0 truncate", SIDEBAR_SHIMMER_CLASS, unread && "text-foreground")}+ >+ {label}+ </ShimmerText>+ {labelSuffix}+ </span>{/* Holds the same right-edge slot as a tree row's avatars, and yieldsit to the unpin button on hover. */}{trailing && (@@ -373,6 +380,7 @@ function PinRow({onUnpin={onUnpin}label={project.title}active={active}+ labelSuffix={project.visibility === "private" && <PrivateProjectLock />}iconNode={project.icon ? <ProjectIcon project={project} size="md" /> : <Folder className="size-4 shrink-0" />}diff --git a/packages/views/layout/panels/sidebar-tree.tsx b/packages/views/layout/panels/sidebar-tree.tsxindex e3245103b6..475afc2053 100644--- a/packages/views/layout/panels/sidebar-tree.tsx+++ b/packages/views/layout/panels/sidebar-tree.tsx@@ -2,8 +2,9 @@import { forwardRef, memo, useCallback, useLayoutEffect, useRef, useState } from "react";import { keepPreviousData, useQuery } from "@tanstack/react-query";-import { ChevronDown, ChevronRight, ChevronUp } from "@multica/ui/icons";+import { ChevronDown, ChevronRight, ChevronUp, Lock } from "@multica/ui/icons";import { cn } from "@multica/ui/lib/utils";+import { TooltipHint } from "@multica/ui/components/common/tooltip-hint";import { TruncatedTooltip } from "@multica/ui/components/common/truncated-tooltip";import { ShimmerText } from "@multica/ui/components/common/shimmer-text";import { Tooltip, TooltipContent, TooltipTrigger } from "@multica/ui/components/ui/tooltip";@@ -52,6 +53,8 @@ interface TreeRowProps extends React.ComponentProps<"div"> {/** Label for the expand toggle; `aria-expanded` carries its state. */toggleLabel?: string;onPrefetch?: () => void;+ /** Right after the label, which truncates before it: a marker like a lock. */+ labelSuffix?: React.ReactNode;/** End of the row: a count, or a settings button. */trailing?: React.ReactNode;onNavigate?: (event: React.MouseEvent<HTMLAnchorElement>) => void;@@ -76,6 +79,7 @@ export const TreeRow = forwardRef<HTMLAnchorElement, TreeRowProps>(function TreelistId,toggleLabel,onPrefetch,+ labelSuffix,trailing,onNavigate,onNavigateInPlace,@@ -155,9 +159,10 @@ export const TreeRow = forwardRef<HTMLAnchorElement, TreeRowProps>(function TreeonKeyDown={onKeyDown}onClick={onNavigate}onNavigateInPlace={onNavigateInPlace}- className="min-w-0 flex-1 truncate outline-none after:absolute after:inset-0 after:rounded-lg focus-visible:after:outline-2 focus-visible:after:outline-ring"+ className="flex min-w-0 flex-1 items-center gap-1.5 outline-none after:absolute after:inset-0 after:rounded-lg focus-visible:after:outline-2 focus-visible:after:outline-ring">- {label}+ <span className="min-w-0 truncate">{label}</span>+ {labelSuffix}</AppLink></TruncatedTooltip>{trailing}@@ -165,6 +170,25 @@ export const TreeRow = forwardRef<HTMLAnchorElement, TreeRowProps>(function Tree);});+/** Marks a private project, which only its members and workspace owners and+ * admins can see. It sits above the row link's+ * stretched hit area so its tooltip opens; a click still reaches the link. */+export function PrivateProjectLock() {+ const { t } = useT("layout");+ const label = t(($) => $.panels.work.private_project);+ return (+ <TooltipHint label={label}>+ <span+ role="img"+ aria-label={label}+ className="relative z-10 flex shrink-0 text-faint-foreground in-data-[active=true]:text-muted-foreground"+ >+ <Lock className="size-3" />+ </span>+ </TooltipHint>+ );+}+/** Issues under an expanded row sit flush and a step smaller than the rows* around them, so a group reads as one block. */const TREE_CHILD_ROW_CLASS =diff --git a/packages/views/layout/panels/work-tree.test.tsx b/packages/views/layout/panels/work-tree.test.tsxindex 19ce127a62..633612747c 100644--- a/packages/views/layout/panels/work-tree.test.tsx+++ b/packages/views/layout/panels/work-tree.test.tsx@@ -131,6 +131,13 @@ describe("ProjectsSection", () => {expect(iconSlot("Mobile")?.querySelector("svg")).not.toBeNull();});+ it("marks a private project with a lock inside its link", () => {+ renderSection([{ ...project("p1", "Desktop"), visibility: "private" }, { ...project("p2", "Mobile"), visibility: "workspace" }]);+ const lock = screen.getByRole("img", { name: "Visible to project members and workspace owners and admins" });+ expect(lock.closest("a")).toHaveTextContent("Desktop");+ expect(screen.getAllByRole("img", { name: "Visible to project members and workspace owners and admins" })).toHaveLength(1);+ });+it("expands a project in place, keeping its count", () => {renderSection();expect(screen.getAllByText("3")).toHaveLength(3);diff --git a/packages/views/layout/panels/work-tree.tsx b/packages/views/layout/panels/work-tree.tsxindex fd83577964..f45aed5421 100644--- a/packages/views/layout/panels/work-tree.tsx+++ b/packages/views/layout/panels/work-tree.tsx@@ -42,7 +42,7 @@ import { shouldOpenRowMenu, useRowMenu } from "../../common/point-menu";import { CollectionRowContext } from "../collection-list/row-context";import { useDragClickGuard } from "../use-drag-click-guard";import { ProjectsSectionSettings } from "./sidebar-settings";-import { SidebarIssueList, TreeRow } from "./sidebar-tree";+import { PrivateProjectLock, SidebarIssueList, TreeRow } from "./sidebar-tree";const DRAG_MODIFIERS = [restrictToVerticalAxis, restrictToFirstScrollableAncestor];@@ -317,6 +317,7 @@ function ProjectTreeItem({listId={listId}toggleLabel={t(($) => $.panels.work.project_issues, { name: project.title })}onPrefetch={prefetch}+ labelSuffix={project.visibility === "private" && <PrivateProjectLock />}onContextMenu={(event: MouseEvent) => {if (shouldOpenRowMenu(event)) rowMenu.openAtPointer(event);}}diff --git a/packages/views/locales/en/layout.json b/packages/views/locales/en/layout.jsonindex 71b98a0705..3db01dd8ec 100644--- a/packages/views/locales/en/layout.json+++ b/packages/views/locales/en/layout.json@@ -128,6 +128,7 @@"views": "Views","new_project": "New project","new_issue_in_project": "New issue in {{name}}",+ "private_project": "Visible to project members and workspace owners and admins","all_projects_one": "All {{count}} project","all_projects_other": "All {{count}} projects","project_issues": "Issues in {{name}}",diff --git a/packages/views/locales/es/layout.json b/packages/views/locales/es/layout.jsonindex ff3ffb46af..bfce350b83 100644--- a/packages/views/locales/es/layout.json+++ b/packages/views/locales/es/layout.json@@ -128,6 +128,7 @@"views": "Vistas","new_project": "Nuevo proyecto","new_issue_in_project": "Nueva tarea en {{name}}",+ "private_project": "Visible para los miembros del proyecto y los owner y admin del espacio de trabajo","all_projects_one": "{{count}} proyecto en total","all_projects_other": "{{count}} proyectos en total","project_issues": "Tareas en {{name}}",diff --git a/packages/views/locales/fr/layout.json b/packages/views/locales/fr/layout.jsonindex 5c1f64ce56..38ddbf0eba 100644--- a/packages/views/locales/fr/layout.json+++ b/packages/views/locales/fr/layout.json@@ -128,6 +128,7 @@"views": "Vues","new_project": "Nouveau projet","new_issue_in_project": "Nouvelle tâche dans {{name}}",+ "private_project": "Visible par les membres du projet et les owner et admin de l’espace de travail","all_projects_one": "Tous les projets ({{count}})","all_projects_other": "Tous les projets ({{count}})","project_issues": "Tâches de {{name}}",diff --git a/packages/views/locales/ja/layout.json b/packages/views/locales/ja/layout.jsonindex 401879f42f..fc542cfb60 100644--- a/packages/views/locales/ja/layout.json+++ b/packages/views/locales/ja/layout.json@@ -125,6 +125,7 @@"views": "ビュー","new_project": "新規プロジェクト","new_issue_in_project": "{{name}} に新規タスク",+ "private_project": "プロジェクトメンバーとワークスペースの owner と admin が閲覧できます","all_projects_other": "すべてのプロジェクト({{count}})","project_issues": "{{name}} のタスク","project_issues_empty": "タスクはありません",diff --git a/packages/views/locales/ko/layout.json b/packages/views/locales/ko/layout.jsonindex 816d1b99e9..508d16ceea 100644--- a/packages/views/locales/ko/layout.json+++ b/packages/views/locales/ko/layout.json@@ -125,6 +125,7 @@"views": "뷰","new_project": "새 프로젝트","new_issue_in_project": "{{name}}에 새 태스크",+ "private_project": "프로젝트 멤버와 워크스페이스 owner, admin이 볼 수 있습니다","all_projects_other": "전체 프로젝트 {{count}}개","project_issues": "{{name}}의 태스크","project_issues_empty": "태스크가 없습니다",diff --git a/packages/views/locales/ru/layout.json b/packages/views/locales/ru/layout.jsonindex cdb6e03946..1bb48340e8 100644--- a/packages/views/locales/ru/layout.json+++ b/packages/views/locales/ru/layout.json@@ -107,6 +107,7 @@"views": "Представления","new_project": "Новый проект","new_issue_in_project": "Новая задача в «{{name}}»",+ "private_project": "Видно участникам проекта, а также owner и admin рабочего пространства","all_projects_one": "Всего {{count}} проект","all_projects_other": "Всего {{count}} проекта","project_issues": "Задачи в «{{name}}»",diff --git a/packages/views/locales/zh-Hans/layout.json b/packages/views/locales/zh-Hans/layout.jsonindex 87e753a412..e03c83d9c0 100644--- a/packages/views/locales/zh-Hans/layout.json+++ b/packages/views/locales/zh-Hans/layout.json@@ -125,6 +125,7 @@"views": "视图","new_project": "新建项目","new_issue_in_project": "在 {{name}} 中新建任务",+ "private_project": "项目成员及工作区 owner 和 admin 可见","all_projects_other": "全部 {{count}} 个项目","project_issues": "{{name}} 的任务","project_issues_empty": "没有任务",diff --git a/packages/views/locales/zh-Hant/layout.json b/packages/views/locales/zh-Hant/layout.jsonindex e45ebda8a4..94fc2ba667 100644--- a/packages/views/locales/zh-Hant/layout.json+++ b/packages/views/locales/zh-Hant/layout.json@@ -125,6 +125,7 @@"views": "檢視","new_project": "新建專案","new_issue_in_project": "在 {{name}} 中新建任務",+ "private_project": "專案成員及工作區 owner 和 admin 可見","all_projects_other": "全部 {{count}} 個專案","project_issues": "{{name}} 的任務","project_issues_empty": "沒有任務",