import React from "react"; import {TunnelObject} from "./TunnelObject.tsx"; interface TunnelConnection { sourcePort: number; endpointPort: number; endpointHost: string; maxRetries: number; retryInterval: number; autoStart: boolean; } interface SSHHost { id: number; name: string; ip: string; port: number; username: string; folder: string; tags: string[]; pin: boolean; authType: string; enableTerminal: boolean; enableTunnel: boolean; enableConfigEditor: boolean; defaultPath: string; tunnelConnections: TunnelConnection[]; createdAt: string; updatedAt: string; } interface TunnelStatus { status: string; reason?: string; errorType?: string; retryCount?: number; maxRetries?: number; nextRetryIn?: number; retryExhausted?: boolean; } interface SSHTunnelViewerProps { hosts: SSHHost[]; tunnelStatuses: Record; tunnelActions: Record; onTunnelAction: (action: 'connect' | 'disconnect' | 'cancel', host: SSHHost, tunnelIndex: number) => Promise; } export function TunnelViewer({ hosts = [], tunnelStatuses = {}, tunnelActions = {}, onTunnelAction }: SSHTunnelViewerProps): React.ReactElement { // Single-host view: use first host if present const activeHost: SSHHost | undefined = Array.isArray(hosts) && hosts.length > 0 ? hosts[0] : undefined; if (!activeHost || !activeHost.tunnelConnections || activeHost.tunnelConnections.length === 0) { return (

No SSH Tunnels

Create your first SSH tunnel to get started. Use the SSH Manager to add hosts with tunnel connections.

); } return (

SSH Tunnels

{activeHost.tunnelConnections.map((t, idx) => ( onTunnelAction(action, activeHost, idx)} compact bare /> ))}
); }