Merge "Add exclusion notice for "width" option in Appearance menu"

This commit is contained in:
jenkins-bot 2024-05-09 21:53:22 +00:00 committed by Gerrit Code Review
commit 68742b8c41
5 changed files with 26 additions and 7 deletions

View file

@ -70,6 +70,7 @@
"vector-limited-width-toggle": "Toggle limited content width",
"vector-limited-width-toggle-on-popup": "You have switched your layout to full width. To go back to limited width, press this button.",
"vector-limited-width-toggle-off-popup": "You can toggle between a limited width and full width by clicking this button.",
"vector-feature-limited-width-exclusion-notice": "This page is always wide",
"vector-page-tools-label": "Tools",
"vector-page-tools-general-label": "General",
"vector-page-tools-actions-label": "Actions",

View file

@ -56,6 +56,7 @@
"vector-feature-custom-font-size-name": "Heading label for font size",
"vector-feature-limited-width-0-label": "Label for option to disable limited width. An adjective that describes width ({{msg-mw|Vector-feature-limited-width-name}}).",
"vector-feature-limited-width-1-label": "Label for option to enable limited width. An adjective that describes width ({{msg-mw|Vector-feature-limited-width-name}}).",
"vector-feature-limited-width-exclusion-notice": "Notice when limited width option is disabled.",
"vector-feature-custom-font-size-0-label": "Label for small (legacy) font size. An adjective that describes \"text\" ({{msg-mw|Vector-feature-custom-font-size-name}}).",
"vector-feature-custom-font-size-1-label": "Label for standard font size. An adjective that describes \"text\" ({{msg-mw|Vector-feature-custom-font-size-name}}).",
"vector-feature-custom-font-size-2-label": "Label for large font size. An adjective that describes \"text\" ({{msg-mw|Vector-feature-custom-font-size-name}}).",

View file

@ -188,10 +188,9 @@ class FeatureManager {
if ( ConfigHelper::shouldDisable( $config->get( 'VectorNightModeOptions' ), $request, $title ) ) {
// The additional "-" prefix, makes this an invalid client preference for anonymous users.
return 'skin-theme-clientpref--excluded';
} else {
$prefix = '';
}
$prefix = '';
$valueRequest = $request->getText( 'vectornightmode' );
// If night mode query string is used, hardcode pref value to the night mode value
// NOTE: The query string parameter only works for logged in users.
@ -205,6 +204,14 @@ class FeatureManager {
$prefix .= 'skin-theme-';
break;
case CONSTANTS::FEATURE_LIMITED_WIDTH:
if ( ConfigHelper::shouldDisable( $config->get( 'VectorMaxWidthOptions' ), $request, $title ) ) {
return 'vector-feature-limited-width-clientpref--excluded';
}
$suffixEnabled = 'clientpref-1';
$suffixDisabled = 'clientpref-0';
break;
case CONSTANTS::FEATURE_TOC_PINNED:
case CONSTANTS::FEATURE_APPEARANCE_PINNED:
$suffixEnabled = 'clientpref-1';

View file

@ -389,6 +389,7 @@
"vector-feature-limited-width-name",
"vector-feature-limited-width-0-label",
"vector-feature-limited-width-1-label",
"vector-feature-limited-width-exclusion-notice",
"vector-feature-custom-font-size-name",
"vector-feature-custom-font-size-0-label",
"vector-feature-custom-font-size-1-label",

View file

@ -34,7 +34,10 @@ class FeatureManagerTest extends \MediaWikiIntegrationTestCase {
$featureManager = $this->newFeatureManager();
$featureManager->registerSimpleRequirement( 'requirement', $enabled );
$featureManager->registerFeature( $feature, [ 'requirement' ] );
// Title is required for checking whether or not the feature is excluded
// based on page title.
$context = RequestContext::getMain();
$context->setTitle( Title::makeTitle( NS_MAIN, 'Main Page' ) );
$this->assertSame( [ $expected ], $featureManager->getFeatureBodyClass() );
}
@ -88,26 +91,32 @@ class FeatureManagerTest extends \MediaWikiIntegrationTestCase {
}
/** ensure the class is present when disabled and absent when not */
public static function provideGetFeatureBodyClassNightModeDisabled() {
public static function provideGetFeatureBodyClassExcluded() {
return [
[ true ], [ false ]
];
}
/**
* @dataProvider provideGetFeatureBodyClassNightModeDisabled
* @dataProvider provideGetFeatureBodyClassExcluded
* @covers ::getFeatureBodyClass pref night mode specifics - disabled pages
*/
public function testGetFeatureBodyClassNightModeDisabled( $disabled ) {
public function testGetFeatureBodyClassExcluded( $disabled ) {
$featureManager = $this->newFeatureManager();
$featureManager->registerFeature( CONSTANTS::PREF_NIGHT_MODE, [] );
$featureManager->registerFeature( CONSTANTS::FEATURE_LIMITED_WIDTH, [] );
$context = RequestContext::getMain();
$context->setTitle( Title::makeTitle( NS_MAIN, 'Main Page' ) );
$this->overrideConfigValues( [ 'VectorNightModeOptions' => [ 'exclude' => [ 'mainpage' => $disabled ] ] ] );
$this->overrideConfigValues( [ 'VectorMaxWidthOptions' => [ 'exclude' => [ 'mainpage' => $disabled ] ] ] );
$bodyClasses = $featureManager->getFeatureBodyClass();
$this->assertEquals(
in_array( 'skin-theme-clientpref--excluded', $featureManager->getFeatureBodyClass() ),
in_array( 'skin-theme-clientpref--excluded', $bodyClasses ) &&
in_array( 'vector-feature-limited-width-clientpref--excluded', $bodyClasses ),
$disabled
);
}