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