github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/ui/app/controllers/jobs/job/versions.js (about)

     1  import Controller from '@ember/controller';
     2  import WithNamespaceResetting from 'nomad-ui/mixins/with-namespace-resetting';
     3  import { alias } from '@ember/object/computed';
     4  import { action, computed } from '@ember/object';
     5  import classic from 'ember-classic-decorator';
     6  
     7  const alertClassFallback = 'is-info';
     8  
     9  const errorLevelToAlertClass = {
    10    danger: 'is-danger',
    11    warn: 'is-warning',
    12  };
    13  
    14  @classic
    15  export default class VersionsController extends Controller.extend(
    16    WithNamespaceResetting
    17  ) {
    18    error = null;
    19  
    20    @alias('model') job;
    21  
    22    @computed('error.level')
    23    get errorLevelClass() {
    24      return (
    25        errorLevelToAlertClass[this.get('error.level')] || alertClassFallback
    26      );
    27    }
    28  
    29    onDismiss() {
    30      this.set('error', null);
    31    }
    32  
    33    @action
    34    handleError(errorObject) {
    35      this.set('error', errorObject);
    36    }
    37  }