diff --git a/packages/web/src/app/[domain]/components/pathHeader.tsx b/packages/web/src/app/[domain]/components/pathHeader.tsx index bdde8a16..18806937 100644 --- a/packages/web/src/app/[domain]/components/pathHeader.tsx +++ b/packages/web/src/app/[domain]/components/pathHeader.tsx @@ -3,7 +3,7 @@ import { cn, getCodeHostInfoForRepo } from "@/lib/utils"; import { LaptopIcon } from "@radix-ui/react-icons"; import Image from "next/image"; -import { useBrowseNavigation } from "../browse/hooks/useBrowseNavigation"; +import { getBrowsePath } from "../browse/hooks/useBrowseNavigation"; import { ChevronRight, MoreHorizontal } from "lucide-react"; import { useCallback, useState, useMemo, useRef, useEffect } from "react"; import { useToast } from "@/components/hooks/use-toast"; @@ -15,6 +15,8 @@ import { } from "@/components/ui/dropdown-menu"; import { VscodeFileIcon } from "@/app/components/vscodeFileIcon"; import { CopyIconButton } from "./copyIconButton"; +import Link from "next/link"; +import { useDomain } from "@/hooks/useDomain"; interface FileHeaderProps { path: string; @@ -64,11 +66,11 @@ export const PathHeader = ({ webUrl: repo.webUrl, }); - const { navigateToPath } = useBrowseNavigation(); const { toast } = useToast(); const containerRef = useRef(null); const breadcrumbsRef = useRef(null); const [visibleSegmentCount, setVisibleSegmentCount] = useState(null); + const domain = useDomain(); // Create breadcrumb segments from file path const breadcrumbSegments = useMemo(() => { @@ -179,16 +181,6 @@ export const PathHeader = ({ return true; }, [path, toast]); - const onBreadcrumbClick = useCallback((segment: BreadcrumbSegment) => { - navigateToPath({ - repoName: repo.name, - path: segment.fullPath, - pathType: segment.isLastSegment ? pathType : 'tree', - revisionName: branchDisplayName, - }); - }, [repo.name, branchDisplayName, navigateToPath, pathType]); - - const renderSegmentWithHighlight = (segment: BreadcrumbSegment) => { if (!segment.highlightRange) { return segment.name; @@ -224,17 +216,18 @@ export const PathHeader = ({ )} -
navigateToPath({ + href={getBrowsePath({ repoName: repo.name, - path: '', + path: '/', pathType: 'tree', revisionName: branchDisplayName, + domain, })} > {info?.displayName} -
+ {branchDisplayName && (

{hiddenSegments.map((segment) => ( - onBreadcrumbClick(segment)} - className="font-mono text-sm cursor-pointer" > - {renderSegmentWithHighlight(segment)} - + + {renderSegmentWithHighlight(segment)} + + ))} @@ -281,14 +282,20 @@ export const PathHeader = ({ {(isFileIconVisible && index === visibleSegments.length - 1) && ( )} - onBreadcrumbClick(segment)} + href={getBrowsePath({ + repoName: repo.name, + path: segment.fullPath, + pathType: segment.isLastSegment ? pathType : 'tree', + revisionName: branchDisplayName, + domain, + })} > {renderSegmentWithHighlight(segment)} - + {index < visibleSegments.length - 1 && ( )}