6e0a43ae95
* 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
59 lines
1.5 KiB
JavaScript
59 lines
1.5 KiB
JavaScript
import { maybeQueryRecord } from 'vault/macros/maybe-query-record';
|
|
import Component from '@ember/component';
|
|
import { inject as service } from '@ember/service';
|
|
import { alias, or } from '@ember/object/computed';
|
|
|
|
export default Component.extend({
|
|
tagName: '',
|
|
store: service(),
|
|
version: null,
|
|
useDefaultTrigger: false,
|
|
|
|
deleteVersionPath: maybeQueryRecord(
|
|
'capabilities',
|
|
context => {
|
|
let [backend, id] = JSON.parse(context.version.id);
|
|
return {
|
|
id: `${backend}/delete/${id}`,
|
|
};
|
|
},
|
|
'version.id'
|
|
),
|
|
canDeleteVersion: alias('deleteVersionPath.canUpdate'),
|
|
destroyVersionPath: maybeQueryRecord(
|
|
'capabilities',
|
|
context => {
|
|
let [backend, id] = JSON.parse(context.version.id);
|
|
return {
|
|
id: `${backend}/destroy/${id}`,
|
|
};
|
|
},
|
|
'version.id'
|
|
),
|
|
canDestroyVersion: alias('destroyVersionPath.canUpdate'),
|
|
undeleteVersionPath: maybeQueryRecord(
|
|
'capabilities',
|
|
context => {
|
|
let [backend, id] = JSON.parse(context.version.id);
|
|
return {
|
|
id: `${backend}/undelete/${id}`,
|
|
};
|
|
},
|
|
'version.id'
|
|
),
|
|
canUndeleteVersion: alias('undeleteVersionPath.canUpdate'),
|
|
|
|
isFetchingVersionCapabilities: or(
|
|
'deleteVersionPath.isPending',
|
|
'destroyVersionPath.isPending',
|
|
'undeleteVersionPath.isPending'
|
|
),
|
|
actions: {
|
|
deleteVersion(deleteType = 'destroy') {
|
|
return this.store
|
|
.adapterFor('secret-v2-version')
|
|
.v2DeleteOperation(this.store, this.version.id, deleteType);
|
|
},
|
|
},
|
|
});
|