Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.
| Fast pages, required checks on the branch, self-hosted runners, honest incidents | 1 | import type { Route } from "./+types/runners"; |
| 2 | import { page } from "../../lib/meta"; | |
| 3 | import { RunnersPanel } from "../../components/runners"; | |
| 4 | import { actOnRunners, loadRunners } from "../../lib/runners.server"; | |
| 5 | import { repos } from "../../lib/services.server"; | |
| 6 | import { assertSameOrigin, getViewer, requireUser, roleIn } from "../../lib/session.server"; | |
| 7 | ||
| 8 | export function meta({ params, ...args }: Route.MetaArgs) { | |
| 9 | return page(args, { title: `Runners · ${params.owner} · g1t` }); | |
| 10 | } | |
| 11 | ||
| 12 | export async function loader({ params, context, request }: Route.LoaderArgs) { | |
| Runners are owner-only: the page, its actions, the Settings entry and the links to it | 13 | // The workspace's own machines and their tokens: owners only. |
| 14 | if (roleIn(getViewer(context), params.owner) !== "owner") throw new Response(null, { status: 404 }); | |
| Fast pages, required checks on the branch, self-hosted runners, honest incidents | 15 | const user = requireUser(context, request); |
| 16 | const workspace = params.owner.toLowerCase(); | |
| Runners are owner-only: the page, its actions, the Settings entry and the links to it | 17 | const names = (await repos.list(user, { namespace: workspace })).map((repo) => repo.name); |
| 18 | return loadRunners({ workspace }, user, names); | |
| Fast pages, required checks on the branch, self-hosted runners, honest incidents | 19 | } |
| 20 | ||
| 21 | export async function action({ request, params, context }: Route.ActionArgs) { | |
| 22 | assertSameOrigin(request); | |
| Runners are owner-only: the page, its actions, the Settings entry and the links to it | 23 | if (roleIn(getViewer(context), params.owner) !== "owner") throw new Response(null, { status: 404 }); |
| Fast pages, required checks on the branch, self-hosted runners, honest incidents | 24 | const user = requireUser(context, request); |
| 25 | return actOnRunners({ workspace: params.owner.toLowerCase() }, user, await request.formData()); | |
| 26 | } | |
| 27 | ||
| 28 | export default function WorkspaceRunners({ loaderData, actionData }: Route.ComponentProps) { | |
| Runners are owner-only: the page, its actions, the Settings entry and the links to it | 29 | return <RunnersPanel data={loaderData} action={actionData} scope="workspace" manage />; |
| Fast pages, required checks on the branch, self-hosted runners, honest incidents | 30 | } |