open-vault/ui/app/routes/vault/cluster/policy.js
madalynrose 554446ae4e
Licensing in the UI (#5437)
Add licensing to the UI
2018-10-12 15:03:01 -04:00

27 lines
760 B
JavaScript

import { inject as service } from '@ember/service';
import Route from '@ember/routing/route';
import ClusterRoute from 'vault/mixins/cluster-route';
const ALLOWED_TYPES = ['acl', 'egp', 'rgp'];
export default Route.extend(ClusterRoute, {
version: service(),
beforeModel() {
return this.get('version')
.fetchFeatures()
.then(() => {
return this._super(...arguments);
});
},
model(params) {
let policyType = params.type;
if (!ALLOWED_TYPES.includes(policyType)) {
return this.transitionTo('vault.cluster.policies', ALLOWED_TYPES[0]);
}
if (!this.get('version.hasSentinel') && policyType !== 'acl') {
return this.transitionTo('vault.cluster.policies', policyType);
}
return {};
},
});