open-vault/ui/app/routes/vault/cluster/policy/show.js
Matthew Irish d509588cd2
Ember update (#5386)
Ember update - update ember-cli, ember-data, and ember to 3.4 series
2018-09-25 11:28:26 -05:00

34 lines
969 B
JavaScript

import { hash } from 'rsvp';
import Route from '@ember/routing/route';
import UnloadModelRoute from 'vault/mixins/unload-model-route';
export default Route.extend(UnloadModelRoute, {
beforeModel() {
const params = this.paramsFor(this.routeName);
let policyType = this.policyType();
if (policyType === 'acl' && params.policy_name === 'root') {
return this.transitionTo('vault.cluster.policies', 'acl');
}
},
model(params) {
let type = this.policyType();
return hash({
policy: this.store.findRecord(`policy/${type}`, params.policy_name),
capabilities: this.store.findRecord('capabilities', `sys/policies/${type}/${params.policy_name}`),
});
},
setupController(controller, model) {
controller.setProperties({
model: model.policy,
capabilities: model.capabilities,
policyType: this.policyType(),
});
},
policyType() {
return this.paramsFor('vault.cluster.policy').type;
},
});