import * as React from 'react';
import { connect } from 'react-redux';
import * as InternalRedux from '../../Redux/ActionsReducers/InternalRedux';
import { CellSummaryDetails } from './CellSummaryDetails';
import { PanelWithButton } from '../Components/Panels/PanelWithButton';
class CellSummaryPopupComponent extends React.Component {
    componentDidMount() {
        if (this.props.popupParams?.source === 'ColumnMenu' && this.props.popupParams?.column) {
            // if the summary was requested from the column menu, we need to select the entire column
            // afterwards, we will go on with the cell summary logic, as that will evaluate the current(column) cell selection
            this.props.api.columnApi.selectColumn(this.props.popupParams?.column.columnId);
            // we also need to update the internal state of the selected cells
            this.props.api.internalApi.getAdaptableInstance().refreshSelectedCellsState();
        }
        this.props.onCreateCellSummary();
    }
    render() {
        return (React.createElement(PanelWithButton, { headerText: this.props.moduleInfo.FriendlyName, glyphicon: this.props.moduleInfo.Glyph, infoLink: this.props.moduleInfo.HelpPage, infoLinkDisabled: !this.props.api.internalApi.isDocumentationLinksDisplayed() },
            React.createElement(CellSummaryDetails, { CellSummary: this.props.CellSummary })));
    }
}
function mapStateToProps(state, ownProps) {
    return {
        CellSummary: state.Internal.CellSummary.CellSummaryInfo,
    };
}
function mapDispatchToProps(dispatch) {
    return {
        onCreateCellSummary: () => dispatch(InternalRedux.CreateCellSummaryInfo()),
    };
}
export let CellSummaryPopup = connect(mapStateToProps, mapDispatchToProps)(CellSummaryPopupComponent);
