33import { cn , getCodeHostInfoForRepo } from "@/lib/utils" ;
44import { LaptopIcon } from "@radix-ui/react-icons" ;
55import Image from "next/image" ;
6- import { useBrowseNavigation } from "../browse/hooks/useBrowseNavigation" ;
6+ import { getBrowsePath } from "../browse/hooks/useBrowseNavigation" ;
77import { ChevronRight , MoreHorizontal } from "lucide-react" ;
88import { useCallback , useState , useMemo , useRef , useEffect } from "react" ;
99import { useToast } from "@/components/hooks/use-toast" ;
@@ -15,6 +15,8 @@ import {
1515} from "@/components/ui/dropdown-menu" ;
1616import { VscodeFileIcon } from "@/app/components/vscodeFileIcon" ;
1717import { CopyIconButton } from "./copyIconButton" ;
18+ import Link from "next/link" ;
19+ import { useDomain } from "@/hooks/useDomain" ;
1820
1921interface FileHeaderProps {
2022 path : string ;
@@ -64,11 +66,11 @@ export const PathHeader = ({
6466 webUrl : repo . webUrl ,
6567 } ) ;
6668
67- const { navigateToPath } = useBrowseNavigation ( ) ;
6869 const { toast } = useToast ( ) ;
6970 const containerRef = useRef < HTMLDivElement > ( null ) ;
7071 const breadcrumbsRef = useRef < HTMLDivElement > ( null ) ;
7172 const [ visibleSegmentCount , setVisibleSegmentCount ] = useState < number | null > ( null ) ;
73+ const domain = useDomain ( ) ;
7274
7375 // Create breadcrumb segments from file path
7476 const breadcrumbSegments = useMemo ( ( ) => {
@@ -179,16 +181,6 @@ export const PathHeader = ({
179181 return true ;
180182 } , [ path , toast ] ) ;
181183
182- const onBreadcrumbClick = useCallback ( ( segment : BreadcrumbSegment ) => {
183- navigateToPath ( {
184- repoName : repo . name ,
185- path : segment . fullPath ,
186- pathType : segment . isLastSegment ? pathType : 'tree' ,
187- revisionName : branchDisplayName ,
188- } ) ;
189- } , [ repo . name , branchDisplayName , navigateToPath , pathType ] ) ;
190-
191-
192184 const renderSegmentWithHighlight = ( segment : BreadcrumbSegment ) => {
193185 if ( ! segment . highlightRange ) {
194186 return segment . name ;
@@ -224,17 +216,18 @@ export const PathHeader = ({
224216 </ >
225217 ) }
226218
227- < div
219+ < Link
228220 className = { cn ( "font-medium cursor-pointer hover:underline" , repoNameClassName ) }
229- onClick = { ( ) => navigateToPath ( {
221+ href = { getBrowsePath ( {
230222 repoName : repo . name ,
231- path : '' ,
223+ path : '/ ' ,
232224 pathType : 'tree' ,
233225 revisionName : branchDisplayName ,
226+ domain,
234227 } ) }
235228 >
236229 { info ?. displayName }
237- </ div >
230+ </ Link >
238231 { branchDisplayName && (
239232 < p
240233 className = "text-xs font-semibold text-gray-500 dark:text-gray-400 mt-[3px] flex items-center gap-0.5"
@@ -263,13 +256,21 @@ export const PathHeader = ({
263256 </ DropdownMenuTrigger >
264257 < DropdownMenuContent align = "start" className = "min-w-[200px]" >
265258 { hiddenSegments . map ( ( segment ) => (
266- < DropdownMenuItem
259+ < Link
260+ href = { getBrowsePath ( {
261+ repoName : repo . name ,
262+ path : segment . fullPath ,
263+ pathType : segment . isLastSegment ? pathType : 'tree' ,
264+ revisionName : branchDisplayName ,
265+ domain,
266+ } ) }
267+ className = "font-mono text-sm hover:cursor cursor-pointer"
267268 key = { segment . fullPath }
268- onClick = { ( ) => onBreadcrumbClick ( segment ) }
269- className = "font-mono text-sm cursor-pointer"
270269 >
271- { renderSegmentWithHighlight ( segment ) }
272- </ DropdownMenuItem >
270+ < DropdownMenuItem className = "hover:cursor cursor-pointer" >
271+ { renderSegmentWithHighlight ( segment ) }
272+ </ DropdownMenuItem >
273+ </ Link >
273274 ) ) }
274275 </ DropdownMenuContent >
275276 </ DropdownMenu >
@@ -281,14 +282,20 @@ export const PathHeader = ({
281282 { ( isFileIconVisible && index === visibleSegments . length - 1 ) && (
282283 < VscodeFileIcon fileName = { segment . name } className = "h-4 w-4 mr-1" />
283284 ) }
284- < span
285+ < Link
285286 className = { cn (
286287 "font-mono text-sm truncate cursor-pointer hover:underline" ,
287288 ) }
288- onClick = { ( ) => onBreadcrumbClick ( segment ) }
289+ href = { getBrowsePath ( {
290+ repoName : repo . name ,
291+ path : segment . fullPath ,
292+ pathType : segment . isLastSegment ? pathType : 'tree' ,
293+ revisionName : branchDisplayName ,
294+ domain,
295+ } ) }
289296 >
290297 { renderSegmentWithHighlight ( segment ) }
291- </ span >
298+ </ Link >
292299 { index < visibleSegments . length - 1 && (
293300 < ChevronRight className = "h-3 w-3 mx-0.5 text-muted-foreground flex-shrink-0" />
294301 ) }
0 commit comments