Files
tusk/src/components/connections/ConnectionSelector.tsx
A.Shakhmatov d3b98f9261 fix: widen connection selector to fit environment badge
Changed from fixed w-[200px] to w-auto max-w-[280px] so the trigger
sizes to its content without clipping the environment badge.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-11 21:44:48 +03:00

52 lines
1.5 KiB
TypeScript

import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from "@/components/ui/select";
import { useConnections } from "@/hooks/use-connections";
import { useAppStore } from "@/stores/app-store";
import { EnvironmentBadge } from "@/components/connections/EnvironmentBadge";
export function ConnectionSelector() {
const { data: connections } = useConnections();
const { activeConnectionId, setActiveConnectionId, connectedIds } =
useAppStore();
const connectedList = connections?.filter((c) => connectedIds.has(c.id)) ?? [];
if (connectedList.length === 0) {
return (
<div className="text-xs text-muted-foreground px-2">Not connected</div>
);
}
return (
<Select
value={activeConnectionId ?? undefined}
onValueChange={setActiveConnectionId}
>
<SelectTrigger className="h-7 w-auto max-w-[280px] text-xs">
<SelectValue placeholder="Select connection" />
</SelectTrigger>
<SelectContent>
{connectedList.map((conn) => (
<SelectItem key={conn.id} value={conn.id}>
<div className="flex items-center gap-1.5">
{conn.color && (
<span
className="h-2.5 w-2.5 shrink-0 rounded-full"
style={{ backgroundColor: conn.color }}
/>
)}
{conn.name}
<EnvironmentBadge environment={conn.environment} size="sm" />
</div>
</SelectItem>
))}
</SelectContent>
</Select>
);
}