25 lines · 1.2 KBRaw
| 1 | import type { Route } from "./+types/namespace-agents"; |
| 2 | import { HostedAgentsPage, agentsAction, editingFrom } from "../components/hosted-agents"; |
| 3 | import { AppShell, PageHeader } from "../components/shell"; |
| 4 | import { found, signedIn } from "../lib/session"; |
| 5 | |
| 6 | export const meta: Route.MetaFunction = () => [{ title: "Agents · refs" }]; |
| 7 | |
| 8 | export async function loader({ request, context }: Route.LoaderArgs) { |
| 9 | const agents = await found(signedIn(context).namespaceAgents()); |
| 10 | const list = await agents.list(); |
| 11 | return { list, canEdit: agents.canEdit, editing: editingFrom(request, list, "namespace") }; |
| 12 | } |
| 13 | |
| 14 | export async function action({ request, context }: Route.ActionArgs) { |
| 15 | return agentsAction(await found(signedIn(context).namespaceAgents()), request, "/settings/agents"); |
| 16 | } |
| 17 | |
| 18 | export default function NamespaceAgents({ loaderData, actionData }: Route.ComponentProps) { |
| 19 | return ( |
| 20 | <AppShell> |
| 21 | <PageHeader title="Agents" description="Agents that refs runs for every repository in this namespace. A repository can customize one for itself." /> |
| 22 | <HostedAgentsPage list={loaderData.list} canEdit={loaderData.canEdit} level="namespace" editing={loaderData.editing} error={actionData?.error ?? null} /> |
| 23 | </AppShell> |
| 24 | ); |
| 25 | } |