import { createFileRoute, Link } from "@tanstack/react-router";
import { useState } from "react";
import { z } from "zod";
import { dispatchWorkflow, listRuns, listWorkflowFiles } from "~/fns/actions";
import { GITHUB_WORKFLOW_DIR, importGithubWorkflows, listImportableWorkflows } from "~/fns/workflow-import";
import { useAction } from "~/hooks/use-action";
import { useRepo } from "~/hooks/use-repo";
import { Badge } from "~/ui/Badge";
import { EmptyState } from "~/ui/EmptyState";
import { formatDuration } from "~/lib/format";
import { Panel } from "~/ui/Panel";
import { RelativeTime } from "~/ui/RelativeTime";
import { StatusDot, runState } from "~/ui/StatusDot";
import { Button, buttonClass } from "~/ui/Button";
import { inputClass, TextField } from "~/ui/Field";
import { ErrorBanner } from "~/ui/Callout";
import { cn } from "~/utils/cn";
export const Route = createFileRoute("/$owner/$repo/actions/")({
validateSearch: z.object({ workflow: z.string().optional(), page: z.number().int().min(1).optional() }),
loaderDeps: ({ search }) => search,
loader: async ({ params, deps }) => {
const ref = { owner: params.owner, repo: params.repo };
const [runs, files, importable] = await Promise.all([
listRuns({ data: { ...ref, workflow: deps.workflow, page: deps.page ?? 1 } }),
listWorkflowFiles({ data: ref }),
listImportableWorkflows({ data: ref }),
]);
return { ...runs, files, importable };
},
component: ActionsPage,
});
function RunsEmptyState({
importable,
canWrite,
defaultBranch,
}: {
importable: string[];
canWrite: boolean;