mirror of
https://github.com/nasa/openmct.git
synced 2025-05-06 02:28:21 +00:00
[Notifications] Remove custom autoDismiss
This commit is contained in:
parent
c9ac85089a
commit
d63c401e44
@ -61,7 +61,7 @@ define(
|
|||||||
* @property {boolean} [unknownProgress] a boolean indicating that the
|
* @property {boolean} [unknownProgress] a boolean indicating that the
|
||||||
* progress of the underlying task is unknown. This will result in a
|
* progress of the underlying task is unknown. This will result in a
|
||||||
* visually distinct progress bar.
|
* visually distinct progress bar.
|
||||||
* @property {boolean | number} [autoDismiss] If truthy, dialog will
|
* @property {boolean} [autoDismiss] If truthy, dialog will
|
||||||
* be automatically minimized or dismissed (depending on severity).
|
* be automatically minimized or dismissed (depending on severity).
|
||||||
* Additionally, if the provided value is a number, it will be used
|
* Additionally, if the provided value is a number, it will be used
|
||||||
* as the delay period before being dismissed.
|
* as the delay period before being dismissed.
|
||||||
@ -384,9 +384,7 @@ define(
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
NotificationService.prototype.setActiveNotification = function (notification) {
|
NotificationService.prototype.setActiveNotification = function (notification) {
|
||||||
var timeout;
|
|
||||||
var shouldAutoDismiss;
|
var shouldAutoDismiss;
|
||||||
var usesCustomTimeout;
|
|
||||||
this.active.notification = notification;
|
this.active.notification = notification;
|
||||||
|
|
||||||
if (!notification) {
|
if (!notification) {
|
||||||
@ -394,19 +392,16 @@ define(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
usesCustomTimeout = typeof notification.model.autoDismiss === "number";
|
if (notification.model.severity === "info") {
|
||||||
|
|
||||||
if (notification.model.severity === "info" || usesCustomTimeout) {
|
|
||||||
shouldAutoDismiss = true;
|
shouldAutoDismiss = true;
|
||||||
} else {
|
} else {
|
||||||
shouldAutoDismiss = notification.model.autoDismiss;
|
shouldAutoDismiss = notification.model.autoDismiss;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shouldAutoDismiss || this.selectNextNotification()) {
|
if (shouldAutoDismiss || this.selectNextNotification()) {
|
||||||
timeout = usesCustomTimeout ? notification.model.autoDismiss : this.AUTO_DISMISS_TIMEOUT;
|
|
||||||
this.active.timeout = this.$timeout(function () {
|
this.active.timeout = this.$timeout(function () {
|
||||||
notification.dismissOrMinimize();
|
notification.dismissOrMinimize();
|
||||||
}, timeout);
|
}, this.AUTO_DISMISS_TIMEOUT);
|
||||||
} else {
|
} else {
|
||||||
delete this.active.timeout;
|
delete this.active.timeout;
|
||||||
}
|
}
|
||||||
|
@ -118,17 +118,6 @@ define(
|
|||||||
expect(notificationService.getActiveNotification()).toBeUndefined();
|
expect(notificationService.getActiveNotification()).toBeUndefined();
|
||||||
expect(notificationService.notifications.length).toEqual(0);
|
expect(notificationService.notifications.length).toEqual(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("uses a custom auto-dismiss timeout value if provided", function () {
|
|
||||||
var timeoutValueInModel = 1500;
|
|
||||||
var timeoutValueUsedByService = 0;
|
|
||||||
mockTimeout.andCallFake(function (callback, timeout) {
|
|
||||||
timeoutValueUsedByService = timeout;
|
|
||||||
});
|
|
||||||
infoModel.autoDismiss = timeoutValueInModel;
|
|
||||||
notificationService.info(infoModel);
|
|
||||||
expect(timeoutValueUsedByService).toEqual(timeoutValueInModel);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("when receiving alert notifications", function () {
|
describe("when receiving alert notifications", function () {
|
||||||
@ -162,17 +151,6 @@ define(
|
|||||||
expect(notificationService.notifications.length).toEqual(1);
|
expect(notificationService.notifications.length).toEqual(1);
|
||||||
expect(notificationService.notifications[0]).toEqual(notification);
|
expect(notificationService.notifications[0]).toEqual(notification);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("uses a custom auto-dismiss timeout value if provided", function () {
|
|
||||||
var timeoutValueInModel = 1500;
|
|
||||||
var timeoutValueUsedByService = 0;
|
|
||||||
mockTimeout.andCallFake(function (callback, timeout) {
|
|
||||||
timeoutValueUsedByService = timeout;
|
|
||||||
});
|
|
||||||
alertModel.autoDismiss = timeoutValueInModel;
|
|
||||||
notificationService.alert(alertModel);
|
|
||||||
expect(timeoutValueUsedByService).toEqual(timeoutValueInModel);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("when receiving error notifications", function () {
|
describe("when receiving error notifications", function () {
|
||||||
@ -206,17 +184,6 @@ define(
|
|||||||
expect(notificationService.notifications.length).toEqual(1);
|
expect(notificationService.notifications.length).toEqual(1);
|
||||||
expect(notificationService.notifications[0]).toEqual(notification);
|
expect(notificationService.notifications[0]).toEqual(notification);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("uses a custom auto-dismiss timeout value if provided", function () {
|
|
||||||
var timeoutValueInModel = 1500;
|
|
||||||
var timeoutValueUsedByService = 0;
|
|
||||||
mockTimeout.andCallFake(function (callback, timeout) {
|
|
||||||
timeoutValueUsedByService = timeout;
|
|
||||||
});
|
|
||||||
errorModel.autoDismiss = timeoutValueInModel;
|
|
||||||
notificationService.error(errorModel);
|
|
||||||
expect(timeoutValueUsedByService).toEqual(timeoutValueInModel);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("when called with multiple notifications", function () {
|
describe("when called with multiple notifications", function () {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user