Skip to content
35 linesCodeBlameRaw
1import { useLocation } from "react-router";
2
3/** Each of a project's settings pages: its name and what it is for. */
4const PAGES: Record<string, { title: string; about: string }> = {
5 "": { title: "General", about: "The project's name, where its code lives, and what it is for." },
6 deployments: { title: "Deployments", about: "How the project builds, where it runs, and its previews." },
7 domains: { title: "Domains", about: "Addresses of your own for the production deployment." },
8 guardrails: { title: "Guardrails", about: "How long this project's runs may take." },
9 repository: { title: "Repository", about: "Its name, details and default branch, who can see it, and archiving, moving or deleting it." },
10 access: { title: "Access", about: "Who can see and change the repository, with which role, and invitations to it." },
11 keys: { title: "Deploy keys", about: "SSH keys that let a machine clone this repository, or push to it, and reach nothing else." },
12 branches: { title: "Branches and merging", about: "How pull requests merge, and who owns which files." },
13 rules: { title: "Rules", about: "Rulesets: what may happen to branches and tags, what a pull request needs before it merges, and how the rules judged each push and merge." },
14 secrets: { title: "Secrets and variables", about: "Values workflows, builds and deployments read at run time." },
15 actions: { title: "Actions", about: "What workflows' tokens may do, and whose pull requests' runs wait for approval." },
16 environments: { title: "Environments", about: "Protection rules for the environments jobs deploy to: reviews, wait timers and branches." },
17 runners: { title: "Runners", about: "Machines of your own for this project's workflow jobs and sandbox runs." },
18 webhooks: { title: "Webhooks", about: "Addresses g1t calls when something happens in the project." },
19};
20
21/**
22 * The heading of a project's settings page, named from the address. The
23 * pages themselves are listed in the sidebar while you are in settings.
24 */
25export function RepoSettingsHeading({ base }: { base: string }) {
26 const { pathname } = useLocation();
27 const section = pathname.slice(`${base}/settings`.length).replace(/^\//, "").split("/")[0] ?? "";
28 const page = PAGES[section] ?? PAGES[""]!;
29 return (
30 <header className="mb-8 border-b border-line pb-5">
31 <h1 className="text-lg font-semibold tracking-tight">{page.title}</h1>
32 <p className="mt-1 text-sm text-muted">{page.about}</p>
33 </header>
34 );
35}