2022-06-07 01:42:23 +00:00
|
|
|
// @ts-check
|
|
|
|
import Component from '@glimmer/component';
|
|
|
|
import { action } from '@ember/object';
|
|
|
|
import { inject as service } from '@ember/service';
|
2022-06-17 18:03:43 +00:00
|
|
|
import compactPath from '../utils/compact-path';
|
2022-06-07 01:42:23 +00:00
|
|
|
export default class VariablePathsComponent extends Component {
|
|
|
|
@service router;
|
2022-08-09 17:17:55 +00:00
|
|
|
@service can;
|
2022-06-07 01:42:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @returns {Array<Object.<string, Object>>}
|
|
|
|
*/
|
|
|
|
get folders() {
|
2022-06-17 18:03:43 +00:00
|
|
|
return Object.entries(this.args.branch.children).map(([name]) => {
|
|
|
|
return compactPath(this.args.branch.children[name], name);
|
2022-06-07 01:42:23 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
get files() {
|
|
|
|
return this.args.branch.files;
|
|
|
|
}
|
|
|
|
|
|
|
|
@action
|
|
|
|
async handleFolderClick(path) {
|
|
|
|
this.router.transitionTo('variables.path', path);
|
|
|
|
}
|
|
|
|
|
|
|
|
@action
|
2022-08-15 15:56:09 +00:00
|
|
|
async handleFileClick({ path, variable: { id, namespace } }) {
|
2022-08-09 17:17:55 +00:00
|
|
|
if (this.can.can('read variable', null, { path, namespace })) {
|
2022-08-15 15:56:09 +00:00
|
|
|
this.router.transitionTo('variables.variable', id);
|
2022-08-09 17:17:55 +00:00
|
|
|
}
|
2022-06-07 01:42:23 +00:00
|
|
|
}
|
|
|
|
}
|