open-nomad/ui/app/components/variable-paths.js
Phil Renaud d7def242b8
UI variables made to be unique by namespace and path (#14072)
* Starting on namespaced id

* Traversal for variables uniqued by namespace

* Delog

* Basic CRUD complete w namespaces included

* Correct secvar breadcrumb joining and testfix now that namespaces are included

* Testfixes with namespaces in place

* Namespace-aware duplicate path warning

* Duplicate path warning test additions

* Trimpath reimplemented on dupe check

* Solves a bug where slash was not being passed to the can write check

* PR fixes

* variable paths integration test fix now uses store

* Seems far less hacky in retrospect

* PR feedback addressed

* test fixes after inclusion of path as local non-model var

* Prevent confusion by dropping namespace from QPs on PUT, since its already in .data

* Solves a harsh bug where you have namespace access but no secvars access (#14098)

* Solves a harsh bug where you have namespace access but no secvars access

* Lint cleanup

* Remove unneeded condition
2022-08-15 11:56:09 -04:00

35 lines
896 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;
@service can;
/**
* @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, variable: { id, namespace } }) {
if (this.can.can('read variable', null, { path, namespace })) {
this.router.transitionTo('variables.variable', id);
}
}
}