vault/ui/app/utils/openapi-to-attrs.js
Vault Automation 0c6c13dd38
license: update headers to IBM Corp. (#10229) (#10233)
* license: update headers to IBM Corp.
* `make proto`
* update offset because source file changed

Signed-off-by: Ryan Cragun <me@ryan.ec>
Co-authored-by: Ryan Cragun <me@ryan.ec>
2025-10-21 15:20:20 -06:00

29 lines
1013 B
JavaScript

/**
* Copyright IBM Corp. 2016, 2025
* SPDX-License-Identifier: BUSL-1.1
*/
/**
* combineFieldGroups takes the newFields returned from OpenAPI and adds them to the default field group
* if they are not already accounted for in other field groups
* @param {Record<string,string[]>[]} currentGroups Field groups, as an array of objects like: [{ default: [] }, { 'TLS options': [] }]
* @param {string[]} newFields
* @param {string[]} excludedFields
* @returns modified currentGroups
*/
export const combineFieldGroups = function (currentGroups, newFields, excludedFields) {
let allFields = [];
for (const group of currentGroups) {
const fieldName = Object.keys(group)[0];
allFields = allFields.concat(group[fieldName]);
}
const otherFields = newFields.filter((field) => {
return !allFields.includes(field) && !excludedFields.includes(field);
});
if (otherFields.length) {
currentGroups[0].default = currentGroups[0].default.concat(otherFields);
}
return currentGroups;
};