[explore] Split large reducer logic in ExploreViewContainer (#3088)

* split reducer logic for ExploreViewContainer

* fix saveModal component and unit tests

* revert changes in SaveModal_spec.
will make another commit just to improve test coverage for SaveModal component.

* remove comment-out code

* fix merge confilicts
This commit is contained in:
Grace Guo
2017-08-10 14:21:45 -07:00
committed by Maxime Beauchemin
parent 08b7e891a7
commit b3107bb603
14 changed files with 365 additions and 330 deletions

View File

@@ -8,12 +8,15 @@ import ControlPanelsContainer from './ControlPanelsContainer';
import SaveModal from './SaveModal';
import QueryAndSaveBtns from './QueryAndSaveBtns';
import { getExploreUrl } from '../exploreUtils';
import * as actions from '../actions/exploreActions';
import { getFormDataFromControls } from '../stores/store';
import * as exploreActions from '../actions/exploreActions';
import * as saveModalActions from '../actions/saveModalActions';
import * as chartActions from '../actions/chartActions';
const propTypes = {
actions: PropTypes.object.isRequired,
datasource_type: PropTypes.string.isRequired,
isDatasourceMetaLoading: PropTypes.bool.isRequired,
chartStatus: PropTypes.string,
controls: PropTypes.object.isRequired,
forcedHeight: PropTypes.string,
@@ -85,7 +88,6 @@ class ExploreViewContainer extends React.Component {
return `${window.innerHeight - navHeight}px`;
}
triggerQueryIfNeeded() {
if (this.props.triggerQuery && !this.hasErrors()) {
this.props.actions.runQuery(this.props.form_data);
@@ -172,7 +174,9 @@ class ExploreViewContainer extends React.Component {
<ControlPanelsContainer
actions={this.props.actions}
form_data={this.props.form_data}
controls={this.props.controls}
datasource_type={this.props.datasource_type}
isDatasourceMetaLoading={this.props.isDatasourceMetaLoading}
/>
</div>
<div className="col-sm-8">
@@ -186,21 +190,23 @@ class ExploreViewContainer extends React.Component {
ExploreViewContainer.propTypes = propTypes;
function mapStateToProps(state) {
const form_data = getFormDataFromControls(state.controls);
function mapStateToProps({ explore, chart }) {
const form_data = getFormDataFromControls(explore.controls);
return {
chartStatus: state.chartStatus,
datasource_type: state.datasource.type,
controls: state.controls,
isDatasourceMetaLoading: explore.isDatasourceMetaLoading,
datasource_type: explore.datasource.type,
controls: explore.controls,
form_data,
standalone: state.standalone,
triggerQuery: state.triggerQuery,
forcedHeight: state.forced_height,
queryRequest: state.queryRequest,
standalone: explore.standalone,
triggerQuery: explore.triggerQuery,
forcedHeight: explore.forced_height,
queryRequest: chart.queryRequest,
chartStatus: chart.chartStatus,
};
}
function mapDispatchToProps(dispatch) {
const actions = Object.assign({}, exploreActions, saveModalActions, chartActions);
return {
actions: bindActionCreators(actions, dispatch),
};