open-nomad/ui/app/controllers/jobs/job/versions.js
2023-04-10 15:36:59 +00:00

43 lines
899 B
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
import Controller from '@ember/controller';
import WithNamespaceResetting from 'nomad-ui/mixins/with-namespace-resetting';
import { alias } from '@ember/object/computed';
import { action, computed } from '@ember/object';
import classic from 'ember-classic-decorator';
const alertClassFallback = 'is-info';
const errorLevelToAlertClass = {
danger: 'is-danger',
warn: 'is-warning',
};
@classic
export default class VersionsController extends Controller.extend(
WithNamespaceResetting
) {
error = null;
@alias('model') job;
@computed('error.level')
get errorLevelClass() {
return (
errorLevelToAlertClass[this.get('error.level')] || alertClassFallback
);
}
onDismiss() {
this.set('error', null);
}
@action
handleError(errorObject) {
this.set('error', errorObject);
}
}