mirror of
https://github.com/nasa/openmct.git
synced 2025-06-22 17:08:57 +00:00
Notebook saved link (#2998)
* https://github.com/nasa/openmct/issues/2859 * create and store link to default notebook in storage and pass it to notification. * [Notebook] Add link to notebook inside 'Saved to Notebook' notification #2860 * Added custom autoDismissTimeout for into notifications. * Backwards compatibility fix for old notebook model without link in metadata. * lint fixes * added JS Doc description for API changes + changed property names to appropriate function. * fixed bug due to merging. * fixed url update loop Co-authored-by: Andrew Henry <akhenry@gmail.com>
This commit is contained in:
@ -75,13 +75,20 @@ export default class NotificationAPI extends EventEmitter {
|
||||
* Info notifications are low priority informational messages for the user. They will be auto-destroy after a brief
|
||||
* period of time.
|
||||
* @param {string} message The message to display to the user
|
||||
* @param {Object} [options] object with following properties
|
||||
* autoDismissTimeout: {number} in miliseconds to automatically dismisses notification
|
||||
* link: {Object} Add a link to notifications for navigation
|
||||
* onClick: callback function
|
||||
* cssClass: css class name to add style on link
|
||||
* text: text to display for link
|
||||
* @returns {InfoNotification}
|
||||
*/
|
||||
info(message) {
|
||||
info(message, options = {}) {
|
||||
let notificationModel = {
|
||||
message: message,
|
||||
autoDismiss: true,
|
||||
severity: "info"
|
||||
severity: "info",
|
||||
options
|
||||
};
|
||||
|
||||
return this._notify(notificationModel);
|
||||
@ -90,12 +97,19 @@ export default class NotificationAPI extends EventEmitter {
|
||||
/**
|
||||
* Present an alert to the user.
|
||||
* @param {string} message The message to display to the user.
|
||||
* @param {Object} [options] object with following properties
|
||||
* autoDismissTimeout: {number} in miliseconds to automatically dismisses notification
|
||||
* link: {Object} Add a link to notifications for navigation
|
||||
* onClick: callback function
|
||||
* cssClass: css class name to add style on link
|
||||
* text: text to display for link
|
||||
* @returns {Notification}
|
||||
*/
|
||||
alert(message) {
|
||||
alert(message, options = {}) {
|
||||
let notificationModel = {
|
||||
message: message,
|
||||
severity: "alert"
|
||||
severity: "alert",
|
||||
options
|
||||
};
|
||||
|
||||
return this._notify(notificationModel);
|
||||
@ -104,12 +118,19 @@ export default class NotificationAPI extends EventEmitter {
|
||||
/**
|
||||
* Present an error message to the user
|
||||
* @param {string} message
|
||||
* @param {Object} [options] object with following properties
|
||||
* autoDismissTimeout: {number} in miliseconds to automatically dismisses notification
|
||||
* link: {Object} Add a link to notifications for navigation
|
||||
* onClick: callback function
|
||||
* cssClass: css class name to add style on link
|
||||
* text: text to display for link
|
||||
* @returns {Notification}
|
||||
*/
|
||||
error(message) {
|
||||
error(message, options = {}) {
|
||||
let notificationModel = {
|
||||
message: message,
|
||||
severity: "error"
|
||||
severity: "error",
|
||||
options
|
||||
};
|
||||
|
||||
return this._notify(notificationModel);
|
||||
@ -325,9 +346,11 @@ export default class NotificationAPI extends EventEmitter {
|
||||
this.emit('notification', notification);
|
||||
|
||||
if (notification.model.autoDismiss || this._selectNextNotification()) {
|
||||
const autoDismissTimeout = notification.model.options.autoDismissTimeout
|
||||
|| DEFAULT_AUTO_DISMISS_TIMEOUT;
|
||||
this.activeTimeout = setTimeout(() => {
|
||||
this._dismissOrMinimize(notification);
|
||||
}, DEFAULT_AUTO_DISMISS_TIMEOUT);
|
||||
}, autoDismissTimeout);
|
||||
} else {
|
||||
delete this.activeTimeout;
|
||||
}
|
||||
|
Reference in New Issue
Block a user