From 227534102a6c610fe7b4e6576bd781aee2355995 Mon Sep 17 00:00:00 2001 From: jdlrobson Date: Thu, 8 Oct 2020 14:51:27 -0700 Subject: [PATCH] Separate opt out data from sidebar In preparation for using the data provided by SkinMustache class we need to separate the opt out data from the rest of the sidebar. The opt out data is specific to Vector. Change-Id: I4461da92c1787d272bbf99e6644bdb9e6c388a68 --- includes/SkinVector.php | 2 +- stories/Sidebar.stories.data.js | 22 ++++++++-------------- stories/skin.stories.data.js | 8 ++++---- 3 files changed, 13 insertions(+), 19 deletions(-) diff --git a/includes/SkinVector.php b/includes/SkinVector.php index 6507e258d..12cb50b3d 100644 --- a/includes/SkinVector.php +++ b/includes/SkinVector.php @@ -139,7 +139,7 @@ class SkinVector extends SkinMustache { if ( $skin->getUser()->isLoggedIn() ) { // Note: This data is also passed to legacy template where it is unused. - $commonSkinData['data-sidebar']['data-emphasized-sidebar-action'] = [ + $commonSkinData['data-emphasized-sidebar-action'] = [ 'href' => SpecialPage::getTitleFor( 'Preferences', false, diff --git a/stories/Sidebar.stories.data.js b/stories/Sidebar.stories.data.js index 64d14c968..60d58a0bd 100644 --- a/stories/Sidebar.stories.data.js +++ b/stories/Sidebar.stories.data.js @@ -15,25 +15,19 @@ export const SIDEBAR_TEMPLATE_PARTIALS = { Menu: vectorMenuTemplate }; +export const OPT_OUT_DATA = { + 'data-emphasized-sidebar-action': { + href: '#', + 'msg-vector-opt-out': 'Switch to old look', + 'msg-vector-opt-out-tooltip': 'Change your settings to go back to the old look of the skin (legacy Vector)' + } +}; + export const SIDEBAR_DATA = { withNoPortals: { 'array-portals-rest': [], 'html-logo-attributes': HTML_LOGO_ATTRIBUTES }, - withPortalsAndOptOut: { - 'data-portals-first': PORTALS.navigation, - 'data-emphasized-sidebar-action': { - href: '#', - 'msg-vector-opt-out': 'Switch to old look', - 'msg-vector-opt-out-tooltip': 'Change your settings to go back to the old look of the skin (legacy Vector)' - }, - 'array-portals-rest': [ - PORTALS.toolbox, - PORTALS.otherProjects - ], - 'data-portals-languages': PORTALS.langlinks, - 'html-logo-attributes': HTML_LOGO_ATTRIBUTES - }, withPortals: { 'data-portals-first': PORTALS.navigation, 'array-portals-rest': [ diff --git a/stories/skin.stories.data.js b/stories/skin.stories.data.js index 1cf8710d5..eb5d055fb 100644 --- a/stories/skin.stories.data.js +++ b/stories/skin.stories.data.js @@ -11,23 +11,23 @@ import { PERSONAL_MENU_TEMPLATE_DATA, menuTemplate } from './Menu.stories.data'; import { pageActionsData, namespaceTabsData } from './MenuTabs.stories.data'; import { vectorMenuTemplate, moreData, variantsData } from './MenuDropdown.stories.data'; import { searchBoxData, searchBoxTemplate } from './SearchBox.stories.data'; -import { SIDEBAR_DATA, SIDEBAR_TEMPLATE_PARTIALS, +import { SIDEBAR_DATA, SIDEBAR_TEMPLATE_PARTIALS, OPT_OUT_DATA, sidebarLegacyTemplate, sidebarTemplate } from './Sidebar.stories.data'; import { FOOTER_TEMPLATE_DATA, FOOTER_TEMPLATE_PARTIALS, footerTemplate } from './Footer.stories.data'; import { logoTemplate } from './Logo.stories.data'; export const NAVIGATION_TEMPLATE_DATA = { - loggedInWithVariantsAndOptOut: { + loggedInWithVariantsAndOptOut: Object.assign( {}, { 'data-personal-menu': PERSONAL_MENU_TEMPLATE_DATA.loggedInWithEcho, 'data-namespace-tabs': namespaceTabsData, 'data-page-actions': pageActionsData, 'data-variants': variantsData, 'data-search-box': searchBoxData, - 'data-sidebar': SIDEBAR_DATA.withPortalsAndOptOut, + 'data-sidebar': SIDEBAR_DATA.withPortals, 'msg-navigation-heading': 'Navigation menu', 'html-logo-attributes': `class="mw-wiki-logo" href="/wiki/Main_Page" title="Visit the main page"` - }, + }, OPT_OUT_DATA ), loggedOutWithVariants: { 'data-personal-menu': PERSONAL_MENU_TEMPLATE_DATA.loggedOut, 'data-namespace-tabs': namespaceTabsData,