import { useState } from "react"; import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogTrigger, } from "@/components/ui/dialog"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; import { PasswordInput } from "@/components/ui/password-input"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"; import { Monitor, MonitorPlay, Terminal } from "lucide-react"; import { useTabs } from "@/ui/desktop/navigation/tabs/TabContext"; import type { GuacamoleConnectionConfig } from "./GuacamoleDisplay"; interface GuacamoleTestDialogProps { trigger?: React.ReactNode; } export function GuacamoleTestDialog({ trigger }: GuacamoleTestDialogProps) { const [isOpen, setIsOpen] = useState(false); const { addTab } = useTabs(); const [connectionType, setConnectionType] = useState<"rdp" | "vnc" | "telnet">("rdp"); const [hostname, setHostname] = useState(""); const [port, setPort] = useState(""); const [username, setUsername] = useState(""); const [password, setPassword] = useState(""); const [domain, setDomain] = useState(""); const [security, setSecurity] = useState("nla"); const defaultPorts = { rdp: "3389", vnc: "5900", telnet: "23" }; const handleConnect = () => { if (!hostname) return; const config: GuacamoleConnectionConfig = { type: connectionType, hostname, port: parseInt(port || defaultPorts[connectionType]), username: username || undefined, password: password || undefined, domain: domain || undefined, security: connectionType === "rdp" ? security : undefined, "ignore-cert": true, }; // Add a new tab for the remote desktop connection const tabType = connectionType === "rdp" ? "rdp" : connectionType === "vnc" ? "vnc" : "rdp"; const title = `${connectionType.toUpperCase()} - ${hostname}`; addTab({ type: tabType, title, connectionConfig: config, }); // Close the dialog setIsOpen(false); }; return ( {trigger || ( )} Remote Connection
{ setConnectionType(v as "rdp" | "vnc" | "telnet"); setPort(""); }}> RDP VNC Telnet
setHostname(e.target.value)} placeholder="192.168.1.100" />
setPort(e.target.value)} placeholder="3389" />
setDomain(e.target.value)} placeholder="WORKGROUP" />
setUsername(e.target.value)} placeholder="Administrator" />
setPassword(e.target.value)} />
setHostname(e.target.value)} placeholder="192.168.1.100" />
setPort(e.target.value)} placeholder="5900" />
setPassword(e.target.value)} />
setHostname(e.target.value)} placeholder="192.168.1.100" />
setPort(e.target.value)} placeholder="23" />
); }