({
repo,
path,
pathHighlightRange,
revisionName,
branchDisplayName = revisionName,
isBranchDisplayNameVisible = !!branchDisplayName,
branchDisplayTitle,
pathType = 'blob',
isCodeHostIconVisible = true,
isFileIconVisible = true,
repoNameClassName,
}: FileHeaderProps)
| 50 | } |
| 51 | |
| 52 | export const PathHeader = ({ |
| 53 | repo, |
| 54 | path, |
| 55 | pathHighlightRange, |
| 56 | revisionName, |
| 57 | branchDisplayName = revisionName, |
| 58 | isBranchDisplayNameVisible = !!branchDisplayName, |
| 59 | branchDisplayTitle, |
| 60 | pathType = 'blob', |
| 61 | isCodeHostIconVisible = true, |
| 62 | isFileIconVisible = true, |
| 63 | repoNameClassName, |
| 64 | }: FileHeaderProps) => { |
| 65 | const info = getCodeHostInfoForRepo({ |
| 66 | name: repo.name, |
| 67 | codeHostType: repo.codeHostType, |
| 68 | displayName: repo.displayName, |
| 69 | externalWebUrl: repo.externalWebUrl, |
| 70 | }); |
| 71 | |
| 72 | const { toast } = useToast(); |
| 73 | const containerRef = useRef<HTMLDivElement>(null); |
| 74 | const breadcrumbsRef = useRef<HTMLDivElement>(null); |
| 75 | const [visibleSegmentCount, setVisibleSegmentCount] = useState<number | null>(null); |
| 76 | // Create breadcrumb segments from file path |
| 77 | const breadcrumbSegments = useMemo(() => { |
| 78 | const pathParts = path.split('/').filter(Boolean); |
| 79 | const segments: BreadcrumbSegment[] = []; |
| 80 | |
| 81 | let currentPath = ''; |
| 82 | pathParts.forEach((part, index) => { |
| 83 | currentPath = currentPath ? `${currentPath}/${part}` : part; |
| 84 | const isLastSegment = index === pathParts.length - 1; |
| 85 | |
| 86 | // Calculate highlight range for this segment if it exists |
| 87 | let segmentHighlight: { from: number; to: number } | undefined; |
| 88 | if (pathHighlightRange) { |
| 89 | const segmentStart = path.indexOf(part, currentPath.length - part.length); |
| 90 | const segmentEnd = segmentStart + part.length; |
| 91 | |
| 92 | // Check if highlight overlaps with this segment |
| 93 | if (pathHighlightRange.from < segmentEnd && pathHighlightRange.to > segmentStart) { |
| 94 | segmentHighlight = { |
| 95 | from: Math.max(0, pathHighlightRange.from - segmentStart), |
| 96 | to: Math.min(part.length, pathHighlightRange.to - segmentStart) |
| 97 | }; |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | segments.push({ |
| 102 | name: part, |
| 103 | fullPath: currentPath, |
| 104 | isLastSegment, |
| 105 | highlightRange: segmentHighlight |
| 106 | }); |
| 107 | }); |
| 108 | |
| 109 | return segments; |
nothing calls this directly
no test coverage detected