mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-15 03:12:54 +03:00
156260343b
closes #5903, refs #5409 - switch alert/notification component tests from unit to integration where appropriate - rename `notifications.closeAll` to `notifications.clearAll` to better represent it's behaviour - add concept of a "key" to alerts/notifications and ability to close only specified keys through notifications service - close duplicate alerts/notifications before showing a new one - specify a key for all existing alerts - close failure alerts on successful retries - clear all currently displayed alerts on successful sign-in
50 lines
1.3 KiB
JavaScript
50 lines
1.3 KiB
JavaScript
import Ember from 'ember';
|
|
|
|
export default Ember.Component.extend({
|
|
tagName: 'article',
|
|
classNames: ['gh-notification', 'gh-notification-passive'],
|
|
classNameBindings: ['typeClass'],
|
|
|
|
message: null,
|
|
|
|
notifications: Ember.inject.service(),
|
|
|
|
typeClass: Ember.computed('message.type', function () {
|
|
var classes = '',
|
|
type = this.get('message.type'),
|
|
typeMapping;
|
|
|
|
typeMapping = {
|
|
success: 'green',
|
|
error: 'red',
|
|
warn: 'yellow'
|
|
};
|
|
|
|
if (typeMapping[type] !== undefined) {
|
|
classes += 'gh-notification-' + typeMapping[type];
|
|
}
|
|
|
|
return classes;
|
|
}),
|
|
|
|
didInsertElement: function () {
|
|
var self = this;
|
|
|
|
self.$().on('animationend webkitAnimationEnd oanimationend MSAnimationEnd', function (event) {
|
|
if (event.originalEvent.animationName === 'fade-out') {
|
|
self.get('notifications').closeNotification(self.get('message'));
|
|
}
|
|
});
|
|
},
|
|
|
|
willDestroyElement: function () {
|
|
this.$().off('animationend webkitAnimationEnd oanimationend MSAnimationEnd');
|
|
},
|
|
|
|
actions: {
|
|
closeNotification: function () {
|
|
this.get('notifications').closeNotification(this.get('message'));
|
|
}
|
|
}
|
|
});
|