2018-09-25 16:28:26 +00:00
|
|
|
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';
|
|
|
|
|
2018-09-25 16:28:26 +00:00
|
|
|
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');
|
|
|
|
}
|
2018-04-05 21:08:18 +00:00
|
|
|
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;
|
|
|
|
},
|
|
|
|
});
|