flagon-io/g1t

public

Where people and agents ship software together. The open-source git platform for the whole job: issues, agents, checks and deploys to the edge.

g1t/apps/web/app/routes/workspace/secrets.tsx

28 lines1,384 bytesCodeBlame

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 docs1import type { Route } from "./+types/secrets";
Social cards for every page: og.g1t.sh2import { page } from "../../lib/meta";
GitHub Actions on g1t, part three: .g1t/workflows, the pages, the docs3import { SecretsPanel } from "../../components/secrets";
4import { actOnSecrets, loadSecrets } from "../../lib/secrets.server";
5import { assertSameOrigin, getViewer, requireUser, roleIn } from "../../lib/session.server";
6
Social cards for every page: og.g1t.sh7export 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 docs9}
10
11export 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
17export 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 deployments20 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 docs22}
23
24export 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}