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

PullRequestsUnavailableState.tsx

66 lines1.8 KB

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