/** * Port Forwarding New Form Panel * All-in-one form for creating new port forwarding rules (skip wizard mode) */ import { ChevronDown,Zap } from 'lucide-react'; import React from 'react'; import { useI18n } from '../../application/i18n/I18nProvider'; import { Host,PortForwardingRule,PortForwardingType } from '../../domain/models'; import { cn } from '../../lib/utils'; import { DistroAvatar } from '../DistroAvatar'; import { TrafficDiagram } from '../TrafficDiagram'; import { AsidePanel, AsidePanelContent, AsidePanelFooter, type AsidePanelLayout, type AsidePanelResizeProps, } from '../ui/aside-panel'; import { Button } from '../ui/button'; import { Input } from '../ui/input'; import { Tooltip, TooltipContent, TooltipTrigger } from '../ui/tooltip'; import { Label } from '../ui/label'; import { Switch } from '../ui/switch'; import { getTypeLabel } from './utils'; export interface NewFormPanelProps extends AsidePanelResizeProps { draft: Partial; hosts: Host[]; onDraftChange: (updates: Partial) => void; onSave: () => void; onClose: () => void; onOpenHostSelector: () => void; onOpenWizard: () => void; isValid: boolean; layout?: AsidePanelLayout; } export const NewFormPanel: React.FC = ({ draft, hosts, onDraftChange, onSave, onClose, onOpenHostSelector, onOpenWizard, isValid, layout = 'inline', resizable = false, persistWidthStorageKey, resizeAriaLabel, }) => { const { t } = useI18n(); const selectedHost = hosts.find(h => h.id === draft.hostId); return ( {/* Type Selector */}
{(['local', 'remote', 'dynamic'] as PortForwardingType[]).map((type) => ( ))}
{/* Traffic Diagram */}
{/* Label */}
onDraftChange({ label: e.target.value })} />
{/* Local Port */}
onDraftChange({ localPort: parseInt(e.target.value) || undefined })} />
{/* Bind Address */}
onDraftChange({ bindAddress: e.target.value })} />
{/* Intermediate Host */}
{/* Destination - for local/remote only */} {(draft.type === 'local' || draft.type === 'remote') && ( <>
onDraftChange({ remoteHost: e.target.value })} />
onDraftChange({ remotePort: parseInt(e.target.value) || undefined })} />
)} {/* Auto Start Toggle */}

{t('pf.form.autoStartDesc')}

onDraftChange({ autoStart: checked })} />
{t('pf.form.openWizardTitle')}
); }; export default NewFormPanel;