diff --git a/ui/src/components/SidebarCompanyMenu.test.tsx b/ui/src/components/SidebarCompanyMenu.test.tsx index 88fd4b7c890..c1c925d25e9 100644 --- a/ui/src/components/SidebarCompanyMenu.test.tsx +++ b/ui/src/components/SidebarCompanyMenu.test.tsx @@ -84,6 +84,7 @@ vi.mock("@/context/CompanyContext", () => ({ issuePrefix: "PAP", name: "Acme Labs", brandColor: "#3366ff", + logoUrl: "/api/assets/logo-asset-1/content", status: "active", }, setSelectedCompanyId: mockSetSelectedCompanyId, @@ -97,8 +98,8 @@ vi.mock("@/context/DialogContext", () => ({ })); vi.mock("./CompanyPatternIcon", () => ({ - CompanyPatternIcon: ({ companyName }: { companyName: string }) => ( - + CompanyPatternIcon: ({ companyName, logoUrl }: { companyName: string; logoUrl?: string | null }) => ( + ), })); @@ -497,6 +498,35 @@ describe("SidebarCompanyMenu", () => { }); }); + it("shows the synced company logo on the trigger while stack rows keep monograms", async () => { + const { root } = renderMenu({ cloud: true }); + await flushReact(); + await flushReact(); + + // A Cloud tenant holds exactly one company, and the harness pushes the + // stack's uploaded workspace icon into that company's branding — so the + // trigger renders the company logo, not the monogram. + const trigger = container.querySelector( + 'button[aria-label="Open Acme Labs organization switcher"]', + ); + expect(trigger).not.toBeNull(); + expect( + trigger?.querySelector('[data-logo-url="/api/assets/logo-asset-1/content"]'), + ).not.toBeNull(); + + // Other stacks have no hot-linkable icon in the portfolio payload, so + // their rows keep the deterministic monogram treatment. + await openMenu("Open Acme Labs organization switcher"); + const strataRow = Array.from(document.body.querySelectorAll('[data-slot="dropdown-menu-item"]')) + .find((element) => element.textContent?.includes("Strata Systems")); + expect(strataRow).toBeTruthy(); + expect(strataRow?.querySelector("[data-logo-url]")).toBeNull(); + + act(() => { + root.unmount(); + }); + }); + it("enters another stack through a full top-level navigation", async () => { const { root } = renderMenu({ cloud: true }); await flushReact(); diff --git a/ui/src/components/SidebarCompanyMenu.tsx b/ui/src/components/SidebarCompanyMenu.tsx index 167c7b1f48e..928b6e0bac5 100644 --- a/ui/src/components/SidebarCompanyMenu.tsx +++ b/ui/src/components/SidebarCompanyMenu.tsx @@ -73,6 +73,29 @@ function StackIcon({ displayName }: { displayName: string }) { return ; } +/** + * The switcher trigger on a Cloud instance. A Cloud tenant holds exactly one + * company and the harness pushes the stack's uploaded workspace icon into + * that company's branding, so the company logo is the stack logo here. + * The stack rows keep the monogram treatment above. + */ +function CurrentStackIcon({ + displayName, + company, +}: { + displayName: string; + company: Company | null; +}) { + return ( + + ); +} + function CloudStackItem({ stack, isSelected, @@ -336,7 +359,7 @@ export function SidebarCompanyMenu({ open: controlledOpen, onOpenChange }: Sideb > {isCloud - ? currentName ? : null + ? currentName ? : null : selectedCompany ? : null} {/* The header has room for ~110px of name beside the collapse control (~142px on mobile, which hides it) — search moved to