From 941502b710d35d2044e08c58f19f8d71562b9f41 Mon Sep 17 00:00:00 2001 From: Lukas Date: Thu, 23 Apr 2026 09:26:45 +0200 Subject: [PATCH] Fix BanTable to use props exclusively (complete dual state source refactoring) - BanTable now requires all filter props (timeRange, origin, source) - Removed useDashboardFilters() hook dependency from BanTable - Eliminated context fallback chain using ?? operator - Component now exclusively reads from props, never from context Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- frontend/src/components/BanTable.tsx | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/frontend/src/components/BanTable.tsx b/frontend/src/components/BanTable.tsx index 6f4a5c1..938655d 100644 --- a/frontend/src/components/BanTable.tsx +++ b/frontend/src/components/BanTable.tsx @@ -9,7 +9,6 @@ */ import { memo, useMemo } from "react"; -import { useDashboardFilters } from "../providers/DashboardFilterProvider"; import { Badge, Button, @@ -42,16 +41,16 @@ interface BanTableProps { * Active time-range preset — controlled by the parent `DashboardPage`. * Changing this value triggers a re-fetch. */ - timeRange?: TimeRange; + timeRange: TimeRange; /** * Active origin filter — controlled by the parent `DashboardPage`. * Changing this value triggers a re-fetch and resets to page 1. */ - origin?: BanOriginFilter; + origin: BanOriginFilter; /** * Data source used for the table query. */ - source?: "fail2ban" | "archive"; + source: "fail2ban" | "archive"; } // --------------------------------------------------------------------------- @@ -194,14 +193,10 @@ function buildBanColumns(styles: ReturnType): TableColumnDefin */ export const BanTable = memo(function BanTable({ timeRange, origin, source }: BanTableProps): React.JSX.Element { const styles = useStyles(); - const context = useDashboardFilters(); - const effectiveTimeRange = timeRange ?? context.timeRange; - const effectiveOrigin = origin ?? context.originFilter; - const effectiveSource = source ?? context.source; const { banItems, total, page, setPage, loading, error, refresh } = useBans( - effectiveTimeRange, - effectiveOrigin, - effectiveSource, + timeRange, + origin, + source, ); const banColumns = useMemo(() => buildBanColumns(styles), [styles]);