import { getRepoInfoByName } from "@/actions"; import { PathHeader } from "@/app/[domain]/components/pathHeader"; import { Separator } from "@/components/ui/separator"; import { getFileSource } from "@/features/search/fileSourceApi"; import { cn, getCodeHostInfoForRepo, isServiceError } from "@/lib/utils"; import Image from "next/image"; import { PureCodePreviewPanel } from "./pureCodePreviewPanel"; interface CodePreviewPanelProps { path: string; repoName: string; revisionName?: string; domain: string; } export const CodePreviewPanel = async ({ path, repoName, revisionName, domain }: CodePreviewPanelProps) => { const [fileSourceResponse, repoInfoResponse] = await Promise.all([ getFileSource({ fileName: path, repository: repoName, branch: revisionName, }, domain), getRepoInfoByName(repoName, domain), ]); if (isServiceError(fileSourceResponse) || isServiceError(repoInfoResponse)) { return
Error loading file source
} const codeHostInfo = getCodeHostInfoForRepo({ codeHostType: repoInfoResponse.codeHostType, name: repoInfoResponse.name, displayName: repoInfoResponse.displayName, webUrl: repoInfoResponse.webUrl, }); return ( <>
{(fileSourceResponse.webUrl && codeHostInfo) && ( {codeHostInfo.codeHostName} Open in {codeHostInfo.codeHostName} )}
) }