2015-05-21 20:03:24 +03:00
|
|
|
import Ember from 'ember';
|
|
|
|
|
2016-01-19 16:03:27 +03:00
|
|
|
const {
|
|
|
|
Component,
|
|
|
|
computed,
|
|
|
|
inject: {service}
|
|
|
|
} = Ember;
|
2015-10-28 14:36:45 +03:00
|
|
|
|
|
|
|
export default Component.extend({
|
2015-05-21 20:03:24 +03:00
|
|
|
tagName: 'article',
|
2015-06-19 00:56:18 +03:00
|
|
|
classNames: ['gh-alert'],
|
2015-05-21 20:03:24 +03:00
|
|
|
classNameBindings: ['typeClass'],
|
|
|
|
|
2016-01-19 16:03:27 +03:00
|
|
|
notifications: service(),
|
2015-05-26 05:10:50 +03:00
|
|
|
|
2015-10-28 14:36:45 +03:00
|
|
|
typeClass: computed('message.type', function () {
|
|
|
|
let type = this.get('message.type');
|
|
|
|
let classes = '';
|
|
|
|
let typeMapping;
|
2015-06-19 00:56:18 +03:00
|
|
|
|
|
|
|
typeMapping = {
|
|
|
|
success: 'green',
|
|
|
|
error: 'red',
|
|
|
|
warn: 'yellow',
|
|
|
|
info: 'blue'
|
|
|
|
};
|
|
|
|
|
|
|
|
if (typeMapping[type] !== undefined) {
|
2015-10-28 14:36:45 +03:00
|
|
|
classes += `gh-alert-${typeMapping[type]}`;
|
2015-05-21 20:03:24 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return classes;
|
|
|
|
}),
|
|
|
|
|
|
|
|
actions: {
|
2015-10-28 14:36:45 +03:00
|
|
|
closeNotification() {
|
2015-05-26 05:10:50 +03:00
|
|
|
this.get('notifications').closeNotification(this.get('message'));
|
2015-05-21 20:03:24 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|