// YAML 导入对话框 — 粘贴/应用多文档 manifest // Logan.Li import { useState } from 'react'; import { X, Upload, Loader2 } from 'lucide-react'; import { Button } from '@/components/ui/button'; import { ModalOverlay } from '@/components/ui/modal-overlay'; import { useToast } from '@/hooks/use-toast'; import { kubernetesApi } from '@/api'; import { useTranslation } from 'react-i18next'; import { YamlCodeMirror } from './YamlCodeMirror'; import type { JsonData } from '@/types/common'; interface YamlImportDialogProps { clusterCode: string; onClose: () => void; onApplied?: () => void; } export function YamlImportDialog({ clusterCode, onClose, onApplied }: YamlImportDialogProps) { const { t } = useTranslation(); const { toast } = useToast(); const [content, setContent] = useState(''); const [applying, setApplying] = useState(false); const apply = async () => { if (!content.trim()) { toast({ title: t('k8s.yamlImport.empty'), variant: 'destructive' }); return; } setApplying(true); try { await kubernetesApi.applyYAML(clusterCode, content); toast({ title: t('k8s.yamlImport.success'), description: t('k8s.yamlImport.successDesc') }); onApplied?.(); onClose(); } catch (e) { toast({ title: t('k8s.yamlImport.failed'), description: (e as JsonData).message, variant: 'destructive' }); } finally { setApplying(false); } }; return (
e.stopPropagation()} >

{t('k8s.yamlImport.title')}

{t('k8s.yamlImport.hint')}

); }