github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/ui/app/controllers/variables/index.js (about)

     1  import Controller, { inject as controller } from '@ember/controller';
     2  import { inject as service } from '@ember/service';
     3  import { action } from '@ember/object';
     4  
     5  const ALL_NAMESPACE_WILDCARD = '*';
     6  
     7  export default class VariablesIndexController extends Controller {
     8    @service router;
     9    @service store;
    10  
    11    isForbidden = false;
    12  
    13    @action
    14    goToVariable(variable) {
    15      this.router.transitionTo('variables.variable', variable.path);
    16    }
    17  
    18    @controller variables;
    19  
    20    @action
    21    setNamespace(namespace) {
    22      this.variables.setNamespace(namespace);
    23    }
    24  
    25    get namespaceSelection() {
    26      return this.variables.qpNamespace;
    27    }
    28  
    29    get hasVariables() {
    30      return this.model.variables.length;
    31    }
    32  
    33    get root() {
    34      return this.model.root;
    35    }
    36  
    37    get namespaceOptions() {
    38      const namespaces = this.store
    39        .peekAll('namespace')
    40        .map(({ name }) => ({ key: name, label: name }));
    41  
    42      if (namespaces.length <= 1) return null;
    43  
    44      // Create default namespace selection
    45      namespaces.unshift({
    46        key: ALL_NAMESPACE_WILDCARD,
    47        label: 'All (*)',
    48      });
    49  
    50      return namespaces;
    51    }
    52  }