diff --git a/src-tauri/src/models/connection.rs b/src-tauri/src/models/connection.rs index 2bc656a..03c0d47 100644 --- a/src-tauri/src/models/connection.rs +++ b/src-tauri/src/models/connection.rs @@ -11,6 +11,7 @@ pub struct ConnectionConfig { pub database: String, pub ssl_mode: Option, pub color: Option, + pub environment: Option, } impl ConnectionConfig { diff --git a/src/components/connections/ConnectionDialog.tsx b/src/components/connections/ConnectionDialog.tsx index 0a9d5b1..220971c 100644 --- a/src/components/connections/ConnectionDialog.tsx +++ b/src/components/connections/ConnectionDialog.tsx @@ -18,6 +18,7 @@ import { import { useSaveConnection, useTestConnection } from "@/hooks/use-connections"; import { toast } from "sonner"; import type { ConnectionConfig } from "@/types"; +import { ENVIRONMENTS } from "@/lib/environment"; import { Loader2, X } from "lucide-react"; const CONNECTION_COLORS = [ @@ -47,6 +48,7 @@ const emptyConfig: ConnectionConfig = { database: "postgres", ssl_mode: "prefer", color: undefined, + environment: undefined, }; export function ConnectionDialog({ open, onOpenChange, connection }: Props) { @@ -184,6 +186,38 @@ export function ConnectionDialog({ open, onOpenChange, connection }: Props) { +
+ + +
diff --git a/src/components/connections/ConnectionSelector.tsx b/src/components/connections/ConnectionSelector.tsx index cf4ead7..271bdcc 100644 --- a/src/components/connections/ConnectionSelector.tsx +++ b/src/components/connections/ConnectionSelector.tsx @@ -7,6 +7,7 @@ import { } 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(); @@ -37,6 +38,7 @@ export function ConnectionSelector() { /> )} + @@ -50,6 +52,7 @@ export function ConnectionSelector() { /> )} {conn.name} + ))} diff --git a/src/components/connections/EnvironmentBadge.tsx b/src/components/connections/EnvironmentBadge.tsx new file mode 100644 index 0000000..ecc7abc --- /dev/null +++ b/src/components/connections/EnvironmentBadge.tsx @@ -0,0 +1,26 @@ +import { getEnvironment } from "@/lib/environment"; +import { cn } from "@/lib/utils"; + +interface Props { + environment?: string; + size?: "sm" | "md"; +} + +export function EnvironmentBadge({ environment, size = "sm" }: Props) { + const env = getEnvironment(environment); + if (!env) return null; + + return ( + + {env.label} + + ); +} diff --git a/src/components/layout/StatusBar.tsx b/src/components/layout/StatusBar.tsx index fac808e..c5e82c1 100644 --- a/src/components/layout/StatusBar.tsx +++ b/src/components/layout/StatusBar.tsx @@ -1,6 +1,7 @@ import { useAppStore } from "@/stores/app-store"; import { useConnections } from "@/hooks/use-connections"; import { Circle } from "lucide-react"; +import { EnvironmentBadge } from "@/components/connections/EnvironmentBadge"; interface Props { rowCount?: number | null; @@ -31,6 +32,7 @@ export function StatusBar({ rowCount, executionTime }: Props) { /> )} {activeConn ? activeConn.name : "No connection"} + {isConnected && activeConnectionId && ( (null); const { activeConnectionId, addTab } = useAppStore(); const { data: connections } = useConnections(); - const activeColor = connections?.find((c) => c.id === activeConnectionId)?.color; + const activeConn = connections?.find((c) => c.id === activeConnectionId); + const activeEnv = getEnvironment(activeConn?.environment); + const activeColor = activeEnv?.color ?? activeConn?.color; const handleNewQuery = () => { if (!activeConnectionId) return; @@ -54,6 +58,13 @@ export function Toolbar() { + {activeConn?.environment && ( + <> + + + + )} +