github.com/hernad/nomad@v1.6.112/ui/app/controllers/jobs/job/versions.js (about)

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