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
5 changes: 3 additions & 2 deletions packages/app/src/features/auth/account-bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { projectQuery, projectsQuery } from "../projects/queries";
import { jobQuery, jobsQuery } from "../jobs/queries";
import { runStatusQuery } from "../runs/queries";
import { ResourceSwitcher } from "../../shared/resource-switcher";
import { NavIcon } from "../../shared/nav-icon";
import beeMark from "../../assets/bee-mark-monochrome.png";

export function AccountBar() {
Expand Down Expand Up @@ -92,8 +93,8 @@ export function AccountBar() {
</nav>
{authenticated && (pathname === "/" || pathname === "/projects" || pathname === "/skills") && <nav aria-label="Dashboard navigation" className="border-t border-stone-200 dark:border-slate-800">
<div className="mx-auto flex w-full max-w-6xl gap-1 overflow-x-auto px-4 sm:px-6 lg:px-8">
<Link to="/projects" className={`inline-flex min-h-12 shrink-0 items-center border-b-2 px-3 text-sm font-semibold transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-factorize-500 ${pathname === "/projects" ? "border-factorize-500 text-factorize-700 dark:text-factorize-500" : "border-transparent text-slate-600 hover:border-stone-300 hover:text-slate-950 dark:text-slate-300 dark:hover:border-slate-600 dark:hover:text-white"}`} aria-current={pathname === "/projects" ? "page" : undefined}>Projects</Link>
<Link to="/skills" className={`inline-flex min-h-12 shrink-0 items-center border-b-2 px-3 text-sm font-semibold transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-factorize-500 ${pathname === "/skills" ? "border-factorize-500 text-factorize-700 dark:text-factorize-500" : "border-transparent text-slate-600 hover:border-stone-300 hover:text-slate-950 dark:text-slate-300 dark:hover:border-slate-600 dark:hover:text-white"}`} aria-current={pathname === "/skills" ? "page" : undefined}>Skills</Link>
<Link to="/projects" className={`inline-flex min-h-12 shrink-0 items-center gap-2 border-b-2 px-3 text-sm font-semibold transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-factorize-500 ${pathname === "/projects" ? "border-factorize-500 text-factorize-700 dark:text-factorize-500" : "border-transparent text-slate-600 hover:border-stone-300 hover:text-slate-950 dark:text-slate-300 dark:hover:border-slate-600 dark:hover:text-white"}`} aria-current={pathname === "/projects" ? "page" : undefined}><NavIcon name="projects" />Projects</Link>
<Link to="/skills" className={`inline-flex min-h-12 shrink-0 items-center gap-2 border-b-2 px-3 text-sm font-semibold transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-factorize-500 ${pathname === "/skills" ? "border-factorize-500 text-factorize-700 dark:text-factorize-500" : "border-transparent text-slate-600 hover:border-stone-300 hover:text-slate-950 dark:text-slate-300 dark:hover:border-slate-600 dark:hover:text-white"}`} aria-current={pathname === "/skills" ? "page" : undefined}><NavIcon name="skills" />Skills</Link>
</div>
</nav>}
{logout.isError && <p role="alert">{logout.error.message}</p>}
Expand Down
3 changes: 2 additions & 1 deletion packages/app/src/features/jobs/editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { canonicalizeVmImage, applySavedJob, editableJob, emptyJob, reconcile, v
import { TemplateField } from "./template-field";
import { TriggerEditor } from "./trigger-editor";
import { InvocationPermissionEditor } from "./invocation-permission-editor";
import { NavIcon } from "../../shared/nav-icon";
import { messageOf } from "../auth/session";
import { projectsQuery } from "../projects/queries";
import { AutosaveStatus, useDebouncedAutosave } from "../../shared/use-debounced-autosave";
Expand Down Expand Up @@ -90,7 +91,7 @@ function EditorForm({ initial, section }: { initial?: Job; section?: string }) {
const [localConflictDraft, setLocalConflictDraft] = useState(draft);
const selectedSection = initial && ["general", "execution", "context", "permissions", "triggers"].includes(section ?? "") ? section : initial ? "general" : "all";
const show = (name: string) => selectedSection === "all" || selectedSection === name;
const settingsSection = (name: "general" | "execution" | "context" | "permissions" | "triggers") => <Link to="/jobs/$jobId/settings/$section" params={{ jobId: initial!.id, section: name }} aria-current={selectedSection === name ? "page" : undefined} className={`rounded-lg px-3 py-2 text-sm ${selectedSection === name ? "bg-factorize-50 font-semibold text-factorize-700 dark:bg-factorize-500/10 dark:text-factorize-500" : "hover:bg-stone-100 dark:hover:bg-slate-800"}`}>{name[0].toUpperCase() + name.slice(1)}</Link>;
const settingsSection = (name: "general" | "execution" | "context" | "permissions" | "triggers") => <Link to="/jobs/$jobId/settings/$section" params={{ jobId: initial!.id, section: name }} aria-current={selectedSection === name ? "page" : undefined} className={`inline-flex items-center gap-2 rounded-lg px-3 py-2 text-sm ${selectedSection === name ? "bg-factorize-50 font-semibold text-factorize-700 dark:bg-factorize-500/10 dark:text-factorize-500" : "hover:bg-stone-100 dark:hover:bg-slate-800"}`}><NavIcon name={name} />{name[0].toUpperCase() + name.slice(1)}</Link>;
return <Page className="max-w-6xl">
{(remote || reconciling || refreshConflict.error) && <Card role="alert" className="my-4 border p-4"><h2>This job changed while you were editing</h2><p>Your unsaved draft is retained. Review the latest configuration before retrying.</p>
{refreshConflict.isPending && <p>Loading latest configuration…</p>}{refreshConflict.error && <><p>{refreshConflict.error.message}</p><Button onClick={() => refreshConflict.mutate()}>Retry loading latest</Button></>}
Expand Down
7 changes: 4 additions & 3 deletions packages/app/src/features/jobs/job-nav.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { Link } from "@tanstack/react-router";
import { NavIcon } from "../../shared/nav-icon";

type JobTab = "runs" | "settings";

export function JobNav({ jobId, tab }: { jobId: string; tab: JobTab }) {
const tabs = [
{ id: "runs" as const, label: "Runs", to: "/jobs/$jobId" as const },
{ id: "settings" as const, label: "Settings", to: "/jobs/$jobId/settings" as const },
{ id: "runs" as const, label: "Runs", to: "/jobs/$jobId" as const, icon: <NavIcon name="runs" /> },
{ id: "settings" as const, label: "Settings", to: "/jobs/$jobId/settings" as const, icon: <NavIcon name="settings" /> },
];
return <nav aria-label="Job navigation" className="border-y border-stone-200 bg-white dark:border-slate-800 dark:bg-slate-950">
<div className="mx-auto flex w-full max-w-6xl gap-1 overflow-x-auto px-4 sm:px-6 lg:px-8">
{tabs.map(item => <Link key={item.id} to={item.to} params={{ jobId }} className={`inline-flex min-h-12 shrink-0 items-center border-b-2 px-3 text-sm font-semibold transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-factorize-500 ${tab === item.id ? "border-factorize-500 text-factorize-700 dark:text-factorize-500" : "border-transparent text-slate-600 hover:border-stone-300 hover:text-slate-950 dark:text-slate-300 dark:hover:border-slate-600 dark:hover:text-white"}`} aria-current={tab === item.id ? "page" : undefined}>{item.label}</Link>)}
{tabs.map(item => <Link key={item.id} to={item.to} params={{ jobId }} className={`inline-flex min-h-12 shrink-0 items-center gap-2 border-b-2 px-3 text-sm font-semibold transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-factorize-500 ${tab === item.id ? "border-factorize-500 text-factorize-700 dark:text-factorize-500" : "border-transparent text-slate-600 hover:border-stone-300 hover:text-slate-950 dark:text-slate-300 dark:hover:border-slate-600 dark:hover:text-white"}`} aria-current={tab === item.id ? "page" : undefined}>{item.icon}{item.label}</Link>)}
</div>
</nav>;
}
5 changes: 3 additions & 2 deletions packages/app/src/features/jobs/tabs.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { Link } from "@tanstack/react-router";
import { NavIcon } from "../../shared/nav-icon";

export function JobTabs({ jobId }: { jobId: string }) {
const classes = "inline-flex min-h-11 items-center border-b-2 px-4 py-2 text-sm font-semibold hover:bg-stone-100 dark:hover:bg-slate-800";
const activeProps = { className: "border-factorize-500 text-factorize-700 dark:text-factorize-500", "aria-current": "page" as const };
return <nav aria-label="Job views" className="mt-5 flex gap-2 border-b border-stone-200 dark:border-slate-700">
<Link to="/jobs/$jobId" params={{ jobId }} search={{}} activeOptions={{ exact: true, includeSearch: false }} className={classes} activeProps={activeProps} inactiveProps={{ className: "border-transparent" }}>Runs</Link>
<Link to="/jobs/$jobId/settings" params={{ jobId }} activeOptions={{ exact: true, includeSearch: false }} className={classes} activeProps={activeProps} inactiveProps={{ className: "border-transparent" }}>Settings</Link>
<Link to="/jobs/$jobId" params={{ jobId }} search={{}} activeOptions={{ exact: true, includeSearch: false }} className={`${classes} gap-2`} activeProps={activeProps} inactiveProps={{ className: "border-transparent" }}><NavIcon name="runs" />Runs</Link>
<Link to="/jobs/$jobId/settings" params={{ jobId }} activeOptions={{ exact: true, includeSearch: false }} className={`${classes} gap-2`} activeProps={activeProps} inactiveProps={{ className: "border-transparent" }}><NavIcon name="settings" />Settings</Link>
</nav>;
}
7 changes: 4 additions & 3 deletions packages/app/src/features/projects/project-nav.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { Link, useParams } from "@tanstack/react-router";
import { useQuery } from "@tanstack/react-query";
import { Page } from "../../shared/ui";
import { NavIcon } from "../../shared/nav-icon";
import { projectQuery } from "./queries";

type ProjectTab = "jobs" | "runs" | "settings";

const tabs: Array<{ id: ProjectTab; label: string; to: "/projects/$projectId" | "/projects/$projectId/runs" | "/projects/$projectId/settings"; icon: React.ReactNode }> = [
{ id: "jobs", label: "Jobs", to: "/projects/$projectId", icon: <svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" className="size-[18px]"><rect x="3.5" y="7" width="17" height="13.5" rx="2"/><path strokeLinecap="round" strokeLinejoin="round" d="M8.5 7V5.5A1.5 1.5 0 0 1 10 4h4a1.5 1.5 0 0 1 1.5 1.5V7M3.5 12h17m-10 0v1.5h3V12"/></svg> },
{ id: "runs", label: "Runs", to: "/projects/$projectId/runs", icon: <svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" className="size-[18px]"><circle cx="12" cy="12" r="9"/><path fill="currentColor" stroke="none" d="m10 8 6 4-6 4z"/></svg> },
{ id: "settings", label: "Settings", to: "/projects/$projectId/settings", icon: <svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" className="size-[18px]"><path strokeLinecap="round" strokeLinejoin="round" d="M10 3.8h4l.6 2.1 1.6.9 2.1-.6 2 3.5-1.5 1.6v1.8l1.5 1.6-2 3.5-2.1-.6-1.6.9-.6 2.1h-4l-.6-2.1-1.6-.9-2.1.6-2-3.5 1.5-1.6v-1.8L3.7 9.7l2-3.5 2.1.6 1.6-.9z"/><circle cx="12" cy="12" r="3"/></svg> },
{ id: "jobs", label: "Jobs", to: "/projects/$projectId", icon: <NavIcon name="jobs" /> },
{ id: "runs", label: "Runs", to: "/projects/$projectId/runs", icon: <NavIcon name="runs" /> },
{ id: "settings", label: "Settings", to: "/projects/$projectId/settings", icon: <NavIcon name="settings" /> },
];

export function ProjectNav({ tab, projectId: projectIdProp, children }: { tab: ProjectTab; projectId?: string; children?: React.ReactNode }) {
Expand Down
5 changes: 3 additions & 2 deletions packages/app/src/features/runs/detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { jobQuery } from "../jobs/queries";
import { JobNav } from "../jobs/job-nav";
import { ResourceSwitcher } from "../../shared/resource-switcher";
import { messageOf } from "../auth/session";
import { NavIcon } from "../../shared/nav-icon";
function RuntimeInfo({ startedAt, updatedAt, active }: { startedAt: string | null; updatedAt: string; active: boolean }) {
const [now, setNow] = useState(() => Date.now());
useEffect(() => {
Expand Down Expand Up @@ -73,12 +74,12 @@ export function RunDetail() {
{stop.error && <p role="alert">{stop.error.message}</p>}
{!fullTrace && <nav role="tablist" aria-label="Run details" className="mt-5 flex gap-1 overflow-x-auto border-b border-stone-200 dark:border-slate-700">
{(["trace", "info"] as const).map((name, index, tabs) => <Link key={name} to={tabPath(name)} params={{ runId: runId! }} search={{ after: 0 }} role="tab" id={`run-tab-${name}`} aria-controls={`run-panel-${name}`} aria-selected={tab === name} tabIndex={tab === name ? 0 : -1}
className={`min-h-11 shrink-0 border-b-2 px-4 py-3 text-sm capitalize ${tab === name ? "border-factorize-500 font-semibold" : "border-transparent text-slate-600 hover:border-stone-300 dark:text-slate-400"}`}
className={`inline-flex min-h-11 shrink-0 items-center gap-2 border-b-2 px-4 py-3 text-sm capitalize ${tab === name ? "border-factorize-500 font-semibold" : "border-transparent text-slate-600 hover:border-stone-300 dark:text-slate-400"}`}
onKeyDown={event => {
const next = event.key === "ArrowRight" ? (index + 1) % tabs.length : event.key === "ArrowLeft" ? (index + tabs.length - 1) % tabs.length : event.key === "Home" ? 0 : event.key === "End" ? tabs.length - 1 : null;
if (next === null) return;
event.preventDefault(); void navigate({ to: tabPath(tabs[next]), params: { runId: runId! }, search: { after: 0 } }).then(() => document.getElementById(`run-tab-${tabs[next]}`)?.focus());
}}>{name === "info" ? "Info" : name[0].toUpperCase() + name.slice(1)}</Link>)}
}}><NavIcon name={name} />{name === "info" ? "Info" : name[0].toUpperCase() + name.slice(1)}</Link>)}
</nav>}
{!fullTrace && <section role="tabpanel" id="run-panel-info" aria-labelledby="run-tab-info" hidden={tab !== "info"} tabIndex={0}>
{status.data && <dl className="my-4 grid min-w-0 gap-4 sm:grid-cols-2">
Expand Down
12 changes: 11 additions & 1 deletion packages/app/src/features/settings/navigation.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
import type { ReactNode } from "react";
import { Page } from "../../shared/ui";
import { Link } from "@tanstack/react-router";
export function SettingsNavigation() { const cls = "rounded-lg px-3 py-2 hover:bg-stone-100 dark:hover:bg-slate-800"; const active = { className: "bg-factorize-50 text-factorize-700 dark:bg-factorize-500/10 dark:text-factorize-500" }; return <nav aria-label="Settings" className="flex flex-wrap gap-2 border-b border-stone-200 pb-4 text-sm font-semibold dark:border-slate-800 md:flex-col md:border-b-0"><Link className={cls} activeOptions={{ exact: true }} activeProps={active} to="/settings">Integrations</Link><Link className={cls} activeOptions={{ exact: true }} activeProps={active} to="/settings/api-keys">API keys</Link><Link className={cls} activeOptions={{ exact: true }} activeProps={active} to="/settings/authorized-clients">Authorized clients</Link><Link className={cls} activeOptions={{ exact: true }} activeProps={active} to="/settings/password">Change password</Link></nav>; }
import { NavIcon } from "../../shared/nav-icon";
export function SettingsNavigation() {
const cls = "inline-flex items-center gap-2 rounded-lg px-3 py-2 hover:bg-stone-100 dark:hover:bg-slate-800";
const active = { className: "bg-factorize-50 text-factorize-700 dark:bg-factorize-500/10 dark:text-factorize-500" };
return <nav aria-label="Settings" className="flex flex-wrap gap-2 border-b border-stone-200 pb-4 text-sm font-semibold dark:border-slate-800 md:flex-col md:border-b-0">
<Link className={cls} activeOptions={{ exact: true }} activeProps={active} to="/settings"><NavIcon name="integrations" />Integrations</Link>
<Link className={cls} activeOptions={{ exact: true }} activeProps={active} to="/settings/api-keys"><NavIcon name="key" />API keys</Link>
<Link className={cls} activeOptions={{ exact: true }} activeProps={active} to="/settings/authorized-clients"><NavIcon name="users" />Authorized clients</Link>
<Link className={cls} activeOptions={{ exact: true }} activeProps={active} to="/settings/password"><NavIcon name="lock" />Change password</Link>
</nav>;
}
export function SettingsLayout({ title, children }: { title: string; children: ReactNode }) { return <Page><div className="grid min-w-0 gap-8 md:grid-cols-[13rem_minmax(0,1fr)] md:gap-10"><SettingsNavigation /><div className="min-w-0"><h1>{title}</h1><p className="mb-6 text-sm text-slate-600 dark:text-slate-400">{title === "Integrations" ? "Connect every provider used by your jobs. Stored credentials are write-only." : "Manage access to your software factory."}</p>{children}</div></div></Page>; }
28 changes: 28 additions & 0 deletions packages/app/src/shared/nav-icon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
export type NavIconName =
| "jobs" | "runs" | "settings" | "projects" | "skills"
| "integrations" | "key" | "users" | "lock"
| "general" | "execution" | "context" | "permissions" | "triggers"
| "trace" | "info";

const paths: Record<NavIconName, React.ReactNode> = {
jobs: <><rect x="3.5" y="7" width="17" height="13.5" rx="2"/><path strokeLinecap="round" strokeLinejoin="round" d="M8.5 7V5.5A1.5 1.5 0 0 1 10 4h4a1.5 1.5 0 0 1 1.5 1.5V7M3.5 12h17m-10 0v1.5h3V12"/></>,
runs: <><circle cx="12" cy="12" r="9"/><path fill="currentColor" stroke="none" d="m10 8 6 4-6 4z"/></>,
settings: <><path strokeLinecap="round" strokeLinejoin="round" d="M10 3.8h4l.6 2.1 1.6.9 2.1-.6 2 3.5-1.5 1.6v1.8l1.5 1.6-2 3.5-2.1-.6-1.6.9-.6 2.1h-4l-.6-2.1-1.6-.9-2.1.6-2-3.5 1.5-1.6v-1.8L3.7 9.7l2-3.5 2.1.6 1.6-.9z"/><circle cx="12" cy="12" r="3"/></>,
projects: <><rect x="3" y="4" width="8" height="7" rx="1.5"/><rect x="13" y="4" width="8" height="7" rx="1.5"/><rect x="3" y="13" width="8" height="7" rx="1.5"/><rect x="13" y="13" width="8" height="7" rx="1.5"/></>,
skills: <><path strokeLinecap="round" strokeLinejoin="round" d="m12 3 2.1 5.9L20 11l-5.9 2.1L12 19l-2.1-5.9L4 11l5.9-2.1zM19 16v5m-2.5-2.5h5"/></>,
integrations: <><rect x="3" y="4" width="7" height="7" rx="1.5"/><rect x="14" y="4" width="7" height="7" rx="1.5"/><rect x="3" y="14" width="7" height="7" rx="1.5"/><rect x="14" y="14" width="7" height="7" rx="1.5"/></>,
key: <><circle cx="8" cy="15" r="4"/><path strokeLinecap="round" strokeLinejoin="round" d="m11 12 8-8 2 2-2 2 2 2-3 3-2-2-2 2"/></>,
users: <><circle cx="9" cy="8" r="3"/><path strokeLinecap="round" strokeLinejoin="round" d="M3 20v-1a6 6 0 0 1 12 0v1zm12-12a3 3 0 1 1 0 6m2 1a5 5 0 0 1 4 5"/></>,
lock: <><rect x="4" y="10" width="16" height="11" rx="2"/><path strokeLinecap="round" strokeLinejoin="round" d="M8 10V7a4 4 0 1 1 8 0v3m-4 4v3"/></>,
general: <><circle cx="12" cy="12" r="9"/><circle cx="12" cy="9" r="3"/><path strokeLinecap="round" strokeLinejoin="round" d="M6.5 19a6 6 0 0 1 11 0"/></>,
execution: <><path strokeLinecap="round" strokeLinejoin="round" d="M13 2 4 14h7l-1 8 10-13h-7z"/></>,
context: <><path strokeLinecap="round" strokeLinejoin="round" d="M4 5h16M4 12h16M4 19h10"/><circle cx="18" cy="19" r="2"/></>,
permissions: <><path strokeLinecap="round" strokeLinejoin="round" d="M12 3 20 6v5c0 5-3.5 8-8 10-4.5-2-8-5-8-10V6z"/><path strokeLinecap="round" strokeLinejoin="round" d="m9 12 2 2 4-4"/></>,
triggers: <><path strokeLinecap="round" strokeLinejoin="round" d="M12 3 4 13h6l-1 8 11-12h-6z"/></>,
trace: <><path strokeLinecap="round" strokeLinejoin="round" d="M3 12h4l3-7 4 14 3-7h4"/></>,
info: <><circle cx="12" cy="12" r="9"/><path strokeLinecap="round" strokeLinejoin="round" d="M12 11v5m0-8h.01"/></>,
};

export function NavIcon({ name, className = "size-[18px]" }: { name: NavIconName; className?: string }) {
return <svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" className={className}>{paths[name]}</svg>;
}