open-vault/ui/app/routes/vault/cluster/secrets/backend/actions.js
2018-04-03 09:16:57 -05:00

31 lines
972 B
JavaScript

import EditBase from './secret-edit';
import utils from 'vault/lib/key-utils';
export default EditBase.extend({
queryParams: {
selectedAction: {
replace: true,
},
},
templateName: 'vault/cluster/secrets/backend/transitActionsLayout',
beforeModel() {
const { secret } = this.paramsFor(this.routeName);
const parentKey = utils.parentKeyForKey(secret);
const { backend } = this.paramsFor('vault.cluster.secrets.backend');
if (this.backendType(backend) !== 'transit') {
if (parentKey) {
return this.transitionTo('vault.cluster.secrets.backend.show', parentKey);
} else {
return this.transitionTo('vault.cluster.secrets.backend.show-root');
}
}
},
setupController(controller, model) {
this._super(...arguments);
const { selectedAction } = this.paramsFor(this.routeName);
controller.set('selectedAction', selectedAction || model.secret.get('supportedActions.firstObject'));
},
});