import { data } from "react-router"; import type { Route } from "./+types/repo-tree"; import { splatSegments } from "@refs/backend/contract"; import { TreeView } from "@refs/design-system"; import { useLastChanges } from "../components/last-changes"; import { commitCheck } from "../lib/commit-check"; import { found, refs, fullName, nowSeconds } from "../lib/session"; export const meta: Route.MetaFunction = ({ params }) => [{ title: `${params["*"]} · ${fullName(params)} · refs` }]; export async function loader({ params, context }: Route.LoaderArgs) { const segments = splatSegments(params["*"]); if (!segments) throw data(null, { status: 404 }); const repo = await found(refs(context).repo(fullName(params))); const [tree, refList] = await found(Promise.all([repo.tree(segments), repo.refs()])); const check = commitCheck(repo.summary.name, await repo.ci().runs({ sha: tree.commit.hash, limit: 10 })); return { repo: repo.summary.name, cloneUrl: repo.summary.cloneUrl, refs: refList, tree, check, now: nowSeconds() }; } export default function RepoTree({ loaderData }: Route.ComponentProps) { const { repo, cloneUrl, refs: refList, tree, now } = loaderData; const last = useLastChanges(repo, tree.location.ref, tree.location.path); return ; }