mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-02 08:13:34 +03:00
e021843e3f
no issue - migrated `notifications` service from EmberObject to true native class - switched to tracked properties and use of `TrackedArray` - swapped computed properties to getters - dropped unnecessary usage of `get` and `set` - migrated alert/notification related components to Glimmer components
37 lines
835 B
JavaScript
37 lines
835 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;
|
|
|
|
message = null;
|
|
|
|
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);
|
|
}
|
|
}
|