mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-28 01:30:15 +00:00
Limit 2 secondary actions outside the menu
If there are more than 2 prioritized actions, put those actions in the dotdotdot menu. Also, correct the name of a variable from "isInsideMenu" to what it actually represents, which is, in fact, "isOutsideMenu" Bug: T126617 Bug: T125949 Change-Id: I95fcae8f822e51d9353599c09f1550797e4ad673
This commit is contained in:
parent
95681a694c
commit
ce354678b4
|
@ -16,7 +16,8 @@
|
||||||
* @cfg {boolean} [bundle=false] This notification item is part of a bundle.
|
* @cfg {boolean} [bundle=false] This notification item is part of a bundle.
|
||||||
*/
|
*/
|
||||||
mw.echo.ui.NotificationItemWidget = function MwEchoUiNotificationItemWidget( controller, model, config ) {
|
mw.echo.ui.NotificationItemWidget = function MwEchoUiNotificationItemWidget( controller, model, config ) {
|
||||||
var i, secondaryUrls, urlObj, linkButton, $icon, isInsideMenu, echoMoment,
|
var i, secondaryUrls, urlObj, linkButton, $icon, isOutsideMenu, echoMoment,
|
||||||
|
outsideMenuItemCounter = 0,
|
||||||
$message = $( '<div>' ).addClass( 'mw-echo-ui-notificationItemWidget-content-message' );
|
$message = $( '<div>' ).addClass( 'mw-echo-ui-notificationItemWidget-content-message' );
|
||||||
|
|
||||||
config = config || {};
|
config = config || {};
|
||||||
|
@ -120,7 +121,11 @@
|
||||||
for ( i = 0; i < secondaryUrls.length; i++ ) {
|
for ( i = 0; i < secondaryUrls.length; i++ ) {
|
||||||
urlObj = secondaryUrls[ i ];
|
urlObj = secondaryUrls[ i ];
|
||||||
|
|
||||||
isInsideMenu = !this.bundle && urlObj.prioritized !== undefined;
|
// Items are placed outside the dotdotdot menu if they are
|
||||||
|
// prioritized explicitly, *except* for items inside a bundle
|
||||||
|
// (where all actions are inside the menu) or there are more than
|
||||||
|
// two prioritized actions (all others go into the menu)
|
||||||
|
isOutsideMenu = !this.bundle && urlObj.prioritized !== undefined && outsideMenuItemCounter < 2;
|
||||||
|
|
||||||
linkButton = new mw.echo.ui.MenuItemWidget( {
|
linkButton = new mw.echo.ui.MenuItemWidget( {
|
||||||
icon: urlObj.icon || 'next',
|
icon: urlObj.icon || 'next',
|
||||||
|
@ -128,15 +133,18 @@
|
||||||
tooltip: urlObj.tooltip,
|
tooltip: urlObj.tooltip,
|
||||||
description: urlObj.description,
|
description: urlObj.description,
|
||||||
url: urlObj.url,
|
url: urlObj.url,
|
||||||
prioritized: isInsideMenu
|
prioritized: isOutsideMenu
|
||||||
} );
|
} );
|
||||||
|
|
||||||
if ( isInsideMenu ) {
|
// Limit to 2 items outside the menu
|
||||||
|
if ( isOutsideMenu ) {
|
||||||
this.actionsButtonSelectWidget.addItems( [ linkButton ] );
|
this.actionsButtonSelectWidget.addItems( [ linkButton ] );
|
||||||
|
outsideMenuItemCounter++;
|
||||||
} else {
|
} else {
|
||||||
this.menuPopupButtonWidget.getMenu().addItems( [ linkButton ] );
|
this.menuPopupButtonWidget.getMenu().addItems( [ linkButton ] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add a "mark as read" secondary action
|
// Add a "mark as read" secondary action
|
||||||
this.toggleReadSecondaryButton = new mw.echo.ui.MenuItemWidget( {
|
this.toggleReadSecondaryButton = new mw.echo.ui.MenuItemWidget( {
|
||||||
data: 'toggleRead',
|
data: 'toggleRead',
|
||||||
|
|
Loading…
Reference in a new issue