Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

PullRequestsUnavailableState.tsx

67 lines1.9 KB

1import { RefreshIcon } from "~/components/ui/refresh-icon";
2import { ExternalLinkIcon } from "lucide-react";
3​
4import { Button } from "../ui/button";
5import {
6 Empty,
7 EmptyContent,
8 EmptyDescription,
9 EmptyHeader,
10 EmptyMedia,
11 EmptyTitle,
12} from "../ui/empty";
13import { PullRequestGlyph } from "./pullRequestIcons";
14​
15export function PullRequestsUnavailableState({
16 title = "Could not load pull requests",
17 error,
18 onRetry,
19 refreshing = false,
20 gitHubUrl,
21}: {
22 title?: string;
23 error: string;
24 onRetry?: () => void;
25 refreshing?: boolean;
26 gitHubUrl?: string;
27}) {
28 return (
29 <Empty className="min-h-0 justify-center-safe overflow-y-auto px-4 py-16 md:px-4 [&>*]:shrink-0">
30 <EmptyMedia variant="icon">
31 <PullRequestGlyph.pullRequest />
32 </EmptyMedia>
33 <EmptyHeader>
34 <EmptyTitle>{title}</EmptyTitle>
35 {/* The caller names the fix — update the environment, install gh, sign in — so this
36 shows its message rather than trying to infer one from the failure text. */}
37 <EmptyDescription>{error}</EmptyDescription>
38 </EmptyHeader>
39 {onRetry || gitHubUrl ? (
40 <EmptyContent className="flex-row flex-wrap justify-center gap-2">
41 {onRetry ? (
42 <Button
43 size="sm"
44 variant="outline"
45 onClick={onRetry}
46 disabled={refreshing}
47 aria-busy={refreshing}
48 >
49 <RefreshIcon className="size-3.5" refreshing={refreshing} />
50 Retry
51 </Button>
52 ) : null}
53 {gitHubUrl ? (
54 <Button
55 size="sm"
56 variant="outline"
57 render={<a href={gitHubUrl} target="_blank" rel="noopener noreferrer" />}
58 >
59 <ExternalLinkIcon aria-hidden className="size-3.5" />
60 Open on GitHub
61 </Button>
62 ) : null}
63 </EmptyContent>
64 ) : null}
65 </Empty>
66 );