From 6e4fc4bc0e4f8928c883c0b1c1275dd4a0fd8cc5 Mon Sep 17 00:00:00 2001 From: Yongjie Zhao Date: Wed, 4 May 2022 04:37:36 +0800 Subject: [PATCH] fix: can not correctly set force in store (#19932) * fix: can not correctly set force in store * fix ut --- superset-frontend/src/explore/actions/exploreActions.ts | 9 +++++++++ .../components/DataTablesPane/DataTablesPane.test.tsx | 1 + .../src/explore/components/DataTablesPane/index.tsx | 3 +++ .../src/explore/components/ExploreChartPanel.jsx | 2 ++ .../explore/components/ExploreViewContainer/index.jsx | 1 + superset-frontend/src/explore/reducers/exploreReducer.js | 6 ++++++ 6 files changed, 22 insertions(+) diff --git a/superset-frontend/src/explore/actions/exploreActions.ts b/superset-frontend/src/explore/actions/exploreActions.ts index a3911e792256..a05f3cd3b813 100644 --- a/superset-frontend/src/explore/actions/exploreActions.ts +++ b/superset-frontend/src/explore/actions/exploreActions.ts @@ -180,6 +180,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, @@ -197,6 +205,7 @@ export const exploreActions = { sliceUpdated, setTimeFormattedColumn, unsetTimeFormattedColumn, + setForceQuery, }; export type ExploreActions = typeof exploreActions; diff --git a/superset-frontend/src/explore/components/DataTablesPane/DataTablesPane.test.tsx b/superset-frontend/src/explore/components/DataTablesPane/DataTablesPane.test.tsx index 04869f5f1002..b2b3f168c910 100644 --- a/superset-frontend/src/explore/components/DataTablesPane/DataTablesPane.test.tsx +++ b/superset-frontend/src/explore/components/DataTablesPane/DataTablesPane.test.tsx @@ -54,6 +54,7 @@ const createProps = () => ({ sort_y_axis: 'alpha_asc', extra_form_data: {}, }, + queryForce: false, chartStatus: 'rendered', onCollapseChange: jest.fn(), queriesResponse: [ diff --git a/superset-frontend/src/explore/components/DataTablesPane/index.tsx b/superset-frontend/src/explore/components/DataTablesPane/index.tsx index e8c27bac0b9f..75c8b3f1e5b1 100644 --- a/superset-frontend/src/explore/components/DataTablesPane/index.tsx +++ b/superset-frontend/src/explore/components/DataTablesPane/index.tsx @@ -233,6 +233,7 @@ const TableControls = ({ export const DataTablesPane = ({ queryFormData, + queryForce, onCollapseChange, chartStatus, ownState, @@ -240,6 +241,7 @@ export const DataTablesPane = ({ queriesResponse, }: { queryFormData: Record; + queryForce: boolean; chartStatus: string; ownState?: JsonObject; onCollapseChange: (isOpen: boolean) => void; @@ -271,6 +273,7 @@ export const DataTablesPane = ({ })); return getChartDataRequest({ formData: queryFormData, + force: queryForce, resultFormat: 'json', resultType, ownState, diff --git a/superset-frontend/src/explore/components/ExploreChartPanel.jsx b/superset-frontend/src/explore/components/ExploreChartPanel.jsx index 082d987b3cf4..f669c85f82af 100644 --- a/superset-frontend/src/explore/components/ExploreChartPanel.jsx +++ b/superset-frontend/src/explore/components/ExploreChartPanel.jsx @@ -189,6 +189,7 @@ const ExploreChartPanel = ({ }, []); const refreshCachedQuery = useCallback(() => { + actions.setForceQuery(true); actions.postChartFormData( formData, true, @@ -387,6 +388,7 @@ const ExploreChartPanel = ({ { + props.actions.setForceQuery(false); props.actions.triggerQuery(true, props.chart.id); addHistory(); setLastQueriedControls(props.controls); diff --git a/superset-frontend/src/explore/reducers/exploreReducer.js b/superset-frontend/src/explore/reducers/exploreReducer.js index 1078df6a2829..8c6410128cb2 100644 --- a/superset-frontend/src/explore/reducers/exploreReducer.js +++ b/superset-frontend/src/explore/reducers/exploreReducer.js @@ -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) {