Open History to see the last commit
1import type { EnvironmentId } from "@t3tools/contracts";
2import type { ComponentProps } from "react";
3import { View } from "react-native";
4
5import { SymbolView } from "../../components/AppSymbol";
6import { AppText as Text } from "../../components/AppText";
7import { cn } from "../../lib/cn";
8import { ConnectionEnvironmentRow } from "./ConnectionEnvironmentRow";
9
10type EnvironmentRowProps = ComponentProps<typeof ConnectionEnvironmentRow>;
11
12/** Shared list and empty state for environment management entry points. */
13export function LocalEnvironmentList({
14 environments,
15 expandedId,
16 onToggle,
17 ...rowActions
18}: Pick<EnvironmentRowProps, "onReconnect" | "onRemove" | "onSetEnabled" | "onUpdate"> & {
19 readonly environments: ReadonlyArray<EnvironmentRowProps["environment"]>;
20 readonly expandedId: EnvironmentId | null;
21 readonly onToggle: (environmentId: EnvironmentId) => void;
22}) {
23 if (environments.length === 0) {
24 return (
25 <View collapsable={false} className="items-center gap-3 rounded-[24px] bg-card px-6 py-8">
26 <View className="h-12 w-12 items-center justify-center rounded-[16px] bg-subtle">
27 <SymbolView
28 name="point.3.connected.trianglepath.dotted"
29 size={20}
30 tintColorClassName="accent-icon-muted"
31 type="monochrome"
32 />
33 </View>
34 <Text className="text-center text-sm leading-normal text-foreground-muted">
35 No environments connected yet.{"\n"}Tap{" "}
36 <Text className="font-t3-bold text-foreground">+</Text> to add one.
37 </Text>
38 </View>
39 );
40 }
41
42 return (
43 <View collapsable={false} className="overflow-hidden rounded-[24px] bg-card">
44 {environments.map((environment, index) => (
45 <View
46 key={environment.environmentId}
47 collapsable={false}
48 className={cn(index !== 0 && "border-t border-border")}
49 >
50 <ConnectionEnvironmentRow
51 environment={environment}
52 expanded={expandedId === environment.environmentId}
53 onToggle={() => onToggle(environment.environmentId)}
54 {...rowActions}
55 />
56 </View>
57 ))}
58 </View>
59 );
60}