Skip to content

Commit

Permalink
[dashboard bug]Instant control should take effect instantly
Browse files Browse the repository at this point in the history
in explore view, controls like color cheme, legend, rich tooltip, etc., change these controls should see effect instantly, without click Run Query.
  • Loading branch information
Grace Guo committed Nov 17, 2017
1 parent fa35d7d commit e36c4cf
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion superset/assets/javascripts/chart/ChartContainer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ function mapStateToProps({ charts }, ownProps) {
chartUpdateEndTime: chart.chartUpdateEndTime,
chartUpdateStartTime: chart.chartUpdateStartTime,
latestQueryFormData: chart.latestQueryFormData,
lastRendered: chart.lastRendered,
queryResponse: chart.queryResponse,
queryRequest: chart.queryRequest,
triggerQuery: chart.triggerQuery,
triggerRender: chart.triggerRender,
};
}

Expand Down
2 changes: 2 additions & 0 deletions superset/assets/javascripts/chart/chartReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const chartPropType = {
chartUpdateEndTime: PropTypes.number,
chartUpdateStartTime: PropTypes.number,
latestQueryFormData: PropTypes.object,
queryRequest: PropTypes.object,
queryResponse: PropTypes.object,
triggerQuery: PropTypes.bool,
lastRendered: PropTypes.number,
Expand All @@ -24,6 +25,7 @@ export const chart = {
chartUpdateEndTime: null,
chartUpdateStartTime: now(),
latestQueryFormData: null,
queryRequest: null,
queryResponse: null,
triggerQuery: true,
lastRendered: 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import ControlPanelsContainer from './ControlPanelsContainer';
import SaveModal from './SaveModal';
import QueryAndSaveBtns from './QueryAndSaveBtns';
import { getExploreUrl } from '../exploreUtils';
import { areObjectsEqual } from '../../reduxUtils';
import { getFormDataFromControls } from '../stores/store';
import { chartPropType } from '../../chart/chartReducer';
import * as exploreActions from '../actions/exploreActions';
Expand Down Expand Up @@ -50,6 +51,11 @@ class ExploreViewContainer extends React.Component {
if (np.controls.datasource.value !== this.props.controls.datasource.value) {
this.props.actions.fetchDatasourceMetadata(np.form_data.datasource, true);
}
// if any control value changed and it's an instant control
if (Object.keys(np.controls).some(key => (np.controls[key].renderTrigger &&
!areObjectsEqual(np.controls[key].value, this.props.controls[key].value)))) {
this.props.actions.renderTriggered(new Date().getTime(), this.props.chart.chartKey);
}
}

componentDidUpdate() {
Expand Down
5 changes: 3 additions & 2 deletions superset/assets/javascripts/explore/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,14 @@ const initState = {
[chartKey]: {
chartKey,
chartAlert: null,
chartStatus: null,
chartStatus: 'loading',
chartUpdateEndTime: null,
chartUpdateStartTime: now(),
latestQueryFormData: getFormDataFromControls(controls),
queryRequest: null,
queryResponse: null,
triggerQuery: true,
triggerRender: false,
lastRendered: 0,
},
},
saveModal: {
Expand Down

0 comments on commit e36c4cf

Please sign in to comment.