From ffdba0532977ca1663f27a2aa012fed7c82220f8 Mon Sep 17 00:00:00 2001 From: Yongjie Zhao Date: Fri, 29 Apr 2022 13:20:40 +0800 Subject: [PATCH 1/2] fix: can not correctly set force in store --- superset-frontend/src/explore/actions/exploreActions.ts | 9 +++++++++ .../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 ++++++ 5 files changed, 21 insertions(+) diff --git a/superset-frontend/src/explore/actions/exploreActions.ts b/superset-frontend/src/explore/actions/exploreActions.ts index 395df7aa13c0..61e73e8cc485 100644 --- a/superset-frontend/src/explore/actions/exploreActions.ts +++ b/superset-frontend/src/explore/actions/exploreActions.ts @@ -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, @@ -181,6 +189,7 @@ export const exploreActions = { sliceUpdated, setTimeFormattedColumn, unsetTimeFormattedColumn, + setForceQuery, }; export type ExploreActions = typeof exploreActions; diff --git a/superset-frontend/src/explore/components/DataTablesPane/index.tsx b/superset-frontend/src/explore/components/DataTablesPane/index.tsx index a41af3626f1e..22f39328013c 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 5cd818f52ee8..49ed20848d68 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 96fa18be53bb..4025f726cd72 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) { From 63cef9c1e8c554f8b83071e01fc54e84f4d16a8d Mon Sep 17 00:00:00 2001 From: Yongjie Zhao Date: Tue, 3 May 2022 09:57:47 +0800 Subject: [PATCH 2/2] fix ut --- .../explore/components/DataTablesPane/DataTablesPane.test.tsx | 1 + 1 file changed, 1 insertion(+) 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: [