From 1e61706e0e655e904665f8572bbf63cd8cb3fdd7 Mon Sep 17 00:00:00 2001 From: Stephen Niedzielski Date: Wed, 19 Jun 2019 11:31:16 -0600 Subject: [PATCH] Hygiene: rename "secondary button" to "user notifications" The secondary button is not generic. Rename it to match its specific purpose. Bug: T214540 Change-Id: I50b7e7fa7bea91a029a8ca71199b0309dff1c518 --- includes/skins/MinervaTemplate.php | 2 +- includes/skins/SkinMinerva.php | 4 ++-- includes/skins/minerva.mustache | 2 +- ...on.mustache => userNotifications.mustache} | 4 ++-- resources/skins.minerva.notifications/init.js | 2 +- skin.json | 2 +- tests/phpunit/skins/SkinMinervaTest.php | 22 +++++++++---------- 7 files changed, 19 insertions(+), 19 deletions(-) rename includes/skins/{secondaryButton.mustache => userNotifications.mustache} (91%) diff --git a/includes/skins/MinervaTemplate.php b/includes/skins/MinervaTemplate.php index 7e19af4..7ce13a2 100644 --- a/includes/skins/MinervaTemplate.php +++ b/includes/skins/MinervaTemplate.php @@ -251,7 +251,7 @@ class MinervaTemplate extends BaseTemplate { 'id' => 'searchIcon', 'class' => MinervaUI::iconClass( 'magnifying-glass', 'element', 'skin-minerva-search-trigger' ), ], wfMessage( 'searchbutton' ) ), - 'secondaryButtonData' => $data['secondaryButtonData'], + 'userNotificationsData' => $data['userNotificationsData'], 'mainmenuhtml' => $this->getMainMenuHtml( $data ), 'hasheadingholder' => $hasHeadingHolder, 'taglinehtml' => $data['taglinehtml'], diff --git a/includes/skins/SkinMinerva.php b/includes/skins/SkinMinerva.php index e4976e8..d52e94e 100644 --- a/includes/skins/SkinMinerva.php +++ b/includes/skins/SkinMinerva.php @@ -390,7 +390,7 @@ class SkinMinerva extends SkinTemplate { */ protected function prepareUserNotificationsButton( QuickTemplate $tpl, $newTalks ) { // Set user button to empty string by default - $tpl->set( 'secondaryButtonData', '' ); + $tpl->set( 'userNotificationsData', '' ); $notificationsTitle = ''; $count = 0; $countLabel = ''; @@ -441,7 +441,7 @@ class SkinMinerva extends SkinTemplate { $url = $notificationsTitle->getLocalURL( [ 'returnto' => $currentTitle->getPrefixedText() ] ); - $tpl->set( 'secondaryButtonData', [ + $tpl->set( 'userNotificationsData', [ 'notificationIconClass' => MinervaUI::iconClass( 'notifications' ), 'title' => $notificationsMsg, 'url' => $url, diff --git a/includes/skins/minerva.mustache b/includes/skins/minerva.mustache index 28ca08f..791e75a 100644 --- a/includes/skins/minerva.mustache +++ b/includes/skins/minerva.mustache @@ -19,7 +19,7 @@ value="{{search}}">
{{{searchButton}}}
- {{^isAnon}}
{{#secondaryButtonData}}{{>secondaryButton}}{{/secondaryButtonData}}
{{/isAnon}} + {{^isAnon}}
{{#userNotificationsData}}{{>userNotifications}}{{/userNotificationsData}}
{{/isAnon}}
diff --git a/includes/skins/secondaryButton.mustache b/includes/skins/userNotifications.mustache similarity index 91% rename from includes/skins/secondaryButton.mustache rename to includes/skins/userNotifications.mustache index fda9035..df44d28 100644 --- a/includes/skins/secondaryButton.mustache +++ b/includes/skins/userNotifications.mustache @@ -1,12 +1,12 @@ {{^hasNotifications}} + class="{{notificationIconClass}} user-button main-header-button" id="user-notifications"> {{title}} {{/hasNotifications}} {{#hasNotifications}}
diff --git a/resources/skins.minerva.notifications/init.js b/resources/skins.minerva.notifications/init.js index bef7f40..9d018ac 100644 --- a/resources/skins.minerva.notifications/init.js +++ b/resources/skins.minerva.notifications/init.js @@ -41,7 +41,7 @@ return false; }, // eslint-disable-next-line no-jquery/no-global-selector - el: $( '#secondary-button.user-button' ).parent() + el: $( '#user-notifications.user-button' ).parent() } ); overlayManager.add( /^\/notifications$/, showNotificationOverlay ); diff --git a/skin.json b/skin.json index e25583b..62a5768 100644 --- a/skin.json +++ b/skin.json @@ -531,7 +531,7 @@ "resources/skins.minerva.notifications.badge/NotificationBadge.js" ], "templates": { - "badge.mustache": "includes/skins/secondaryButton.mustache" + "badge.mustache": "includes/skins/userNotifications.mustache" }, "targets": [ "mobile", diff --git a/tests/phpunit/skins/SkinMinervaTest.php b/tests/phpunit/skins/SkinMinervaTest.php index 6a67f94..58d5b23 100644 --- a/tests/phpunit/skins/SkinMinervaTest.php +++ b/tests/phpunit/skins/SkinMinervaTest.php @@ -173,7 +173,7 @@ class SkinMinervaTest extends MediaWikiTestCase { * * @covers ::prepareUserNotificationsButton * @dataProvider providePrepareUserNotificationsButton - * @param array|string $expectedSecondaryButtonData Expected test case outcome + * @param array|string $expectedUserNotificationsData Expected test case outcome * @param string $message Test message * @param Title $title * @param bool $useEcho Whether to use Extension:Echo @@ -187,7 +187,7 @@ class SkinMinervaTest extends MediaWikiTestCase { * @param string|bool $formattedEchoNotificationCount */ public function testPrepareUserNotificationsButton( - $expectedSecondaryButtonData, $message, $title, $useEcho, $isUserLoggedIn, + $expectedUserNotificationsData, $message, $title, $useEcho, $isUserLoggedIn, $newtalks, $lastUnreadAlertTime = false, $lastUnreadMessageTime = false, $echoNotificationCount = false, $alertSeenTime = false, $msgSeenTime = false, $formattedEchoNotificationCount = false @@ -241,8 +241,8 @@ class SkinMinervaTest extends MediaWikiTestCase { $skin->prepareUserNotificationsButton( $tpl, $newtalks ); $this->assertEquals( - $expectedSecondaryButtonData, - $tpl->get( 'secondaryButtonData' ), + $expectedUserNotificationsData, + $tpl->get( 'userNotificationsData' ), $message ); } @@ -257,7 +257,7 @@ class SkinMinervaTest extends MediaWikiTestCase { * @param bool $hasUnseen * @return array */ - private function getSecondaryButtonExpectedResult( + private function getUserNotificationsExpectedResult( $title, $notificationsMsg, $notificationsTitle, @@ -295,7 +295,7 @@ class SkinMinervaTest extends MediaWikiTestCase { Title::newFromText( 'Special:Notifications' ), true, true, 'newtalks alert' ], - [ $this->getSecondaryButtonExpectedResult( + [ $this->getUserNotificationsExpectedResult( $title, 'Show my notifications', 'Notifications', @@ -311,7 +311,7 @@ class SkinMinervaTest extends MediaWikiTestCase { MWTimestamp::getInstance( strtotime( '2017-05-12T07:18:42Z' ) ), 110, '2017-05-11T20:28:11Z', '2017-05-11T20:28:11Z', '99+' ], - [ $this->getSecondaryButtonExpectedResult( + [ $this->getUserNotificationsExpectedResult( $title, 'Show my notifications', 'Notifications', @@ -327,7 +327,7 @@ class SkinMinervaTest extends MediaWikiTestCase { MWTimestamp::getInstance( strtotime( '2017-03-27T17:07:57Z' ) ), 3, '2017-03-25T00:17:44Z', '2017-03-28T19:00:42Z', '3' ], - [ $this->getSecondaryButtonExpectedResult( + [ $this->getUserNotificationsExpectedResult( $title, 'Show my notifications', 'Notifications', @@ -343,7 +343,7 @@ class SkinMinervaTest extends MediaWikiTestCase { MWTimestamp::getInstance( strtotime( '2017-04-10T15:12:31Z' ) ), 3, '2017-04-12T10:37:13Z', '2017-04-11T12:55:47Z', '3' ], - [ $this->getSecondaryButtonExpectedResult( + [ $this->getUserNotificationsExpectedResult( $title, 'Show my notifications', 'Notifications', @@ -359,7 +359,7 @@ class SkinMinervaTest extends MediaWikiTestCase { MWTimestamp::getInstance( strtotime( '2017-12-15T08:14:33Z' ) ), 5, '2017-12-21T18:07:24Z', '2017-12-19T16:55:52Z', '5' ], - [ $this->getSecondaryButtonExpectedResult( + [ $this->getUserNotificationsExpectedResult( $title, 'Show my notifications', 'Notifications', @@ -387,7 +387,7 @@ class SkinMinervaTest extends MediaWikiTestCase { $title, false, false, '' ], [ '', 'No Echo, logged in, no talk page alerts', $title, false, true, '' ], - [ $this->getSecondaryButtonExpectedResult( + [ $this->getUserNotificationsExpectedResult( $title, 'You have new messages on your talk page', 'Mytalk',