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