Merge "Copy interwiki links into sidebar"

This commit is contained in:
jenkins-bot 2021-07-27 21:21:20 +00:00 committed by Gerrit Code Review
commit 63dcfb720d
3 changed files with 33 additions and 5 deletions

View File

@ -316,10 +316,6 @@ class SkinVector extends SkinMustache {
$title = $out->getTitle();
$parentData = parent::getTemplateData();
if ( $this->shouldHideLanguages() ) {
$parentData['data-portlets']['data-languages'] = null;
}
// Naming conventions for Mustache parameters.
//
// Value type (first segment):
@ -497,6 +493,13 @@ class SkinVector extends SkinMustache {
// ext.uls.interface attaches click handler to this selector.
' mw-interlanguage-selector ',
];
// Adds class to hide language button
// Temporary solution to T287206, can be removed when ULS dialog includes interwiki links
if ( $this->shouldHideLanguages() ) {
$languageButtonData['class'] = ' mw-portlet-empty';
}
return array_merge( $portletData, $languageButtonData );
}

View File

@ -1,3 +1,20 @@
/**
* Copies interwiki links to sidebar
*
* Temporary solution to T287206, can be removed when the new ULS built in Vue.js
* has been released and contains this
*/
function addInterwikiLinkToSidebar() {
// eslint-disable-next-line no-jquery/no-global-selector
var $editLink = $( '#p-lang-btn .wbc-editpage' );
if ( $editLink.length ) {
// Use title attribute for link text
$editLink.text( $editLink.attr( 'title' ) || '' );
var $li = $( '<li>' ).append( $editLink );
$li.appendTo( '#p-tb ul' );
}
}
/**
* Checks whether ULS is enabled and if so disables the default
* drop down behavior of the button.
@ -13,7 +30,8 @@ function disableLanguageDropdown() {
return;
}
if ( !pLangBtn.querySelectorAll( '.mw-interlanguage-selector' ).length ) {
// The ext.uls.interface module removed the selector, because the feature is disabled. Do nothing.
// The ext.uls.interface module removed the selector,
// because the feature is disabled. Do nothing.
return;
}
pLangBtn.classList.add( 'vector-menu--hide-dropdown' );
@ -35,4 +53,5 @@ function disableLanguageDropdown() {
*/
module.exports = function () {
disableLanguageDropdown();
addInterwikiLinkToSidebar();
};

View File

@ -93,3 +93,9 @@
}
}
}
// Hides language button with CSS, ensures language button is in DOM for temporary JS hack for interwiki links
// Temporary solution to T287206, can be removed when ULS dialog includes interwiki links
#p-lang-btn.mw-portlet-empty {
display: none;
}