@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 04:45 UTC

main
tsx 80 lines 2.63 KB
Raw
1 import { Button } from "../../components/ui/Button";
2 import { projectCloneDisplayName, type ProjectCloneSnapshot } from "@t3tools/contracts";
3 import { projectCloneProgressSummary } from "@t3tools/client-runtime/contract-labels";
4 import { T, useGT, useMessages, Var } from "gt-react-native";
5 import { View } from "react-native";
6
7 import { AppActivityIndicator } from "../../components/ui/AppActivityIndicator";
8 import { cn } from "../../lib/cn";
9 import { AppText as Text } from "../../components/ui/AppText";
10
11 export function ProjectCloneBanner(props: {
12 readonly clone: ProjectCloneSnapshot;
13 readonly onCancel: () => void;
14 readonly onRetry: () => void;
15 readonly onRemove: () => void;
16 }) {
17 const gt = useGT();
18 const m = useMessages();
19 const { clone } = props;
20 const name = projectCloneDisplayName(clone);
21 if (clone.phase === "running") {
22 return (
23 <View className="flex-row items-center gap-3 rounded-2xl border border-border bg-card px-3.5 py-3">
24 <AppActivityIndicator size="small" />
25 <View className="min-w-0 flex-1">
26 <Text className="font-t3-medium text-sm" numberOfLines={1}>
27 <T>
28 Cloning <Var>{name}</Var>
29 </T>
30 </Text>
31 <Text className="text-xs text-foreground-muted" numberOfLines={1}>
32 {projectCloneProgressSummary(clone, m)}
33 </Text>
34 </View>
35 <BannerAction label={gt("Cancel")} onPress={props.onCancel} />
36 </View>
37 );
38 }
39 const cancelled = clone.phase === "cancelled";
40 return (
41 <View
42 className={cn(
43 "rounded-2xl border px-3.5 py-3",
44 cancelled ? "border-warning-border bg-warning" : "border-danger-border bg-danger",
45 )}
46 >
47 <Text
48 className={cn(
49 "font-t3-medium text-sm",
50 cancelled ? "text-warning-foreground" : "text-danger-foreground",
51 )}
52 numberOfLines={1}
53 >
54 {cancelled
55 ? gt("Cancelled cloning {name}", { name })
56 : gt("Failed to clone {name}", { name })}
57 </Text>
58 {clone.error ? (
59 <Text className="mt-0.5 text-xs text-danger-foreground" numberOfLines={3}>
60 {clone.error}
61 </Text>
62 ) : null}
63 <View className="mt-2 flex-row justify-end gap-2">
64 <BannerAction label={gt("Remove project")} onPress={props.onRemove} />
65 <BannerAction label={gt("Retry")} onPress={props.onRetry} />
66 </View>
67 </View>
68 );
69 }
70
71 function BannerAction(props: { readonly label: string; readonly onPress: () => void }) {
72 return (
73 <Button
74 label={props.label}
75 tone="secondary"
76 accessibilityLabel={props.label}
77 onPress={props.onPress}
78 />
79 );
80 }