mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-03-09 22:23:28 +08:00
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.
This commit is contained in:
parent
a5ecc1a36e
commit
d7b63f5941
1 changed files with 21 additions and 0 deletions
21
app/javascript/src/componentLoader/massageConfiguration.js
Normal file
21
app/javascript/src/componentLoader/massageConfiguration.js
Normal file
|
@ -0,0 +1,21 @@
|
|||
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;
|
Loading…
Reference in a new issue