d56f0ccb72
* wait for all hash promises to be settled * skeleton tests with policies for write without read * adjust what gets returned from the model hook * refactor secret-edit model hook to use async/await * return a stub version if we can't read secret data * return a stub model for v1 kv * tweak tests to make re-runs friendlier * allow write without CAS if both v2 models cannot be read * show warnings on edit pages for different write without read scenarios * add no read empty states on secret show pages * review feedback * make message language consistent * use version models from metadata if we can read it * refresh route on delete / undelete / destroy * hide controls in the toolbar when you can't read the secret data * show deleted / destroyed messaging over cannot read messaging on the show page * fix test with model stub * refactor large model hook into several functions * comment clarifications
61 lines
1.6 KiB
JavaScript
61 lines
1.6 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,
|
|
onRefresh() {},
|
|
|
|
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)
|
|
.then(this.onRefresh);
|
|
},
|
|
},
|
|
});
|