import { FormControl, FormDescription, FormField, FormItem, FormLabel, } from "@/components/ui/form.tsx"; import { Input } from "@/components/ui/input.tsx"; import { Switch } from "@/components/ui/switch.tsx"; import { Alert, AlertDescription } from "@/components/ui/alert.tsx"; import { Button } from "@/components/ui/button.tsx"; import type { HostTunnelTabProps } from "./shared/tab-types"; export function HostTunnelTab({ form, sshConfigDropdownOpen, setSshConfigDropdownOpen, sshConfigInputRefs, sshConfigDropdownRefs, getFilteredSshConfigs, handleSshConfigClick, t, }: HostTunnelTabProps) { return (
( {t("hosts.enableTunnel")} {t("hosts.enableTunnelDesc")} )} /> {form.watch("enableTunnel") && ( <> {t("hosts.sshpassRequired")}
{t("hosts.sshpassRequiredDesc")}{" "} sudo apt install sshpass {" "} {t("hosts.debianUbuntuEquivalent")}
{t("hosts.otherInstallMethods")}
• {t("hosts.centosRhelFedora")}{" "} sudo yum install sshpass {" "} {t("hosts.or")}{" "} sudo dnf install sshpass
• {t("hosts.macos")}{" "} brew install hudochenkov/sshpass/sshpass
• {t("hosts.windows")}
{t("hosts.sshServerConfigRequired")}
{t("hosts.sshServerConfigDesc")}
•{" "} GatewayPorts yes {" "} {t("hosts.gatewayPortsYes")}
•{" "} AllowTcpForwarding yes {" "} {t("hosts.allowTcpForwardingYes")}
•{" "} PermitRootLogin yes {" "} {t("hosts.permitRootLoginYes")}
{t("hosts.editSshConfig")}
( {t("hosts.tunnelConnections")}
{field.value.map((connection, index) => (

{t("hosts.connection")} {index + 1}

( {t("hosts.sourcePort")} {t("hosts.sourcePortDesc")} )} /> ( {t("hosts.endpointPort")} )} /> ( {t("hosts.endpointSshConfig")} { sshConfigInputRefs.current[index] = el; }} placeholder={t("placeholders.sshConfig")} className="min-h-[40px]" autoComplete="off" value={endpointHostField.value} onFocus={() => setSshConfigDropdownOpen((prev) => ({ ...prev, [index]: true, })) } onChange={(e) => { endpointHostField.onChange(e); setSshConfigDropdownOpen((prev) => ({ ...prev, [index]: true, })); }} onBlur={(e) => { endpointHostField.onChange( e.target.value.trim(), ); endpointHostField.onBlur(); }} /> {sshConfigDropdownOpen[index] && getFilteredSshConfigs(index).length > 0 && (
{ sshConfigDropdownRefs.current[index] = el; }} className="absolute top-full left-0 z-50 mt-1 w-full bg-canvas border border-input rounded-md shadow-lg max-h-40 overflow-y-auto thin-scrollbar p-1" >
{getFilteredSshConfigs(index).map( (config) => ( ), )}
)}
)} />

{t("hosts.tunnelForwardDescription", { sourcePort: form.watch( `tunnelConnections.${index}.sourcePort`, ) || "22", endpointPort: form.watch( `tunnelConnections.${index}.endpointPort`, ) || "224", })}

( {t("hosts.maxRetries")} {t("hosts.maxRetriesDescription")} )} /> ( {t("hosts.retryInterval")} {t("hosts.retryIntervalDescription")} )} /> ( {t("hosts.autoStartContainer")} {t("hosts.autoStartDesc")} )} />
))}
)} /> )}
); }