diff --git a/packages/web/src/app/[domain]/browse/[...path]/components/404NotFound.tsx b/packages/web/src/app/[domain]/browse/[...path]/components/404NotFound.tsx new file mode 100644 index 000000000..dce1d7cba --- /dev/null +++ b/packages/web/src/app/[domain]/browse/[...path]/components/404NotFound.tsx @@ -0,0 +1,115 @@ +import { $Enums } from "@sourcebot/db"; +import { ServiceError } from "@/lib/serviceError"; +import { TriangleAlert } from "lucide-react"; +import { Button } from "@/components/ui/button"; +import Link from "next/link"; +import { getBrowsePath } from "@/app/[domain]/browse/hooks/utils"; +import { SINGLE_TENANT_ORG_DOMAIN } from "@/lib/constants"; +import { FileSourceResponse } from "@/features/git/getFileSourceApi"; +import { PathHeader } from "@/app/[domain]/components/pathHeader"; + +type RepoInfoResponse = ServiceError | { + id: number; + name: string; + displayName: string | undefined; + codeHostType: $Enums.CodeHostType; + externalWebUrl: string | undefined; + imageUrl: string | undefined; + indexedAt: Date | undefined; +} + +type FileSourceResponseType = FileSourceResponse | ServiceError; + +export const FileNotFound = ({ + repoInfoResponse, + fileSourceResponse, + revisionName, + path, + repoName +}: { + repoInfoResponse: RepoInfoResponse; + fileSourceResponse: FileSourceResponseType; + revisionName?: string; + path: string; + repoName: string; +}) => { + // Get display name from repoInfoResponse if available, otherwise use repoName + const displayRepoName = !('statusCode' in repoInfoResponse) + ? (repoInfoResponse.displayName || repoInfoResponse.name.split('/').pop() || repoName) + : repoName; + + // Use revisionName if provided, otherwise default to HEAD + const branchName = revisionName || 'HEAD'; + const filePath = path; + + // Check if repoInfoResponse is a ServiceError + const isRepoInfoError = 'statusCode' in repoInfoResponse; + const repoInfo = isRepoInfoError ? null : repoInfoResponse; + + return <> +
+ The {branchName} branch of {displayRepoName} does not contain the path {filePath}. +
+