Add sticky header edit feature flag
Can be disabled via &vectorstickyheaderedit=0 or configuration change. This will allow us to fine tune the edit features without blocking deploying the existing feature. Bug: T294383 Change-Id: Ic282ea4f2ff0108eeaa154c8a77e4e5fd30daeae
This commit is contained in:
parent
34d77d5e41
commit
768a07ec6c
|
@ -171,21 +171,41 @@ final class Constants {
|
||||||
*/
|
*/
|
||||||
public const QUERY_PARAM_STICKY_HEADER = 'vectorstickyheader';
|
public const QUERY_PARAM_STICKY_HEADER = 'vectorstickyheader';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public const QUERY_PARAM_STICKY_HEADER_EDIT = 'vectorstickyheaderedit';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public const CONFIG_STICKY_HEADER = 'VectorStickyHeader';
|
public const CONFIG_STICKY_HEADER = 'VectorStickyHeader';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public const CONFIG_STICKY_HEADER_EDIT = 'VectorStickyHeaderEdit';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public const REQUIREMENT_STICKY_HEADER = 'StickyHeader';
|
public const REQUIREMENT_STICKY_HEADER = 'StickyHeader';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public const REQUIREMENT_STICKY_HEADER_EDIT = 'StickyHeaderEdit';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public const FEATURE_STICKY_HEADER = 'StickyHeader';
|
public const FEATURE_STICKY_HEADER = 'StickyHeader';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public const FEATURE_STICKY_HEADER_EDIT = 'StickyHeaderEdit';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The `mediawiki.searchSuggest` protocol piece of the SearchSatisfaction instrumention reads
|
* The `mediawiki.searchSuggest` protocol piece of the SearchSatisfaction instrumention reads
|
||||||
* the value of an element with the "data-search-loc" attribute and set the event's
|
* the value of an element with the "data-search-loc" attribute and set the event's
|
||||||
|
|
|
@ -167,6 +167,19 @@ return [
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$featureManager->registerRequirement(
|
||||||
|
new OverridableConfigRequirement(
|
||||||
|
$services->getMainConfig(),
|
||||||
|
$context->getUser(),
|
||||||
|
$context->getRequest(),
|
||||||
|
null,
|
||||||
|
Constants::CONFIG_STICKY_HEADER_EDIT,
|
||||||
|
Constants::REQUIREMENT_STICKY_HEADER_EDIT,
|
||||||
|
Constants::QUERY_PARAM_STICKY_HEADER_EDIT,
|
||||||
|
null
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
$featureManager->registerFeature(
|
$featureManager->registerFeature(
|
||||||
Constants::FEATURE_STICKY_HEADER,
|
Constants::FEATURE_STICKY_HEADER,
|
||||||
[
|
[
|
||||||
|
@ -176,6 +189,16 @@ return [
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$featureManager->registerFeature(
|
||||||
|
Constants::FEATURE_STICKY_HEADER_EDIT,
|
||||||
|
[
|
||||||
|
Constants::REQUIREMENT_FULLY_INITIALISED,
|
||||||
|
Constants::REQUIREMENT_LATEST_SKIN_VERSION,
|
||||||
|
Constants::REQUIREMENT_STICKY_HEADER,
|
||||||
|
Constants::REQUIREMENT_STICKY_HEADER_EDIT,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
return $featureManager;
|
return $featureManager;
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
|
@ -376,11 +376,20 @@ class SkinVector extends SkinMustache {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate data needed to generate the sticky header.
|
* Generate data needed to generate the sticky header.
|
||||||
* Lack of i18n is intentional and will be done as part of follow up work.
|
|
||||||
* @param array $searchBoxData
|
* @param array $searchBoxData
|
||||||
|
* @param bool $includeEditIcons
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
private function getStickyHeaderData( $searchBoxData ): array {
|
private function getStickyHeaderData( $searchBoxData, $includeEditIcons ): array {
|
||||||
|
$btns = [
|
||||||
|
self::TALK_ICON,
|
||||||
|
self::HISTORY_ICON,
|
||||||
|
];
|
||||||
|
if ( $includeEditIcons ) {
|
||||||
|
$btns[] = self::EDIT_WIKITEXT_ICON;
|
||||||
|
$btns[] = self::EDIT_PROTECTED_ICON;
|
||||||
|
$btns[] = self::EDIT_VE_ICON;
|
||||||
|
}
|
||||||
return [
|
return [
|
||||||
'data-primary-action' => !$this->shouldHideLanguages() ? $this->getULSButtonData() : null,
|
'data-primary-action' => !$this->shouldHideLanguages() ? $this->getULSButtonData() : null,
|
||||||
'data-button-start' => [
|
'data-button-start' => [
|
||||||
|
@ -391,13 +400,7 @@ class SkinVector extends SkinMustache {
|
||||||
'class' => 'vector-sticky-header-search-toggle',
|
'class' => 'vector-sticky-header-search-toggle',
|
||||||
],
|
],
|
||||||
'data-search' => $searchBoxData,
|
'data-search' => $searchBoxData,
|
||||||
'data-buttons' => [
|
'data-buttons' => $btns,
|
||||||
self::TALK_ICON,
|
|
||||||
self::HISTORY_ICON,
|
|
||||||
self::EDIT_WIKITEXT_ICON,
|
|
||||||
self::EDIT_PROTECTED_ICON,
|
|
||||||
self::EDIT_VE_ICON
|
|
||||||
]
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -452,6 +455,9 @@ class SkinVector extends SkinMustache {
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
'vector-sticky-search-form'
|
'vector-sticky-search-form'
|
||||||
|
),
|
||||||
|
VectorServices::getFeatureManager()->isFeatureEnabled(
|
||||||
|
Constants::FEATURE_STICKY_HEADER_EDIT
|
||||||
)
|
)
|
||||||
) : false,
|
) : false,
|
||||||
] );
|
] );
|
||||||
|
|
|
@ -133,11 +133,14 @@ function prepareEditIcons(
|
||||||
disableStickyHeader
|
disableStickyHeader
|
||||||
) {
|
) {
|
||||||
const
|
const
|
||||||
primaryEditSticky = toHTMLElement(
|
primaryEditStickyElement = header.querySelector(
|
||||||
|
'#ca-ve-edit-sticky-header'
|
||||||
|
),
|
||||||
|
primaryEditSticky = primaryEditStickyElement ? toHTMLElement(
|
||||||
header.querySelector(
|
header.querySelector(
|
||||||
'#ca-ve-edit-sticky-header'
|
'#ca-ve-edit-sticky-header'
|
||||||
)
|
)
|
||||||
),
|
) : null,
|
||||||
protectedSticky = toHTMLElement(
|
protectedSticky = toHTMLElement(
|
||||||
header.querySelector(
|
header.querySelector(
|
||||||
'#ca-viewsource-sticky-header'
|
'#ca-viewsource-sticky-header'
|
||||||
|
@ -149,6 +152,10 @@ function prepareEditIcons(
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// If no primary edit icon is present the feature is disabled.
|
||||||
|
if ( !primaryEditSticky ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if ( !primaryEdit ) {
|
if ( !primaryEdit ) {
|
||||||
removeNode( protectedSticky );
|
removeNode( protectedSticky );
|
||||||
removeNode( wikitextSticky );
|
removeNode( wikitextSticky );
|
||||||
|
|
|
@ -357,6 +357,13 @@
|
||||||
},
|
},
|
||||||
"description": "@var array Enables a persistent header that allows quick access to user links, editing tools, search and other links while scrolling down a page"
|
"description": "@var array Enables a persistent header that allows quick access to user links, editing tools, search and other links while scrolling down a page"
|
||||||
},
|
},
|
||||||
|
"VectorStickyHeaderEdit": {
|
||||||
|
"value": {
|
||||||
|
"logged_in": true,
|
||||||
|
"logged_out": false
|
||||||
|
},
|
||||||
|
"description": "@var array Enables the edit icons if $wgVectorStickyHeader is true."
|
||||||
|
},
|
||||||
"VectorDisableSidebarPersistence": {
|
"VectorDisableSidebarPersistence": {
|
||||||
"value": false,
|
"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."
|
"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."
|
||||||
|
|
Loading…
Reference in New Issue