[solidus_admin] Add configurable pagination resource ratios for admin index pages - #6587
[solidus_admin] Add configurable pagination resource ratios for admin index pages#6587forkata wants to merge 2 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6587 +/- ##
==========================================
+ Coverage 92.16% 92.26% +0.09%
==========================================
Files 1037 1037
Lines 21210 21242 +32
==========================================
+ Hits 19549 19599 +50
+ Misses 1661 1643 -18 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This would allow users of the new admin to configure the number of resources seen on each index route, without having to override the controller actions or the default constant defined in Geared Pagination[^1]. We considered doing this as a hash per resource type, but for now a global config is a good starting point. [^1]: https://github.com/basecamp/geared_pagination/blob/master/lib/geared_pagination/recordset.rb#L3 Co-authored-by: Senem Soy <senem@super.gd>
This passes the new config when paginating orders and products in the Solidus admin. These two controllers explicitly call the `set_and_extract_portion_from` helper so they need to receive this argument explicitly, otherwise the default configuration from the geared pagination will be used. Co-authored-by: Senem Soy <senem@super.gd>
76d67c8 to
ef99146
Compare
| # items to display per page in the admin interface. The values in this | ||
| # array represent the number of resources displayed on the first, second, | ||
| # third and every subsequent page after. | ||
| preference :pagination_ratios_per_page, :array, default: [15, 30, 50, 100] |
There was a problem hiding this comment.
I have never seen a pagination feature like this before, but I also can't find evidence that anyone else calls something like this "ratios." I find that the default values don't seem to be "ratios per page" of any kind. So, I am concerned that :pagination_ratios_per_page is wrong descriptor and maybe :pagination_items_per_page is more straightforward.
There was a problem hiding this comment.
Yeah, the language here is specific to the geared_pagination implementation, we can make it more generic to remove the need for renaming when we inevitably change libraries in the future 👍🏼 Any thoughts on exposing the values as an array? There is a similar PR to this that does it as a single value, but loses out on the ability to have a different counts for first, second, third page?
There was a problem hiding this comment.
I personally think that having different pages with different counts could be confusing the end users because (to the best of my knowledge?) it's unusual and it's not uniform. I might feel differently if the interface was recreational in nature, but end users here are admins and they do not want to be surprised.
For example, a user might skip to the third page because they want to see the 75th item, not realizing that that would have been on the second page because of a configured [25, 50, 75, 100].
Summary
This change aims to introduce a new config that can be used in the admin to customize the resource count ratios for geared pagination, without having to override the global configuration that gem provides.
In the future we can extend this to a per-model config, by switching the static configuration to a hash keyed by the resource name, but for now a single config for all resource types is used.
This is still a rough draft, but since there is another PR attempting to do a similar thing, we thought it may be good to open it up for early feedback. The next step is to specify this in the base resources controller and also extract a shared partial that can be used throughout all other index views.
This PR addresses issue #6520
Checklist
Check out our PR guidelines for more details.
The following are mandatory for all PRs:
The following are not always needed: