diff --git a/webui2/src/components/bugs/BugRow.tsx b/webui2/src/components/bugs/BugRow.tsx index f5f6fd1976e3d01ad3a6a5e778b5b7630d898228..10ce30635ec24c7256250c169e5bc86b7e9eb60f 100644 --- a/webui2/src/components/bugs/BugRow.tsx +++ b/webui2/src/components/bugs/BugRow.tsx @@ -15,8 +15,7 @@ interface BugRowProps { author: { humanId: string; displayName: string; avatarUrl?: string | null }; createdAt: string; commentCount: number; - /** Current repo slug, used to build /:repo/issues/:id and /:repo/user/:id links. */ - repo: string | null; + repo: string; onLabelClick?: (name: string) => void; } @@ -36,9 +35,6 @@ export function BugRow({ const isOpen = status === Status.Open; const StatusIcon = isOpen ? CircleDot : CircleCheck; - const issueHref = repo ? `/${repo}/issues/${humanId}` : `/issues/${humanId}`; - const authorHref = repo ? `/${repo}/user/${author.humanId}` : `/user/${author.humanId}`; - return (
{title} @@ -68,7 +65,11 @@ export function BugRow({

#{humanId} opened {formatDistanceToNow(new Date(createdAt), { addSuffix: true })} by{" "} - + {author.displayName}

diff --git a/webui2/src/components/code/FileTree.tsx b/webui2/src/components/code/FileTree.tsx index 2d28742a8ca0189234e4c94b023f84a010ca71d7..d4c05c2315e3827225358616366cc0743ff62531 100644 --- a/webui2/src/components/code/FileTree.tsx +++ b/webui2/src/components/code/FileTree.tsx @@ -15,24 +15,16 @@ export interface TreeEntryWithCommit extends GitTreeEntry { } interface FileTreeProps { - repo: string | null; + repo: string; + currentRef: string; + currentPath: string; entries: TreeEntryWithCommit[]; - path: string; loading?: boolean; - onNavigate: (entry: TreeEntryWithCommit) => void; - onNavigateUp: () => void; } // Directory listing table for the code browser. Shows each entry's icon, // name, last-commit message (linked to commit detail), and relative date. -export function FileTree({ - repo, - entries, - path, - loading, - onNavigate, - onNavigateUp, -}: FileTreeProps) { +export function FileTree({ repo, currentRef, currentPath, entries, loading }: FileTreeProps) { // Directories first, then files — each group alphabetical const sorted = entries.toSorted((a, b) => { if (a.type !== b.type) return a.type === GitObjectType.Tree ? -1 : 1; @@ -45,18 +37,32 @@ export function FileTree({
- {path && ( - - + - - )} {sorted.map((entry) => ( - + ))}
- + {currentPath && ( +
+ + + .. + .. -
@@ -67,16 +73,23 @@ export function FileTree({ function FileTreeRow({ entry, repo, - onNavigate, + currentRef, + currentPath, }: { entry: TreeEntryWithCommit; - repo: string | null; - onNavigate: (entry: TreeEntryWithCommit) => void; + repo: string; + currentRef: string; + currentPath: string; }) { const isDir = entry.type === GitObjectType.Tree; + const entryPath = currentPath ? `${currentPath}/${entry.name}` : entry.name; + + const entryLink = isDir + ? { to: "/$repo/tree/$ref/$" as const, params: { repo, ref: currentRef, _splat: entryPath } } + : { to: "/$repo/blob/$ref/$" as const, params: { repo, ref: currentRef, _splat: entryPath } }; return ( - onNavigate(entry)}> + {isDir ? ( @@ -85,17 +98,16 @@ function FileTreeRow({ )} - + {entry.name} - + {entry.lastCommit && ( e.stopPropagation()} > {entry.lastCommit.message} diff --git a/webui2/src/routes/$repo/_code/tree/$ref/$.tsx b/webui2/src/routes/$repo/_code/tree/$ref/$.tsx index 2059fa890661d189bcffbdd8ca78bee8671224b3..f98d80af74669d591d2e1486b52d975f3d1b1ad4 100644 --- a/webui2/src/routes/$repo/_code/tree/$ref/$.tsx +++ b/webui2/src/routes/$repo/_code/tree/$ref/$.tsx @@ -2,7 +2,7 @@ import { gql } from "@apollo/client"; import { useQuery } from "@apollo/client/react"; -import { createFileRoute, useNavigate } from "@tanstack/react-router"; +import { createFileRoute } from "@tanstack/react-router"; import { GitObjectType, @@ -70,7 +70,6 @@ export const Route = createFileRoute("/$repo/_code/tree/$ref/$")({ function TreeView() { const { repo, ref: currentRef, _splat: currentPath = "" } = Route.useParams(); const { ref: repoRef } = Route.useRouteContext(); - const navigate = useNavigate(); const { data: treeData, loading: treeLoading } = useQuery(TREE_QUERY, { variables: { repo: repoRef, ref: currentRef, path: currentPath || null }, @@ -104,39 +103,14 @@ function TreeView() { }); const readme: string | null = readmeBlobData?.repository?.blob?.text ?? null; - function handleEntryClick(entry: TreeEntryWithCommit) { - const newPath = currentPath ? `${currentPath}/${entry.name}` : entry.name; - if (entry.type === GitObjectType.Blob) { - void navigate({ - to: "/$repo/blob/$ref/$", - params: { repo, ref: currentRef, _splat: newPath }, - }); - } else { - void navigate({ - to: "/$repo/tree/$ref/$", - params: { repo, ref: currentRef, _splat: newPath }, - }); - } - } - - function handleNavigateUp() { - const parts = currentPath.split("/").filter(Boolean); - parts.pop(); - void navigate({ - to: "/$repo/tree/$ref/$", - params: { repo, ref: currentRef, _splat: parts.join("/") }, - }); - } - return ( <> {readme && (
diff --git a/webui2/src/routes/$repo/commit/$hash.tsx b/webui2/src/routes/$repo/commit/$hash.tsx index 452df07af366b9ac7546644abd934901a79a614e..d2af8fee105da2cd8f3faf53763812eda3ad5a81 100644 --- a/webui2/src/routes/$repo/commit/$hash.tsx +++ b/webui2/src/routes/$repo/commit/$hash.tsx @@ -3,7 +3,7 @@ import { gql } from "@apollo/client"; import { useReadQuery } from "@apollo/client/react"; -import { createFileRoute, Link } from "@tanstack/react-router"; +import { createFileRoute, Link, useCanGoBack, useRouter } from "@tanstack/react-router"; import { format } from "date-fns"; import { ArrowLeft, GitCommit } from "lucide-react"; @@ -68,6 +68,8 @@ function RouteComponent() { const { repo } = Route.useParams(); const { commitRef } = Route.useLoaderData(); const { data } = useReadQuery(commitRef); + const canGoBack = useCanGoBack(); + const router = useRouter(); const commit = data?.repository?.commit; if (!commit) return null; @@ -77,15 +79,15 @@ function RouteComponent() { return (
- + {canGoBack && ( + + )}