Select initial side bar visibility depends on user login state and defaults

Bug: T254230
Change-Id: If121b6c8187ef6b8562d135bd1c40403be3e9564
This commit is contained in:
Peter Ovchyn 2020-07-07 11:59:14 +03:00
parent 5b28e0b014
commit ac140d53e6
3 changed files with 38 additions and 1 deletions

View File

@ -55,6 +55,18 @@ final class Constants {
public const CONFIG_KEY_DEFAULT_SKIN_VERSION_FOR_NEW_ACCOUNTS =
'VectorDefaultSkinVersionForNewAccounts';
/**
* @var string
*/
public const CONFIG_KEY_DEFAULT_SIDEBAR_VISIBLE_FOR_AUTHORISED_USER =
'VectorDefaultSidebarVisibleForAuthorisedUser';
/**
* @var string
*/
public const CONFIG_KEY_DEFAULT_SIDEBAR_VISIBLE_FOR_ANONYMOUS_USER =
'VectorDefaultSidebarVisibleForAnonymousUser';
/**
* @var string
*/

View File

@ -22,6 +22,8 @@
* @ingroup Skins
*/
use Vector\Constants;
/**
* QuickTemplate subclass for Vector
* @ingroup Skins
@ -170,7 +172,7 @@ class VectorTemplate extends BaseTemplate {
'data-sidebar' => $this->buildSidebar(),
// [todo] fetch user preference when logged in (T246427).
'sidebar-visible' => true,
'sidebar-visible' => $this->isSidebarVisible(),
'msg-vector-action-toggle-sidebar' => $this->msg( 'vector-action-toggle-sidebar' )->text(),
] + $this->getMenuProps();
@ -259,6 +261,23 @@ class VectorTemplate extends BaseTemplate {
return $data;
}
/**
* Determines wheather the initial state of sidebar is visible on not
*
* @return bool
*/
private function isSidebarVisible() {
$skin = $this->getSkin();
if ( $skin->getUser()->isLoggedIn() ) {
return $this->getConfig()->get(
Constants::CONFIG_KEY_DEFAULT_SIDEBAR_VISIBLE_FOR_AUTHORISED_USER
);
}
return $this->getConfig()->get(
Constants::CONFIG_KEY_DEFAULT_SIDEBAR_VISIBLE_FOR_ANONYMOUS_USER
);
}
/**
* Render a series of portals
*

View File

@ -153,6 +153,12 @@
"VectorDefaultSkinVersionForNewAccounts": {
"value": "1",
"description": "@var string:['2'|'1'] The version ('2' for latest, '1' for legacy) of the Vector skin to **set** for newly created user accounts. **The value is persisted as a user preference.** This configuration is not used for preexisting accounts (see VectorDefaultSkinVersionForExistingAccounts) and only ever executed once at new account creation time."
},
"VectorDefaultSidebarVisibleForAuthorisedUser": {
"value": true
},
"VectorDefaultSidebarVisibleForAnonymousUser": {
"value": false
}
},
"ServiceWiringFiles": [