fix(web): metric monitor edit keeps for_sec 0 and allows 0 minutes

This commit is contained in:
2026-09-17 09:25:02 +00:00
parent 42766968e3
commit ffc6853142
2 changed files with 5 additions and 3 deletions
+4 -2
View File
@@ -114,7 +114,9 @@ export function MonitorForm({
const [metric, setMetric] = useState<MetricKind>(initial?.target.metric ?? "disk_pct");
const [threshold, setThreshold] = useState<number>(initial?.target.threshold ?? 90);
const [mount, setMount] = useState(initial?.target.mount ?? "");
const [forMin, setForMin] = useState(Math.round((initial?.for_sec ?? 300) / 60));
// for_sec 0 is omitted from JSON, so an existing monitor without it means
// "alert immediately"; only a new monitor gets the 5 minute default.
const [forMin, setForMin] = useState(Math.round((initial ? (initial.for_sec ?? 0) : 300) / 60));
const [selector, setSelector] = useState<Record<string, string>>(initial?.target.selector ?? {});
const { data: servers } = useQuery({ queryKey: ["servers"], queryFn: () => api.listServers() });
@@ -356,7 +358,7 @@ export function MonitorForm({
className={`${inputClass} font-mono tabular-nums`}
value={forMin}
onChange={(e) => setForMin(Number(e.target.value))}
min={1}
min={0}
/>
</Field>
</div>
File diff suppressed because one or more lines are too long