2022-05-25 14:16:31 +03:00
|
|
|
import Component from '@glimmer/component';
|
|
|
|
import {action} from '@ember/object';
|
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
|
|
|
export default class GhNotification extends Component {
|
2022-02-01 20:03:45 +03:00
|
|
|
@service notifications;
|
2018-01-11 20:43:23 +03:00
|
|
|
|
2022-02-01 12:34:03 +03:00
|
|
|
get typeClass() {
|
2022-05-25 14:16:31 +03:00
|
|
|
const typeMapping = {
|
2015-06-19 00:56:18 +03:00
|
|
|
error: 'red',
|
|
|
|
warn: 'yellow'
|
|
|
|
};
|
2014-07-09 08:17:30 +04:00
|
|
|
|
2022-05-25 14:16:31 +03:00
|
|
|
const type = this.args.message.type;
|
|
|
|
let classes = '';
|
2015-06-19 00:56:18 +03:00
|
|
|
if (typeMapping[type] !== undefined) {
|
2015-10-28 14:36:45 +03:00
|
|
|
classes += `gh-notification-${typeMapping[type]}`;
|
2014-07-09 08:17:30 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return classes;
|
2022-02-01 12:34:03 +03:00
|
|
|
}
|
2014-07-09 08:17:30 +04:00
|
|
|
|
2022-05-25 14:16:31 +03:00
|
|
|
@action
|
|
|
|
closeOnFadeOut(event) {
|
|
|
|
if (event.animationName === 'fade-out') {
|
|
|
|
this.closeNotification();
|
|
|
|
}
|
2022-02-01 12:34:03 +03:00
|
|
|
}
|
2015-06-19 00:56:18 +03:00
|
|
|
|
2022-02-01 12:34:03 +03:00
|
|
|
@action
|
|
|
|
closeNotification() {
|
2022-05-25 14:16:31 +03:00
|
|
|
this.notifications.closeNotification(this.args.message);
|
2014-03-22 16:08:15 +04:00
|
|
|
}
|
2022-02-01 12:34:03 +03:00
|
|
|
}
|