import { useState } from "react"; import { useTranslation } from "react-i18next"; import { Eye, EyeOff, FolderSearch, Terminal } from "lucide-react"; import { Input } from "@/components/input"; import type { Host } from "@/types/ui-types"; interface QuickConnectPanelProps { onConnect: (host: Host, type: "terminal" | "files") => void; } export function QuickConnectPanel({ onConnect }: QuickConnectPanelProps) { const { t } = useTranslation(); const [host, setHost] = useState(""); const [port, setPort] = useState("22"); const [username, setUsername] = useState(""); const [authType, setAuthType] = useState<"password" | "key" | "credential">( "password", ); const [password, setPassword] = useState(""); const [privateKey, setPrivateKey] = useState(""); const [showPassword, setShowPassword] = useState(false); const connect = (type: "terminal" | "files") => { if (!host || !username) return; const hostConfig: Host = { id: `quick-connect-${Date.now()}`, name: `${username}@${host}`, ip: host, port: parseInt(port) || 22, username, authType, password: authType === "password" ? password : undefined, key: authType === "key" ? privateKey : undefined, folder: "", online: false, cpu: null, ram: null, lastAccess: new Date().toISOString(), pin: false, defaultPath: "", serverTunnels: [], quickActions: [], enableTerminal: true, enableFileManager: true, enableTunnel: true, enableDocker: true, enableSsh: true, enableRdp: false, enableVnc: false, enableTelnet: false, sshPort: parseInt(port) || 22, rdpPort: 3389, vncPort: 5900, telnetPort: 23, }; onConnect(hostConfig, type); }; return (
setHost(e.target.value)} onKeyDown={(e) => { if (e.key === "Enter") connect("terminal"); }} className="h-7 text-xs" />
setPort(e.target.value)} onKeyDown={(e) => { if (e.key === "Enter") connect("terminal"); }} className="h-7 text-xs" />
setUsername(e.target.value)} onKeyDown={(e) => { if (e.key === "Enter") connect("terminal"); }} className="h-7 text-xs" />
{(["password", "key", "credential"] as const).map((type) => ( ))}
{authType === "password" && (
setPassword(e.target.value)} onKeyDown={(e) => { if (e.key === "Enter") connect("terminal"); }} className="h-7 text-xs pr-8" />
)} {authType === "key" && (