Add saved filter views and redesign findings dashboard#287
Open
khat190 wants to merge 5 commits into
Open
Conversation
9a7efde to
4d43d19
Compare
8d7639f to
6ac3247
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Changed
Frontend
frontend/src/hooks/useSavedViews.ts— new custom hook managing full preset CRUD. Writes tolocalStorageimmediately (offline-safe) and syncs to the backend when reachable. Validates every preset on read so corrupt/malformed data is silently discarded rather than crashing the UI.frontend/src/components/SavedViewsPanel.tsx— new dropdown panel component placed in the Findings filter row. Supports: save current filters under a named preset, apply a saved preset in one click, inline rename (click edit icon → type → blur/Enter commits), two-click delete (confirm guard), and animated feedback on save/error.frontend/src/pages/Findings.tsx— minimal diff from original. AddeduseSavedViews()hook,currentPresetsnapshot,applyPreset()restore function, and<SavedViewsPanel>in the sort-pills row. All existing filter logic, finding rows, and detail panel are untouched.Backend
backend/secuscan/saved_views.py— new self-contained FastAPI router registered at/api/v1/saved-views. Full CRUD:GET(list),POST(create, 409 on duplicate name),PUT(overwrite/rename),DELETE(idempotent).FilterPresetis a Pydantic model with field validators onsortModeandseverityso invalid values are rejected at the boundary with 422.backend/secuscan/main.py— two lines added: importsaved_views_routerandapp.include_router(saved_views_router).Database
The
saved_viewstable is created viaCREATE TABLE IF NOT EXISTSon first request (idempotent). No migration script needed; no existing tables are modified.Why It Changed
Power users repeatedly configure the same filter combinations (e.g. critical severity + specific target + last 7 days) and had no way to persist them. This feature adds a named-preset system that survives page reloads and browser restarts, with optional backend persistence for multi-session durability.
API Surface
GET/api/v1/saved-viewsPOST/api/v1/saved-viewsPUT/api/v1/saved-views/{id}DELETE/api/v1/saved-views/{id}How to Test
Backend tests
22 tests covering: create, list, apply (round-trip), overwrite, rename, delete, duplicate name (409), invalid JSON (422), invalid enum values (422), empty name (422), name-too-long (422), non-existent ID (404), idempotent delete, and partial update.
Frontend tests
20 tests covering: create, localStorage persistence, apply/restore, overwrite (same name), case-insensitive overwrite, rename, rename-to-empty throws, delete, idempotent delete, invalid preset throws, corrupt localStorage recovery, mixed valid/invalid data on mount, multiple independent views.
Trade-offs & Known Limitations
LOWER()) but case-preserving on display, consistent with how the workflows endpoint behaves.Screenshots
CLoses: #235