UNPKG

@talend/react-containers

Version:

Provide connected components aka containers for @talend/react-cmf based on @talend/react-components.

38 lines 1.25 kB
import cmf, { cmfConnect } from '@talend/react-cmf'; import Container, { DEFAULT_STATE } from './HeaderBar.container'; import Constants from './HeaderBar.constant'; import { get } from "lodash"; const getHeaderActionProps = (actionName, ownProps, state) => { const expression = get(ownProps, `${actionName}.renderIfExpression`); let actionProps = ownProps[actionName]; if (expression) { actionProps = { ...ownProps[actionName], ...cmf.expression.mapStateToProps(state, ownProps[actionName]) }; if (actionProps.renderIf === false) { actionProps = null; } } return actionProps; }; export function mapStateToProps(state, ownProps) { return { productsItems: cmf.selectors.collections.toJS(state, Constants.COLLECTION_ID), callToAction: getHeaderActionProps('callToAction', ownProps, state), genericAction: getHeaderActionProps('genericAction', ownProps, state) }; } export default cmfConnect({ defaultState: DEFAULT_STATE, defaultProps: { saga: 'HeaderBar#default' }, mapStateToProps, omitCMFProps: true, withComponentRegistry: true, withDispatch: true, withDispatchActionCreator: true, withComponentId: true })(Container); //# sourceMappingURL=HeaderBar.connect.js.map