[Grid preparation] Add feature flag for grid
Additional changes: * Make the query string parameter optional and if not defined set it to lowercase configuration name. I think this makes it more predictable as some configuration flags are prefixed with vector and some without. This has the following consequences: languageinheader => vectorlanguageinheader languageinmainpageheader => vectorlanguageinmainpageheader languagealertinsidebar => vectorlanguagealertinsidebar titleabovetabs => vectortitleabovetabs Note since table of contents query string is used in the A/B test I've kept that as tableofcontents for now. Bug: T303484 Change-Id: Iaca026ef5f32836098dc3b6f0f18632fe84fa8d0
This commit is contained in:
parent
32069a75fe
commit
d74890df63
|
@ -109,29 +109,6 @@ final class Constants {
|
|||
*/
|
||||
public const CONFIG_LANGUAGE_IN_HEADER_TREATMENT_AB_TEST = 'VectorLanguageInHeaderTreatmentABTest';
|
||||
|
||||
// These are used for query parameters.
|
||||
/**
|
||||
* If undefined and AB test enabled, user will be bucketed as usual.
|
||||
*
|
||||
* If set, overrides the language in header AB test config:
|
||||
*
|
||||
* 'languageinheader=0' will show existing treatment.
|
||||
* 'languageinheader=1' will show new treatment.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public const QUERY_PARAM_LANGUAGE_IN_HEADER = 'languageinheader';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const QUERY_PARAM_STICKY_HEADER = 'vectorstickyheader';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const QUERY_PARAM_STICKY_HEADER_EDIT = 'vectorstickyheaderedit';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
|
@ -209,11 +186,6 @@ final class Constants {
|
|||
*/
|
||||
public const CONFIG_LANGUAGE_IN_MAIN_PAGE_HEADER = 'VectorLanguageInMainPageHeader';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const QUERY_PARAM_LANGUAGE_IN_MAIN_PAGE_HEADER = 'languageinmainpageheader';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
|
@ -229,11 +201,6 @@ final class Constants {
|
|||
*/
|
||||
public const CONFIG_LANGUAGE_ALERT_IN_SIDEBAR = 'VectorLanguageAlertInSidebar';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const QUERY_PARAM_LANGUAGE_ALERT_IN_SIDEBAR = 'languagealertinsidebar';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
|
@ -277,12 +244,22 @@ final class Constants {
|
|||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const QUERY_PARAM_TITLE_ABOVE_TABS = 'titleabovetabs';
|
||||
public const FEATURE_TITLE_ABOVE_TABS = 'TitleAboveTabs';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const FEATURE_TITLE_ABOVE_TABS = 'TitleAboveTabs';
|
||||
public const CONFIG_GRID = 'VectorGrid';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const REQUIREMENT_GRID = 'Grid';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const FEATURE_GRID = 'Grid';
|
||||
|
||||
/**
|
||||
* This class is for namespacing constants only. Forbid construction.
|
||||
|
|
|
@ -117,7 +117,8 @@ final class OverridableConfigRequirement implements Requirement {
|
|||
* @param CentralIdLookup|null $centralIdLookup
|
||||
* @param string $configName Any `Config` key. This name is used to query `$config` state.
|
||||
* @param string $requirementName The name of the requirement presented to FeatureManager.
|
||||
* @param string $overrideName The name of the override presented to FeatureManager, i.e. query parameter.
|
||||
* @param string|null $overrideName The name of the override presented to FeatureManager, i.e. query parameter.
|
||||
* When not set defaults to lowercase version of config key.
|
||||
* @param string|null $configTestName The name of the AB test config presented to FeatureManager if applicable.
|
||||
*/
|
||||
public function __construct(
|
||||
|
@ -127,8 +128,8 @@ final class OverridableConfigRequirement implements Requirement {
|
|||
?CentralIdLookup $centralIdLookup,
|
||||
string $configName,
|
||||
string $requirementName,
|
||||
string $overrideName,
|
||||
?string $configTestName
|
||||
?string $overrideName = null,
|
||||
?string $configTestName = null
|
||||
) {
|
||||
$this->config = $config;
|
||||
$this->user = $user;
|
||||
|
@ -136,7 +137,7 @@ final class OverridableConfigRequirement implements Requirement {
|
|||
$this->centralIdLookup = $centralIdLookup;
|
||||
$this->configName = $configName;
|
||||
$this->requirementName = $requirementName;
|
||||
$this->overrideName = $overrideName;
|
||||
$this->overrideName = $overrideName === null ? strtolower( $configName ) : $overrideName;
|
||||
$this->configTestName = $configTestName;
|
||||
}
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ return [
|
|||
$services->getCentralIdLookupFactory()->getNonLocalLookup(),
|
||||
Constants::CONFIG_KEY_LANGUAGE_IN_HEADER,
|
||||
Constants::REQUIREMENT_LANGUAGE_IN_HEADER,
|
||||
Constants::QUERY_PARAM_LANGUAGE_IN_HEADER,
|
||||
null,
|
||||
Constants::CONFIG_LANGUAGE_IN_HEADER_TREATMENT_AB_TEST
|
||||
)
|
||||
);
|
||||
|
@ -104,9 +104,7 @@ return [
|
|||
$context->getRequest(),
|
||||
null,
|
||||
Constants::CONFIG_LANGUAGE_IN_MAIN_PAGE_HEADER,
|
||||
Constants::REQUIREMENT_LANGUAGE_IN_MAIN_PAGE_HEADER,
|
||||
Constants::QUERY_PARAM_LANGUAGE_IN_MAIN_PAGE_HEADER,
|
||||
null
|
||||
Constants::REQUIREMENT_LANGUAGE_IN_MAIN_PAGE_HEADER
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -134,9 +132,7 @@ return [
|
|||
$context->getRequest(),
|
||||
null,
|
||||
Constants::CONFIG_LANGUAGE_ALERT_IN_SIDEBAR,
|
||||
Constants::REQUIREMENT_LANGUAGE_ALERT_IN_SIDEBAR,
|
||||
Constants::QUERY_PARAM_LANGUAGE_ALERT_IN_SIDEBAR,
|
||||
null
|
||||
Constants::REQUIREMENT_LANGUAGE_ALERT_IN_SIDEBAR
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -181,9 +177,7 @@ return [
|
|||
$context->getRequest(),
|
||||
null,
|
||||
Constants::CONFIG_STICKY_HEADER,
|
||||
Constants::REQUIREMENT_STICKY_HEADER,
|
||||
Constants::QUERY_PARAM_STICKY_HEADER,
|
||||
null
|
||||
Constants::REQUIREMENT_STICKY_HEADER
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -194,9 +188,7 @@ return [
|
|||
$context->getRequest(),
|
||||
null,
|
||||
Constants::CONFIG_STICKY_HEADER_EDIT,
|
||||
Constants::REQUIREMENT_STICKY_HEADER_EDIT,
|
||||
Constants::QUERY_PARAM_STICKY_HEADER_EDIT,
|
||||
null
|
||||
Constants::REQUIREMENT_STICKY_HEADER_EDIT
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -226,9 +218,7 @@ return [
|
|||
$context->getRequest(),
|
||||
null,
|
||||
Constants::CONFIG_TITLE_ABOVE_TABS,
|
||||
Constants::REQUIREMENT_TITLE_ABOVE_TABS,
|
||||
Constants::QUERY_PARAM_TITLE_ABOVE_TABS,
|
||||
null
|
||||
Constants::REQUIREMENT_TITLE_ABOVE_TABS
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -240,6 +230,32 @@ return [
|
|||
]
|
||||
);
|
||||
|
||||
// Feature: Grid
|
||||
// ================================
|
||||
$featureManager->registerRequirement(
|
||||
new OverridableConfigRequirement(
|
||||
$services->getMainConfig(),
|
||||
$context->getUser(),
|
||||
$context->getRequest(),
|
||||
null,
|
||||
Constants::CONFIG_GRID,
|
||||
Constants::REQUIREMENT_GRID
|
||||
)
|
||||
);
|
||||
|
||||
// Requires both table of contents and title above tabs
|
||||
// to be enabled to simplify the number of variants it needs
|
||||
// to consider.
|
||||
$featureManager->registerFeature(
|
||||
Constants::FEATURE_GRID,
|
||||
[
|
||||
Constants::REQUIREMENT_FULLY_INITIALISED,
|
||||
Constants::REQUIREMENT_TITLE_ABOVE_TABS,
|
||||
Constants::REQUIREMENT_GRID,
|
||||
Constants::REQUIREMENT_TABLE_OF_CONTENTS,
|
||||
]
|
||||
);
|
||||
|
||||
return $featureManager;
|
||||
}
|
||||
];
|
||||
|
|
|
@ -151,7 +151,12 @@ class SkinVector22 extends SkinVector {
|
|||
}
|
||||
$parentData = $this->mergeViewOverflowIntoActions( $parentData );
|
||||
|
||||
$isGrid = $featureManager->isFeatureEnabled(
|
||||
Constants::FEATURE_GRID
|
||||
);
|
||||
return $parentData + [
|
||||
'is-vector-grid' => $isGrid,
|
||||
'vector-layout-class' => $isGrid ? 'vector-layout-grid vector-toc-visible' : 'vector-layout-legacy',
|
||||
'data-vector-sticky-header' => $featureManager->isFeatureEnabled(
|
||||
Constants::FEATURE_STICKY_HEADER
|
||||
) ? $this->getStickyHeaderData(
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
object data-portlets-sidebar. See Sidebar.mustache for documentation.
|
||||
object data-footer for footer template partial. see Footer.mustache for documentation.
|
||||
}}
|
||||
<div class="mw-page-container vector-layout-legacy">
|
||||
<div class="mw-page-container {{vector-layout-class}}">
|
||||
<span id="top-page"></span>
|
||||
<a class="mw-jump-link" href="#content">{{msg-vector-jumptocontent}}</a>
|
||||
<div class="mw-page-container-inner {{#data-toc}} vector-toc-visible{{/data-toc}}">
|
||||
|
|
|
@ -512,6 +512,10 @@
|
|||
"value": 20,
|
||||
"description": "@var When `VectorTableOfContents` is enabled, the minimum number of headings required to collapse all headings in the sticky table of contents by default."
|
||||
},
|
||||
"VectorGrid": {
|
||||
"value": false,
|
||||
"description": "@var boolean `VectorGrid` enforces a grid system"
|
||||
},
|
||||
"VectorTitleAboveTabs": {
|
||||
"value": false,
|
||||
"description": "@var boolean `VectorTitleAboveTabs` places the tittle of the page above the tabs that link to history/talk etc."
|
||||
|
|
Loading…
Reference in New Issue