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

Backport 1.8.x: UI Fix KMIP Role not saving (#13594) #13598

Merged
merged 1 commit into from
Jan 13, 2022
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/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