mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/Vector.git
synced 2024-11-23 23:33:54 +00:00
Add exclusion notice for "width" option in Appearance menu
Adds the notice "This page is always wide" and disables the inputs for the "width" options in the Appearance menu when pages are excluded via configuration ( `$wgVectorMaxWidthOptions`). Bug: T364015 Change-Id: Ie99b41c9130f496ab23b60c95e551a9ea602d5a0
This commit is contained in:
parent
277135ef58
commit
89c250c18e
|
@ -70,6 +70,7 @@
|
||||||
"vector-limited-width-toggle": "Toggle limited content width",
|
"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-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-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-label": "Tools",
|
||||||
"vector-page-tools-general-label": "General",
|
"vector-page-tools-general-label": "General",
|
||||||
"vector-page-tools-actions-label": "Actions",
|
"vector-page-tools-actions-label": "Actions",
|
||||||
|
|
|
@ -56,6 +56,7 @@
|
||||||
"vector-feature-custom-font-size-name": "Heading label for font size",
|
"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-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-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-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-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}}).",
|
"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}}).",
|
||||||
|
|
|
@ -188,10 +188,9 @@ class FeatureManager {
|
||||||
if ( ConfigHelper::shouldDisable( $config->get( 'VectorNightModeOptions' ), $request, $title ) ) {
|
if ( ConfigHelper::shouldDisable( $config->get( 'VectorNightModeOptions' ), $request, $title ) ) {
|
||||||
// The additional "-" prefix, makes this an invalid client preference for anonymous users.
|
// The additional "-" prefix, makes this an invalid client preference for anonymous users.
|
||||||
return 'skin-theme-clientpref--excluded';
|
return 'skin-theme-clientpref--excluded';
|
||||||
} else {
|
|
||||||
$prefix = '';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$prefix = '';
|
||||||
$valueRequest = $request->getText( 'vectornightmode' );
|
$valueRequest = $request->getText( 'vectornightmode' );
|
||||||
// If night mode query string is used, hardcode pref value to the night mode value
|
// 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.
|
// NOTE: The query string parameter only works for logged in users.
|
||||||
|
@ -205,6 +204,14 @@ class FeatureManager {
|
||||||
$prefix .= 'skin-theme-';
|
$prefix .= 'skin-theme-';
|
||||||
break;
|
break;
|
||||||
case CONSTANTS::FEATURE_LIMITED_WIDTH:
|
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_TOC_PINNED:
|
||||||
case CONSTANTS::FEATURE_APPEARANCE_PINNED:
|
case CONSTANTS::FEATURE_APPEARANCE_PINNED:
|
||||||
$suffixEnabled = 'clientpref-1';
|
$suffixEnabled = 'clientpref-1';
|
||||||
|
|
|
@ -389,6 +389,7 @@
|
||||||
"vector-feature-limited-width-name",
|
"vector-feature-limited-width-name",
|
||||||
"vector-feature-limited-width-0-label",
|
"vector-feature-limited-width-0-label",
|
||||||
"vector-feature-limited-width-1-label",
|
"vector-feature-limited-width-1-label",
|
||||||
|
"vector-feature-limited-width-exclusion-notice",
|
||||||
"vector-feature-custom-font-size-name",
|
"vector-feature-custom-font-size-name",
|
||||||
"vector-feature-custom-font-size-0-label",
|
"vector-feature-custom-font-size-0-label",
|
||||||
"vector-feature-custom-font-size-1-label",
|
"vector-feature-custom-font-size-1-label",
|
||||||
|
|
|
@ -34,7 +34,10 @@ class FeatureManagerTest extends \MediaWikiIntegrationTestCase {
|
||||||
$featureManager = $this->newFeatureManager();
|
$featureManager = $this->newFeatureManager();
|
||||||
$featureManager->registerSimpleRequirement( 'requirement', $enabled );
|
$featureManager->registerSimpleRequirement( 'requirement', $enabled );
|
||||||
$featureManager->registerFeature( $feature, [ 'requirement' ] );
|
$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() );
|
$this->assertSame( [ $expected ], $featureManager->getFeatureBodyClass() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,26 +91,32 @@ class FeatureManagerTest extends \MediaWikiIntegrationTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** ensure the class is present when disabled and absent when not */
|
/** ensure the class is present when disabled and absent when not */
|
||||||
public static function provideGetFeatureBodyClassNightModeDisabled() {
|
public static function provideGetFeatureBodyClassExcluded() {
|
||||||
return [
|
return [
|
||||||
[ true ], [ false ]
|
[ true ], [ false ]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider provideGetFeatureBodyClassNightModeDisabled
|
* @dataProvider provideGetFeatureBodyClassExcluded
|
||||||
* @covers ::getFeatureBodyClass pref night mode specifics - disabled pages
|
* @covers ::getFeatureBodyClass pref night mode specifics - disabled pages
|
||||||
*/
|
*/
|
||||||
public function testGetFeatureBodyClassNightModeDisabled( $disabled ) {
|
public function testGetFeatureBodyClassExcluded( $disabled ) {
|
||||||
$featureManager = $this->newFeatureManager();
|
$featureManager = $this->newFeatureManager();
|
||||||
$featureManager->registerFeature( CONSTANTS::PREF_NIGHT_MODE, [] );
|
$featureManager->registerFeature( CONSTANTS::PREF_NIGHT_MODE, [] );
|
||||||
|
$featureManager->registerFeature( CONSTANTS::FEATURE_LIMITED_WIDTH, [] );
|
||||||
|
|
||||||
$context = RequestContext::getMain();
|
$context = RequestContext::getMain();
|
||||||
$context->setTitle( Title::makeTitle( NS_MAIN, 'Main Page' ) );
|
$context->setTitle( Title::makeTitle( NS_MAIN, 'Main Page' ) );
|
||||||
|
|
||||||
$this->overrideConfigValues( [ 'VectorNightModeOptions' => [ 'exclude' => [ 'mainpage' => $disabled ] ] ] );
|
$this->overrideConfigValues( [ 'VectorNightModeOptions' => [ 'exclude' => [ 'mainpage' => $disabled ] ] ] );
|
||||||
|
$this->overrideConfigValues( [ 'VectorMaxWidthOptions' => [ 'exclude' => [ 'mainpage' => $disabled ] ] ] );
|
||||||
|
|
||||||
|
$bodyClasses = $featureManager->getFeatureBodyClass();
|
||||||
|
|
||||||
$this->assertEquals(
|
$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
|
$disabled
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue