import React from "react"; import { TunnelObject } from "./TunnelObject.tsx"; import { useTranslation } from "react-i18next"; import type { SSHHost, TunnelStatus } from "../../../types/index.js"; 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 { const { t } = useTranslation(); const activeHost: SSHHost | undefined = Array.isArray(hosts) && hosts.length > 0 ? hosts[0] : undefined; if ( !activeHost || !activeHost.tunnelConnections || activeHost.tunnelConnections.length === 0 ) { return (

{t("tunnels.noSshTunnels")}

{t("tunnels.createFirstTunnelMessage")}

); } return (

{t("tunnels.title")}

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