Remove SkinVector::ICON_USER_LINK_MAP usage

Per T284594, we are now setting the icon key/value when the relevant
menu item is created (e.g see I95f2a0a01134f2c3dfc22083be66c99de26b530f
) to allow for easier reuse of icons across skins.

Additionally:

* Refactor SkinVector to pull the appropriate login/logout icon from
core instead of setting this in Vector

Bug: T284594
Depends-On: I95f2a0a01134f2c3dfc22083be66c99de26b530f
Depends-On: I6292de50c3940f39b0084a2af4f79af78583720f
Change-Id: I02163645937de4b8a2c4375f29851c29462a582d
This commit is contained in:
Nicholas Ray 2021-06-22 16:29:04 -06:00 committed by Jdlrobson
parent 02de393331
commit b82ecc2173
2 changed files with 3 additions and 33 deletions

View File

@ -23,20 +23,6 @@ use Vector\HTMLForm\Fields\HTMLLegacySkinVersionField;
* @internal
*/
class Hooks {
/**
* Icon map of user link keys and icon names.
*/
public const ICON_USER_LINK_MAP = [
'mytalk' => 'userTalk',
'anontalk' => 'userTalk',
'preferences' => 'settings',
'betafeatures' => 'labFlask',
'watchlist' => 'unStar',
'mycontris' => 'userContributions',
'anoncontribs' => 'userContributions',
'logout' => 'logOut',
];
/**
* Passes config variables to Vector (modern) ResourceLoader module.
* @param ResourceLoaderContext $context
@ -163,10 +149,7 @@ class Hooks {
$user_menu = $content_navigation['user-menu'];
// Loop through each menu to check/append its link classes.
foreach ( $user_menu as $menu_key => $menu_value ) {
// Check if the menu has an icon key (provided by extensions). If not, get the icon from the icon map.
$icon_name = array_key_exists( 'icon', $menu_value )
? $menu_value['icon']
: self::getIconFromKey( $menu_key );
$icon_name = $menu_value['icon'] ?? '';
// Set the default menu icon classes.
$menu_icon_classes = [ 'mw-ui-icon', 'mw-ui-icon-before', 'mw-ui-icon-wikimedia-' . $icon_name ];
@ -487,17 +470,4 @@ class Hooks {
private static function isSkinVersionLegacy(): bool {
return !VectorServices::getFeatureManager()->isFeatureEnabled( Constants::FEATURE_LATEST_SKIN );
}
/**
* Gets the associated icon name for a user link menu item in the personal toolbar.
*
* @param string $key
*
* @return string
*/
private static function getIconFromKey( string $key ): string {
$icon_map = self::ICON_USER_LINK_MAP;
return $icon_map[$key] ?? '';
}
}

View File

@ -197,7 +197,7 @@ class SkinVector extends SkinMustache {
$loginData['class'] = [
'vector-menu-content-item',
'mw-ui-icon mw-ui-icon-before',
'mw-ui-icon-wikimedia-logIn'
'mw-ui-icon-wikimedia-' . ( $loginData[ 'icon' ] ?? '' )
];
$learnMoreLinkData = [
@ -227,7 +227,7 @@ class SkinVector extends SkinMustache {
$logoutLinkData['class'] = [
'vector-menu-content-item',
'mw-ui-icon mw-ui-icon-before',
'mw-ui-icon-wikimedia-logOut'
'mw-ui-icon-wikimedia-' . ( $logoutLinkData[ 'icon' ] ?? '' )
];
return $templateParser->processTemplate( 'UserLinks__logout', [