refactor: AlertCenter拆分(723→390行)+修复TopologyView类型错误
- AlertCenter.tsx: 723→390行,提取类型/helpers/渠道Tab到子组件 - alert-center-helpers.tsx: 新建(127行),共享Alert/AlertRule/NotificationChannel类型+mapAlert+badge helpers - AlertChannelDialog.tsx: 新建(121行),通知渠道创建/编辑对话框(自包含useEffect同步) - AlertChannelsTab.tsx: 新建(152行),通知渠道Tab自包含(状态+API+渲染+CRUD) - AlertCenterDetail.tsx: 去重getSeverityBadge,统一从helpers导入 - TopologyView.tsx: 修复editForm.type类型推断(string→TopologyNode['type'])
This commit is contained in:
1 parent
805cb767a8
commit
76a41f5eeb
6 files changed
+458
-406
No files matched your search
@@ -1,26 +1,11 @@
|
||||
import {
|
||||
Check, ChevronRight, AlertCircle, AlertTriangle, Info,
|
||||
} from 'lucide-react';
|
||||
import { Check, ChevronRight } from 'lucide-react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
import { Label } from '@/components/ui/label';
|
||||
import {
|
||||
Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription, DialogFooter,
|
||||
} from '@/components/ui/dialog';
|
||||
import type { Alert } from './AlertCenter';
|
||||
|
||||
function getSeverityBadge(severity: string) {
|
||||
switch (severity) {
|
||||
case 'critical':
|
||||
return <Badge variant="destructive" className="gap-1"><AlertCircle className="w-3 h-3" />严重</Badge>;
|
||||
case 'warning':
|
||||
return <Badge variant="default" className="bg-orange-500 gap-1"><AlertTriangle className="w-3 h-3" />警告</Badge>;
|
||||
case 'info':
|
||||
return <Badge variant="default" className="bg-blue-500 gap-1"><Info className="w-3 h-3" />信息</Badge>;
|
||||
default:
|
||||
return <Badge variant="secondary">未知</Badge>;
|
||||
}
|
||||
}
|
||||
import { type Alert, getSeverityBadge } from './alert-center-helpers'; // Logan.Li — 统一从 helpers 导入
|
||||
|
||||
export function AlertDetailDialog({
|
||||
alert,
|
||||
|
||||
Reference in new issue
Block a user