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

PullRequestOverviewLoading.tsx

109 lines3.8 KB

1import { Chip } from "../../components/ui/Chip";
2import { PullRequestSectionHeading } from "./PullRequestSectionHeading";
3import type { PullRequestListEntry } from "@t3tools/contracts";
4import { View } from "react-native";
5import { PullRequestCardGroup, PullRequestCardRow } from "./PullRequestControls";
6import { PullRequestStackCard } from "./PullRequestStackCard";
7import type { PullRequestParams } from "./usePullRequestDiff";
8import type { PullRequestStackState } from "./usePullRequestStack";
9import { pullRequestListReviewStatus } from "./pullRequestList";
10import { PullRequestGlyph } from "./pullRequestGlyphs";
11​
12export function PullRequestOverviewLoading({
13 summary,
14 params,
15 stack,
16}: {
17 readonly summary: PullRequestListEntry;
18 readonly params: PullRequestParams;
19 readonly stack: PullRequestStackState;
20}) {
21 const review = pullRequestListReviewStatus(summary);
22 const conflicting = summary.mergeability === "conflicting";
23 const clean = summary.mergeability === "mergeable";
24 return (
25 <View
26 className="gap-5"
27 accessibilityLabel="Loading pull request details"
28 accessibilityState={{ busy: true }}
29 >
30 <PullRequestStackCard params={params} state={stack} />
31 <PullRequestCardGroup>
32 <PullRequestCardRow
33 compact
34 title={
35 summary.checksState === "passing"
36 ? "Checks completed"
37 : summary.checksState === "failing"
38 ? "Checks failing"
39 : summary.checksState === "pending"
40 ? "Checks running"
41 : "Checks"
42 }
43 icon={
44 summary.checksState === "passing"
45 ? "checkmark.circle"
46 : summary.checksState === "failing"
47 ? "exclamationmark.circle"
48 : "clock"
49 }
50 tint={
51 summary.checksState === "passing"
52 ? "accent-adaptive-emerald-600-400"
53 : summary.checksState === "failing"
54 ? "accent-danger-foreground"
55 : "accent-icon-muted"
56 }
57 >
58 <View className="h-3 w-16 rounded bg-subtle-strong" />
59 </PullRequestCardRow>
60 <PullRequestCardRow
61 compact
62 title={review?.accessibleLabel ?? "Reviews"}
63 icon={review?.icon ?? "bubble.left"}
64 tint={review?.tint}
65 >
66 <View className="h-3 w-20 rounded bg-subtle-strong" />
67 </PullRequestCardRow>
68 <PullRequestCardRow
69 compact
70 title={
71 conflicting
72 ? `Conflicts with ${summary.baseBranch}`
73 : clean
74 ? `No conflicts with ${summary.baseBranch}`
75 : "Branch"
76 }
77 icon={
78 conflicting ? PullRequestGlyph.conflicting : clean ? "checkmark.circle" : "arrow.branch"
79 }
80 tint={
81 conflicting
82 ? "accent-danger-foreground"
83 : clean
84 ? "accent-adaptive-emerald-600-400"
85 : undefined
86 }
87 />
88 <View className="border-t border-border-subtle p-3">
89 <View className="h-11 rounded-xl bg-subtle-strong" />
90 </View>
91 </PullRequestCardGroup>
92 {summary.labels.length ? (
93 <View className="flex-row flex-wrap gap-2">
94 {summary.labels.map((label) => (
95 <Chip key={label.name} label={label.name} size="small" />
96 ))}
97 </View>
98 ) : null}
99 <View className="gap-3">
100 <PullRequestSectionHeading>Description</PullRequestSectionHeading>
101 <View className="gap-3 py-1">
102 <View className="h-4 w-full rounded bg-subtle-strong" />
103 <View className="h-4 w-full rounded bg-subtle-strong" />
104 <View className="h-4 w-3/4 rounded bg-subtle-strong" />
105 </View>
106 </View>
107 </View>
108 );