Page MenuHomePhabricator

Allow special pages to register navigation links in skins
Closed, ResolvedPublic

Description

Currently special pages render a single "Special" tab. This appears in all skins, but position varies based on skin.

Screen Shot 2022-07-19 at 11.53.24 AM.png (384×2 px, 153 KB)
Screen Shot 2022-07-19 at 11.53.02 AM.png (458×2 px, 112 KB)

Going forward to support the work in T286466 we would like to add SpecialPage::getSubpages. This method returns an array of sub pages that can be rendered by the skin in the UI. It works similar to getSubpagesForPrefixSearch but will usually be a subset of the pages returned by getSubpagesForPrefixSearch and in many cases will be an empty list.

Specification

  • The feature is opt in. Skins like Vector can continue to work as before
  • A new method SpecialPage::getRelatedNavigationLinks will be added to describe tabs. A page with no sub page will be described by an empty string. eg. return ['Special:Watchlist', 'Special:Watchlist/raw']; on Special:Watchlist would generate two tabs - one link to Special:Watchlist and one to Special:Watchlist/raw. An empty array will mean no tabs should be rendered. By default, the return value will be empty (e.g. no tabs)
  • A new method SpecialPage::getShortDescription will be added - this will allow special pages to define a label to describe the page that will be rendered as the text of the associated tab. By default it will use subpagetab-<special page name>-<subpage>. For example Special:Watchlist/raw would be described by subpagetab-watchlist-raw. It will be stable to override this to change the label.
  • A new menu will be made available to skins in Skin:: buildContentNavigationUrlsInternal called "associatedPages". This can be used instead of the existing namespace key, but also contain definitions for subpages. This ensures the change is backwards compatible.

Sign off steps

  • It's important at least one of the special pages in core use this feature. We're targetting the Special:Contributions page as the first consumer (see T286466)

Event Timeline

Change 813710 had a related patch set uploaded (by Jdlrobson; author: Jdlrobson):

[mediawiki/core@master] SpecialPages: Can formally register sub pages to the UI

https://gerrit.wikimedia.org/r/813710

Several special pages use OutputPage::setSubtitle() for a poor man's navigation menu (e.g. https://meta.wikimedia.org/wiki/Special:AbuseFilter or https://meta.wikimedia.org/wiki/Special:OAuthConsumerRegistration/propose ), it would be nice if the new system could replace that. Note that these are not strictly subpages (see e.g. the AbuseFilter example) and might be context-dependent (e.g. if a sufficiently privileged user views Special:OAuthListConsumers/view/xxx , the navigation tab will link to Special:OAuthConsumerRegistration/update/xxx, Special:OAuthManageConsumers/xxx and Special:OAuthManageMyGrants/update/yyy). So maybe better to think of this as a generic navigation menu for special pages, and just fetch titles or URLs instead of subpage names in the API. (Another use case: if there is a navigation system similar to page tabs, I'd want to be able to navigate from Special:Delete/Foo to Foo and Talk:Foo.)

Thanks for the input here @Tgr and the over usecase - that's super useful. Definitely want to get away from "poor man's navigation" so yes AbuseFilter would be a good fit here. It would implement the SpecialPage method (https://gerrit.wikimedia.org/r/c/mediawiki/core/+/813710/5/includes/specialpage/SpecialPage.php)

I am leaning more towards the function being called getNavigationLinks() and expanding it to accept any wiki page title. If I get time I'll amend the core patch with that in mind tomorrow.

Jdlrobson renamed this task from Allow special pages to register "subpage tabs" that replace namespaces. to Allow special pages to register navigation links in skins.Jul 22 2022, 6:02 PM

Change 816209 had a related patch set uploaded (by Jdlrobson; author: Jdlrobson):

[mediawiki/skins/Vector@master] Enable related tabs on Vector

https://gerrit.wikimedia.org/r/816209

Change 816211 had a related patch set uploaded (by Jdlrobson; author: Jdlrobson):

[mediawiki/extensions/AbuseFilter@master] Register AbuseFilter menu as standard tabs

https://gerrit.wikimedia.org/r/816211

@Tgr I can confirm the architecture now supports use on Special:AbuseFilter.

Change 813710 merged by jenkins-bot:

[mediawiki/core@master] SpecialPages: Can formally register navigation links

https://gerrit.wikimedia.org/r/813710

Jdlrobson triaged this task as Medium priority.Aug 18 2022, 6:15 AM
Jdlrobson updated the task description. (Show Details)
Jdlrobson added a subscriber: Mabualruz.

Adding to sprint board. @Mabualruz I'm wondering if SpecialPage::getRelatedNavigationLinks should be renamed to SpecialPage::getAssociatedNavigationLinks. What do you think?

Adding to sprint board. @Mabualruz I'm wondering if SpecialPage::getRelatedNavigationLinks should be renamed to SpecialPage::getAssociatedNavigationLinks. What do you think?

I think we should that to make it more coherent, Still current gerrit patch is merged should I just open a new one ?

Change 824393 had a related patch set uploaded (by Mabualruz; author: Mabualruz):

[mediawiki/core@master] SpecialPages: Can formally register navigation links

https://gerrit.wikimedia.org/r/824393

Change 824393 merged by jenkins-bot:

[mediawiki/core@master] SpecialPages: "related" references updated to "associated"

https://gerrit.wikimedia.org/r/824393

Test wiki created on Patch demo by Jdlrobson using patch(es) linked to this task:
https://patchdemo.wmflabs.org/wikis/9fbff0695f/w

Test wiki created on Patch demo by Jdlrobson using patch(es) linked to this task:
https://patchdemo.wmflabs.org/wikis/a189b0db80/w

Change 827599 had a related patch set uploaded (by Jdlrobson; author: Jdlrobson):

[mediawiki/core@master] LocalisationCache: Remove accidentally checked in code

https://gerrit.wikimedia.org/r/827599

Change 827599 merged by jenkins-bot:

[mediawiki/core@master] LocalisationCache: Remove accidentally checked in code

https://gerrit.wikimedia.org/r/827599

Change 828096 had a related patch set uploaded (by Jdlrobson; author: Jdlrobson):

[mediawiki/core@master] Skin: Use camel case for menu name

https://gerrit.wikimedia.org/r/828096

Change 828096 merged by jenkins-bot:

[mediawiki/core@master] Skin: Use camel case for menu name

https://gerrit.wikimedia.org/r/828096

Test wiki on Patch demo by Jdlrobson using patch(es) linked to this task was deleted:

https://patchdemo.wmflabs.org/wikis/9fbff0695f/w/

Test wiki on Patch demo by Jdlrobson using patch(es) linked to this task was deleted:

https://patchdemo.wmflabs.org/wikis/a189b0db80/w/