diff --git a/ui/CHANGELOG.md b/ui/CHANGELOG.md index 4ccdd6e361..f7d99f9090 100644 --- a/ui/CHANGELOG.md +++ b/ui/CHANGELOG.md @@ -19,7 +19,7 @@ All notable changes to the **Prowler UI** are documented in this file. - Filter navigations not coordinating with Suspense boundaries due to missing startTransition in ProviderTypeSelector, AccountsSelector, and muted findings checkbox [(#10013)](https://github.com/prowler-cloud/prowler/pull/10013) - Scans page pagination not updating table data because ScansTableWithPolling kept stale state from initial mount [(#10013)](https://github.com/prowler-cloud/prowler/pull/10013) - Duplicate `filter[search]` parameter in findings and scans API calls [(#10013)](https://github.com/prowler-cloud/prowler/pull/10013) -- All filters on `/findings` silently reverting on first click in production [(#10025)](https://github.com/prowler-cloud/prowler/pull/10025) +- All filters on `/findings` silently reverting on first click in production [(#10034)](https://github.com/prowler-cloud/prowler/pull/10034) --- diff --git a/ui/hooks/use-url-filters.ts b/ui/hooks/use-url-filters.ts index 6ac36762a7..3c2ca7004b 100644 --- a/ui/hooks/use-url-filters.ts +++ b/ui/hooks/use-url-filters.ts @@ -2,6 +2,9 @@ import { usePathname, useRouter, useSearchParams } from "next/navigation"; +const FINDINGS_PATH = "/findings"; +const DEFAULT_MUTED_FILTER = "false"; + /** * Custom hook to handle URL filters and automatically reset * pagination when filters change. @@ -15,7 +18,16 @@ export const useUrlFilters = () => { const pathname = usePathname(); const isPending = false; + const ensureFindingsDefaultMuted = (params: URLSearchParams) => { + // Findings defaults to excluding muted findings unless user sets it explicitly. + if (pathname === FINDINGS_PATH && !params.has("filter[muted]")) { + params.set("filter[muted]", DEFAULT_MUTED_FILTER); + } + }; + const navigate = (params: URLSearchParams) => { + ensureFindingsDefaultMuted(params); + const queryString = params.toString(); const targetUrl = queryString ? `${pathname}?${queryString}` : pathname; router.push(targetUrl, { scroll: false }); diff --git a/ui/proxy.ts b/ui/proxy.ts index 5827f39844..98b0725dea 100644 --- a/ui/proxy.ts +++ b/ui/proxy.ts @@ -50,20 +50,6 @@ export default auth((req: NextRequest & { auth: any }) => { } } - // Redirect /findings to include default muted filter if not present - if ( - pathname === "/findings" && - !req.nextUrl.searchParams.has("filter[muted]") - ) { - const findingsUrl = new URL("/findings", req.url); - // Preserve existing search params - req.nextUrl.searchParams.forEach((value, key) => { - findingsUrl.searchParams.set(key, value); - }); - findingsUrl.searchParams.set("filter[muted]", "false"); - return NextResponse.redirect(findingsUrl); - } - return NextResponse.next(); });