Refactor: Clarify functions that return booleans and template booleans

We prefix templates that are booleans with "is-" and tend to prefix
functions that return booleans with "if" or "should"

This renames the new "shouldConsolidateLinks" method.

Follow up to I1c305d89bece147a6f1b478441119c3169abfbdd

Change-Id: I6a5908b8b35ca6bceec8b864e3ac651fc7e8ced8
This commit is contained in:
jdlrobson 2021-05-06 15:54:55 -07:00 committed by Jdlrobson
parent 840bc5b0cd
commit e7a4ecf9db
2 changed files with 10 additions and 8 deletions

View File

@ -162,7 +162,7 @@ class SkinVector extends SkinMustache {
* If in modern Vector and the config is set to consolidate user links, enable user link consolidation.
* @return bool
*/
private function consolidateUserLinks() {
private function shouldConsolidateUserLinks() {
$featureManager = VectorServices::getFeatureManager();
return !$this->isLegacy() &&
$featureManager->isFeatureEnabled(
@ -202,7 +202,7 @@ class SkinVector extends SkinMustache {
// Conditionally used values must use null to indicate absence (not false or '').
$commonSkinData = array_merge( $parentData, [
'consolidate-user-links' => $this->consolidateUserLinks(),
'is-consolidated-user-links' => $this->shouldConsolidateUserLinks(),
'page-isarticle' => (bool)$out->isArticle(),
@ -337,7 +337,9 @@ class SkinVector extends SkinMustache {
];
$portletData['heading-class'] = 'vector-menu-heading';
// Add target class to apply different icon to personal menu dropdown for logged in users.
if ( $portletData['id'] === 'p-personal' && $this->consolidateUserLinks() && !$this->getUser()->isAnon() ) {
if ( $portletData['id'] === 'p-personal' && $this->shouldConsolidateUserLinks() &&
!$this->getUser()->isAnon()
) {
$portletData['heading-class'] .= ' mw-portlet-personal-page__heading--auth';
// Replace dropdown arrow with ellipsis icon if feature flag is enabled and user is logged in.
$portletData['heading-class'] .= ' mw-ui-icon mw-ui-icon-element mw-ui-icon-wikimedia-ellipsis';
@ -360,7 +362,7 @@ class SkinVector extends SkinMustache {
) : array {
switch ( $label ) {
case 'user-menu':
$type = $this->consolidateUserLinks() && $this->getUser()->isRegistered() ?
$type = $this->shouldConsolidateUserLinks() && $this->getUser()->isRegistered() ?
self::MENU_TYPE_DROPDOWN : self::MENU_TYPE_DEFAULT;
break;
case 'actions':

View File

@ -11,12 +11,12 @@
</label>
{{>Logo}}
{{#data-search-box}}{{>SearchBox}}{{/data-search-box}}
{{^consolidate-user-links}}
{{^is-consolidated-user-links}}
{{#data-portlets}}
{{#data-personal}}{{>Menu}}{{/data-personal}}
{{/data-portlets}}
{{/consolidate-user-links}}
{{#consolidate-user-links}}
{{/is-consolidated-user-links}}
{{#is-consolidated-user-links}}
{{#data-portlets}}
{{#data-notifications}}{{>Menu}}{{/data-notifications}}
{{/data-portlets}}
@ -26,5 +26,5 @@
{{#data-portlets}}
{{#data-user-menu}}{{>Menu}}{{/data-user-menu}}
{{/data-portlets}}
{{/consolidate-user-links}}
{{/is-consolidated-user-links}}
</header>