glass-app-manager
Version:
Informatica's Glass Framework CLI for bootstrapping
36 lines (27 loc) • 1.06 kB
JavaScript
/**
* We get all plugins with name attached to string 'GLASS' as 'GLASS_$productname' (GLASS_cai or GLASS_cdi etc)
* We need to make window.GLASS variable cleaner
*
* This function check for that variable and changes to window.GLASS.product.$productname
*
*/
function ConsolidatePlugins() {
const GLASS_UI = window.GLASS_UI_CONFIG ? window.GLASS_UI_CONFIG : {};
const SUPPORTED_PRODUCTS = GLASS_UI.plugins;
if (SUPPORTED_PRODUCTS && SUPPORTED_PRODUCTS.length > 0) {
window.GLASS = {
product: {}
};
SUPPORTED_PRODUCTS.forEach(product => {
const PRODUCT_KEY = product;
const CURRENT_PLUGIN = window[`GLASS_${PRODUCT_KEY}`];
if (CURRENT_PLUGIN && CURRENT_PLUGIN.product) {
window.GLASS.product[PRODUCT_KEY] = {
...CURRENT_PLUGIN.product[PRODUCT_KEY]
}
delete window[`GLASS_${PRODUCT_KEY}`];
}
})
}
}
export default ConsolidatePlugins;