/* 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 ( <>