flagon-io/g1t

public

Where people and agents ship software together. The open-source git platform for the whole job: issues, agents, checks and deploys to the edge.

g1t/apps/web/app/routes/workspace/layout.tsx

132 lines5,494 bytesCodeBlame

Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.

Integrations: your own model provider, alerts that open issues, tickets agents read1import { CreditCard, KeyRound, LayoutGrid, Plug, Plus, Settings, Users } from "lucide-react";
A catalogue of model providers, and settings that feel like settings2import { Outlet, data, useLocation, useRouteLoaderData } from "react-router";
Agents as a team: lifecycle, merge queue, billing and a new shell3
4import type { Route } from "./+types/layout";
Social cards for every page: og.g1t.sh5import { page } from "../../lib/meta";
Agents as a team: lifecycle, merge queue, billing and a new shell6import { Avatar, ButtonLink, Pill, TabLink } from "../../components/ui";
7import { identity } from "../../lib/services.server";
8import { getViewer, roleIn } from "../../lib/session.server";
9
Social cards for every page: og.g1t.sh10export function meta({ loaderData, params, ...args }: Route.MetaArgs) {
11 return page(args, { title: `${loaderData?.workspace.name ?? params.owner} · g1t` });
Agents as a team: lifecycle, merge queue, billing and a new shell12}
13
14export async function loader({ params, context }: Route.LoaderArgs) {
15 const workspace = await identity.getWorkspace(params.owner);
16 if (!workspace) throw data(null, { status: 404 });
17 return { workspace, role: roleIn(getViewer(context), workspace.slug) };
18}
19
A catalogue of model providers, and settings that feel like settings20/** A workspace's own pages, each with its title and what it is for. */
21const PAGES: Record<string, { title: string; about: string }> = {
Workspace names and icons, and a component kit for every control22 settings: { title: "General", about: "The workspace's name, icon, address and description." },
A catalogue of model providers, and settings that feel like settings23 people: {
24 title: "Members",
25 about: "Members create repositories, push, manage issues and merge pull requests. Owners also manage members, tokens, billing and integrations.",
26 },
27 tokens: {
28 title: "Access tokens",
29 about: "Tokens that belong to the workspace, not a person: for CI, integrations and agents that work for the whole team.",
30 },
31 usage: { title: "Usage", about: "What the workspace's agents cost, run by run, by repository, pull request and model." },
Secrets and variables: one list, rows per environment, for workflows and deployments32 billing: { title: "Billing and plans", about: "Paid plans, agent credit, and every charge against it." },
Webhooks: every event, to your own addresses, signed and retried33 webhooks: {
34 title: "Webhooks",
35 about: "Every repository's events, sent to your own addresses as they happen. A repository can also have its own, under its settings.",
36 },
GitHub Actions on g1t, part three: .g1t/workflows, the pages, the docs37 secrets: {
38 title: "Secrets and variables",
Secrets and variables: one list, rows per environment, for workflows and deployments39 about: "Shared with every repository, or the ones you link: read by workflows, deployments, or both. A repository's own row of the same key wins.",
GitHub Actions on g1t, part three: .g1t/workflows, the pages, the docs40 },
A catalogue of model providers, and settings that feel like settings41 integrations: {
42 title: "Integrations",
43 about: "Model providers, alerts and trackers. Secrets are sealed when saved, and agents never see them.",
44 },
45};
46
Agents as a team: lifecycle, merge queue, billing and a new shell47export default function WorkspaceLayout({ loaderData }: Route.ComponentProps) {
48 const { workspace, role } = loaderData;
49 const base = `/${workspace.slug}`;
50 const signedIn = useRouteLoaderData("root")?.user != null;
A catalogue of model providers, and settings that feel like settings51 // The sidebar finds the workspace's pages for someone signed in, so its
52 // pages need a title, not the workspace's whole header again.
53 const page = PAGES[useLocation().pathname.split("/-/")[1]?.split("/")[0] ?? ""];
54 if (signedIn && page) {
55 return (
56 <div className="mx-auto max-w-5xl px-4 py-10 sm:px-8">
57 <header className="mb-8 border-b border-line pb-6">
58 <h1 className="text-2xl font-semibold tracking-tight">{page.title}</h1>
59 <p className="mt-1.5 text-sm text-muted">{page.about}</p>
60 </header>
61 <Outlet />
62 </div>
63 );
64 }
Agents as a team: lifecycle, merge queue, billing and a new shell65 return (
66 <>
67 {/* The workspace's own header band, under the site header. */}
68 <div className="border-b border-line bg-surface/60">
69 <div className="mx-auto max-w-6xl px-4 pt-8">
70 <div className="flex flex-wrap items-center gap-4">
Workspace names and icons, and a component kit for every control71 <Avatar name={workspace.slug} image={workspace.avatar} size={52} square />
Agents as a team: lifecycle, merge queue, billing and a new shell72 <div className="min-w-0 grow">
73 <div className="flex flex-wrap items-center gap-2.5">
74 <h1 className="truncate text-2xl font-semibold tracking-tight">
75 {workspace.name}
76 </h1>
77 {role && <Pill>{role}</Pill>}
78 </div>
79 <p className="font-mono text-sm text-muted">g1t.sh/{workspace.slug}</p>
80 </div>
81 {role && (
82 <ButtonLink to={`/new?workspace=${workspace.slug}`}>
83 <Plus size={15} />
Projects live: fixes from walking them end to end84 New project
Agents as a team: lifecycle, merge queue, billing and a new shell85 </ButtonLink>
86 )}
87 </div>
88 {workspace.description && (
89 <p className="mt-4 max-w-2xl text-sm text-muted">{workspace.description}</p>
90 )}
91 {signedIn ? (
92 <div className="pb-8" />
93 ) : (
94 <nav className="mt-6 flex flex-wrap gap-x-6">
95 <TabLink to={base} end icon={<LayoutGrid size={15} />}>
96 Overview
97 </TabLink>
98 {role && (
99 <>
100 <TabLink
101 to={`${base}/-/people`}
102 icon={<Users size={15} />}
103 count={workspace.memberCount}
104 >
Secrets and variables: one list, rows per environment, for workflows and deployments105 Members
Agents as a team: lifecycle, merge queue, billing and a new shell106 </TabLink>
107 <TabLink to={`${base}/-/tokens`} icon={<KeyRound size={15} />}>
108 Access tokens
109 </TabLink>
110 <TabLink to={`${base}/-/billing`} icon={<CreditCard size={15} />}>
111 Billing
112 </TabLink>
Integrations: your own model provider, alerts that open issues, tickets agents read113 <TabLink to={`${base}/-/integrations`} icon={<Plug size={15} />}>
114 Integrations
115 </TabLink>
Agents as a team: lifecycle, merge queue, billing and a new shell116 </>
117 )}
118 {role === "owner" && (
119 <TabLink to={`${base}/-/settings`} icon={<Settings size={15} />}>
120 Settings
121 </TabLink>
122 )}
123 </nav>
124 )}
125 </div>
126 </div>
127 <div className="mx-auto max-w-6xl px-4 py-8">
128 <Outlet />
129 </div>
130 </>
131 );
132}