From 230c837052de1f4e501e056831729b59f4121783 Mon Sep 17 00:00:00 2001 From: bwang Date: Mon, 26 Feb 2024 13:58:28 -0600 Subject: [PATCH] Remove language notice Bug: T353619 Change-Id: I75430c8b1e66158f798fbe27eec4942a089f3931 --- i18n/en.json | 1 - i18n/qqq.json | 1 - .../Components/VectorComponentClientPrefs.php | 2 +- .../Components/VectorComponentMainMenu.php | 12 ----- ...onentMainMenuActionLanguageSwitchAlert.php | 46 ---------------- .../Components/VectorComponentPageTools.php | 2 +- includes/SkinVector22.php | 18 ------- includes/templates/MainMenu.mustache | 2 - .../components/MainMenu.less | 13 ----- tests/phpunit/integration/SkinVectorTest.php | 53 ------------------- .../VectorComponentMainMenuTest.php | 14 +---- 11 files changed, 3 insertions(+), 161 deletions(-) delete mode 100644 includes/Components/VectorComponentMainMenuActionLanguageSwitchAlert.php diff --git a/i18n/en.json b/i18n/en.json index 266c8690e..b2ff2735f 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -18,7 +18,6 @@ "vector-language-button-label": "{{PLURAL:$1|$1 language|$1 languages}}", "vector-no-language-button-label": "Add languages", "vector-no-language-button-aria-label": "This article exist only in this language. Add the article for other languages", - "vector-language-redirect-to-top": "Language links are at the top of the page across from the title.", "vector-language-variant-switcher-label": "Change language variant", "vector-action-addsection": "Add topic", "vector-action-delete": "Delete", diff --git a/i18n/qqq.json b/i18n/qqq.json index 12f9b5077..8f5253bf0 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -35,7 +35,6 @@ "vector-language-button-label": "Label for language button in modern Vector.\n\nArguments:\n* $1 number of languages, supports plural", "vector-no-language-button-label": "Label for language button when article does not exist in any other language.", "vector-no-language-button-aria-label": "Accessibility label for language button dropdown menu in modern Vector.", - "vector-language-redirect-to-top": "Explains language links location at top of page and provides link to top. See also [[:phab:T295555]].", "vector-language-variant-switcher-label": "Label for the language variant switcher.", "vector-action-addsection": "Used in the Vector skin. See for example {{canonicalurl:Talk:Main_Page|useskin=vector}}\n{{Identical|Add topic}}", "vector-action-delete": "Used in the Vector skin, as the name of a tab at the top of the page. See for example {{canonicalurl:Translating:MediaWiki|useskin=vector}}\n\n{{Identical|Delete}}", diff --git a/includes/Components/VectorComponentClientPrefs.php b/includes/Components/VectorComponentClientPrefs.php index 475855356..a4f8ab047 100644 --- a/includes/Components/VectorComponentClientPrefs.php +++ b/includes/Components/VectorComponentClientPrefs.php @@ -6,7 +6,7 @@ use MediaWiki\Skins\Vector\FeatureManagement\FeatureManager; use MessageLocalizer; /** - * VectorComponentMainMenu component + * VectorComponentClientPrefs component */ class VectorComponentClientPrefs implements VectorComponent { diff --git a/includes/Components/VectorComponentMainMenu.php b/includes/Components/VectorComponentMainMenu.php index 6bd8abf1f..7afcc3037 100644 --- a/includes/Components/VectorComponentMainMenu.php +++ b/includes/Components/VectorComponentMainMenu.php @@ -13,8 +13,6 @@ use Skin; class VectorComponentMainMenu implements VectorComponent { /** @var VectorComponent|null */ private $optOut; - /** @var VectorComponent|null */ - private $alert; /** @var array */ private $sidebarData; /** @var array */ @@ -30,8 +28,6 @@ class VectorComponentMainMenu implements VectorComponent { /** * @param array $sidebarData - * @param bool $shouldLanguageAlertBeInSidebar - * @param int $numLanguages * @param array $languageData * @param MessageLocalizer $localizer * @param User $user @@ -40,8 +36,6 @@ class VectorComponentMainMenu implements VectorComponent { */ public function __construct( array $sidebarData, - bool $shouldLanguageAlertBeInSidebar, - int $numLanguages, array $languageData, MessageLocalizer $localizer, User $user, @@ -63,9 +57,6 @@ class VectorComponentMainMenu implements VectorComponent { if ( $user->isRegistered() ) { $this->optOut = new VectorComponentMainMenuActionOptOut( $skin ); } - if ( $shouldLanguageAlertBeInSidebar ) { - $this->alert = new VectorComponentMainMenuActionLanguageSwitchAlert( $skin, $numLanguages ); - } } /** @@ -73,7 +64,6 @@ class VectorComponentMainMenu implements VectorComponent { */ public function getTemplateData(): array { $action = $this->optOut; - $alert = $this->alert; $pinnableHeader = $this->pinnableHeader; $portletsRest = []; @@ -90,8 +80,6 @@ class VectorComponentMainMenu implements VectorComponent { 'data-portlets-first' => $firstPortlet->getTemplateData(), 'array-portlets-rest' => $portletsRest, 'data-main-menu-action' => $action ? $action->getTemplateData() : null, - // T295555 Add language switch alert message temporarily (to be removed). - 'data-vector-language-switch-alert' => $alert ? $alert->getTemplateData() : null, 'data-pinnable-header' => $pinnableHeader ? $pinnableHeader->getTemplateData() : null, 'data-languages' => $languageMenu->getTemplateData(), ]; diff --git a/includes/Components/VectorComponentMainMenuActionLanguageSwitchAlert.php b/includes/Components/VectorComponentMainMenuActionLanguageSwitchAlert.php deleted file mode 100644 index ee94d6d68..000000000 --- a/includes/Components/VectorComponentMainMenuActionLanguageSwitchAlert.php +++ /dev/null @@ -1,46 +0,0 @@ -skin = $skin; - $this->numLanguages = $numLanguages; - } - - /** - * @inheritDoc - */ - public function getTemplateData(): array { - $skin = $this->skin; - $languageSwitchAlert = [ - 'html-content' => Html::noticeBox( - $skin->msg( 'vector-language-redirect-to-top' )->parse(), - 'vector-language-sidebar-alert' - ), - ]; - $headingOptions = [ - 'heading' => $skin->msg( 'vector-languages' )->plain(), - ]; - - $component = new VectorComponentMainMenuAction( - 'lang-alert', $skin, $languageSwitchAlert, $headingOptions, - ( $this->numLanguages === 0 ? 'vector-main-menu-action-lang-alert-empty' : '' ) - ); - return $component->getTemplateData(); - } -} diff --git a/includes/Components/VectorComponentPageTools.php b/includes/Components/VectorComponentPageTools.php index 33a89370e..606e63bad 100644 --- a/includes/Components/VectorComponentPageTools.php +++ b/includes/Components/VectorComponentPageTools.php @@ -6,7 +6,7 @@ use MediaWiki\Skins\Vector\FeatureManagement\FeatureManager; use MessageLocalizer; /** - * VectorComponentMainMenu component + * VectorComponentPageTools component */ class VectorComponentPageTools implements VectorComponent { diff --git a/includes/SkinVector22.php b/includes/SkinVector22.php index f116f98ac..8767d66a2 100644 --- a/includes/SkinVector22.php +++ b/includes/SkinVector22.php @@ -203,22 +203,6 @@ class SkinVector22 extends SkinMustache { return !$this->isLanguagesInContent() || !$this->isULSExtensionEnabled() || !$isSubjectPage; } - /** - * Determines if the language switching alert box should be in the sidebar. - * - * @return bool - */ - private function shouldLanguageAlertBeInSidebar(): bool { - $featureManager = VectorServices::getFeatureManager(); - $title = $this->getTitle(); - $isMainPage = $title ? $title->isMainPage() : false; - $shouldShowOnMainPage = $isMainPage && $this->getLanguagesCached() !== [] && - $featureManager->isFeatureEnabled( Constants::FEATURE_LANGUAGE_IN_MAIN_PAGE_HEADER ); - return ( $this->isLanguagesInContentAt( 'top' ) && !$isMainPage && !$this->shouldHideLanguages() && - $featureManager->isFeatureEnabled( Constants::FEATURE_LANGUAGE_IN_HEADER ) ) || - $shouldShowOnMainPage; - } - /** * Merges the `view-overflow` menu into the `action` menu. * This ensures that the previous state of the menu e.g. emptyPortlet class @@ -441,8 +425,6 @@ class SkinVector22 extends SkinMustache { ), 'data-main-menu' => new VectorComponentMainMenu( $sidebar, - $this->shouldLanguageAlertBeInSidebar(), - count( $this->getLanguagesCached() ), $portlets['data-languages'] ?? [], $localizer, $user, diff --git a/includes/templates/MainMenu.mustache b/includes/templates/MainMenu.mustache index 46650c48a..90828f384 100644 --- a/includes/templates/MainMenu.mustache +++ b/includes/templates/MainMenu.mustache @@ -6,6 +6,4 @@ {{^is-language-in-content}} {{#data-languages}}{{>Menu}}{{/data-languages}} {{/is-language-in-content}} - {{! T295555 Add language switch alert message. }} - {{#data-vector-language-switch-alert}}{{>MainMenuAction}}{{/data-vector-language-switch-alert}} {{>PinnableElement/Close}} diff --git a/resources/skins.vector.styles/components/MainMenu.less b/resources/skins.vector.styles/components/MainMenu.less index d7d28ae3e..7ee83cc69 100644 --- a/resources/skins.vector.styles/components/MainMenu.less +++ b/resources/skins.vector.styles/components/MainMenu.less @@ -24,17 +24,4 @@ .vector-main-menu-action-lang-alert .vector-main-menu-action-content { padding-top: 0; } - - // Hide the sidebar alert if there are no languages and JavaScript is disabled (T326185) - .vector-main-menu-action-lang-alert.vector-main-menu-action-lang-alert-empty { - .client-nojs& { - display: none; - } - } - - .vector-language-sidebar-alert { - // Override default .mw-message-box styles - padding: 8px; - margin: 0; - } } diff --git a/tests/phpunit/integration/SkinVectorTest.php b/tests/phpunit/integration/SkinVectorTest.php index bc1b1b9f6..1424646bc 100644 --- a/tests/phpunit/integration/SkinVectorTest.php +++ b/tests/phpunit/integration/SkinVectorTest.php @@ -1,16 +1,13 @@ overrideConfigValues( array_merge( $requirements, [ - 'DefaultSkin' => 'vector-2022', - 'VectorDefaultSkinVersion' => '2', - 'VectorSkinMigrationMode' => true, - ] ) ); - - $mockSkinVector = $this->getMockBuilder( SkinVector22::class ) - ->disableOriginalConstructor() - ->onlyMethods( [ 'getTitle', 'getLanguagesCached','isLanguagesInContentAt', 'shouldHideLanguages' ] ) - ->getMock(); - $mockSkinVector->method( 'getTitle' ) - ->willReturn( $title ); - $mockSkinVector->method( 'getLanguagesCached' ) - ->willReturn( $getLanguagesCached ); - $mockSkinVector->method( 'isLanguagesInContentAt' )->with( 'top' ) - ->willReturn( $isLanguagesInContentAt ); - $mockSkinVector->method( 'shouldHideLanguages' ) - ->willReturn( $shouldHideLanguages ); - - $shouldLanguageAlertBeInSidebarMethod = new ReflectionMethod( - SkinVector22::class, - 'shouldLanguageAlertBeInSidebar' - ); - $shouldLanguageAlertBeInSidebarMethod->setAccessible( true ); - - $this->assertSame( - $expected, - $shouldLanguageAlertBeInSidebarMethod->invoke( $mockSkinVector ) - ); - } } diff --git a/tests/phpunit/unit/components/VectorComponentMainMenuTest.php b/tests/phpunit/unit/components/VectorComponentMainMenuTest.php index 5fa63fce6..206ce2248 100644 --- a/tests/phpunit/unit/components/VectorComponentMainMenuTest.php +++ b/tests/phpunit/unit/components/VectorComponentMainMenuTest.php @@ -44,7 +44,6 @@ class VectorComponentMainMenuTest extends MediaWikiUnitTestCase { public function testConstruct() { // Mock the sidebar data, number of languages, and language data $sidebarData = []; - $numLanguages = 5; $languageData = []; // Mock the MessageLocalizer, User, FeatureManager, and Skin classes @@ -56,8 +55,6 @@ class VectorComponentMainMenuTest extends MediaWikiUnitTestCase { // Create a new VectorComponentMainMenu object $mainMenu = new VectorComponentMainMenu( $sidebarData, - true, - $numLanguages, $languageData, $localizerMock, $userMock, @@ -79,8 +76,6 @@ class VectorComponentMainMenuTest extends MediaWikiUnitTestCase { 'data-portlets-first' => [], 'array-portlets-rest' => [], ], - 'shouldLanguageAlertBeInSidebar' => false, - 'numLanguages' => 2, 'languageData' => [], 'isPinned' => true, ], @@ -89,8 +84,6 @@ class VectorComponentMainMenuTest extends MediaWikiUnitTestCase { 'data-portlets-first' => [], 'array-portlets-rest' => [], ], - 'shouldLanguageAlertBeInSidebar' => false, - 'numLanguages' => 2, 'languageData' => [], 'isPinned' => false, ], @@ -101,8 +94,7 @@ class VectorComponentMainMenuTest extends MediaWikiUnitTestCase { * @covers ::getTemplateData * @dataProvider provideMainMenuScenarios */ - public function testGetTemplateData( array $sidebarData, bool $shouldLanguageAlertBeInSidebar, int $numLanguages, - array $languageData, bool $isPinned ) { + public function testGetTemplateData( array $sidebarData, array $languageData, bool $isPinned ) { // Mock the MessageLocalizer, User, FeatureManager, and Skin classes $localizerMock = $this->createMock( MessageLocalizer::class ); $userMock = $this->createMock( User::class ); @@ -120,8 +112,6 @@ class VectorComponentMainMenuTest extends MediaWikiUnitTestCase { // Create a new VectorComponentMainMenu object $mainMenu = new VectorComponentMainMenu( $sidebarData, - $shouldLanguageAlertBeInSidebar, - $numLanguages, $languageData, $localizerMock, $userMock, @@ -140,7 +130,6 @@ class VectorComponentMainMenuTest extends MediaWikiUnitTestCase { $this->assertIsArray( $templateData['data-portlets-first'] ); $this->assertIsArray( $templateData['array-portlets-rest'] ); $this->assertNull( $templateData['data-main-menu-action'] ); - $this->assertNull( $templateData['data-vector-language-switch-alert'] ); // Assert data-pinnable-header $this->assertIsArray( $templateData['data-pinnable-header'] ); @@ -150,7 +139,6 @@ class VectorComponentMainMenuTest extends MediaWikiUnitTestCase { $this->assertArrayHasKey( 'data-portlets-first', $templateData ); $this->assertArrayHasKey( 'array-portlets-rest', $templateData ); $this->assertArrayHasKey( 'data-main-menu-action', $templateData ); - $this->assertArrayHasKey( 'data-vector-language-switch-alert', $templateData ); $this->assertArrayHasKey( 'data-pinnable-header', $templateData ); $this->assertArrayHasKey( 'data-languages', $templateData ); }