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

     1  import Controller, { inject as controller } from '@ember/controller';
     2  import { action } from '@ember/object';
     3  
     4  const ALL_NAMESPACE_WILDCARD = '*';
     5  
     6  export default class VariablesPathController extends Controller {
     7    get absolutePath() {
     8      return this.model?.absolutePath || '';
     9    }
    10    get breadcrumbs() {
    11      if (this.absolutePath) {
    12        let crumbs = [];
    13        this.absolutePath.split('/').reduce((m, n) => {
    14          crumbs.push({
    15            label: n,
    16            args: [`variables.path`, m + n],
    17          });
    18          return m + n + '/';
    19        }, []);
    20        return crumbs;
    21      } else {
    22        return [];
    23      }
    24    }
    25  
    26    @controller variables;
    27  
    28    @action
    29    setNamespace(namespace) {
    30      this.variables.setNamespace(namespace);
    31    }
    32  
    33    get namespaceSelection() {
    34      return this.variables.qpNamespace;
    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  }