Merge "Add feature flag for sticky table of contents"

This commit is contained in:
jenkins-bot 2021-12-15 18:16:16 +00:00 committed by Gerrit Code Review
commit 9efaaf8afa
6 changed files with 69 additions and 0 deletions

View file

@ -296,6 +296,26 @@ final class Constants {
*/
public const FEATURE_LANGUAGE_ALERT_IN_SIDEBAR = 'LanguageAlertInSidebar';
/**
* @var string
*/
public const REQUIREMENT_TABLE_OF_CONTENTS = 'TableOfContents';
/**
* @var string
*/
public const CONFIG_TABLE_OF_CONTENTS = 'VectorTableOfContents';
/**
* @var string
*/
public const QUERY_PARAM_TABLE_OF_CONTENTS = 'tableofcontents';
/**
* @var string
*/
public const FEATURE_TABLE_OF_CONTENTS = 'TableOfContents';
/**
* This class is for namespacing constants only. Forbid construction.
* @throws FatalError

View file

@ -191,6 +191,30 @@ return [
]
);
// Feature: T297610: Table of Contents
// ================================
$featureManager->registerRequirement(
new OverridableConfigRequirement(
$services->getMainConfig(),
$context->getUser(),
$context->getRequest(),
null,
Constants::CONFIG_TABLE_OF_CONTENTS,
Constants::REQUIREMENT_TABLE_OF_CONTENTS,
Constants::QUERY_PARAM_TABLE_OF_CONTENTS,
null
)
);
$featureManager->registerFeature(
Constants::FEATURE_TABLE_OF_CONTENTS,
[
Constants::REQUIREMENT_FULLY_INITIALISED,
Constants::REQUIREMENT_LATEST_SKIN_VERSION,
Constants::REQUIREMENT_TABLE_OF_CONTENTS
]
);
// Feature: Use Wvui Search
// ================================
$featureManager->registerRequirement(

View file

@ -461,6 +461,16 @@ class SkinVector extends SkinMustache {
return $featureManager->isFeatureEnabled( Constants::FEATURE_LANGUAGE_ALERT_IN_SIDEBAR );
}
/**
* Determines if the Table of Contents should be visible.
*
* @return bool
*/
private function isTableOfContentsVisible(): bool {
$featureManager = VectorServices::getFeatureManager();
return $featureManager->isFeatureEnabled( Constants::FEATURE_TABLE_OF_CONTENTS );
}
/**
* @inheritDoc
*/
@ -498,6 +508,8 @@ class SkinVector extends SkinMustache {
'is-language-in-content-top' => $this->isLanguagesInContentAt( 'top' ),
'is-language-in-content-bottom' => $this->isLanguagesInContentAt( 'bottom' ),
'is-vector-table-of-contents-visible' => $this->isTableOfContentsVisible(),
'data-search-box' => $this->getSearchData(
$parentData['data-search-box'],
!$this->isLegacy(),

View file

@ -0,0 +1,3 @@
<div id="mw-panel-toc" class="mw-sidebar">
<!-- sticky TOC goes here -->
</div>

View file

@ -43,6 +43,9 @@
{{#sidebar-visible}}checked{{/sidebar-visible}}>
{{>Header}}
{{#is-vector-table-of-contents-visible}}{{>TableOfContents}}{{/is-vector-table-of-contents-visible}}
<div class="mw-workspace-container">
{{>Navigation}}
<div class="mw-content-container">

View file

@ -420,6 +420,13 @@
"VectorDisableSidebarPersistence": {
"value": false,
"description": "@var boolean Temporary feature flag that disables saving the sidebar expanded/collapsed state as a user-preference (triggered via clicking the main menu icon). This is intended as a temporary kill-switch in the event that the DB is overloaded with writes to the user_options table."
},
"VectorTableOfContents": {
"value": {
"logged_in": false,
"logged_out": false
},
"description": "@var When `VectorTableOfContents` is enabled, the sticky table of contents is shown."
}
},
"ServiceWiringFiles": [