Skip to content

Add filters and pagination to users page#2229

Merged
stephencdaly merged 13 commits into
mainfrom
add-filters-and-pagination-to-users
Sep 19, 2025
Merged

Add filters and pagination to users page#2229
stephencdaly merged 13 commits into
mainfrom
add-filters-and-pagination-to-users

Conversation

@stephencdaly
Copy link
Copy Markdown
Contributor

@stephencdaly stephencdaly commented Sep 17, 2025

What problem does this pull request solve?

Trello card: https://trello.com/c/IlcvX9A9/186-add-filters-and-pagination-for-users-page

Add a filter component an pagination to the users page so it loads quicker and it's easier to find users.

50 users are displayed per page - this could be changed if desired.

Add indexes on the users table to make the search using the filters as efficient as possible.

Screenshot 2025-09-18 at 16 46 11

Things to consider when reviewing

  • Ensure that you consider the wider context.
  • Does it work when run on your machine?
  • Is it clear what the code is doing?
  • Do the commit messages explain why the changes were made?
  • Are there all the unit tests needed?
  • Do the end to end tests need updating before these changes will pass?
  • Has all relevant documentation been updated?

@stephencdaly stephencdaly force-pushed the add-filters-and-pagination-to-users branch from 166b95d to 814279d Compare September 17, 2025 16:39
@stephencdaly stephencdaly reopened this Sep 17, 2025
@stephencdaly stephencdaly marked this pull request as ready for review September 18, 2025 08:50
@stephencdaly stephencdaly force-pushed the add-filters-and-pagination-to-users branch 4 times, most recently from 5148913 to 788331a Compare September 18, 2025 15:47
@stephencdaly stephencdaly changed the title Add filters and pagination to users Add filters and pagination to users page Sep 18, 2025
Comment thread config/brakeman.ignore Outdated
@stephencdaly stephencdaly force-pushed the add-filters-and-pagination-to-users branch from 788331a to d833b67 Compare September 19, 2025 09:37
@stephencdaly stephencdaly force-pushed the add-filters-and-pagination-to-users branch from d833b67 to 93d7bf5 Compare September 19, 2025 09:48
stephencdaly and others added 13 commits September 19, 2025 11:12
Add scopes to get Users by:
- Name with a case insensitive, partial match strategy
- Email with a case insensitive, partial match strategy
- Organisation ID
We have tables on other pages, such as the group members page without
a caption. The caption here is redundant as the table is the only
thing on the page and is described by the page heading.
Install pagy for pagination on the users index page. govuk-components
supports pagy out of the box, making it a suitable choice over other
gems.
Use the pagy gem and the govuk_pagination component to add pagination
to the users index page.
Add a component to the index page to specify filters for the user list
and apply the specified filters in the controller.
Show a link to load the users page without filters if any filters are
applied.
Add a GIN index on LOWER(name) to optimize case-insensitive searches
for users.
Add a GIN index on LOWER(email) to optimize case-insensitive searches
for users.

We already have a unique index on email but we cannot make gin indexes
unique so we need to add a separate index for searches.
So that the filter component size does not change hen the menu is
shown, set the displayMenu option for the accessible-autocomplete to
be 'overlay'.
We want to re-use these methods to get the options for filters in the
users index view. Move them to a separarte helper module to be
included in the FilterInput without having to import ApplicationHelper.

Change calls to `t` to `I18n.t` so that these methods can be called
from non-view contexts.
Add additional filters to filter by user role and whether they have
access to the platform. Include blank options for both of these
filters to display all users regardless of role or access.
This warning was triggered because we have the query parameter `role`.
This is a false positive as there is no danger with being able to
specify the role in this case.
@stephencdaly stephencdaly force-pushed the add-filters-and-pagination-to-users branch from 93d7bf5 to c0cb789 Compare September 19, 2025 10:12
@sonarqubecloud
Copy link
Copy Markdown

@github-actions
Copy link
Copy Markdown

🎉 A review copy of this PR has been deployed! You can reach it at: https://pr-2229.admin.review.forms.service.gov.uk/

It may take 5 minutes or so for the application to be fully deployed and working. If it still isn't ready
after 5 minutes, there may be something wrong with the ECS task. You will need to go to the integration AWS account
to debug, or otherwise ask an infrastructure person.

For the sign in details and more information, see the review apps wiki page.

@stephencdaly stephencdaly merged commit 49a95bb into main Sep 19, 2025
6 checks passed
@stephencdaly stephencdaly deleted the add-filters-and-pagination-to-users branch September 19, 2025 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants