import { Link } from "@tanstack/react-router"; import { CommitAuthor } from "./CommitAuthor"; import { Markdown } from "~/ui/Markdown"; import { Panel } from "~/ui/Panel"; import { RelativeTime } from "~/ui/RelativeTime"; import { StatusDot } from "~/ui/StatusDot"; import { buttonClass } from "~/ui/Button"; import { Breadcrumbs } from "./RefNavigation"; import { RefSwitcher } from "./RefSwitcher"; import { useLastCommits } from "~/hooks/use-last-commits"; import type { CommitSummary, StatusState, TreeEntry } from "~/lib/types"; import type { CommitBrief } from "~/lib/code-intel"; type Props = { owner: string; repo: string; gitRef: { kind: string; name: string; sha: string }; path: string; entries: TreeEntry[]; commit: CommitSummary & { authorAccount: string | null }; commitStatus: StatusState | null; /** Latest workflow run for the commit; the status dot links to it, else to the commit's checks. */ commitRun: number | null; readme: { path: string; html: string | null; text: string | null } | null; branches: string[]; tags: string[]; canWrite: boolean; /** The viewer may boot editor containers here (write access, containers on, plan includes them). */ containersAllowed: boolean; }; function EntryCommit({ commit }: { commit: CommitBrief | null | undefined }) { if (commit === undefined) return ; if (commit === null) return null; return ( {commit.subject} ); } function CommitStatusLink({ owner, repo, sha, state, run, }: { owner: string; repo: string; sha: string; state: StatusState | null; run: number | null; }) { if (!state) return null; const className = "flex rounded-full"; if (run === null) { return ( ); } return ( ); } const ICONS: Record = { tree: "▸", blob: "·", exec: "⚙", symlink: "↪", gitlink: "⊙" }; export function TreeView({ owner, repo, gitRef, path, entries, commit, commitStatus, commitRun, readme, branches, tags, canWrite, containersAllowed, }: Props) { const parent = path.split("/").slice(0, -1).join("/"); const lastCommits = useLastCommits(owner, repo, gitRef.sha, path); return (
Go to file {canWrite && gitRef.kind === "branch" && ( Open in editor )} {containersAllowed && gitRef.kind === "branch" && ( Open in container )} Search code History {branches.length} branches {canWrite && gitRef.kind === "branch" && ( Add file )} Download
{commit.subject}
} actions={ {commit.shortSha} {" "} · } >
    {path && (
  • ..
  • )} {entries.map((entry) => (
  • {ICONS[entry.type]} {entry.name}
  • ))}
{readme && ( {readme.path}
}>
{readme.html !== null ? ( ) : (
{readme.text}
)}
)} ); }