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 GhAlert extends Component {
|
2022-02-01 20:03:45 +03:00
|
|
|
@service notifications;
|
2015-05-26 05:10:50 +03:00
|
|
|
|
2022-02-01 12:34:03 +03:00
|
|
|
get typeClass() {
|
2022-05-25 14:43:02 +03:00
|
|
|
const typeMapping = {
|
2015-06-19 00:56:18 +03:00
|
|
|
success: 'green',
|
|
|
|
error: 'red',
|
2017-07-20 17:00:41 +03:00
|
|
|
warn: 'blue',
|
2015-06-19 00:56:18 +03:00
|
|
|
info: 'blue'
|
|
|
|
};
|
|
|
|
|
2022-05-25 14:43:02 +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-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() {
|
2022-05-25 14:43:02 +03:00
|
|
|
this.notifications.closeNotification(this.args.message);
|
2015-05-21 20:03:24 +03:00
|
|
|
}
|
2022-02-01 12:34:03 +03:00
|
|
|
}
|