From ecd4c1e514780be0e577349dcb9024731b7577fc Mon Sep 17 00:00:00 2001 From: Chelsea Shaw <82459713+hashishaw@users.noreply.github.com> Date: Wed, 16 Mar 2022 11:00:08 -0500 Subject: [PATCH] UI/fix kv data cache (#14489) * KV fetches recent version on every page, no longer disallow new version without metadata access * Don't flash no read permissions warning * Send noMetadataVersion on destroy if version is undefined * test coverage * add changelog, fix tests * Fix failing test --- changelog/14489.txt | 3 +++ ui/app/adapters/secret-v2-version.js | 1 + .../cluster/secrets/backend/secret-edit.js | 15 +---------- .../components/secret-create-or-update.hbs | 4 +-- .../components/secret-edit-toolbar.hbs | 9 ++++--- .../access/identity/_shared-alias-tests.js | 3 +-- .../secrets/backend/kv/secret-test.js | 26 ++++++++++++++----- .../pages/components/identity/edit-form.js | 7 +++++ 8 files changed, 40 insertions(+), 28 deletions(-) create mode 100644 changelog/14489.txt diff --git a/changelog/14489.txt b/changelog/14489.txt new file mode 100644 index 000000000..014d0a50f --- /dev/null +++ b/changelog/14489.txt @@ -0,0 +1,3 @@ +```release-note:bug +ui: Fixes caching issue on kv new version create +``` diff --git a/ui/app/adapters/secret-v2-version.js b/ui/app/adapters/secret-v2-version.js index 1d51a41bc..319501400 100644 --- a/ui/app/adapters/secret-v2-version.js +++ b/ui/app/adapters/secret-v2-version.js @@ -149,6 +149,7 @@ export default ApplicationAdapter.extend({ } else if (deleteType === 'soft-delete') { return this.softDelete(backend, path, version); } else { + version = version || currentVersionForNoReadMetadata; return this.deleteByDeleteType(backend, path, deleteType, version); } }, diff --git a/ui/app/routes/vault/cluster/secrets/backend/secret-edit.js b/ui/app/routes/vault/cluster/secrets/backend/secret-edit.js index fb697b944..98d015b23 100644 --- a/ui/app/routes/vault/cluster/secrets/backend/secret-edit.js +++ b/ui/app/routes/vault/cluster/secrets/backend/secret-edit.js @@ -248,20 +248,7 @@ export default Route.extend(UnloadModelRoute, { if (modelType === 'secret-v2') { // after the the base model fetch, kv-v2 has a second associated // version model that contains the secret data - - // if no read access to metadata, return current Version from secret data. - if (!secretModel.currentVersion) { - let adapter = this.store.adapterFor('secret-v2-version'); - try { - secretModel.currentVersion = await adapter.getSecretDataVersion(backend, secret); - } catch { - // will get error if you have deleted the secret - // if this is the case do nothing - } - secretModel = await this.fetchV2Models(capabilities, secretModel, params); - } else { - secretModel = await this.fetchV2Models(capabilities, secretModel, params); - } + secretModel = await this.fetchV2Models(capabilities, secretModel, params); } return { secret: secretModel, diff --git a/ui/app/templates/components/secret-create-or-update.hbs b/ui/app/templates/components/secret-create-or-update.hbs index 4d27a2410..cb72e8ada 100644 --- a/ui/app/templates/components/secret-create-or-update.hbs +++ b/ui/app/templates/components/secret-create-or-update.hbs @@ -152,13 +152,13 @@