feat: disable automatic machine alert tickets

This commit is contained in:
Esdras Renan 2025-10-16 22:31:05 -03:00
parent 7951bc25a3
commit ac986410a3
2 changed files with 21 additions and 3 deletions

View file

@ -534,6 +534,24 @@ const statusClasses: Record<string, string> = {
unknown: "border-slate-300 bg-slate-200 text-slate-700",
}
const POSTURE_ALERT_LABELS: Record<string, string> = {
CPU_HIGH: "CPU alta",
SERVICE_DOWN: "Serviço indisponível",
SMART_FAIL: "Falha SMART",
}
function formatPostureAlertKind(raw?: string | null): string {
if (!raw) return "Alerta"
const normalized = raw.toUpperCase()
if (POSTURE_ALERT_LABELS[normalized]) {
return POSTURE_ALERT_LABELS[normalized]
}
return raw
.toLowerCase()
.replace(/_/g, " ")
.replace(/\b\w/g, (char) => char.toUpperCase())
}
function formatRelativeTime(date?: Date | null) {
if (!date) return "Nunca"
try {
@ -1833,8 +1851,8 @@ export function MachineDetails({ machine }: MachineDetailsProps) {
<div key={`alert-${i}`} className={cn("flex items-center justify-between rounded-md border px-3 py-2 text-sm",
(a?.severity ?? "warning").toLowerCase() === "critical" ? "border-rose-500/20 bg-rose-500/10" : "border-amber-500/20 bg-amber-500/10")
}>
<span className="font-medium text-foreground">{a?.message ?? a?.kind ?? "Alerta"}</span>
<Badge variant="outline">{String(a?.kind ?? "ALERTA")}</Badge>
<span className="font-medium text-foreground">{a?.message ?? formatPostureAlertKind(a?.kind)}</span>
<Badge variant="outline">{formatPostureAlertKind(a?.kind)}</Badge>
</div>
))}
</div>