Open History to see the last commit
1import type { ScopedThreadRef } from "@t3tools/contracts";
2import { useOpenLink } from "~/browser/useOpenLink";
3import { RefreshIcon } from "~/components/ui/refresh-icon";
4import { T, useGT } from "gt-react";
5import { ExternalLinkIcon } from "lucide-react";
6
7import { Button } from "../ui/button";
8import { Empty, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle } from "../ui/empty";
9import { PullRequestGlyph } from "./pullRequestIcons";
10
11export function PullRequestsUnavailableState({
12 title,
13 error,
14 onRetry,
15 refreshing = false,
16 host,
17}: {
18 title?: string;
19 error: string;
20 onRetry?: () => void;
21 refreshing?: boolean;
22 host?: {
23 readonly url: string;
24 readonly openLabel: string;
25 readonly threadRef: ScopedThreadRef | null;
26 };
27}) {
28 const gt = useGT();
29 const openLink = useOpenLink(host?.threadRef);
30 return (
31 <Empty className="scrollbar-gutter-both min-h-0 justify-center-safe overflow-y-auto [&>*]:shrink-0">
32 <EmptyMedia variant="icon">
33 <PullRequestGlyph.pullRequest />
34 </EmptyMedia>
35 <EmptyHeader>
36 <EmptyTitle>{title ?? gt("Could not load pull requests")}</EmptyTitle>
37 <EmptyDescription>{error}</EmptyDescription>
38 </EmptyHeader>
39 {onRetry || host ? (
40 <div className="flex 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 size="sm" refreshing={refreshing} />
50 <T>Retry</T>
51 </Button>
52 ) : null}
53 {host ? (
54 <Button
55 size="sm"
56 variant="outline"
57 render={<a href={host.url} target="_blank" rel="noopener noreferrer" />}
58 onClick={(event) => {
59 event.preventDefault();
60 void openLink(host.url, { event }).catch(console.error);
61 }}
62 >
63 <ExternalLinkIcon aria-hidden className="size-3.5" />
64 {host.openLabel}
65 </Button>
66 ) : null}
67 </div>
68 ) : null}
69 </Empty>
70 );
71}