fix: YAML查看器按钮文案 '清理并编辑' → '编辑',统一简洁命名
This commit is contained in:
1 parent
a8b4af4409
commit
4bd9fa629b
14 files changed
+2146
-400
No files matched your search
@@ -27,6 +27,7 @@ import {
|
||||
Trash2,
|
||||
Search,
|
||||
Container,
|
||||
Download,
|
||||
} from 'lucide-react';
|
||||
import { kubernetesApi } from '@/services/api';
|
||||
import { toast } from 'sonner';
|
||||
@@ -49,6 +50,11 @@ export function KubernetesClusters() {
|
||||
const [kubectlCluster, setKubectlCluster] = useState<{id: number; name: string} | null>(null);
|
||||
const [kubectlTerminalOpen, setKubectlTerminalOpen] = useState(false);
|
||||
|
||||
// 导出资源弹窗
|
||||
const [exportCluster, setExportCluster] = useState<any>(null);
|
||||
const [exportNs, setExportNs] = useState('default');
|
||||
const [exporting, setExporting] = useState(false);
|
||||
|
||||
const loadData = async () => {
|
||||
try {
|
||||
setLoading(true);
|
||||
@@ -104,6 +110,23 @@ export function KubernetesClusters() {
|
||||
}
|
||||
};
|
||||
|
||||
const handleExport = async () => {
|
||||
if (!exportCluster) return;
|
||||
const code = exportCluster.code || String(exportCluster.id);
|
||||
if (!exportNs.trim()) { toast.error('请输入命名空间'); return; }
|
||||
try {
|
||||
setExporting(true);
|
||||
toast.info(`正在导出 ${exportNs} 命名空间的资源...`);
|
||||
await kubernetesApi.exportResources(code, exportNs.trim());
|
||||
toast.success('导出完成,已开始下载');
|
||||
setExportCluster(null);
|
||||
} catch (e: any) {
|
||||
toast.error(e?.message || '导出失败');
|
||||
} finally {
|
||||
setExporting(false);
|
||||
}
|
||||
};
|
||||
|
||||
const filteredClusters = clusters.filter(
|
||||
(cluster) =>
|
||||
(cluster.name || '').toLowerCase().includes(searchQuery.toLowerCase()) ||
|
||||
@@ -331,6 +354,17 @@ export function KubernetesClusters() {
|
||||
<Container className="h-4 w-4 mr-2" />
|
||||
kubectl
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem
|
||||
className="text-blue-400 focus:bg-slate-700 focus:text-blue-300"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
setExportCluster(cluster);
|
||||
setExportNs('default');
|
||||
}}
|
||||
>
|
||||
<Download className="h-4 w-4 mr-2" />
|
||||
导出资源
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuSeparator className="bg-slate-700" />
|
||||
<DropdownMenuItem
|
||||
className="text-red-400 focus:bg-slate-700 focus:text-red-400"
|
||||
@@ -432,6 +466,32 @@ export function KubernetesClusters() {
|
||||
clusterName={kubectlCluster.name}
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* 导出资源弹窗 */}
|
||||
{exportCluster && (
|
||||
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black/60" onClick={() => setExportCluster(null)}>
|
||||
<div className="bg-slate-900 border border-slate-700 rounded-lg p-5 w-96 shadow-xl" onClick={(e) => e.stopPropagation()}>
|
||||
<h3 className="text-base font-semibold text-slate-100 mb-1">导出集群资源</h3>
|
||||
<p className="text-xs text-slate-400 mb-4">
|
||||
导出 {exportCluster.name} 的 Deployment + Service + Ingress + ConfigMap + Secret 为 tar.gz
|
||||
</p>
|
||||
<label className="text-xs text-slate-300 mb-1.5 block">命名空间</label>
|
||||
<Input
|
||||
value={exportNs}
|
||||
onChange={(e) => setExportNs(e.target.value)}
|
||||
placeholder="default"
|
||||
className="bg-slate-800 border-slate-700 text-slate-100 mb-4"
|
||||
onKeyDown={(e) => e.key === 'Enter' && handleExport()}
|
||||
/>
|
||||
<div className="flex justify-end gap-2">
|
||||
<Button variant="outline" className="border-slate-700 text-slate-300" onClick={() => setExportCluster(null)}>取消</Button>
|
||||
<Button className="bg-blue-600 hover:bg-blue-700 text-white" onClick={handleExport} disabled={exporting}>
|
||||
{exporting ? '导出中...' : '确认导出'}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user