g1t/apps/web/app/routes/workspace/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 { SecretsPanel } from "../../components/secrets"; |
| 4 | import { actOnSecrets, loadSecrets } from "../../lib/secrets.server"; | |
| 5 | import { assertSameOrigin, getViewer, requireUser, roleIn } from "../../lib/session.server"; | |
| 6 | ||
| Social cards for every page: og.g1t.sh | 7 | export function meta({ params, ...args }: Route.MetaArgs) { |
| 8 | return page(args, { title: `Secrets and variables · ${params.owner} · g1t` }); | |
| GitHub Actions on g1t, part three: .g1t/workflows, the pages, the docs | 9 | } |
| 10 | ||
| 11 | export async function loader({ params, context, request }: Route.LoaderArgs) { | |
| 12 | const role = roleIn(getViewer(context), params.owner); | |
| 13 | if (!role) throw new Response(null, { status: 404 }); | |
| 14 | return { role, ...(await loadSecrets({ workspace: params.owner.toLowerCase() }, requireUser(context, request))) }; | |
| 15 | } | |
| 16 | ||
| 17 | export async function action({ request, params, context }: Route.ActionArgs) { | |
| 18 | assertSameOrigin(request); | |
| 19 | const user = requireUser(context, request); | |
| Secrets and variables: one list, rows per environment, for workflows and deployments | 20 | const page = `/${params.owner}/-/secrets`; |
| 21 | return actOnSecrets({ workspace: params.owner.toLowerCase() }, user, await request.formData(), page); | |
| GitHub Actions on g1t, part three: .g1t/workflows, the pages, the docs | 22 | } |
| 23 | ||
| 24 | export default function WorkspaceSecrets({ loaderData, actionData }: Route.ComponentProps) { | |
| 25 | const { role, ...data } = loaderData; | |
| 26 | // Every repository reads a workspace's, so only its owners change them. | |
| 27 | return <SecretsPanel data={data} action={actionData} scope="workspace" manage={role === "owner"} />; | |
| 28 | } |