Ghost/ghost/admin/app/components/gh-alert.js
Kevin Ansfield e021843e3f Migrated notifications to Octane patterns
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
2022-05-25 12:16:37 +01:00

32 lines
722 B
JavaScript

import Component from '@glimmer/component';
import {action} from '@ember/object';
import {inject as service} from '@ember/service';
export default class GhAlert extends Component {
@service notifications;
get typeClass() {
let type = this.args.message.type;
let classes = '';
let typeMapping;
typeMapping = {
success: 'green',
error: 'red',
warn: 'blue',
info: 'blue'
};
if (typeMapping[type] !== undefined) {
classes += `gh-alert-${typeMapping[type]}`;
}
return classes;
}
@action
closeNotification() {
this.notifications.closeNotification(this.message);
}
}