mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/Vector.git
synced 2024-11-24 07:43:47 +00:00
Move "logout" button to bottom of user links menu in modern Vector
For modern Vector, removes the logout link in the user menu and places it below that menu by appending it to the html-after-portal property of the skin data. Also modifies the `.vector-user-menu-login` style to accommodate both the login and logout button. bug: T281791 Depends-On: If82a736e37174aaadd0ff07019a1fae3759a9e51 Change-Id: I7675230e09a50eaeab448182329f850ad2689514
This commit is contained in:
parent
20d127a8df
commit
c26ae0f965
|
@ -149,6 +149,8 @@ class Hooks {
|
||||||
if ( $sk->loggedin ) {
|
if ( $sk->loggedin ) {
|
||||||
// Remove user page from personal menu dropdown for logged in users.
|
// Remove user page from personal menu dropdown for logged in users.
|
||||||
unset( $content_navigation['user-menu']['userpage'] );
|
unset( $content_navigation['user-menu']['userpage'] );
|
||||||
|
// Remove logout link from user-menu and recreate it in SkinVector,
|
||||||
|
unset( $content_navigation['user-menu']['logout'] );
|
||||||
} else {
|
} else {
|
||||||
// Remove "Not logged in" from personal menu dropdown for anon users.
|
// Remove "Not logged in" from personal menu dropdown for anon users.
|
||||||
unset( $content_navigation['user-menu']['anonuserpage'] );
|
unset( $content_navigation['user-menu']['anonuserpage'] );
|
||||||
|
|
|
@ -212,6 +212,25 @@ class SkinVector extends SkinMustache {
|
||||||
] );
|
] );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns HTML for the logout button that should be placed in the user (personal) menu
|
||||||
|
* after the menu itself.
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
private function getLogoutHTML() {
|
||||||
|
$logoutLinkData = $this->buildLogoutLinkData();
|
||||||
|
$templateParser = $this->getTemplateParser();
|
||||||
|
$logoutLinkData['class'] = [
|
||||||
|
'vector-menu-content-item',
|
||||||
|
'mw-ui-icon mw-ui-icon-before',
|
||||||
|
'mw-ui-icon-wikimedia-logOut'
|
||||||
|
];
|
||||||
|
|
||||||
|
return $templateParser->processTemplate( 'UserLinks__logout', [
|
||||||
|
'htmlLogout' => $this->makeLink( 'logout', $logoutLinkData )
|
||||||
|
] );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns template data for UserLinks.mustache
|
* Returns template data for UserLinks.mustache
|
||||||
* @param array $menuData existing menu template data to be transformed and copied for UserLinks
|
* @param array $menuData existing menu template data to be transformed and copied for UserLinks
|
||||||
|
@ -225,6 +244,11 @@ class SkinVector extends SkinMustache {
|
||||||
$userMenuData = $menuData[ 'data-user-menu' ];
|
$userMenuData = $menuData[ 'data-user-menu' ];
|
||||||
$userMenuData[ 'html-before-portal' ] = $this->getLoginHTML( $returnto, $useCombinedLoginLink );
|
$userMenuData[ 'html-before-portal' ] = $this->getLoginHTML( $returnto, $useCombinedLoginLink );
|
||||||
|
|
||||||
|
if ( !$isAnon ) {
|
||||||
|
// Appending as to not override data potentially set by the onSkinAfterPortlet hook.
|
||||||
|
$userMenuData[ 'html-after-portal' ] .= $this->getLogoutHTML();
|
||||||
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'is-anon' => $isAnon,
|
'is-anon' => $isAnon,
|
||||||
'html-create-account' => $htmlCreateAccount,
|
'html-create-account' => $htmlCreateAccount,
|
||||||
|
|
4
includes/templates/UserLinks__logout.mustache
Normal file
4
includes/templates/UserLinks__logout.mustache
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
{{!-- The #pt-logout ID is required for the AJAX enabled logout in mediawiki.page.ready to work.}}
|
||||||
|
<div id="pt-logout" class="vector-user-menu-login">
|
||||||
|
{{{htmlLogout}}}
|
||||||
|
</div>
|
|
@ -69,26 +69,26 @@
|
||||||
font-size: @font-size-tabs;
|
font-size: @font-size-tabs;
|
||||||
}
|
}
|
||||||
|
|
||||||
// "Login" link in anonymous user menus
|
// "Login" and "Logout" links in user menu
|
||||||
.vector-user-menu-login {
|
.vector-user-menu-login {
|
||||||
border-bottom: 1px solid @border-color-base;
|
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
background-color: @background-color-secondary;
|
background-color: @background-color-secondary;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&:first-child {
|
||||||
|
border-bottom: 1px solid @border-color-base;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:last-child {
|
||||||
|
border-top: 1px solid @border-color-base;
|
||||||
|
}
|
||||||
|
|
||||||
a {
|
a {
|
||||||
display: block;
|
display: block;
|
||||||
color: #000;
|
color: #000;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// "Log out" link in logged in user menus
|
|
||||||
// FIXME: Should not use ID selector. To be fixed as part of T281791.
|
|
||||||
#pt-logout {
|
|
||||||
border-top: 1px solid @border-color-base;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.mw-portlet-notifications {
|
.mw-portlet-notifications {
|
||||||
|
|
Loading…
Reference in a new issue