From 3163309130865e5ba0e048c56f693af9f2c67e73 Mon Sep 17 00:00:00 2001 From: claire bontempo <68122737+hellobontempo@users.noreply.github.com> Date: Tue, 13 Sep 2022 15:11:08 -0700 Subject: [PATCH] UI: Fix KV engine deleting latest version instead of specified version depending on policy (#17124) * update modal copy to clarify when a user is unable to delete a specific version * add tests * cleanup tests, move console commands into helper function * cleanup hbs * add changelog --- changelog/17124.txt | 2 + ui/app/components/secret-delete-menu.js | 2 +- .../components/secret-delete-menu.hbs | 21 +- .../components/secret-version-menu.hbs | 7 +- .../secrets/backend/kv/secret-test.js | 257 ++++++++++-------- 5 files changed, 167 insertions(+), 122 deletions(-) create mode 100644 changelog/17124.txt diff --git a/changelog/17124.txt b/changelog/17124.txt new file mode 100644 index 000000000..ef4f116d9 --- /dev/null +++ b/changelog/17124.txt @@ -0,0 +1,2 @@ +```release-note:bug +ui: Fix kv deleting the latest version when not allowed to soft delete (and delete a specific version of a secret) \ No newline at end of file diff --git a/ui/app/components/secret-delete-menu.js b/ui/app/components/secret-delete-menu.js index cc9ae6bf9..ab8bd5754 100644 --- a/ui/app/components/secret-delete-menu.js +++ b/ui/app/components/secret-delete-menu.js @@ -129,7 +129,7 @@ export default class SecretDeleteMenu extends Component { }); } else { // if they do not have read access on the metadata endpoint we need to pull the version from modelForData so they can perform delete and undelete operations - // only perform if no access to metatdata otherwise it will only delete latest version for any deleteType === delete + // only perform if no access to metadata otherwise it will only delete latest version for any deleteType === delete let currentVersionForNoReadMetadata; if (!this.args.canReadSecretMetadata) { currentVersionForNoReadMetadata = this.args.modelForData?.version; diff --git a/ui/app/templates/components/secret-delete-menu.hbs b/ui/app/templates/components/secret-delete-menu.hbs index d474ce081..11b1fda7f 100644 --- a/ui/app/templates/components/secret-delete-menu.hbs +++ b/ui/app/templates/components/secret-delete-menu.hbs @@ -57,12 +57,21 @@ @onChange={{fn (mut this.deleteType)}} />
- This deletes Version - {{@modelForData.version}} - of the secret. It can be un-deleted later. -
+ {{#if this.canSoftDeleteSecretData}} + ++ This deletes Version + {{@modelForData.version}} + of the secret. It can be un-deleted later. +
+ {{else}} + ++ Your policy does not allow deleting a specific version of this secret. This will delete the + latest version + of this secret. It can be un-deleted later. +
+ {{/if}}