/** * Terminal Authentication Dialog * Displays auth form with password/key selection for SSH connection */ import { AlertCircle,ChevronDown,Eye,EyeOff,Key,Lock } from 'lucide-react'; import React from 'react'; import { cn } from '../../lib/utils'; import { SSHKey } from '../../types'; import { Button } from '../ui/button'; import { Input } from '../ui/input'; import { Label } from '../ui/label'; import { Popover,PopoverContent,PopoverTrigger } from '../ui/popover'; export interface TerminalAuthDialogProps { authMethod: 'password' | 'key'; setAuthMethod: (method: 'password' | 'key') => void; authUsername: string; setAuthUsername: (username: string) => void; authPassword: string; setAuthPassword: (password: string) => void; authKeyId: string | null; setAuthKeyId: (keyId: string | null) => void; showAuthPassword: boolean; setShowAuthPassword: (show: boolean) => void; authRetryMessage: string | null; keys: SSHKey[]; onSubmit: () => void; onSubmitWithoutSave?: () => void; onCancel: () => void; isValid: boolean; } export const TerminalAuthDialog: React.FC = ({ authMethod, setAuthMethod, authUsername, setAuthUsername, authPassword, setAuthPassword, authKeyId, setAuthKeyId, showAuthPassword, setShowAuthPassword, authRetryMessage, keys, onSubmit, onSubmitWithoutSave, onCancel, isValid, }) => { const handleKeyDown = (e: React.KeyboardEvent) => { if (e.key === 'Enter' && isValid) { onSubmit(); } }; return ( <> {/* Auth method tabs */}
{/* Auth retry error message */} {authRetryMessage && (
{authRetryMessage}
)}
setAuthUsername(e.target.value)} placeholder="root" />
{authMethod === 'password' ? (
setAuthPassword(e.target.value)} placeholder="Enter password" className={cn("pr-10", authRetryMessage && "border-destructive/50")} autoFocus={!!authRetryMessage} onKeyDown={handleKeyDown} />
) : (
{keys.filter(k => k.category === 'key').length === 0 ? (
No keys available. Add keys in the Keychain section.
) : (
{keys.filter(k => k.category === 'key').map((key) => ( ))}
)}
)}
); }; export default TerminalAuthDialog;