// 中间件实例卡片 — 紧凑列表项,详情见右侧可观测面板 // Logan.Li import { Button } from '@/components/ui/button'; import { useTranslation } from 'react-i18next'; import { AlertTriangle, Loader2, Pencil, Trash2, Zap } from 'lucide-react'; import type { MwTarget } from './helpers'; import { evalMwHealth, fmtLastSeen, fmtVal, healthLevelColor, redisModeLabel, worstHealthLevel, } from './helpers'; interface Props { target: MwTarget; selected?: boolean; onSelect: () => void; onEdit: () => void; onDelete: () => void; onTest: () => void; testing: boolean; } export function InstanceCard({ target, selected, onSelect, onEdit, onDelete, onTest, testing }: Props) { const { t } = useTranslation(); const m = target.latest_metrics || {}; const isRedis = target.description === 'redis'; const issues = evalMwHealth(target); const health = worstHealthLevel(issues); const healthColor = healthLevelColor(health); return ( {target.name} {health !== 'ok' && ( )} {target.ip}:{target.port} {isRedis && ` · ${redisModeLabel(target.config_public?.redis_mode)}`} {' · '}{fmtLastSeen(target.last_seen_at)} {isRedis ? ( <> > ) : ( <> > )} e.stopPropagation()}> {testing ? : }{t('monitor.mwInstance.test')} {t('common.edit')} {t('common.delete')} ); } function MetricPill({ label, value }: { label: string; value: string }) { return ( {label} {value} ); }
{target.ip}:{target.port} {isRedis && ` · ${redisModeLabel(target.config_public?.redis_mode)}`} {' · '}{fmtLastSeen(target.last_seen_at)}