Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let views = {},
viewsDefinitionObject;
if (!state.views) {
viewsDefinitionObject = { $default: pick(state, ['component']) };
} else {
viewsDefinitionObject = map(
state.views,
(val: any, key) => {
if (val.component) return val;
return { component: val };
},
viewsDefinitionObject,
);
}
forEach(viewsDefinitionObject, function(config, name) {
name = name || '$default'; // Account for views: { "": { template... } }
if (Object.keys(config).length == 0) return;
config.$type = 'react';
config.$context = state;
config.$name = name;
let normalized = ViewService.normalizeUIViewTarget(
config.$context,
config.$name,
);
config.$uiViewName = normalized.uiViewName;
config.$uiViewContextAnchor = normalized.uiViewContextAnchor;
views[name] = config;
});
export function reactViewsBuilder(state: StateObject) {
let views = {},
viewsDefinitionObject;
if (!state.views) {
viewsDefinitionObject = { $default: pick(state, ['component']) };
} else {
viewsDefinitionObject = map(state.views, (val: any, key) => {
if (val.component) return val;
return { component: val };
});
}
forEach(viewsDefinitionObject, function(config, name) {
name = name || '$default'; // Account for views: { "": { template... } }
if (Object.keys(config).length == 0) return;
config.$type = 'react';
config.$context = state;
config.$name = name;
let normalized = ViewService.normalizeUIViewTarget(config.$context, config.$name);
config.$uiViewName = normalized.uiViewName;
config.$uiViewContextAnchor = normalized.uiViewContextAnchor;
views[name] = config;
});
return views;
}