Procházet zdrojové kódy

fix(roaming): hide the DAWN filter when the network has no DAWN (#909) (#912)

The events type filter always offered a DAWN button, but usteer-only
deployments never produce dawn_decision events, so the option was dead
weight and confusing (the rest of the section already detects usteer).
Show it only when the backend reports DAWN in use, and treat a stale
dawn_decision selection as 'all' if DAWN disappears from the network.
Nacho před 2 měsíci
rodič
revize
260aabae2f
1 změnil soubory, kde provedl 13 přidání a 6 odebrání
  1. 13 6
      app/src/pages/Roaming.tsx

+ 13 - 6
app/src/pages/Roaming.tsx

@@ -609,7 +609,7 @@ export default function Roaming() {
 
 
       {tab === 'events' && (
       {tab === 'events' && (
         <div role="tabpanel" id="panel-events" aria-labelledby="tab-events" tabIndex={0}>
         <div role="tabpanel" id="panel-events" aria-labelledby="tab-events" tabIndex={0}>
-          <EventsPanel events={events} loading={eventsLoading} error={eventsError} noApi={eventsNoApi} typeFilter={eventsTypeFilter} setTypeFilter={setEventsTypeFilter} nameByMac={nameByMac} />
+          <EventsPanel events={events} loading={eventsLoading} error={eventsError} noApi={eventsNoApi} typeFilter={eventsTypeFilter} setTypeFilter={setEventsTypeFilter} nameByMac={nameByMac} hasDawn={dawnDeprecated} />
         </div>
         </div>
       )}
       )}
 
 
@@ -1500,6 +1500,7 @@ function EventsPanel({
   typeFilter,
   typeFilter,
   setTypeFilter,
   setTypeFilter,
   nameByMac,
   nameByMac,
+  hasDawn,
 }: {
 }: {
   events: RoamEvent[]
   events: RoamEvent[]
   loading: boolean
   loading: boolean
@@ -1508,15 +1509,21 @@ function EventsPanel({
   typeFilter: EventTypeFilter
   typeFilter: EventTypeFilter
   setTypeFilter: (t: EventTypeFilter) => void
   setTypeFilter: (t: EventTypeFilter) => void
   nameByMac: Map<string, string>
   nameByMac: Map<string, string>
+  hasDawn: boolean
 }) {
 }) {
   const { t } = useTranslation()
   const { t } = useTranslation()
   const reduce = useReducedMotion()
   const reduce = useReducedMotion()
   const initial = reduce ? false : { opacity: 0, y: 12 }
   const initial = reduce ? false : { opacity: 0, y: 12 }
 
 
+  // #909: la opción DAWN solo tiene sentido cuando la red tiene routers con
+  // DAWN (usteer no emite dawn_decision). Si el filtro activo quedó obsoleto
+  // (DAWN desapareció de la red), se trata como 'all'.
+  const effectiveFilter: EventTypeFilter = typeFilter === 'dawn_decision' && !hasDawn ? 'all' : typeFilter
+
   const filtered = useMemo(() => {
   const filtered = useMemo(() => {
-    if (typeFilter === 'all') return events
-    return events.filter((e) => e.type === typeFilter)
-  }, [events, typeFilter])
+    if (effectiveFilter === 'all') return events
+    return events.filter((e) => e.type === effectiveFilter)
+  }, [events, effectiveFilter])
 
 
   if (loading && events.length === 0) {
   if (loading && events.length === 0) {
     return (
     return (
@@ -1540,7 +1547,7 @@ function EventsPanel({
     )
     )
   }
   }
 
 
-  const typeOptions: EventTypeFilter[] = ['all', 'connected', 'disconnected', 'dawn_decision']
+  const typeOptions: EventTypeFilter[] = ['all', 'connected', 'disconnected', ...(hasDawn ? ['dawn_decision' as const] : [])]
 
 
   return (
   return (
     <motion.section
     <motion.section
@@ -1565,7 +1572,7 @@ function EventsPanel({
                 onClick={() => setTypeFilter(tf)}
                 onClick={() => setTypeFilter(tf)}
                 className={cn(
                 className={cn(
                   'rounded-md px-2.5 py-1 text-caption font-medium transition-colors',
                   'rounded-md px-2.5 py-1 text-caption font-medium transition-colors',
-                  typeFilter === tf ? 'bg-accent/15 text-accent' : 'text-text-muted hover:text-text-secondary',
+                  effectiveFilter === tf ? 'bg-accent/15 text-accent' : 'text-text-muted hover:text-text-secondary',
                 )}
                 )}
               >
               >
                 {t(`roaming.events.type_${tf}`)}
                 {t(`roaming.events.type_${tf}`)}