Open History to see the last commit
1import type { SourceControlProviderKind } from "@t3tools/contracts";
2import { ExternalLinkIcon, TriangleAlertIcon } from "lucide-react";
3
4import { getSourceControlPresentationForKind } from "~/sourceControlPresentation";
5
6import { Button } from "../ui/button";
7import { Empty, EmptyDescription, EmptyHeader, EmptyTitle } from "../ui/empty";
8import { RefreshIcon } from "../ui/refresh-icon";
9import { describePullRequestDiffError } from "./pullRequestDiffError";
10
11export function PullRequestDiffUnavailableState({
12 error,
13 provider,
14 url,
15 onRetry,
16}: {
17 error: string;
18 provider: SourceControlProviderKind;
19 url: string;
20 onRetry: () => void;
21}) {
22 const { providerName } = getSourceControlPresentationForKind(provider);
23 const { title, description } = describePullRequestDiffError(error, providerName);
24
25 return (
26 <Empty size="compact" className="min-h-full" role="status">
27 <div className="flex size-11 items-center justify-center rounded-full bg-warning-surface text-warning">
28 <TriangleAlertIcon aria-hidden className="size-5" />
29 </div>
30 <EmptyHeader>
31 <EmptyTitle>{title}</EmptyTitle>
32 <EmptyDescription>{description}</EmptyDescription>
33 </EmptyHeader>
34 <div className="flex flex-wrap justify-center gap-2">
35 <Button size="sm" variant="default" onClick={onRetry}>
36 <RefreshIcon />
37 Try again
38 </Button>
39 <Button
40 size="sm"
41 variant="outline"
42 render={<a href={url} target="_blank" rel="noopener noreferrer" />}
43 >
44 <ExternalLinkIcon aria-hidden />
45 Open on {providerName}
46 </Button>
47 </div>
48 <details className="w-full max-w-lg text-xs text-muted-foreground">
49 <summary className="mx-auto w-fit cursor-pointer rounded-sm -outline-offset-2 hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring">
50 Technical details
51 </summary>
52 <pre className="scrollbar-gutter-both mt-3 max-h-40 overflow-auto whitespace-pre-wrap break-words rounded-lg border border-border bg-muted/40 p-3 text-left font-mono text-xs">
53 {error}
54 </pre>
55 </details>
56 </Empty>
57 );
58}