UNPKG

@talend/react-containers

Version:

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

33 lines (32 loc) 1.1 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = pushNotification; var _immutable = _interopRequireDefault(require("immutable")); var _utils = require("@talend/utils"); var _lodash = require("lodash"); function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } /** * transform the APP state to push notification into the Notification component state slot on redux * even if this component is not already mounted. * @param {state} state * @param {*} notification * @returns {state} */function pushNotification(state, notification) { if (!(0, _lodash.get)(notification, 'message')) { return state; } const path = ['Container(Notification)', 'Notification', 'notifications']; let notifs = state.cmf.components.getIn(path, new _immutable.default.List()); notifs = notifs.push({ id: (0, _utils.randomUUID)(), ...notification }); const newState = { ...state }; newState.cmf.components = state.cmf.components.setIn(path, notifs); return newState; } //# sourceMappingURL=pushNotification.js.map