UNPKG

@talend/react-containers

Version:

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

50 lines (47 loc) 1.81 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = exports.DEFAULT_STATE = void 0; var _immutable = require("immutable"); var _reactCmf = require("@talend/react-cmf"); var _actionAPI = require("../actionAPI"); var _reactComponents = require("@talend/react-components"); var _lodash = require("lodash"); var _jsxRuntime = require("react/jsx-runtime"); const DEFAULT_STATE = exports.DEFAULT_STATE = new _immutable.Map({ show: false }); // eslint-disable-next-line react/prefer-stateless-function function ConfirmDialog(props) { const context = (0, _reactCmf.useCMFContext)(); const state = (props.state || DEFAULT_STATE).toJS(); if (!state.validateAction || !state.cancelAction) { return null; } // this should be enough /* const props = Object.assign( {}, state, omit(props, cmfConnect.INJECTED_PROPS), ); */ // but as we don't have access to dispatch in the created context of mapStateToProps // we're having an issue on the setup of the onClick on button // for now we'll recompute them here where the context has dispatch // so the connect is only here to force the refresh for now state.validateAction = (0, _actionAPI.getActionsProps)(context, state.validateAction, state.model); state.cancelAction = (0, _actionAPI.getActionsProps)(context, state.cancelAction, state.model); const newProps = { ...(0, _lodash.omit)(props, _reactCmf.cmfConnect.INJECTED_PROPS), ...state }; return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactComponents.ConfirmDialog, { ...newProps }); } ConfirmDialog.displayName = 'CMFContainer(ConfirmDialog)'; ConfirmDialog.propTypes = { ..._reactCmf.cmfConnect.propTypes }; var _default = exports.default = ConfirmDialog; //# sourceMappingURL=ConfirmDialog.container.js.map