open-vault/ui/app/routes/vault/cluster/policies/create.js

33 lines
1 KiB
JavaScript
Raw Normal View History

import { inject as service } from '@ember/service';
import Route from '@ember/routing/route';
2018-04-03 14:16:57 +00:00
import UnloadModelRoute from 'vault/mixins/unload-model-route';
import UnsavedModelRoute from 'vault/mixins/unsaved-model-route';
export default Route.extend(UnloadModelRoute, UnsavedModelRoute, {
version: service(),
wizard: service(),
2018-04-03 14:16:57 +00:00
model() {
let policyType = this.policyType();
2018-08-28 05:03:55 +00:00
if (
policyType === 'acl' &&
this.get('wizard.currentMachine') === 'policies' &&
this.get('wizard.featureState') === 'idle'
) {
this.get('wizard').transitionFeatureMachine(this.get('wizard.featureState'), 'CONTINUE');
}
if (!this.get('version.hasSentinel') && policyType !== 'acl') {
2018-04-03 14:16:57 +00:00
return this.transitionTo('vault.cluster.policies', policyType);
}
return this.store.createRecord(`policy/${policyType}`, {});
},
setupController(controller) {
this._super(...arguments);
controller.set('policyType', this.policyType());
},
policyType() {
return this.paramsFor('vault.cluster.policies').type;
},
});