2017-08-22 10:53:26 +03:00
|
|
|
import Component from '@ember/component';
|
2022-02-01 12:34:03 +03:00
|
|
|
import classic from 'ember-classic-decorator';
|
|
|
|
import {action, computed} from '@ember/object';
|
|
|
|
import {classNameBindings, classNames, tagName} from '@ember-decorators/component';
|
2017-10-30 12:38:01 +03:00
|
|
|
import {inject as service} from '@ember/service';
|
2015-10-28 14:36:45 +03:00
|
|
|
|
2022-02-01 12:34:03 +03:00
|
|
|
@classic
|
|
|
|
@classNameBindings('typeClass')
|
|
|
|
@classNames('gh-alert')
|
|
|
|
@tagName('article')
|
|
|
|
export default class GhAlert extends Component {
|
|
|
|
@service
|
|
|
|
notifications;
|
2015-05-26 05:10:50 +03:00
|
|
|
|
2022-02-01 12:34:03 +03:00
|
|
|
@computed('message.type')
|
|
|
|
get typeClass() {
|
2015-10-28 14:36:45 +03:00
|
|
|
let type = this.get('message.type');
|
|
|
|
let classes = '';
|
|
|
|
let typeMapping;
|
2015-06-19 00:56:18 +03:00
|
|
|
|
|
|
|
typeMapping = {
|
|
|
|
success: 'green',
|
|
|
|
error: 'red',
|
2017-07-20 17:00:41 +03:00
|
|
|
warn: 'blue',
|
2015-06-19 00:56:18 +03:00
|
|
|
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;
|
2022-02-01 12:34:03 +03:00
|
|
|
}
|
2015-05-21 20:03:24 +03:00
|
|
|
|
2022-02-01 12:34:03 +03:00
|
|
|
@action
|
|
|
|
closeNotification() {
|
|
|
|
this.notifications.closeNotification(this.message);
|
2015-05-21 20:03:24 +03:00
|
|
|
}
|
2022-02-01 12:34:03 +03:00
|
|
|
}
|