github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/ui/app/components/variable-paths.js (about)

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