open-nomad/ui/app/components/variable-paths.js
Phil Renaud 4c58356af1 Path Tree compaction refactor (#13415)
* Bones of a just-in-time compaction pathTree

* wooo got compaction going in sub-ms times

* PR cleanup

* Path compaction tests

* lint fix to equal instead of .ok()

* Name prop specifically being equality checked
2022-07-11 13:34:05 -04:00

32 lines
773 B
JavaScript

// @ts-check
import Component from '@glimmer/component';
import { action } from '@ember/object';
import { inject as service } from '@ember/service';
import compactPath from '../utils/compact-path';
export default class VariablePathsComponent extends Component {
@service router;
/**
* @returns {Array<Object.<string, Object>>}
*/
get folders() {
return Object.entries(this.args.branch.children).map(([name]) => {
return compactPath(this.args.branch.children[name], name);
});
}
get files() {
return this.args.branch.files;
}
@action
async handleFolderClick(path) {
this.router.transitionTo('variables.path', path);
}
@action
async handleFileClick(path) {
this.router.transitionTo('variables.variable', path);
}
}