open-vault/ui/app/routes/vault/cluster/tools/tool.js

37 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 { toolsActions } from 'vault/helpers/tools-actions';
export default Route.extend({
wizard: service(),
2018-08-28 05:03:55 +00:00
2018-04-03 14:16:57 +00:00
beforeModel(transition) {
const supportedActions = toolsActions();
const { selected_action: selectedAction } = this.paramsFor(this.routeName);
2018-04-03 14:16:57 +00:00
if (!selectedAction || !supportedActions.includes(selectedAction)) {
transition.abort();
return this.transitionTo(this.routeName, supportedActions[0]);
}
},
model(params) {
return params.selected_action;
},
setupController(controller, model) {
this._super(...arguments);
controller.set('selectedAction', model);
},
2018-04-03 14:16:57 +00:00
actions: {
didTransition() {
const params = this.paramsFor(this.routeName);
if (this.wizard.currentMachine === 'tools') {
this.wizard.transitionFeatureMachine(this.wizard.featureState, params.selected_action.toUpperCase());
2018-08-28 05:03:55 +00:00
}
2018-04-03 14:16:57 +00:00
this.controller.setProperties(params);
2018-08-28 05:03:55 +00:00
return true;
2018-04-03 14:16:57 +00:00
},
},
});