mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/Vector.git
synced 2024-11-24 07:43:47 +00:00
Merge "Add feature flag for sticky table of contents"
This commit is contained in:
commit
9efaaf8afa
|
@ -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
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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(),
|
||||
|
|
3
includes/templates/TableOfContents.mustache
Normal file
3
includes/templates/TableOfContents.mustache
Normal file
|
@ -0,0 +1,3 @@
|
|||
<div id="mw-panel-toc" class="mw-sidebar">
|
||||
<!-- sticky TOC goes here -->
|
||||
</div>
|
|
@ -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">
|
||||
|
|
|
@ -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": [
|
||||
|
|
Loading…
Reference in a new issue