Skip to content

Commit

Permalink
UI: Fix KMIP Role not saving (#13594)
Browse files Browse the repository at this point in the history
  • Loading branch information
hashishaw committed Jan 7, 2022
1 parent 6f1b295 commit de4e980
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
3 changes: 3 additions & 0 deletions changelog/13585.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
ui: Fixes issue saving KMIP role correctly
```
2 changes: 1 addition & 1 deletion ui/app/adapters/kmip/role.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
20 changes: 13 additions & 7 deletions ui/app/models/kmip/role.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand All @@ -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;
Expand All @@ -61,16 +67,16 @@ const ModelExport = Model.extend(COMPUTEDS, {
];
if (others.length) {
groups.push({
'': others,
Other: others,
});
}
return fieldToAttrs(this, groups);
}),
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);
}),
});

Expand Down

0 comments on commit de4e980

Please sign in to comment.