mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-03-21 18:58:04 +00:00
fix(ui): move default muted filter from middleware to client-side hook (#10034)
This commit is contained in:
@@ -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)
|
- 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)
|
- 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)
|
- 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)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,9 @@
|
|||||||
|
|
||||||
import { usePathname, useRouter, useSearchParams } from "next/navigation";
|
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
|
* Custom hook to handle URL filters and automatically reset
|
||||||
* pagination when filters change.
|
* pagination when filters change.
|
||||||
@@ -15,7 +18,16 @@ export const useUrlFilters = () => {
|
|||||||
const pathname = usePathname();
|
const pathname = usePathname();
|
||||||
const isPending = false;
|
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) => {
|
const navigate = (params: URLSearchParams) => {
|
||||||
|
ensureFindingsDefaultMuted(params);
|
||||||
|
|
||||||
const queryString = params.toString();
|
const queryString = params.toString();
|
||||||
const targetUrl = queryString ? `${pathname}?${queryString}` : pathname;
|
const targetUrl = queryString ? `${pathname}?${queryString}` : pathname;
|
||||||
router.push(targetUrl, { scroll: false });
|
router.push(targetUrl, { scroll: false });
|
||||||
|
|||||||
14
ui/proxy.ts
14
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();
|
return NextResponse.next();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user