d7def242b8
* 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
43 lines
1,021 B
JavaScript
43 lines
1,021 B
JavaScript
import Route from '@ember/routing/route';
|
|
import { inject as service } from '@ember/service';
|
|
import WithForbiddenState from 'nomad-ui/mixins/with-forbidden-state';
|
|
import notifyForbidden from 'nomad-ui/utils/notify-forbidden';
|
|
import PathTree from 'nomad-ui/utils/path-tree';
|
|
|
|
export default class VariablesRoute extends Route.extend(WithForbiddenState) {
|
|
@service can;
|
|
@service router;
|
|
@service store;
|
|
|
|
queryParams = {
|
|
qpNamespace: {
|
|
refreshModel: true,
|
|
},
|
|
};
|
|
|
|
beforeModel() {
|
|
if (this.can.cannot('list variables')) {
|
|
this.router.transitionTo('/jobs');
|
|
}
|
|
}
|
|
|
|
async model({ qpNamespace }) {
|
|
const namespace = qpNamespace ?? '*';
|
|
try {
|
|
await this.store.findAll('namespace');
|
|
const variables = await this.store.query(
|
|
'variable',
|
|
{ namespace },
|
|
{ reload: true }
|
|
);
|
|
return {
|
|
variables,
|
|
pathTree: new PathTree(variables),
|
|
};
|
|
} catch (e) {
|
|
notifyForbidden(this)(e);
|
|
return e;
|
|
}
|
|
}
|
|
}
|