/* Git Servers — the forge host registry. Each row maps a host to the token env var to * inject at spawn (and the credential-helper scope). Holds no secrets, only the var name. */ "use client"; import { useState } from "react"; import { useDashboard } from "@/components/store"; import { Badge, Button, Card, Input, Select } from "@/components/ui"; import type { Host } from "@/lib/api"; const FORGE_OPTS = [ { value: "github", label: "github" }, { value: "gitlab", label: "gitlab" }, { value: "gitea", label: "gitea" }, { value: "forgejo", label: "forgejo" }, { value: "bitbucket", label: "bitbucket" }, ]; const empty = { hostname: "", forge_type: "github", token_env_var: "", base_url: "" }; export function GitServersSection() { const s = useDashboard(); const [form, setForm] = useState(empty); const [editing, setEditing] = useState(false); const reset = () => { setForm(empty); setEditing(false); }; const save = async () => { const ok = editing ? await s.updateHost(form.hostname, form) : await s.createHost(form); if (ok) reset(); }; const edit = (h: Host) => { setForm({ hostname: h.hostname, forge_type: h.forge_type, token_env_var: h.token_env_var ?? "", base_url: h.base_url ?? "", }); setEditing(true); }; return ( <>
Git Servers
Maps a git host to the token env var injected at spawn. The built-in host map is the fallback when no row matches.
{editing ? `Edit server · ${form.hostname}` : "Add a git server"}
setForm({ ...form, hostname: v })} placeholder="git.corp.internal" disabled={editing} /> setForm({ ...form, token_env_var: v })} placeholder="GITEA_TOKEN" /> setForm({ ...form, base_url: v })} placeholder="https://git.corp.internal (optional)" />
{editing && ( )}
{s.hosts.length === 0 && (
No git servers registered (built-in host map still applies).
)} {s.hosts.map((h) => (
{h.hostname}
{h.forge_type}
token env {h.token_env_var || "—"} {h.base_url ? ` · ${h.base_url}` : ""}
))}
); }