Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

MUL-8759 feat(views): show project icon in sidebar project tree (#10116)

MamRezb962fb8b033c
diff --git a/packages/views/layout/panels/pinned-section.test.tsx b/packages/views/layout/panels/pinned-section.test.tsx
index 65c5f72957..0f1b18bf2f 100644
--- a/packages/views/layout/panels/pinned-section.test.tsx
+++ b/packages/views/layout/panels/pinned-section.test.tsx
@@ -69,7 +69,7 @@ vi.mock("@tanstack/react-query", async (importOriginal) => ({
...(await importOriginal<typeof import("@tanstack/react-query")>()),
useQuery: ({ queryKey }: { queryKey: readonly unknown[] }) => {
if (queryKey[0] === "pins") return { data: state.pins };
- if (queryKey[0] === "issue") return state.detail;
+ if (queryKey[0] === "issue" || queryKey[0] === "project") return state.detail;
return { isPending: true, isError: false, data: undefined, error: null };
},
}));
@@ -186,6 +186,21 @@ describe("PinnedSection", () => {
expect(activePinnedRoute).toBe(false);
});
+ it("shows a pinned project's chosen icon, keeping the folder when it has none", async () => {
+ state.pins = [{ ...pin(1), item_type: "project", item_id: "project-1" }];
+ state.detail = { isPending: false, isError: false, data: { title: "Rocket launch", icon: "πŸš€" }, error: null };
+ const { unmount } = renderWithI18n(<Harness pathname="/acme/issues" />);
+ const iconSlot = async () => (await screen.findByText("Rocket launch")).closest("a")!.previousElementSibling;
+ expect(await iconSlot()).toHaveTextContent("πŸš€");
+ expect((await iconSlot())?.matches("svg")).toBe(false);
+ unmount();
+
+ state.detail = { isPending: false, isError: false, data: { title: "Rocket launch", icon: null }, error: null };
+ renderWithI18n(<Harness pathname="/acme/issues" />);
+ expect(await iconSlot()).not.toHaveTextContent("πŸš€");
+ expect((await iconSlot())?.matches("svg")).toBe(true);
+ });
+
it("renders nothing without pins", () => {
state.pins = [];
const { container } = renderWithI18n(<Harness pathname="/acme/issues" />);
diff --git a/packages/views/layout/panels/pinned-section.tsx b/packages/views/layout/panels/pinned-section.tsx
index b360a54182..7144b279ba 100644
--- a/packages/views/layout/panels/pinned-section.tsx
+++ b/packages/views/layout/panels/pinned-section.tsx
@@ -29,6 +29,7 @@ import type { Issue, PinnedItem } from "@multica/core/types";
import { AppLink } from "../../navigation";
import { IssueActionsContextMenu } from "../../issues/actions";
import { useStatusLabel } from "../../issues/utils/status-label";
+import { ProjectIcon } from "../../projects/components/project-icon";
import { useT } from "../../i18n";
import { PANEL_ROW_CLASS, PanelList, PanelSection, isPathWithin, panelRowStateClass } from "../panel-nav";
import {
@@ -373,7 +374,9 @@ function PinRow({
onUnpin={onUnpin}
label={project.title}
active={active}
- iconNode={<Folder className="size-4 shrink-0" />}
+ iconNode={
+ project.icon ? <ProjectIcon project={project} size="md" /> : <Folder className="size-4 shrink-0" />
+ }
/>
);
}
diff --git a/packages/views/layout/panels/work-tree.test.tsx b/packages/views/layout/panels/work-tree.test.tsx
index 82f0b2d657..53f5b3e6c9 100644
--- a/packages/views/layout/panels/work-tree.test.tsx
+++ b/packages/views/layout/panels/work-tree.test.tsx
@@ -63,8 +63,8 @@ vi.mock("@multica/core/paths", async (importOriginal) => {
return { ...actual, useWorkspacePaths: () => actual.paths.workspace("acme") };
});
-const project = (id: string, title: string): Project =>
- ({ id, title, status: "in_progress", issue_count: 4, done_count: 1 }) as Project;
+const project = (id: string, title: string, icon: string | null = null): Project =>
+ ({ id, title, icon, status: "in_progress", issue_count: 4, done_count: 1 }) as Project;
const PROJECTS = [project("p1", "Desktop"), project("p2", "Mobile"), project("p3", "Web")];
beforeEach(() => {
@@ -81,7 +81,7 @@ const savedPrefs = (prefs: Record<string, unknown>): IssueViewPreference => ({
prefs: { hidden: [], order: [], ...prefs },
});
-function renderSection() {
+function renderSection(projects = PROJECTS) {
const qc = new QueryClient({ defaultOptions: { queries: { enabled: false } } });
qc.setQueryData(
issueViewPreferenceOptions("ws-1", SIDEBAR_PROJECTS_SCOPE).queryKey,
@@ -97,7 +97,7 @@ function renderSection() {
wsId="ws-1"
userId="u1"
pathname="/acme/issues"
- projects={PROJECTS}
+ projects={projects}
totalProjects={4}
plainRowsLit
activeIssueId={null}
@@ -109,6 +109,16 @@ function renderSection() {
}
describe("ProjectsSection", () => {
+ it("shows the project's chosen icon, keeping the folder when it has none", () => {
+ renderSection([project("p1", "Desktop", "πŸš€"), project("p2", "Mobile")]);
+ const iconSlot = (name: string) =>
+ screen.getByRole("button", { name: `Issues in ${name}` }).previousElementSibling;
+ expect(iconSlot("Desktop")).toHaveTextContent("πŸš€");
+ expect(iconSlot("Desktop")?.querySelector("svg")).toBeNull();
+ expect(iconSlot("Mobile")).toHaveTextContent("");
+ expect(iconSlot("Mobile")?.querySelector("svg")).not.toBeNull();
+ });
+
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.tsx
index a5823059f9..e49c8de4d0 100644
--- a/packages/views/layout/panels/work-tree.tsx
+++ b/packages/views/layout/panels/work-tree.tsx
@@ -35,6 +35,7 @@ import {
isPathWithin,
panelRowStateClass,
} from "../panel-nav";
+import { ProjectIcon } from "../../projects/components/project-icon";
import { ProjectsSectionSettings } from "./sidebar-settings";
import { SidebarIssueList, TreeRow } from "./sidebar-tree";
@@ -289,7 +290,9 @@ function ProjectTreeItem({
{...listeners}
href={p.projectDetail(project.id)}
label={project.title}
- icon={<Folder className="size-4 shrink-0" />}
+ icon={
+ project.icon ? <ProjectIcon project={project} size="md" /> : <Folder className="size-4 shrink-0" />
+ }
active={active}
located={located}
expanded={expanded}