fix(web): reset serverFilter when the selected instance is removed
If the user filters to a specific server and that instance is then deleted (e.g. from Settings), shownInstances becomes [] — empty table, no message. A useEffect resets the filter to ALL_SERVERS whenever the selected ID disappears from the instances list.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { Link, useNavigate } from "@tanstack/react-router";
|
||||
import { motion } from "framer-motion";
|
||||
import { Boxes, LayoutDashboard, Network, Settings as SettingsIcon } from "lucide-react";
|
||||
import { useCallback, useMemo, useState } from "react";
|
||||
import { useCallback, useEffect, useMemo, useState } from "react";
|
||||
import {
|
||||
computeFleetAggregates,
|
||||
DEFAULT_ROW_METRICS,
|
||||
@@ -29,6 +29,12 @@ export function Dashboard() {
|
||||
const [serverFilter, setServerFilter] = useState<string>(ALL_SERVERS);
|
||||
const [metricsById, setMetricsById] = useState<Record<string, FleetRowMetrics>>({});
|
||||
|
||||
useEffect(() => {
|
||||
if (serverFilter !== ALL_SERVERS && !instances.find((i) => i.id === serverFilter)) {
|
||||
setServerFilter(ALL_SERVERS);
|
||||
}
|
||||
}, [instances, serverFilter]);
|
||||
|
||||
const onMetrics = useCallback((id: string, m: FleetRowMetrics) => {
|
||||
setMetricsById((prev) => ({ ...prev, [id]: m }));
|
||||
}, []);
|
||||
|
||||
Reference in New Issue
Block a user