Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CTSKF-486] Replace Kaminari with Pagy #7915

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

mpw5
Copy link
Contributor

@mpw5 mpw5 commented Dec 17, 2024

What

Replace the Kaminari pagination gem with Pagy

Ticket

CTSKF-486

Why

The govuk-components gem offers a pagination component which depends on the use of Pagy. By adopting Pagy now we will have the option of using the govuk-components pagination component in future, allowing us to better conform with GDS design standards.

How

  • Remove existing Kaminari configuration and styling
  • Implement Pagy following guidance here: https://ddnexus.github.io/pagy/docs/migration-guide/
    • replace use of Kaminari .per and .page methods with pagy
    • use Pagy pagy_nav helper method to display pagination navigation - this results in navigation which is slightly different to what users currently see (no First or Last links, for example) but should hopefully have little impact (see below for examples). Implementing the govuk pagination component would allow us to standardise the experience
    • use Pagy pagy_info helper method to display information about pagination - again, this is slightly different to the current wording but (in my opinion) gives more useful information (see below for examples)

Screenshots

Kaminari navigation controls:
image

Pagy navigation controls:
image



Kaminari pagination info:

image

Pagy pagination info:

image

@mpw5 mpw5 force-pushed the ctskf-486-kaminari-to-pagy branch 8 times, most recently from 2677462 to f9c2826 Compare December 20, 2024 12:34
mpw5 added 2 commits December 20, 2024 12:38
Replaces the uses of the Kaminari gem for pagination with Pagy on the
superadmin 'All users' page.
@mpw5 mpw5 force-pushed the ctskf-486-kaminari-to-pagy branch from f9c2826 to 4df1d11 Compare December 20, 2024 12:38
Replaces the uses of the Kaminari gem for pagination with Pagy on the
provider 'Your claims', 'Your claim archive', 'Your outstanding claims'
and 'Your authorised claims' pages.
@mpw5 mpw5 force-pushed the ctskf-486-kaminari-to-pagy branch from 4df1d11 to 3e92c41 Compare December 20, 2024 12:41
mpw5 added 3 commits December 20, 2024 12:57
Replaces the uses of the Kaminari gem for pagination with Pagy on the
caseworker claims pages.

This is more complex than the change to the provider claims pages due to
the way claims data is fetched from the API. Pagination is currently
done by the API, so it is necessary to make changes there too.

This commit

* updates `API::V2::CaseWorkers::Claim` to use Pagy to paginate claims
and pass the resulting Pagy object to `API::Entities::PaginatedCollection`
* updates `API::Entities::PaginatedCollection` to read pagination data
from the Pagy object and include it in the API response
* updates `CaseWorkers::ClaimsController` to create a new Pagy object on
the client side based on pagination data received from the API
* updates views to use the Pagy object when displaying pagination controls
Replaces the uses of the Kaminari gem for pagination with Pagy on the
caseworker allocation pages.

This is more complex than the change to the provider claims pages due to
the way claims data is fetched from the API. Pagination is currently
done by the API, so it is necessary to make changes there too.

Similar to the previous commit it is necessary to create a new Pagy object
in the CaseWorkers::Admin::AllocationsController based on pagination data
received from the API. This also fixes a bug(?) where the `sort_and_paginate`
method was never being called in that controller.
Tidies up the views a little by moving the code to generate pagination
controls to a reusable shared partial. This also adds some extra
control to hide the pagination links when only one page is displayed,
in line with GDS guidelines.
@mpw5 mpw5 force-pushed the ctskf-486-kaminari-to-pagy branch from 3e92c41 to ae127ae Compare December 20, 2024 14:49
Requests to the API have changed as Pagy indexes pages from 1, not 0 used
by Kaminari. This means the `pages` parameter in API calls to the
`caseworker/claims` endpoint now use 1 instead of 0, and VCR cassettes
need to be updated to reflect this.

This also updates a feature test which had become inaccurate to a
change of onscreen wording as a result of the use of the @pagy_info
helper method to display pagination data.
@mpw5 mpw5 force-pushed the ctskf-486-kaminari-to-pagy branch from ae127ae to 8bf7608 Compare December 20, 2024 14:52
@mpw5 mpw5 marked this pull request as ready for review December 20, 2024 15:38
@mpw5 mpw5 requested review from a team as code owners December 20, 2024 15:38
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.

1 participant