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