open-nomad/ui/app/controllers/jobs/job/versions.js

38 lines
821 B
JavaScript
Raw Normal View History

import Controller from '@ember/controller';
import WithNamespaceResetting from 'nomad-ui/mixins/with-namespace-resetting';
2018-07-11 16:34:22 +00:00
import { alias } from '@ember/object/computed';
import { action, computed } from '@ember/object';
import classic from 'ember-classic-decorator';
2017-09-19 14:47:10 +00:00
const alertClassFallback = 'is-info';
const errorLevelToAlertClass = {
danger: 'is-danger',
warn: 'is-warning',
};
@classic
2021-12-28 16:08:12 +00:00
export default class VersionsController extends Controller.extend(
WithNamespaceResetting
) {
error = null;
@alias('model') job;
@computed('error.level')
get errorLevelClass() {
2021-12-28 16:08:12 +00:00
return (
errorLevelToAlertClass[this.get('error.level')] || alertClassFallback
);
}
onDismiss() {
this.set('error', null);
}
@action
handleError(errorObject) {
this.set('error', errorObject);
}
}