Commit graph

3 commits

Author SHA1 Message Date
Bartosz Dziewoński
2422e2ae9f PagerNavigationBuilder: Document that nulls in setLinkQuery() etc. are allowed
We already depend on this behavior in IndexPager::getNavigationBuilder(),
but it wasn't allowed by the type hints and wasn't covered by tests.

Change-Id: I9343e852dc4610a50adf1c22ed429ec0a40da816
2022-11-02 23:56:35 +00:00
Bartosz Dziewoński
08895be51b pager: Remove unused PagerNavigationBuilder::setExtra()
Follow-up to Ic75bd597b210e14612ca3aebb531b659897e8294.
No longer needed after I161dc0159e4372e3478341ee3fbea13b723d9fc1.

This is a public method, but it has not been included in a release
yet, so we can remove it without deprecation.

Change-Id: Ie5eea4d3423136812178747e187771e7cf78e95f
2022-11-02 21:38:56 +01:00
Bartosz Dziewoński
cfd6ffe7bb Introduce PagerNavigationBuilder for making pagination links
We had several implementations of almost identical paging links:

* PrevNextNavigationRenderer: The nicest one, somewhat recently added
  (4ca72763ec). Unfortunately it was also the least featureful: only
  supporting paging by numeric offset and not by index, and not able
  to generate "first"/"last" links. Also, I didn't realize that it
  exists when working on 94553a1bcb and b95d208340, so it was missing
  those changes too.

* IndexPager/ReverseChronologicalPager/AlphabeticPager: These have
  been here forever. The most featureful, but not configurable, so
  a large part of the implementation was copy-pasted in two classes.

* SpecialWhatLinksHere: Through some accident of history, this one
  special page ended up with its own implementation???

They are all replaced to use the new PagerNavigationBuilder.
It may be slightly too much, but I had fun writing it.

Notable changes compared to PrevNextNavigationRenderer:
* Adds <div class="mw-pager-navigation-bar"> wrapper around the
  navigation and <span class="…"> wrappers on inactive links
* The current limit link is made inactive
  (like the "prev" link when on first page, etc.)

Notable changes compared to ...Pager/...Pager/...Pager:
* Does not generate useless tooltips that contain only the
  title of the page, can use custom tooltips
* The current limit link is made inactive
  (like the "prev" link when on first page, etc.)
* All links have query parameters in a consistent order:
  ?title= &... &dir= &offset= &limit= (some of them are optional)

These changes affect many special pages and actions. I tested on:
* Special:Contributions (ReverseChronologicalPager)
* action=history (ReverseChronologicalPager)
* Special:Categories (AlphabeticPager)
* Special:WantedPages (PrevNextNavigationRenderer)
* Special:Search (PrevNextNavigationRenderer)
* Special:WhatLinksHere

Bug: T308364
Change-Id: Ic75bd597b210e14612ca3aebb531b659897e8294
2022-09-05 16:10:36 -04:00