Skip to content

Commit

Permalink
fix: can not correctly set force in store (apache#19932)
Browse files Browse the repository at this point in the history
* fix: can not correctly set force in store

* fix ut
  • Loading branch information
zhaoyongjie committed May 11, 2022
1 parent 87d26eb commit ffad938
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 0 deletions.
9 changes: 9 additions & 0 deletions superset-frontend/src/explore/actions/exploreActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,14 @@ export function unsetTimeFormattedColumn(
};
}

export const SET_FORCE_QUERY = 'SET_FORCE_QUERY';
export function setForceQuery(force: boolean) {
return {
type: SET_FORCE_QUERY,
force,
};
}

export const exploreActions = {
...toastActions,
setDatasourceType,
Expand All @@ -181,6 +189,7 @@ export const exploreActions = {
sliceUpdated,
setTimeFormattedColumn,
unsetTimeFormattedColumn,
setForceQuery,
};

export type ExploreActions = typeof exploreActions;
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const createProps = () => ({
sort_y_axis: 'alpha_asc',
extra_form_data: {},
},
queryForce: false,
chartStatus: 'rendered',
onCollapseChange: jest.fn(),
queriesResponse: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,13 +233,15 @@ const TableControls = ({

export const DataTablesPane = ({
queryFormData,
queryForce,
onCollapseChange,
chartStatus,
ownState,
errorMessage,
queriesResponse,
}: {
queryFormData: Record<string, any>;
queryForce: boolean;
chartStatus: string;
ownState?: JsonObject;
onCollapseChange: (isOpen: boolean) => void;
Expand Down Expand Up @@ -271,6 +273,7 @@ export const DataTablesPane = ({
}));
return getChartDataRequest({
formData: queryFormData,
force: queryForce,
resultFormat: 'json',
resultType,
ownState,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ const ExploreChartPanel = ({
}, []);

const refreshCachedQuery = useCallback(() => {
actions.setForceQuery(true);
actions.postChartFormData(
formData,
true,
Expand Down Expand Up @@ -387,6 +388,7 @@ const ExploreChartPanel = ({
<DataTablesPane
ownState={ownState}
queryFormData={queryFormData}
queryForce={force}
onCollapseChange={onCollapseChange}
chartStatus={chart.chartStatus}
errorMessage={errorMessage}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ function ExploreViewContainer(props) {
}, [props.actions, props.chart.id, props.timeout]);

const onQuery = useCallback(() => {
props.actions.setForceQuery(false);
props.actions.triggerQuery(true, props.chart.id);
addHistory();
setLastQueriedControls(props.controls);
Expand Down
6 changes: 6 additions & 0 deletions superset-frontend/src/explore/reducers/exploreReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,12 @@ export default function exploreReducer(state = {}, action) {
);
return { ...state, timeFormattedColumns: newTimeFormattedColumns };
},
[actions.SET_FORCE_QUERY]() {
return {
...state,
force: action.force,
};
},
};

if (action.type in actionHandlers) {
Expand Down

0 comments on commit ffad938

Please sign in to comment.