jenkins-bot has submitted this change and it was merged.
Change subject: Default to alerts tab
......................................................................
Default to alerts tab
The only exception is when there are new message notifications but no new
alert notifications.
Bug: 70461
Change-Id: I06daa3f7d526beeb878eb343c169e01acd49e71f
---
M modules/overlay/ext.echo.overlay.js
M tests/qunit/overlay/test_ext.echo.overlay.js
2 files changed, 20 insertions(+), 71 deletions(-)
Approvals:
Bsitu: Looks good to me, approved
jenkins-bot: Verified
diff --git a/modules/overlay/ext.echo.overlay.js
b/modules/overlay/ext.echo.overlay.js
index c798570..4bf63e7 100644
--- a/modules/overlay/ext.echo.overlay.js
+++ b/modules/overlay/ext.echo.overlay.js
@@ -347,7 +347,20 @@
self.tabs.push( tab );
self.notificationCount.all +=
notifications[tabOptions.name].index.length;
} );
- this._activeTab = this.tabs[0];
+
+ if ( tabs.length === 1 ) {
+ // only one tab exists
+ this._activeTab = this.tabs[0];
+ } else if (
+ notifications.message.rawcount > 0 &&
+ notifications.alert.rawcount === 0
+ ) {
+ // if there are new messages and no new alerts
show the messages tab
+ this._activeTab = this.tabs[0];
+ } else {
+ // otherwise show the alerts tab
+ this._activeTab = this.tabs[1];
+ }
$overlay.prepend( this._getTitleElement() );
$overlay.append( this._getFooterElement() );
diff --git a/tests/qunit/overlay/test_ext.echo.overlay.js
b/tests/qunit/overlay/test_ext.echo.overlay.js
index b255915..cf20e70 100644
--- a/tests/qunit/overlay/test_ext.echo.overlay.js
+++ b/tests/qunit/overlay/test_ext.echo.overlay.js
@@ -158,22 +158,6 @@
false, 'The badge no longer indicates new messages.' );
} );
- QUnit.test( 'mw.echo.overlay.buildOverlay with messages', 5, function(
assert ) {
- var $overlay;
- this.sandbox.stub( mw.echo.overlay, 'api', new this.ApiStub(
'no-new-messages' ) );
- mw.echo.overlay.buildOverlay( function( $o ) {
- $overlay = $o;
- } );
- assert.strictEqual( $overlay.find( '.mw-echo-overlay-title ul
li' ).length, 2, 'There are two tabs in header' );
- assert.strictEqual( $overlay.find( '.mw-echo-notifications'
).length, 2, 'Overlay contains 2 lists of notifications.' );
- assert.strictEqual( $overlay.find( '.mw-echo-overlay-title a'
).eq( 0 ).hasClass( 'mw-ui-active' ),
- true, 'First tab is the selected tab upon opening.' );
- assert.strictEqual( this.$badge.text(),
- '1', 'The label stays as 1 until you switch tabs.' );
- assert.strictEqual( this.$badge.hasClass(
'mw-echo-unread-notifications' ),
- true, 'The notification button class is not updated
until you switch to alert tab.' );
- } );
-
QUnit.test( 'Switch tabs on overlay. No unread messages, 1 unread
alert.', 4, function( assert ) {
var $overlay, $tabs;
@@ -194,27 +178,6 @@
'0', 'The label is now set to 0.' );
assert.strictEqual( this.$badge.hasClass(
'mw-echo-unread-notifications' ),
false, 'There are now zero unread notifications.' );
- } );
-
- QUnit.test( 'Tabs have labels with counts in them.', 4, function(
assert ) {
- var $overlay, $tabs, beforeAlertText, afterAlertText;
-
- this.sandbox.stub( mw.echo.overlay, 'api', new this.ApiStub(
'no-new-messages' ) );
- mw.echo.overlay.buildOverlay( function( $o ) {
- $overlay = $o;
- $tabs = $overlay.find( '.mw-echo-overlay-title li a' );
- beforeAlertText = $overlay.find(
'.mw-echo-overlay-title li a' ).eq( 1 ).text();
- $tabs.eq( 1 ).trigger( 'click' );
- afterAlertText = $overlay.find( '.mw-echo-overlay-title
li a' ).eq( 1 ).text();
- } );
-
- // switch to 2nd tab
- $tabs = $overlay.find( '.mw-echo-overlay-title li a' );
- assert.strictEqual( $overlay.find( '.mw-echo-overlay-title li
a' ).eq( 0 ).text(), 'Messages (0)', 'Check the label has a count in it.' );
- assert.strictEqual( beforeAlertText, 'Alerts (1)', 'Check the
label has a count in it.' );
- assert.strictEqual( afterAlertText, 'Alerts (0)', 'Check the
label has an updated count in it.' );
- assert.strictEqual( $overlay.find( '.mw-echo-overlay-title li
a' ).eq( 1 ).hasClass( 'mw-ui-active' ),
- true, 'Second tab is the selected tab.' );
} );
QUnit.test( 'Unread message behaviour', 5, function( assert ) {
@@ -238,33 +201,6 @@
0, 'There are now no unread notifications in this tab.'
);
assert.strictEqual( $overlay.find( '.mw-echo-notifications >
button' ).length, 0,
'There are no notifications now so no need for button.'
);
- } );
-
- QUnit.test( 'Mark as read.', 8, function( assert ) {
- var $overlay;
- this.$badge.text( '8' );
- this.sandbox.stub( mw.echo.overlay, 'api', new this.ApiStub(
'with-new-messages' ) );
- mw.echo.overlay.buildOverlay( function( $o ) {
- $overlay = $o;
- } );
-
- // Test initial state
- assert.strictEqual( $overlay.find( '.mw-echo-overlay-title li
a' ).eq( 0 ).text(), 'Messages (7)',
- 'Check the label has a count in it and it is not
automatically reset when tab is open.' );
- assert.strictEqual( $overlay.find( '.mw-echo-unread' ).length,
8, 'There are 8 unread notifications.' );
- assert.strictEqual( this.$badge.text(), '8', '8 unread
notifications in badge.' );
- assert.strictEqual( $overlay.find( '.mw-echo-notifications li
button' ).length, 7,
- 'There are 7 mark as read button.' );
-
- // Click first mark as read
- $overlay.find( '.mw-echo-notifications li button' ).eq( 0
).trigger( 'click' );
-
- assert.strictEqual( $overlay.find( '.mw-echo-overlay-title li
a' ).eq( 0 ).text(), 'Messages (6)',
- 'Check the notification was marked as read.' );
- assert.strictEqual( $overlay.find( '.mw-echo-unread' ).length,
7, 'There are now 7 unread notifications.' );
- assert.strictEqual( $overlay.find( '.mw-echo-notifications li
button' ).length, 6,
- 'There are now 6 mark as read buttons.' );
- assert.strictEqual( this.$badge.text(), '7', 'Now 7 unread
notifications.' );
} );
QUnit.test( 'Tabs when there is overflow.', 2, function( assert ) {
@@ -291,17 +227,17 @@
// Test initial state
assert.strictEqual( $overlay.find( '.mw-echo-notifications'
).eq( 0 ).is( ':visible' ),
- true, 'First tab is visible.' );
+ false, 'First tab starts hidden.' );
assert.strictEqual( $overlay.find( '.mw-echo-notifications'
).eq( 1 ).is( ':visible' ),
- false, 'Second tab starts hidden.' );
+ true, 'Second tab is visible.' );
- // Switch to second tab
- $overlay.find( '.mw-echo-overlay-title li a' ).eq( 1 ).trigger(
'click' );
+ // Switch to first tab
+ $overlay.find( '.mw-echo-overlay-title li a' ).eq( 0 ).trigger(
'click' );
// check new tab visibility
assert.strictEqual( $overlay.find( '.mw-echo-notifications'
).eq( 0 ).is( ':visible' ),
- false, 'First tab is now hidden.' );
+ true, 'First tab is now visible.' );
assert.strictEqual( $overlay.find( '.mw-echo-notifications'
).eq( 1 ).is( ':visible' ),
- true, 'Second tab is now visible.' );
+ false, 'Second tab is now hidden.' );
} );
}( jQuery, mediaWiki ) );
--
To view, visit https://gerrit.wikimedia.org/r/158820
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I06daa3f7d526beeb878eb343c169e01acd49e71f
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/extensions/Echo
Gerrit-Branch: master
Gerrit-Owner: EBernhardson <[email protected]>
Gerrit-Reviewer: Bsitu <[email protected]>
Gerrit-Reviewer: EBernhardson <[email protected]>
Gerrit-Reviewer: Jdlrobson <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits