Avoid loading ext.uls.compactlinks module for Vector 2022 skin

Bug: T353850
Change-Id: I43551be73da2126fd84ffaa0d37faec58bc47135
This commit is contained in:
NikG
2024-01-04 20:47:06 +02:00
committed by jenkins-bot
parent 1e4466ec16
commit 0b7ae1dce6
2 changed files with 20 additions and 5 deletions

View File

@@ -97,6 +97,18 @@ class Hooks implements
return (bool)$this->config->get( 'ULSEnable' ); return (bool)$this->config->get( 'ULSEnable' );
} }
/**
* Checks whether language is in header.
*
* @param Skin $skin
* @return bool
*/
private function isLanguageInHeader( Skin $skin ): bool {
$languageInHeaderConfig = $skin->getConfig()->get( 'VectorLanguageInHeader' );
$userStatus = $skin->getUser()->isAnon() ? 'logged_out' : 'logged_in';
return $languageInHeaderConfig[ $userStatus ] ?? true;
}
/** /**
* Whether ULS Compact interlanguage links enabled * Whether ULS Compact interlanguage links enabled
* *
@@ -110,7 +122,7 @@ class Hooks implements
return false; return false;
} }
if ( $skin->getSkinName() === 'vector-2022' ) { if ( $skin->getSkinName() === 'vector-2022' ) {
return true; return !$this->isLanguageInHeader( $skin );
} }
if ( $this->config->get( 'ULSCompactLanguageLinksBetaFeature' ) === true && if ( $this->config->get( 'ULSCompactLanguageLinksBetaFeature' ) === true &&
$this->config->get( 'InterwikiMagic' ) === true && $this->config->get( 'InterwikiMagic' ) === true &&
@@ -165,9 +177,11 @@ class Hooks implements
$excludedLinks = $out->getProperty( 'noexternallanglinks' ); $excludedLinks = $out->getProperty( 'noexternallanglinks' );
$override = is_array( $excludedLinks ) && in_array( '*', $excludedLinks, true ); $override = is_array( $excludedLinks ) && in_array( '*', $excludedLinks, true );
$isCompactLinksEnabled = $this->isCompactLinksEnabled( $out->getUser(), $skin ); $isCompactLinksEnabled = $this->isCompactLinksEnabled( $out->getUser(), $skin );
$isVector2022LanguageInHeader = $skin->getSkinName() === 'vector-2022' && $this->isLanguageInHeader( $skin );
$config = [ $config = [
'wgULSPosition' => $this->config->get( 'ULSPosition' ), 'wgULSPosition' => $this->config->get( 'ULSPosition' ),
'wgULSisCompactLinksEnabled' => $isCompactLinksEnabled, 'wgULSisCompactLinksEnabled' => $isCompactLinksEnabled,
'wgVector2022LanguageInHeader' => $isVector2022LanguageInHeader
]; ];
// Load compact links if no mw-interlanguage-selector element is present in the page HTML. // Load compact links if no mw-interlanguage-selector element is present in the page HTML.

View File

@@ -727,11 +727,12 @@
initPersonalEntryPoint(); initPersonalEntryPoint();
} }
// whether to load compact language links
var compact = mw.config.get( 'wgULSisCompactLinksEnabled' ); var compact = mw.config.get( 'wgULSisCompactLinksEnabled' );
// The scope of the compact language links user preference has been expanded to also // whether to show the omni box or not
// determine whether to show the omni box or not. Compact language links is already not var languageInHeader = mw.config.get( 'wgVector2022LanguageInHeader' );
// loaded server side, so this is only relevant for the omnibox.
if ( compact ) { if ( compact || languageInHeader ) {
// Init compact languages OR omni selector using the mw-interlanguage-selector class // Init compact languages OR omni selector using the mw-interlanguage-selector class
initContentLanguageSelectorClickHandler(); initContentLanguageSelectorClickHandler();
} else { } else {