scinote-web/app/javascript/src/componentLoader/massageConfiguration.js
Adrian Oprea d7b63f5941 feat(massageConfiguration): Add data-transformation function
The meta-configuration structure imposes we change the way `react-hijack` parses and pulls its data. Because that work is both error-prone and also time-consuming, we chose to implement a function that would "massage" the data so it fits the current way react-hijack expects it.
2018-01-16 17:23:15 +02:00

21 lines
475 B
JavaScript

const massageConfiguration = (config, identifier) => {
const result = {
[identifier]: {}
};
Object.keys(config)
.forEach(
addon => Object.keys(config[addon])
.forEach(
component => {
if (config[addon][component].areas.indexOf(identifier) !== -1) {
result[identifier][component] = config[addon][component];
}
}
)
);
return result;
};
export default massageConfiguration;