github.com/hernad/nomad@v1.6.112/ui/app/controllers/variables/path.js (about)

     1  /**
     2   * Copyright (c) HashiCorp, Inc.
     3   * SPDX-License-Identifier: MPL-2.0
     4   */
     5  
     6  import Controller, { inject as controller } from '@ember/controller';
     7  import { inject as service } from '@ember/service';
     8  import { action } from '@ember/object';
     9  
    10  const ALL_NAMESPACE_WILDCARD = '*';
    11  
    12  export default class VariablesPathController extends Controller {
    13    @service router;
    14  
    15    get absolutePath() {
    16      return this.model?.absolutePath || '';
    17    }
    18    get breadcrumbs() {
    19      if (this.absolutePath) {
    20        let crumbs = [];
    21        this.absolutePath.split('/').reduce((m, n) => {
    22          crumbs.push({
    23            label: n,
    24            args: [`variables.path`, m + n],
    25          });
    26          return m + n + '/';
    27        }, []);
    28        return crumbs;
    29      } else {
    30        return [];
    31      }
    32    }
    33  
    34    @action goToNewVariable() {
    35      this.router.transitionTo('variables.new', {
    36        queryParams: { path: `${this.absolutePath}/` },
    37      });
    38    }
    39  
    40    @controller variables;
    41  
    42    @action
    43    setNamespace(namespace) {
    44      this.variables.setNamespace(namespace);
    45    }
    46  
    47    get namespaceSelection() {
    48      return this.variables.qpNamespace;
    49    }
    50  
    51    get namespaceOptions() {
    52      const namespaces = this.store
    53        .peekAll('namespace')
    54        .map(({ name }) => ({ key: name, label: name }));
    55  
    56      if (namespaces.length <= 1) return null;
    57  
    58      // Create default namespace selection
    59      namespaces.unshift({
    60        key: ALL_NAMESPACE_WILDCARD,
    61        label: 'All (*)',
    62      });
    63  
    64      return namespaces;
    65    }
    66  }