diff --git a/includes/Constants.php b/includes/Constants.php index 6527da3..0f6d0a3 100644 --- a/includes/Constants.php +++ b/includes/Constants.php @@ -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 */ diff --git a/includes/VectorTemplate.php b/includes/VectorTemplate.php index f535309..ff1190c 100644 --- a/includes/VectorTemplate.php +++ b/includes/VectorTemplate.php @@ -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 * diff --git a/skin.json b/skin.json index 6ee79b6..b6c4f2a 100644 --- a/skin.json +++ b/skin.json @@ -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": [