Move watchlist button out of user menu dropdown and adds temporary feature flag
Bug: T289619 Change-Id: I57addbed2ea8ead5d98bce659f3db1f88f8a5094
This commit is contained in:
parent
d06a4ab2e7
commit
321e6b19e1
|
@ -206,6 +206,23 @@ final class Constants {
|
|||
*/
|
||||
public const FEATURE_STICKY_HEADER_EDIT = 'StickyHeaderEdit';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const FEATURE_USER_LINKS_WATCHLIST = 'UserLinksWatchlist';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const REQUIREMENT_USER_LINKS_WATCHLIST = 'UserLinksWatchlist';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const CONFIG_USER_LINKS_WATCHLIST = 'VectorUserLinksWatchlist';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const QUERY_PARAM_USER_LINKS_WATCHLIST = 'vectoruserlinkswatchlist';
|
||||
|
||||
/**
|
||||
* Defines whether the Sticky Header A/B test is running. See
|
||||
* https://phabricator.wikimedia.org/T292587 for additional detail about the test.
|
||||
|
|
|
@ -213,6 +213,12 @@ class Hooks {
|
|||
$content_navigation['user-menu']['userpage'],
|
||||
$COLLAPSE_MENU_ITEM_CLASS
|
||||
);
|
||||
if ( VectorServices::getFeatureManager()->isFeatureEnabled( Constants::FEATURE_USER_LINKS_WATCHLIST ) ) {
|
||||
self::appendClassToListItem(
|
||||
$content_navigation['user-menu']['watchlist'],
|
||||
$COLLAPSE_MENU_ITEM_CLASS
|
||||
);
|
||||
}
|
||||
// Remove logout link from user-menu and recreate it in SkinVector,
|
||||
unset( $content_navigation['user-menu']['logout'] );
|
||||
// Don't show icons for anon menu items (besides login and create account).
|
||||
|
@ -272,11 +278,10 @@ class Hooks {
|
|||
/**
|
||||
* Updates user interface preferences for modern Vector to upgrade icon/button menu items.
|
||||
*
|
||||
* @param SkinTemplate $sk
|
||||
* @param array &$content_navigation
|
||||
* @param string $menu identifier
|
||||
*/
|
||||
private static function updateMenuItems( $sk, &$content_navigation, $menu ) {
|
||||
private static function updateMenuItems( &$content_navigation, $menu ) {
|
||||
foreach ( $content_navigation[$menu] as $key => $item ) {
|
||||
$hasButton = $item['button'] ?? false;
|
||||
$hideText = $item['text-hidden'] ?? false;
|
||||
|
@ -337,12 +342,12 @@ class Hooks {
|
|||
// for extensions that have opted in.
|
||||
if ( isset( $content_navigation['user-interface-preferences'] ) ) {
|
||||
self::updateMenuItems(
|
||||
$sk, $content_navigation, 'user-interface-preferences'
|
||||
$content_navigation, 'user-interface-preferences'
|
||||
);
|
||||
}
|
||||
if ( isset( $content_navigation['notifications'] ) ) {
|
||||
self::updateMenuItems(
|
||||
$sk, $content_navigation, 'notifications'
|
||||
$content_navigation, 'notifications'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -261,6 +261,21 @@ return [
|
|||
)
|
||||
);
|
||||
|
||||
// Temporary feature flag for moving watchlist out of user menu
|
||||
// Remove when the new watchlist icon is in OOUI
|
||||
$featureManager->registerRequirement(
|
||||
new OverridableConfigRequirement(
|
||||
$services->getMainConfig(),
|
||||
$context->getUser(),
|
||||
$context->getRequest(),
|
||||
null,
|
||||
Constants::CONFIG_USER_LINKS_WATCHLIST,
|
||||
Constants::REQUIREMENT_USER_LINKS_WATCHLIST,
|
||||
Constants::QUERY_PARAM_USER_LINKS_WATCHLIST,
|
||||
null
|
||||
)
|
||||
);
|
||||
|
||||
$featureManager->registerFeature(
|
||||
Constants::FEATURE_STICKY_HEADER,
|
||||
[
|
||||
|
@ -280,6 +295,15 @@ return [
|
|||
]
|
||||
);
|
||||
|
||||
$featureManager->registerFeature(
|
||||
Constants::FEATURE_USER_LINKS_WATCHLIST,
|
||||
[
|
||||
Constants::REQUIREMENT_FULLY_INITIALISED,
|
||||
Constants::REQUIREMENT_LATEST_SKIN_VERSION,
|
||||
Constants::REQUIREMENT_USER_LINKS_WATCHLIST,
|
||||
]
|
||||
);
|
||||
|
||||
return $featureManager;
|
||||
}
|
||||
];
|
||||
|
|
|
@ -203,7 +203,7 @@ class SkinVector extends SkinMustache {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns HTML for the create account button inside the anon user links
|
||||
* Returns HTML for the create account link inside the anon user links
|
||||
* @param string[] $returnto array of query strings used to build the login link
|
||||
* @param string[] $class array of CSS classes to add.
|
||||
* @param bool $includeIcon Set true to include icon CSS classes.
|
||||
|
@ -212,6 +212,7 @@ class SkinVector extends SkinMustache {
|
|||
private function getCreateAccountHTML( $returnto, $class, $includeIcon ) {
|
||||
$createAccountData = $this->buildCreateAccountData( $returnto );
|
||||
$createAccountData['single-id'] = 'pt-createaccount';
|
||||
unset( $createAccountData['icon'] );
|
||||
|
||||
if ( $includeIcon ) {
|
||||
$class = array_merge(
|
||||
|
@ -224,9 +225,34 @@ class SkinVector extends SkinMustache {
|
|||
}
|
||||
|
||||
$createAccountData['class'] = $class;
|
||||
$htmlCreateAccount = $this->makeLink( 'create-account', $createAccountData );
|
||||
return $this->makeLink( 'create-account', $createAccountData );
|
||||
}
|
||||
|
||||
return $htmlCreateAccount;
|
||||
/**
|
||||
* Returns HTML for the watchlist link inside user links
|
||||
* @return string
|
||||
*/
|
||||
private function getWatchlistHTML() {
|
||||
$title = $this->getTitle();
|
||||
$pageurl = $title->getLocalURL();
|
||||
$href = self::makeSpecialUrl( 'Watchlist' );
|
||||
$watchlistData = [
|
||||
'text' => $this->msg( 'mywatchlist' )->text(),
|
||||
'href' => $href,
|
||||
'active' => ( $href == $pageurl ),
|
||||
'single-id' => 'pt-watchlist',
|
||||
'class' => [
|
||||
'mw-ui-button',
|
||||
'mw-ui-quiet',
|
||||
'mw-ui-icon',
|
||||
'mw-ui-icon-element',
|
||||
'mw-ui-icon-wikimedia-unStar'
|
||||
]
|
||||
];
|
||||
|
||||
$featureManager = VectorServices::getFeatureManager();
|
||||
return $featureManager->isFeatureEnabled( Constants::FEATURE_USER_LINKS_WATCHLIST ) ?
|
||||
$this->makeLink( 'watchlist', $watchlistData ) : '';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -317,6 +343,7 @@ class SkinVector extends SkinMustache {
|
|||
'data-user-interface-preferences' => $menuData[ 'data-user-interface-preferences' ],
|
||||
'data-notifications' => $menuData[ 'data-notifications' ],
|
||||
'data-user-page' => $menuData[ 'data-user-page' ],
|
||||
'html-vector-watchlist' => $this->getWatchlistHTML(),
|
||||
] );
|
||||
$userMoreData = [
|
||||
'id' => 'p-personal-more',
|
||||
|
|
|
@ -7,4 +7,7 @@
|
|||
{{^is-anon}}
|
||||
{{#data-user-page}}{{{html-items}}}{{/data-user-page}}
|
||||
{{#data-notifications}}{{{html-items}}}{{/data-notifications}}
|
||||
<li id="pt-watchlist-2" class="user-links-collapsible-item">
|
||||
{{{html-vector-watchlist}}}
|
||||
</li>
|
||||
{{/is-anon}}
|
||||
|
|
|
@ -405,6 +405,10 @@
|
|||
},
|
||||
"description": "@var array Enables the edit icons if $wgVectorStickyHeader is true."
|
||||
},
|
||||
"VectorUserLinksWatchlist": {
|
||||
"value": false,
|
||||
"description": "@var string Enables moving the watchlist to outside the user menu if true. This feature flag is temporary and subject to removal. "
|
||||
},
|
||||
"VectorWebABTestEnrollment": {
|
||||
"value": {
|
||||
"name": "vector.sticky_header",
|
||||
|
|
Loading…
Reference in New Issue