Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI/fix kvv2 version #11258

Merged
merged 5 commits into from
Apr 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelog/11258.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
ui: Fix bug where the UI does not recognize version 2 KV until refresh, and fix [object Object] error message
```
1 change: 1 addition & 0 deletions ui/app/models/database/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion ui/app/models/mount-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -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],
defaultFormValue: 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
}),
});
24 changes: 11 additions & 13 deletions ui/app/models/secret-engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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() {
Expand Down
5 changes: 4 additions & 1 deletion ui/lib/core/addon/components/message-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ export default Component.extend({
return;
}
if (this.model.adapterError.errors.length > 0) {
return this.model.adapterError.errors;
return this.model.adapterError.errors.map(e => {
if (typeof e === 'object') return e.title || e.message || JSON.stringify(e);
return e;
});
}
return [this.model.adapterError.message];
}
Expand Down
4 changes: 2 additions & 2 deletions ui/lib/core/addon/templates/components/form-field.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@
(action "setAndBroadcast" valuePath)
value="target.value"
}} data-test-input={{attr.name}}>
{{#unless attr.options.defaultValue}}
{{#if attr.options.noDefault}}
<option value="">
Select one
</option>
{{/unless}}
{{/if}}
{{#each (path-or-array attr.options.possibleValues model) as |val|}}
<option selected={{eq (get model valuePath) (or val.value val)}} value={{or val.value val}}>
{{or val.displayName val}}
Expand Down
3 changes: 3 additions & 0 deletions ui/tests/acceptance/secrets/backend/kv/secret-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ module('Acceptance | secrets/secret/create', function(hooks) {
await mountSecrets
.next()
.path(enginePath)
.toggleOptions()
.version(1)
.submit();
await listPage.create();
Expand All @@ -83,6 +84,7 @@ module('Acceptance | secrets/secret/create', function(hooks) {
await mountSecrets
.next()
.path(enginePath)
.toggleOptions()
.version(1)
.submit();
await listPage.create();
Expand Down Expand Up @@ -137,6 +139,7 @@ module('Acceptance | secrets/secret/create', function(hooks) {
await mountSecrets
.next()
.path(enginePath)
.toggleOptions()
.version(1)
.submit();
await listPage.create();
Expand Down