mirror of
https://github.com/ascribe/onion.git
synced 2024-12-22 17:33:14 +01:00
Ignore global notifications that do not contain a message
This commit is contained in:
parent
dcdae7b7b1
commit
4cd093aaa8
@ -26,11 +26,13 @@ let CreateEditionsForm = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
handleSuccess(response) {
|
handleSuccess(response) {
|
||||||
let notification = new GlobalNotificationModel(response.notification, 'success', 10000);
|
const { handleSuccess } = this.props;
|
||||||
|
|
||||||
|
const notification = new GlobalNotificationModel(response.notification, 'success', 10000);
|
||||||
GlobalNotificationActions.appendGlobalNotification(notification);
|
GlobalNotificationActions.appendGlobalNotification(notification);
|
||||||
|
|
||||||
if(this.props.handleSuccess) {
|
if (typeof handleSuccess === 'function') {
|
||||||
this.props.handleSuccess(response);
|
handleSuccess(response);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -2,16 +2,19 @@
|
|||||||
|
|
||||||
export default class GlobalNotificationModel {
|
export default class GlobalNotificationModel {
|
||||||
constructor(message, type = 'info', dismissAfter = 5000) {
|
constructor(message, type = 'info', dismissAfter = 5000) {
|
||||||
if(message) {
|
if (message) {
|
||||||
this.message = message;
|
this.message = message;
|
||||||
} else {
|
} else {
|
||||||
throw new Error('A notifications message must be defined.');
|
console.logGlobal(new Error('Global notification did not contain a message and was ignored'), {
|
||||||
|
dismissAfter,
|
||||||
|
type
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if(type === 'info' || type === 'success' || type === 'warning' || type === 'danger') {
|
if (type === 'info' || type === 'success' || type === 'warning' || type === 'danger') {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
} else {
|
} else {
|
||||||
throw new Error('A notification\'s type either has to be info, success, warning, danger. Not: ' + type);
|
throw new Error(`A notification's type either has to be info, success, warning, danger. Not: ${type}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.dismissAfter = dismissAfter;
|
this.dismissAfter = dismissAfter;
|
||||||
|
@ -16,10 +16,12 @@ class GlobalNotificationStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onAppendGlobalNotification(newNotification) {
|
onAppendGlobalNotification(newNotification) {
|
||||||
this.notificationQueue.push(newNotification);
|
if (newNotification && newNotification.message) {
|
||||||
|
this.notificationQueue.push(newNotification);
|
||||||
|
|
||||||
if (!this.notificationsPaused && this.notificationStatus === 'ready') {
|
if (!this.notificationsPaused && this.notificationStatus === 'ready') {
|
||||||
this.showNextNotification();
|
this.showNextNotification();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user