github.com/hernad/nomad@v1.6.112/ui/app/components/variable-paths.js (about)

     1  /**
     2   * Copyright (c) HashiCorp, Inc.
     3   * SPDX-License-Identifier: MPL-2.0
     4   */
     5  
     6  // @ts-check
     7  import Component from '@glimmer/component';
     8  import { action } from '@ember/object';
     9  import { inject as service } from '@ember/service';
    10  import compactPath from '../utils/compact-path';
    11  export default class VariablePathsComponent extends Component {
    12    @service router;
    13    @service can;
    14  
    15    /**
    16     * @returns {Array<Object.<string, Object>>}
    17     */
    18    get folders() {
    19      return Object.entries(this.args.branch.children).map(([name]) => {
    20        return compactPath(this.args.branch.children[name], name);
    21      });
    22    }
    23  
    24    get files() {
    25      return this.args.branch.files;
    26    }
    27  
    28    @action
    29    async handleFolderClick(path) {
    30      this.router.transitionTo('variables.path', path);
    31    }
    32  
    33    @action
    34    async handleFileClick({ path, variable: { id, namespace } }) {
    35      if (this.can.can('read variable', null, { path, namespace })) {
    36        this.router.transitionTo('variables.variable', id);
    37      }
    38    }
    39  }