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

PullRequestsUnavailableState.tsx

58 lines1.7 KB

1import { RefreshIcon } from "~/components/ui/refresh-icon";
2import { ExternalLinkIcon } from "lucide-react";
3​
4import { Button } from "../ui/button";
5import { Empty, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle } from "../ui/empty";
6import { PullRequestGlyph } from "./pullRequestIcons";
7​
8export function PullRequestsUnavailableState({
9 title = "Could not load pull requests",
10 error,
11 onRetry,
12 refreshing = false,
13 host,
14}: {
15 title?: string;
16 error: string;
17 onRetry?: () => void;
18 refreshing?: boolean;
19 host?: { readonly url: string; readonly openLabel: string };
20}) {
21 return (
22 <Empty className="scrollbar-gutter-both min-h-0 justify-center-safe overflow-y-auto [&>*]:shrink-0">
23 <EmptyMedia variant="icon">
24 <PullRequestGlyph.pullRequest />
25 </EmptyMedia>
26 <EmptyHeader>
27 <EmptyTitle>{title}</EmptyTitle>
28 <EmptyDescription>{error}</EmptyDescription>
29 </EmptyHeader>
30 {onRetry || host ? (
31 <div className="flex flex-wrap justify-center gap-2">
32 {onRetry ? (
33 <Button
34 size="sm"
35 variant="outline"
36 onClick={onRetry}
37 disabled={refreshing}
38 aria-busy={refreshing}
39 >
40 <RefreshIcon size="sm" refreshing={refreshing} />
41 Retry
42 </Button>
43 ) : null}
44 {host ? (
45 <Button
46 size="sm"
47 variant="outline"
48 render={<a href={host.url} target="_blank" rel="noopener noreferrer" />}
49 >
50 <ExternalLinkIcon aria-hidden className="size-3.5" />
51 {host.openLabel}
52 </Button>
53 ) : null}
54 </div>
55 ) : null}
56 </Empty>
57 );