Cleanup: Drop unnecessary isLegacy checks

The has-logo property is redundant:
The Sidebar in legacy is its own component. The logo is always
rendered in the legacy sidebar.

data-emphasized-sidebar-action can be unconditionally sent
The legacy sidebar doesn't use it, so there is no need to conditionally
add a check for legacy

These two changes allow us to remove the isLegacy property in favor
of the single use of the isLegacy method.

Change-Id: Ie7ee3cec29b20d07db81799484627254d4a78f5f
This commit is contained in:
jdlrobson 2020-07-30 13:32:13 -07:00
parent 1aab97ec03
commit d24d858264
4 changed files with 3 additions and 18 deletions

View file

@ -59,9 +59,6 @@ class SkinVector extends SkinMustache {
*/
private const OPT_OUT_LINK_TRACKING_CODE = 'vctw1';
/** @var bool */
private $isLegacy;
/**
* Whether or not the legacy version of the skin is being used.
*
@ -82,9 +79,7 @@ class SkinVector extends SkinMustache {
* @inheritDoc
*/
public function __construct( $options = [] ) {
// Legacy overrides
$this->isLegacy = $this->isLegacy();
if ( $this->isLegacy ) {
if ( $this->isLegacy() ) {
$options['scripts'] = [ 'skins.vector.legacy.js' ];
$options['styles'] = [ 'skins.vector.styles.legacy' ];
$options['template'] = 'skin-legacy';
@ -151,9 +146,8 @@ class SkinVector extends SkinMustache {
'msg-vector-action-toggle-sidebar' => $skin->msg( 'vector-action-toggle-sidebar' )->text(),
] + $this->getMenuProps();
// The following logic is unqiue to Vector (not used by legacy Vector) and
// is planned to be moved in a follow-up patch.
if ( !$this->isLegacy && $skin->getUser()->isLoggedIn() ) {
if ( $skin->getUser()->isLoggedIn() ) {
// Note: This data is also passed to legacy template where it is unused.
$commonSkinData['data-sidebar']['data-emphasized-sidebar-action'] = [
'href' => SpecialPage::getTitleFor(
'Preferences',
@ -342,7 +336,6 @@ class SkinVector extends SkinMustache {
}
return [
'has-logo' => $this->isLegacy,
'html-logo-attributes' => Xml::expandAttributes(
Linker::tooltipAndAccesskeyAttribs( 'p-logo' ) + [
'class' => 'mw-wiki-logo',

View file

@ -4,11 +4,9 @@
}}
<div id="mw-panel">
{{#has-logo}}
<div id="p-logo" role="banner">
<a {{{html-logo-attributes}}}></a>
</div>
{{/has-logo}}
{{#data-portals-first}}{{>Menu}}{{/data-portals-first}}
{{#array-portals-rest}}{{>Menu}}{{/array-portals-rest}}
{{#data-portals-languages}}{{>Menu}}{{/data-portals-languages}}

View file

@ -17,12 +17,10 @@ export const SIDEBAR_TEMPLATE_PARTIALS = {
export const SIDEBAR_DATA = {
withNoPortals: {
'has-logo': true,
'array-portals-rest': [],
'html-logo-attributes': HTML_LOGO_ATTRIBUTES
},
withPortalsAndOptOut: {
'has-logo': false,
'data-portals-first': PORTALS.navigation,
'data-emphasized-sidebar-action': {
href: '#',
@ -37,7 +35,6 @@ export const SIDEBAR_DATA = {
'html-logo-attributes': HTML_LOGO_ATTRIBUTES
},
withPortals: {
'has-logo': true,
'data-portals-first': PORTALS.navigation,
'array-portals-rest': [
PORTALS.toolbox,
@ -47,7 +44,6 @@ export const SIDEBAR_DATA = {
'html-logo-attributes': HTML_LOGO_ATTRIBUTES
},
withoutLogo: {
'has-logo': false,
'data-portals-languages': PORTALS.langlinks,
'array-portals-first': PORTALS.navigation,
'array-portals-rest': [
@ -56,7 +52,6 @@ export const SIDEBAR_DATA = {
]
},
thirdParty: {
'has-logo': true,
'array-portals-rest': [
PORTALS.toolbox,
PORTALS.navigation,

View file

@ -34,7 +34,6 @@
* @property {MenuDefinition} data-portals-languages
* @property {MenuDefinition} data-portals-first
* @property {MenuDefinition[]} array-portals-rest
* @property {boolean} [has-logo] whether to show a logo or not.
*/
/**