Ghost/ghost/admin/app/components/gh-alert.js

40 lines
982 B
JavaScript
Raw Normal View History

import Component from '@ember/component';
import classic from 'ember-classic-decorator';
import {action, computed} from '@ember/object';
import {classNameBindings, classNames, tagName} from '@ember-decorators/component';
import {inject as service} from '@ember/service';
@classic
@classNameBindings('typeClass')
@classNames('gh-alert')
@tagName('article')
export default class GhAlert extends Component {
@service
notifications;
@computed('message.type')
get typeClass() {
let type = this.get('message.type');
let classes = '';
let typeMapping;
typeMapping = {
success: 'green',
error: 'red',
warn: 'blue',
info: 'blue'
};
if (typeMapping[type] !== undefined) {
classes += `gh-alert-${typeMapping[type]}`;
2015-05-21 20:03:24 +03:00
}
return classes;
}
2015-05-21 20:03:24 +03:00
@action
closeNotification() {
this.notifications.closeNotification(this.message);
2015-05-21 20:03:24 +03:00
}
}