g1t/apps/web/app/routes/repo/secrets.tsx
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"; |
| Social cards for every page: og.g1t.sh | 2 | import { page } from "../../lib/meta"; |
| GitHub Actions on g1t, part three: .g1t/workflows, the pages, the docs | 3 | import { RepoSettingsTabs } from "../../components/repo-settings-tabs"; |
| 4 | import { SecretsPanel } from "../../components/secrets"; | |
| 5 | import { actOnSecrets, loadSecrets } from "../../lib/secrets.server"; | |
| 6 | import { assertSameOrigin, getViewer, requireUser, roleIn } from "../../lib/session.server"; | |
| 7 | ||
| Social cards for every page: og.g1t.sh | 8 | export function meta({ params, ...args }: Route.MetaArgs) { |
| 9 | return page(args, { title: `Secrets and variables · ${params.owner}/${params.repo} · g1t` }); | |
| GitHub Actions on g1t, part three: .g1t/workflows, the pages, the docs | 10 | } |
| 11 | ||
| 12 | const ownerOf = (params: { owner: string; repo: string }) => ({ repo: { namespace: params.owner, name: params.repo } }); | |
| 13 | ||
| 14 | export async function loader({ params, context, request }: Route.LoaderArgs) { | |
| 15 | // A repository's settings are its workspace's members' to see. | |
| 16 | if (!roleIn(getViewer(context), params.owner)) throw new Response(null, { status: 404 }); | |
| 17 | return loadSecrets(ownerOf(params), requireUser(context, request)); | |
| 18 | } | |
| 19 | ||
| 20 | export async function action({ request, params, context }: Route.ActionArgs) { | |
| 21 | assertSameOrigin(request); | |
| 22 | const user = requireUser(context, request); | |
| Secrets and variables: one list, rows per environment, for workflows and deployments | 23 | const page = `/${params.owner}/${params.repo}/settings/secrets`; |
| 24 | return actOnSecrets(ownerOf(params), user, await request.formData(), page); | |
| GitHub Actions on g1t, part three: .g1t/workflows, the pages, the docs | 25 | } |
| 26 | ||
| 27 | export default function RepoSecrets({ loaderData, actionData, params }: Route.ComponentProps) { | |
| 28 | return ( | |
| 29 | <div> | |
| 30 | <RepoSettingsTabs base={`/${params.owner}/${params.repo}`} /> | |
| Projects: what a workspace builds and runs, first on every page | 31 | <SecretsPanel data={loaderData} action={actionData} scope="project" manage /> |
| GitHub Actions on g1t, part three: .g1t/workflows, the pages, the docs | 32 | </div> |
| 33 | ); | |
| 34 | } |