Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions packages/app/src/features/auth/account-bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ export function AccountBar() {
<Link to="/" aria-label="Factorize dashboard" className="flex shrink-0 items-center"><img src={beeMark} alt="" className="size-8 object-contain" /></Link>
<span aria-hidden="true" className="hidden h-8 w-px shrink-0 bg-stone-300 dark:bg-slate-700" />
{authenticated ? <div className="flex min-w-0 flex-1 items-center gap-1 text-sm font-semibold sm:flex-initial sm:gap-2">
{currentProjectId && <><span aria-hidden="true" className="hidden text-slate-400 sm:inline">/</span><div className="flex min-w-0 items-center">
{currentProject ? <Link to="/projects/$projectId" params={{ projectId: currentProject.id }} title={currentProject.name} className="min-w-0 max-w-[55vw] truncate text-slate-700 hover:text-factorize-700 dark:text-slate-200 sm:max-w-64">{currentProject.name}</Link> : <span className="truncate text-slate-600 dark:text-slate-300">{routeProject.isPending ? "Loading project…" : routeProject.error ? "Project unavailable" : "Project"}</span>}
{currentProjectId && <><div className="flex min-w-0 items-center">
{currentProject ? <Link to="/projects/$projectId" params={{ projectId: currentProject.id }} title={currentProject.name} className="-mx-2 min-w-0 max-w-[55vw] truncate rounded-md px-2 py-1 text-slate-700 transition-colors hover:bg-stone-100 hover:text-factorize-700 dark:text-slate-200 dark:hover:bg-slate-800 sm:max-w-64">{currentProject.name}</Link> : <span className="truncate text-slate-600 dark:text-slate-300">{routeProject.isPending ? "Loading project…" : routeProject.error ? "Project unavailable" : "Project"}</span>}
<ResourceSwitcher kind="Project" items={projects.data ?? []} currentId={currentProjectId} loading={projects.isPending} error={projects.error?.message} onSelect={chooseProject} />
</div></>}
{currentJobId && <><span aria-hidden="true" className="hidden text-slate-400 sm:inline">/</span><div className="flex min-w-0 items-center">
{routeJob.data ? <Link to="/jobs/$jobId" params={{ jobId: routeJob.data.id }} title={routeJob.data.name} className="min-w-0 max-w-[42vw] truncate text-slate-700 hover:text-factorize-700 dark:text-slate-200 sm:max-w-56">{routeJob.data.name}</Link> : <span className="truncate text-slate-600 dark:text-slate-300">{routeJob.isPending ? "Loading job…" : routeJob.error ? "Job unavailable" : "Job"}</span>}
{routeJob.data ? <Link to="/jobs/$jobId" params={{ jobId: routeJob.data.id }} title={routeJob.data.name} className="-mx-2 min-w-0 max-w-[42vw] truncate rounded-md px-2 py-1 text-slate-700 transition-colors hover:bg-stone-100 hover:text-factorize-700 dark:text-slate-200 dark:hover:bg-slate-800 sm:max-w-56">{routeJob.data.name}</Link> : <span className="truncate text-slate-600 dark:text-slate-300">{routeJob.isPending ? "Loading job…" : routeJob.error ? "Job unavailable" : "Job"}</span>}
<ResourceSwitcher kind="Job" items={(projectJobs.data?.items ?? []).map(job => ({ id: job.id, name: job.name }))} currentId={currentJobId} loading={projectJobs.isPending} error={projectJobs.error?.message} onSelect={chooseJob} />
</div></>}
</div> : <Link to="/" className="text-sm font-semibold">Dashboard</Link>}
Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/shared/resource-switcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export function ResourceSwitcher({
const select = (id: string) => { setOpen(false); setSearch(""); onSelect(id); };
return <div ref={root} className="relative flex min-w-0 items-center">
<button ref={trigger} type="button" aria-label={`Switch ${kind.toLocaleLowerCase()}`} aria-haspopup="listbox" aria-expanded={open}
className="ml-0 flex size-8 shrink-0 items-center justify-center rounded-md text-slate-600 hover:bg-stone-100 focus-visible:outline focus-visible:outline-2 focus-visible:outline-factorize-500 dark:text-slate-300 dark:hover:bg-slate-800 sm:ml-1"
className="ml-0 flex size-8 shrink-0 items-center justify-center rounded-md p-1.5 text-slate-600 hover:bg-stone-100 focus-visible:outline focus-visible:outline-2 focus-visible:outline-factorize-500 dark:text-slate-300 dark:hover:bg-slate-800 sm:ml-1"
onClick={() => { setOpen(value => !value); setSearch(""); setActive(0); requestAnimationFrame(() => input.current?.focus()); }}>
<svg aria-hidden="true" viewBox="0 0 20 20" className="size-4 fill-current"><path d="m5 7 5 5 5-5" /></svg>
</button>
Expand Down
7 changes: 7 additions & 0 deletions packages/app/test/jobs.browser.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -360,12 +360,19 @@ test("main navigation shows the current project switcher inside a project and it
assert.equal(await mainNav.getByRole("button", { name: "Switch project" }).count(), 0);
await page.goto(origin + `/projects/${projectId}`);
await mainNav.getByRole("link", { name: "Release project", exact: true }).waitFor();
assert.equal(await mainNav.locator('span[aria-hidden="true"]').filter({ hasText: "/" }).count(), 0);
const projectLink = mainNav.getByRole("link", { name: "Release project", exact: true });
await projectLink.hover();
await page.waitForFunction(element => getComputedStyle(element).backgroundColor !== "rgba(0, 0, 0, 0)", await projectLink.elementHandle());
assert.match(await projectLink.evaluate(element => getComputedStyle(element).backgroundColor), /rgba?\(246, 243, 233(?:,|\))/);
const switcher = mainNav.getByRole("button", { name: "Switch project" });
assert.equal(await switcher.count(), 1);
assert.equal(await switcher.evaluate(element => getComputedStyle(element).padding), "6px");
await switcher.click();
await page.getByRole("option", { name: /Release project/ }).waitFor();
await page.goto(origin + `/jobs/${jobId}`);
await mainNav.getByRole("link", { name: "Release project", exact: true }).waitFor();
assert.equal(await mainNav.locator('span[aria-hidden="true"]').filter({ hasText: "/" }).count(), 1);
const jobSwitcher = mainNav.getByRole("button", { name: "Switch project" });
assert.equal(await jobSwitcher.count(), 1);
await jobSwitcher.click();
Expand Down
Loading