mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-30 11:54:33 +03:00
7356bfbcd9
refs e021843e3f
- fixed closing of alerts due to missing `.args` after migrating to glimmer syntax
- updated related tests for glimmer component syntax
35 lines
814 B
JavaScript
35 lines
814 B
JavaScript
import Component from '@glimmer/component';
|
|
import {action} from '@ember/object';
|
|
import {inject as service} from '@ember/service';
|
|
|
|
export default class GhNotification extends Component {
|
|
@service notifications;
|
|
|
|
get typeClass() {
|
|
const typeMapping = {
|
|
error: 'red',
|
|
warn: 'yellow'
|
|
};
|
|
|
|
const type = this.args.message.type;
|
|
let classes = '';
|
|
if (typeMapping[type] !== undefined) {
|
|
classes += `gh-notification-${typeMapping[type]}`;
|
|
}
|
|
|
|
return classes;
|
|
}
|
|
|
|
@action
|
|
closeOnFadeOut(event) {
|
|
if (event.animationName === 'fade-out') {
|
|
this.closeNotification();
|
|
}
|
|
}
|
|
|
|
@action
|
|
closeNotification() {
|
|
this.notifications.closeNotification(this.args.message);
|
|
}
|
|
}
|