Skip to content

Implement persistent filters usage in frontend - #4775

Open
arbulu89 wants to merge 9 commits into
mainfrom
persistent-frontend-filters
Open

arbulu89 wants to merge 9 commits into
mainfrom
persistent-frontend-filters

Conversation

@arbulu89

@arbulu89 arbulu89 commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Description

Add persistent filters usage in the frontend. This way, once the user has selected a filter in a page, moves somewhere else, and moves back, the same filters are applied.

The code creates a viewSettings library to handle the session storage and a hook that "upgrades" searchParams to get persistent filters if they exist combined with the query string params.

Caveats:

  • The filters are stored in the sessionStorage and are per user. This means that a logout or opening the app in a new tab won't bring the previously applied filters.
  • I have only implemented the filters usage in the Hosts overview, to keep the PR smaller.
persistent-filters

How was this tested?

UT and e2e

Documentation changes

I guess we will need to document the feature

@arbulu89 arbulu89 added enhancement New feature or request env Create an ephimeral environment for the pr branch labels Sep 14, 2026
@github-actions

Copy link
Copy Markdown

The preview environment for this pull request is ready at 4775.prenv.trento.suse.com.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Address the session-storage failure handling and restore browser history coverage.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Adds user-scoped session persistence for Hosts filters and page size.

Changes:

  • Adds view-settings, search-parameter, and persistence-hook utilities.
  • Integrates persistence with Hosts, authentication lifecycle, tables, and pagination.
  • Adds unit, component, and Cypress coverage.

Final findings:

  • Moderate (2 votes): Clear the existing view-settings entry when sessionStorage.setItem fails, and add coverage.
  • Moderate (1 vote): Restore dedicated browser back/forward history coverage.
File summaries
File Summary
test/e2e/cypress/e2e/hosts_overview.cy.js Updates Hosts persistence E2E coverage.
assets/js/pages/Layout/Layout.jsx Clears settings on logout.
assets/js/pages/HostsList/HostsList.test.jsx Tests Hosts list behavior.
assets/js/pages/HostsList/HostsList.jsx Enables persistent Hosts search parameters.
assets/js/pages/Guard/Guard.jsx Initializes settings per user.
assets/js/lib/viewSettings/index.test.js Tests view-settings storage.
assets/js/lib/viewSettings/index.js Stores user-scoped view settings.
assets/js/lib/searchParams/index.test.js Tests search-parameter helpers.
assets/js/lib/searchParams/index.js Provides search-parameter update helpers.
assets/js/hooks/usePersistentSearchParams.test.jsx Tests persistent search parameters.
assets/js/hooks/usePersistentSearchParams.js Restores and persists URL parameters.
assets/js/common/Table/Table.test.jsx Tests URL-bound table behavior.
assets/js/common/Table/Table.jsx Binds page size to URL parameters.
assets/js/common/Table/index.js Exports the table component.
assets/js/common/Pagination/Pagination.jsx Makes page-size selection controlled.
Review details

Suppressed comments (1)

test/e2e/cypress/e2e/hosts_overview.cy.js:228

  • This replacement no longer exercises browser back/forward behavior, and the deleted cases also covered returning to the previous page and avoiding duplicate history entries. Since the new hook performs mount-time setSearchParams(..., { replace: true }), keep a dedicated back/forward assertion (or add an equivalent hook test) so regressions in history handling are still detected.
      hostsOverviewPage.visit();
  • Files reviewed: 15/15 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread assets/js/lib/viewSettings/index.js
@arbulu89
arbulu89 marked this pull request as ready for review September 15, 2026 07:32
@arbulu89
arbulu89 force-pushed the persistent-frontend-filters branch from a92e2a3 to f95d808 Compare September 15, 2026 14:29
@arbulu89
arbulu89 force-pushed the persistent-frontend-filters branch from f95d808 to f813de2 Compare September 16, 2026 13:01
@arbulu89
arbulu89 force-pushed the persistent-frontend-filters branch from f813de2 to 67b4da2 Compare September 16, 2026 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request env Create an ephimeral environment for the pr branch

Development

Successfully merging this pull request may close these issues.

2 participants