Ghost/core/client/app/components/gh-alert.js
Kevin Ansfield 7ac6ebb920 Refactor notifications service & components
issue #5409

- change persistent/passive notification status to alert/notification
- replace showSuccess/Info/Warn/Error with showNotification/showAlert
- fix and clean up notification/alert components
2015-07-28 12:26:11 +01:00

36 lines
837 B
JavaScript

import Ember from 'ember';
export default Ember.Component.extend({
tagName: 'article',
classNames: ['gh-alert'],
classNameBindings: ['typeClass'],
notifications: Ember.inject.service(),
typeClass: Ember.computed(function () {
var classes = '',
message = this.get('message'),
type = Ember.get(message, 'type'),
typeMapping;
typeMapping = {
success: 'green',
error: 'red',
warn: 'yellow',
info: 'blue'
};
if (typeMapping[type] !== undefined) {
classes += 'gh-alert-' + typeMapping[type];
}
return classes;
}),
actions: {
closeNotification: function () {
this.get('notifications').closeNotification(this.get('message'));
}
}
});