fix vault brokered credentials display (#2583)

* fix: 🐛 brokered credential display in credential panel
This commit is contained in:
Dharini Jeeva authored and GitHub committed 2024-11-26 14:34:10 -08:00
1 parent b049635d28
commit 36c2aee271
6 files changed
+188 -4

No files matched your search

@@ -0,0 +1,27 @@
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/
import { typeOf } from '@ember/utils';
/**
* Flattens a nested object into a single-level object.
* @param obj
* @param result
* @param parentKey
* @returns {Object}
*/
export const flattenObject = (obj, result = {}, parentKey = '') => {
for (const key in obj) {
// Check if the value is an object and it is not null
if (typeOf(obj[key]) === 'object' && obj[key] !== null) {
// Recursively flatten the object
flattenObject(obj[key], result, `${parentKey}${key}.`);
} else if (obj[key]) {
// Only add to result if the value is not null
result[`${parentKey}${key}`] = obj[key];
}
}
return result;
};