open-vault/ui/app/routes/vault/cluster/secrets/backend/versions.js
Matthew Irish 6e0a43ae95
UI - kv v2 versions page (#5563)
* add versions routes

* move commands and permissions check to stand-alone menu component

* add versions template

* make list-item component more flexible and use hasMenu to optionally render the menu

* move current check next to the version

* fix linting

* remove is-wide from secret list popup
2018-10-19 17:24:57 -05:00

28 lines
914 B
JavaScript

import Route from '@ember/routing/route';
import utils from 'vault/lib/key-utils';
import UnloadModelRoute from 'vault/mixins/unload-model-route';
export default Route.extend(UnloadModelRoute, {
templateName: 'vault/cluster/secrets/backend/versions',
beforeModel() {
let backendModel = this.modelFor('vault.cluster.secrets.backend');
const { secret } = this.paramsFor(this.routeName);
const parentKey = utils.parentKeyForKey(secret);
if (backendModel.get('isV2KV')) {
return;
}
if (parentKey) {
return this.transitionTo('vault.cluster.secrets.backend.list', parentKey);
} else {
return this.transitionTo('vault.cluster.secrets.backend.list-root');
}
},
model(params) {
let { secret } = params;
const { backend } = this.paramsFor('vault.cluster.secrets.backend');
return this.store.queryRecord('secret-v2', { id: secret, backend });
},
});