From 3300fed6e65dfff6f7b841f92e7969e18b68a7d5 Mon Sep 17 00:00:00 2001 From: Chelsea Shaw Date: Wed, 31 Mar 2021 16:31:22 -0500 Subject: [PATCH 1/5] Update default form values for kv --- ui/app/models/mount-config.js | 2 +- ui/app/models/mount-options.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/app/models/mount-config.js b/ui/app/models/mount-config.js index f2f12b563ce7a..de82e90627cbb 100644 --- a/ui/app/models/mount-config.js +++ b/ui/app/models/mount-config.js @@ -36,6 +36,6 @@ export default Fragment.extend({ helpText: "The type of token that should be generated via this role. Can be `service`, `batch`, or `default` to use the mount's default (which unless changed will be `service` tokens).", possibleValues: ['default', 'batch', 'service'], - defaultFormValue: 'default', + defaultValue: 'default', }), }); diff --git a/ui/app/models/mount-options.js b/ui/app/models/mount-options.js index 17a89e10caf03..72b04fe20e021 100644 --- a/ui/app/models/mount-options.js +++ b/ui/app/models/mount-options.js @@ -7,6 +7,6 @@ export default Fragment.extend({ helpText: 'The KV Secrets Engine can operate in different modes. Version 1 is the original generic Secrets Engine the allows for storing of static key/value pairs. Version 2 added more features including data versioning, TTLs, and check and set.', possibleValues: [2, 1], - defaultFormValue: 2, + defaultValue: 2, }), }); From 0dada3747ee3179de7db3500ba76b1d9f602e33d Mon Sep 17 00:00:00 2001 From: Chelsea Shaw Date: Wed, 31 Mar 2021 16:56:47 -0500 Subject: [PATCH 2/5] Group kv version option in 'Method Options' group --- ui/app/models/secret-engine.js | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/ui/app/models/secret-engine.js b/ui/app/models/secret-engine.js index 5d9147f8c6b83..f5a050924240c 100644 --- a/ui/app/models/secret-engine.js +++ b/ui/app/models/secret-engine.js @@ -60,8 +60,17 @@ export default Model.extend({ formFieldGroups: computed('engineType', function() { let type = this.engineType; let defaultGroup = { default: ['path'] }; + let optionsGroup = { + 'Method Options': [ + 'description', + 'config.listingVisibility', + 'local', + 'sealWrap', + 'config.{defaultLeaseTtl,maxLeaseTtl,auditNonHmacRequestKeys,auditNonHmacResponseKeys,passthroughRequestHeaders}', + ], + }; if (type === 'kv' || type === 'generic') { - defaultGroup.default.push('options.{version}'); + optionsGroup['Method Options'].unshift('options.{version}'); } if (type === 'database') { // For the Database Secret Engine we want to highlight the defaultLeaseTtl and maxLeaseTtl, removing them from the options object @@ -79,18 +88,7 @@ export default Model.extend({ }, ]; } - return [ - defaultGroup, - { - 'Method Options': [ - 'description', - 'config.listingVisibility', - 'local', - 'sealWrap', - 'config.{defaultLeaseTtl,maxLeaseTtl,auditNonHmacRequestKeys,auditNonHmacResponseKeys,passthroughRequestHeaders}', - ], - }, - ]; + return [defaultGroup, optionsGroup]; }), attrs: computed('formFields', function() { From 9471397aa5ac723f7406c7648eea49fb0728d917 Mon Sep 17 00:00:00 2001 From: Chelsea Shaw Date: Thu, 1 Apr 2021 14:31:40 -0500 Subject: [PATCH 3/5] Fix tests, explicitly set if select input does not have default --- ui/app/models/database/connection.js | 1 + ui/app/models/mount-config.js | 2 +- ui/app/models/mount-options.js | 3 ++- ui/lib/core/addon/templates/components/form-field.hbs | 4 ++-- ui/tests/acceptance/secrets/backend/kv/secret-test.js | 3 +++ 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/ui/app/models/database/connection.js b/ui/app/models/database/connection.js index f5b2bf23b8991..e80610fa415b8 100644 --- a/ui/app/models/database/connection.js +++ b/ui/app/models/database/connection.js @@ -31,6 +31,7 @@ export default Model.extend({ plugin_name: attr('string', { label: 'Database plugin', possibleValues: AVAILABLE_PLUGIN_TYPES, + noDefault: true, }), verify_connection: attr('boolean', { defaultValue: true, diff --git a/ui/app/models/mount-config.js b/ui/app/models/mount-config.js index de82e90627cbb..f2f12b563ce7a 100644 --- a/ui/app/models/mount-config.js +++ b/ui/app/models/mount-config.js @@ -36,6 +36,6 @@ export default Fragment.extend({ helpText: "The type of token that should be generated via this role. Can be `service`, `batch`, or `default` to use the mount's default (which unless changed will be `service` tokens).", possibleValues: ['default', 'batch', 'service'], - defaultValue: 'default', + defaultFormValue: 'default', }), }); diff --git a/ui/app/models/mount-options.js b/ui/app/models/mount-options.js index 72b04fe20e021..f0212be114dd6 100644 --- a/ui/app/models/mount-options.js +++ b/ui/app/models/mount-options.js @@ -7,6 +7,7 @@ export default Fragment.extend({ helpText: 'The KV Secrets Engine can operate in different modes. Version 1 is the original generic Secrets Engine the allows for storing of static key/value pairs. Version 2 added more features including data versioning, TTLs, and check and set.', possibleValues: [2, 1], - defaultValue: 2, + // This shouldn't be defaultValue because if no version comes back from API we should assume it's v1 + defaultFormValue: 2, // Set the form to 2 by default }), }); diff --git a/ui/lib/core/addon/templates/components/form-field.hbs b/ui/lib/core/addon/templates/components/form-field.hbs index 9a58dcddc3144..e97f842b51ca7 100644 --- a/ui/lib/core/addon/templates/components/form-field.hbs +++ b/ui/lib/core/addon/templates/components/form-field.hbs @@ -38,11 +38,11 @@ (action "setAndBroadcast" valuePath) value="target.value" }} data-test-input={{attr.name}}> - {{#unless attr.options.defaultValue}} + {{#if attr.options.noDefault}} - {{/unless}} + {{/if}} {{#each (path-or-array attr.options.possibleValues model) as |val|}}