Merge "Enable related tabs on Vector"

This commit is contained in:
jenkins-bot 2022-09-01 20:36:15 +00:00 committed by Gerrit Code Review
commit d59885cf89
4 changed files with 39 additions and 1 deletions

View File

@ -843,6 +843,7 @@ abstract class SkinVector extends SkinMustache {
$type = self::MENU_TYPE_DROPDOWN;
break;
case 'data-views':
case 'data-associated-pages':
case 'data-namespaces':
$type = self::MENU_TYPE_TABS;
break;

View File

@ -3,7 +3,7 @@
<div class="mw-article-toolbar-container">
{{#data-portlets}}
<div id="left-navigation">
{{#data-namespaces}}{{>Menu}}{{/data-namespaces}}
{{#data-associated-pages}}{{>Menu}}{{/data-associated-pages}}
{{#data-variants}}{{>Menu}}{{/data-variants}}
</div>
<div id="right-navigation" class="vector-collapsible {{#data-views.is-empty}}{{#data-actions.is-empty}}right-navigation-empty{{/data-actions.is-empty}}{{/data-views.is-empty}}">

View File

@ -36,6 +36,32 @@ function enableCssAnimations( document ) {
document.documentElement.classList.add( 'vector-animations-ready' );
}
/**
* In https://phabricator.wikimedia.org/T313409 #p-namespaces was renamed to #p-associatedPages
* This code maps items added by gadgets to the new menu.
* This code can be removed in MediaWiki 1.40.
*/
function addNamespacesGadgetSupport() {
// Set up hidden dummy portlet.
var dummyPortlet = document.createElement( 'div' );
dummyPortlet.setAttribute( 'id', 'p-namespaces' );
dummyPortlet.setAttribute( 'style', 'display: none;' );
dummyPortlet.appendChild( document.createElement( 'ul' ) );
document.body.appendChild( dummyPortlet );
mw.hook( 'util.addPortletLink' ).add( function ( /** @type {Element} */ node ) {
// If it was added to p-namespaces, show warning and move.
// eslint-disable-next-line no-jquery/no-global-selector
if ( $( '#p-namespaces' ).find( node ).length ) {
// eslint-disable-next-line no-jquery/no-global-selector
$( '#p-associated-pages ul' ).append( node );
// @ts-ignore
mw.log.warn( 'Please update call to mw.util.addPortletLink with ID p-namespaces. Use p-associatedPages instead.' );
// in case it was empty before:
mw.util.showPortlet( 'p-associated-pages' );
}
} );
}
/**
* @param {Window} window
* @return {void}
@ -47,6 +73,7 @@ function main( window ) {
initSearchLoader( document );
languageButton();
dropdownMenus();
addNamespacesGadgetSupport();
}
/**

View File

@ -41,6 +41,16 @@
"skin-vector",
"skin-vector-search-vue"
],
"menus": [
"user-interface-preferences",
"user-page",
"user-menu",
"notifications",
"views",
"actions",
"variants",
"associated-pages"
],
"scripts": [
"skins.vector.user",
"skins.vector.js",