Просмотр исходного кода

fix(home): decide the service row span from the cards that render (#1834) (#1837)

Nacho 1 месяц назад
Родитель
Сommit
f97172d870
2 измененных файлов с 13 добавлено и 8 удалено
  1. 9 3
      app/src/pages/Home.tsx
  2. 4 5
      app/src/sections/GatewayServices.tsx

+ 9 - 3
app/src/pages/Home.tsx

@@ -14,14 +14,20 @@ import { useServicesVisibility } from '@/hooks/useServicesVisibility'
  *  tráfico WAN a todo lo ancho, flota, collector, SLEs y los servicios del
  *  gateway (AdGuard/WireGuard) AL FINAL. */
 export default function Home() {
-  const { isDemo } = useNetPulse()
+  const { isDemo, adguard, wireguard } = useNetPulse()
   const [services] = useServicesVisibility()
   // Clave ESTABLE por tarjeta (#223): si AdGuard/WireGuard se deshabilitan en
   // Ajustes la lista se reordena y, con key={i}, React remontaría los paneles.
   // Cada id identifica al hijo, no su posición. Orden #983: AdGuard primero.
+  // La lista lleva solo lo que de verdad se pinta (#1834): el checkbox dice
+  // que el servicio interesa, los datos dicen si existe. Contar checkboxes
+  // dejaba media fila vacía en un gateway sin AdGuard, porque la tarjeta se
+  // ocultaba sola (#813) y el ancho ya estaba repartido.
   const serviceCards: { id: string; node: ReactNode }[] = []
-  if (services.adguard) serviceCards.push({ id: 'adguard', node: <AdGuardCard /> })
-  if (services.wireguard) serviceCards.push({ id: 'wireguard', node: <WireGuardCard /> })
+  if (services.adguard && adguard.host) serviceCards.push({ id: 'adguard', node: <AdGuardCard /> })
+  if (services.wireguard && wireguard.interface) {
+    serviceCards.push({ id: 'wireguard', node: <WireGuardCard /> })
+  }
   const serviceSpan = serviceCards.length >= 2 ? 'lg:col-span-6' : 'lg:col-span-12'
   return (
     <div className="grid grid-cols-1 gap-4 md:gap-5 lg:grid-cols-12">

+ 4 - 5
app/src/sections/GatewayServices.tsx

@@ -88,17 +88,16 @@ function PeerRow({ peer, index }: { peer: WGPeer; index: number }) {
   )
 }
 
-/** ③a Tarjeta AdGuard Home (home.md §③) */
+/** ③a Tarjeta AdGuard Home (home.md §③). Si el gateway no tiene AdGuard
+ * configurado no se pinta, y quien decide eso es Home (#1834), que es el
+ * mismo sitio que reparte el ancho de la fila: una sola fuente para las dos
+ * cosas. Antes la tarjeta se ocultaba sola (#813) y el ancho no se enteraba. */
 export function AdGuardCard({ index = 0 }: { index?: number }) {
   const { t } = useTranslation()
   const { refreshKey } = useDashboard()
   const { adguard } = useNetPulse()
   const maxBlocked = Math.max(...adguard.topBlocked.map((d) => d.count))
 
-  // Sin config (host vacío) la tarjeta no aplica: al desactivar AdGuard (#813)
-  // desaparece en vez de quedarse en "inactivo".
-  if (!adguard.host) return null
-
   return (
       <ServicePanel
         icon={ShieldCheck}