diff --git a/changelog/13585.txt b/changelog/13585.txt new file mode 100644 index 0000000000000..886c8ed60d582 --- /dev/null +++ b/changelog/13585.txt @@ -0,0 +1,3 @@ +```release-note:bug +ui: Fixes issue saving KMIP role correctly +``` \ No newline at end of file diff --git a/ui/app/adapters/kmip/role.js b/ui/app/adapters/kmip/role.js index 1f76a0400c5f9..31667bf3f2229 100644 --- a/ui/app/adapters/kmip/role.js +++ b/ui/app/adapters/kmip/role.js @@ -38,7 +38,7 @@ export default BaseAdapter.extend({ serialize(snapshot) { // the endpoint here won't allow sending `operation_all` and `operation_none` at the same time or with - // other values, so we manually check for them and send an abbreviated object + // other operation_ values, so we manually check for them and send an abbreviated object let json = snapshot.serialize(); let keys = snapshot.record.nonOperationFields.map(decamelize); let nonOperationFields = getProperties(json, keys); diff --git a/ui/app/models/kmip/role.js b/ui/app/models/kmip/role.js index c1317c5dd7340..a21e2618e00c7 100644 --- a/ui/app/models/kmip/role.js +++ b/ui/app/models/kmip/role.js @@ -17,10 +17,16 @@ export const COMPUTEDS = { return ['tlsClientKeyBits', 'tlsClientKeyType', 'tlsClientTtl']; }), - nonOperationFields: computed('newFields', 'operationFields', 'tlsFields', function() { + // For rendering on the create/edit pages + defaultFields: computed('newFields', 'operationFields', 'tlsFields', function() { let excludeFields = ['role'].concat(this.operationFields, this.tlsFields); return this.newFields.slice().removeObjects(excludeFields); }), + + // For adapter/serializer + nonOperationFields: computed('newFields', 'operationFields', function() { + return this.newFields.slice().removeObjects(this.operationFields); + }), }; const ModelExport = Model.extend(COMPUTEDS, { @@ -31,10 +37,10 @@ const ModelExport = Model.extend(COMPUTEDS, { getHelpUrl(path) { return `/v1/${path}/scope/example/role/example?help=1`; }, - fieldGroups: computed('fields', 'nonOperationFields.length', 'tlsFields', function() { + fieldGroups: computed('fields', 'defaultFields.length', 'tlsFields', function() { const groups = [{ TLS: this.tlsFields }]; - if (this.nonOperationFields.length) { - groups.unshift({ default: this.nonOperationFields }); + if (this.defaultFields.length) { + groups.unshift({ default: this.defaultFields }); } let ret = fieldToAttrs(this, groups); return ret; @@ -61,7 +67,7 @@ const ModelExport = Model.extend(COMPUTEDS, { ]; if (others.length) { groups.push({ - '': others, + Other: others, }); } return fieldToAttrs(this, groups); @@ -69,8 +75,8 @@ const ModelExport = Model.extend(COMPUTEDS, { tlsFormFields: computed('tlsFields', function() { return expandAttributeMeta(this, this.tlsFields); }), - fields: computed('nonOperationFields', function() { - return expandAttributeMeta(this, this.nonOperationFields); + fields: computed('defaultFields', function() { + return expandAttributeMeta(this, this.defaultFields); }), });