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.
| GitHub Actions on g1t, part three: .g1t/workflows, the pages, the docs | 1 | import type { Route } from "./+types/secrets"; |
| 2 | import { RepoSettingsTabs } from "../../components/repo-settings-tabs"; | |
| 3 | import { SecretsPanel } from "../../components/secrets"; | |
| 4 | import { actOnSecrets, loadSecrets } from "../../lib/secrets.server"; | |
| 5 | import { assertSameOrigin, getViewer, requireUser, roleIn } from "../../lib/session.server"; | |
| 6 | ||
| 7 | export function meta({ params }: Route.MetaArgs) { | |
| 8 | return [{ title: `Secrets and variables · ${params.owner}/${params.repo} · g1t` }]; | |
| 9 | } | |
| 10 | ||
| 11 | const ownerOf = (params: { owner: string; repo: string }) => ({ repo: { namespace: params.owner, name: params.repo } }); | |
| 12 | ||
| 13 | export async function loader({ params, context, request }: Route.LoaderArgs) { | |
| 14 | // A repository's settings are its workspace's members' to see. | |
| 15 | if (!roleIn(getViewer(context), params.owner)) throw new Response(null, { status: 404 }); | |
| 16 | return loadSecrets(ownerOf(params), requireUser(context, request)); | |
| 17 | } | |
| 18 | ||
| 19 | export async function action({ request, params, context }: Route.ActionArgs) { | |
| 20 | assertSameOrigin(request); | |
| 21 | const user = requireUser(context, request); | |
| 22 | return actOnSecrets(ownerOf(params), user, await request.formData()); | |
| 23 | } | |
| 24 | ||
| 25 | export default function RepoSecrets({ loaderData, actionData, params }: Route.ComponentProps) { | |
| 26 | return ( | |
| 27 | <div> | |
| 28 | <RepoSettingsTabs base={`/${params.owner}/${params.repo}`} /> | |
| 29 | <SecretsPanel data={loaderData} action={actionData} scope="repository" manage /> | |
| 30 | </div> | |
| 31 | ); | |
| 32 | } |