open-nomad/ui/app/routes/variables/path.js
2023-04-10 15:36:59 +00:00

26 lines
714 B
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
import Route from '@ember/routing/route';
import WithForbiddenState from 'nomad-ui/mixins/with-forbidden-state';
import notifyForbidden from 'nomad-ui/utils/notify-forbidden';
export default class VariablesPathRoute extends Route.extend(
WithForbiddenState
) {
model({ absolutePath }) {
if (this.modelFor('variables').errors) {
notifyForbidden(this)(this.modelFor('variables'));
} else {
const treeAtPath =
this.modelFor('variables').pathTree.findPath(absolutePath);
if (treeAtPath) {
return { treeAtPath, absolutePath };
} else {
return { absolutePath };
}
}
}
}