/** * Environment Variables Editor Section * Visual editor for profile environment variables */ import { ScrollArea } from '@/components/ui/scroll-area'; import { Input } from '@/components/ui/input'; import { Label } from '@/components/ui/label'; import { Badge } from '@/components/ui/badge'; import { Button } from '@/components/ui/button'; import { MaskedInput } from '@/components/ui/masked-input'; import { Plus } from 'lucide-react'; import { isSensitiveKey } from './utils'; import type { Settings } from './types'; import { useTranslation } from 'react-i18next'; interface EnvEditorSectionProps { currentSettings: Settings | undefined; newEnvKey: string; newEnvValue: string; onNewEnvKeyChange: (value: string) => void; onNewEnvValueChange: (value: string) => void; onEnvValueChange: (key: string, value: string) => void; onAddEnvVar: () => void; } export function EnvEditorSection({ currentSettings, newEnvKey, newEnvValue, onNewEnvKeyChange, onNewEnvValueChange, onEnvValueChange, onAddEnvVar, }: EnvEditorSectionProps) { const { t } = useTranslation(); return ( <> {/* Scrollable Environment Variables List */}
{currentSettings?.env && Object.keys(currentSettings.env).length > 0 ? ( <> {Object.entries(currentSettings.env).map(([key, value]) => (
{isSensitiveKey(key) ? ( onEnvValueChange(key, e.target.value)} className="font-mono text-sm h-8" /> ) : ( onEnvValueChange(key, e.target.value)} className="font-mono text-sm h-8" /> )}
))} ) : (

{t('envEditor.none')}

{t('envEditor.noneHint')}

)}
{/* Fixed Add Input at Bottom */}
onNewEnvKeyChange(e.target.value.toUpperCase())} className="font-mono text-sm h-8 w-2/5" onKeyDown={(e) => e.key === 'Enter' && newEnvKey.trim() && onAddEnvVar()} /> onNewEnvValueChange(e.target.value)} className="font-mono text-sm h-8 flex-1" onKeyDown={(e) => e.key === 'Enter' && newEnvKey.trim() && onAddEnvVar()} />
); }