mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/Vector.git
synced 2024-11-23 23:33:54 +00:00
Remove language notice
Bug: T353619 Change-Id: I75430c8b1e66158f798fbe27eec4942a089f3931
This commit is contained in:
parent
15ea165a7b
commit
230c837052
|
@ -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",
|
||||
|
|
|
@ -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}}",
|
||||
|
|
|
@ -6,7 +6,7 @@ use MediaWiki\Skins\Vector\FeatureManagement\FeatureManager;
|
|||
use MessageLocalizer;
|
||||
|
||||
/**
|
||||
* VectorComponentMainMenu component
|
||||
* VectorComponentClientPrefs component
|
||||
*/
|
||||
class VectorComponentClientPrefs implements VectorComponent {
|
||||
|
||||
|
|
|
@ -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(),
|
||||
];
|
||||
|
|
|
@ -1,46 +0,0 @@
|
|||
<?php
|
||||
namespace MediaWiki\Skins\Vector\Components;
|
||||
|
||||
use MediaWiki\Html\Html;
|
||||
use Skin;
|
||||
|
||||
/**
|
||||
* VectorComponentMainMenuActionLanguageSwitchAlert component
|
||||
*/
|
||||
class VectorComponentMainMenuActionLanguageSwitchAlert implements VectorComponent {
|
||||
/** @var Skin */
|
||||
private $skin;
|
||||
/** @var int */
|
||||
private $numLanguages;
|
||||
|
||||
/**
|
||||
* @param Skin $skin
|
||||
* @param int $numLanguages
|
||||
*/
|
||||
public function __construct( Skin $skin, int $numLanguages ) {
|
||||
$this->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();
|
||||
}
|
||||
}
|
|
@ -6,7 +6,7 @@ use MediaWiki\Skins\Vector\FeatureManagement\FeatureManager;
|
|||
use MessageLocalizer;
|
||||
|
||||
/**
|
||||
* VectorComponentMainMenu component
|
||||
* VectorComponentPageTools component
|
||||
*/
|
||||
class VectorComponentPageTools implements VectorComponent {
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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}}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +1,13 @@
|
|||
<?php
|
||||
namespace MediaWiki\Skins\Vector\Tests\Integration;
|
||||
|
||||
use Exception;
|
||||
use LinkCache;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use MediaWiki\Skins\Vector\SkinVector22;
|
||||
use MediaWiki\Skins\Vector\SkinVectorLegacy;
|
||||
use MediaWiki\Tests\Unit\Permissions\MockAuthorityTrait;
|
||||
use MediaWiki\Title\Title;
|
||||
use MediaWiki\User\TalkPageNotificationManager;
|
||||
use MediaWikiIntegrationTestCase;
|
||||
use ReflectionMethod;
|
||||
use RequestContext;
|
||||
use Wikimedia\TestingAccessWrapper;
|
||||
|
||||
|
@ -242,54 +239,4 @@ class SkinVectorTest extends MediaWikiIntegrationTestCase {
|
|||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerLanguageAlertRequirements
|
||||
* @covers \MediaWiki\Skins\Vector\SkinVector22::shouldLanguageAlertBeInSidebar
|
||||
* @param array $requirements
|
||||
* @param Title $title
|
||||
* @param array $getLanguagesCached
|
||||
* @param bool $isLanguagesInContentAt
|
||||
* @param bool $shouldHideLanguages
|
||||
* @param bool $expected
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testShouldLanguageAlertBeInSidebar(
|
||||
array $requirements,
|
||||
Title $title,
|
||||
array $getLanguagesCached,
|
||||
bool $isLanguagesInContentAt,
|
||||
bool $shouldHideLanguages,
|
||||
bool $expected
|
||||
) {
|
||||
$this->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 )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue