This is an automated email from the ASF dual-hosted git repository.
michaelsmolina pushed a commit to branch 4.0
in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to refs/heads/4.0 by this push:
new 8de2efc870 fix(Explore): Keep necessary form data to allow query mode
switching (#29234)
8de2efc870 is described below
commit 8de2efc8703ea5b14373cd27c81539f9c6d2566b
Author: Ross Mabbett <[email protected]>
AuthorDate: Thu Jun 13 13:30:49 2024 -0400
fix(Explore): Keep necessary form data to allow query mode switching
(#29234)
(cherry picked from commit 0dc9215c899076b89766ea120caca3419704c708)
---
.../explore/components/ExploreViewContainer/index.jsx | 16 ++++++++++++----
superset-frontend/src/explore/constants.ts | 8 ++++++++
2 files changed, 20 insertions(+), 4 deletions(-)
diff --git
a/superset-frontend/src/explore/components/ExploreViewContainer/index.jsx
b/superset-frontend/src/explore/components/ExploreViewContainer/index.jsx
index fe5d277242..a2ac4223a4 100644
--- a/superset-frontend/src/explore/components/ExploreViewContainer/index.jsx
+++ b/superset-frontend/src/explore/components/ExploreViewContainer/index.jsx
@@ -43,6 +43,7 @@ import {
LocalStorageKeys,
} from 'src/utils/localStorageHelpers';
import { RESERVED_CHART_URL_PARAMS, URL_PARAMS } from 'src/constants';
+import { QUERY_MODE_REQUISITES } from 'src/explore/constants';
import { areObjectsEqual } from 'src/reduxUtils';
import * as logActions from 'src/logger/actions';
import {
@@ -704,6 +705,12 @@ function ExploreViewContainer(props) {
ExploreViewContainer.propTypes = propTypes;
+const retainQueryModeRequirements = hiddenFormData => {
+ Object.keys(hiddenFormData ?? {}).filter(
+ key => !QUERY_MODE_REQUISITES.has(key),
+ );
+};
+
function mapStateToProps(state) {
const {
explore,
@@ -716,10 +723,11 @@ function mapStateToProps(state) {
saveModal,
} = state;
const { controls, slice, datasource, metadata, hiddenFormData } = explore;
- const form_data = omit(
- getFormDataFromControls(controls),
- Object.keys(hiddenFormData ?? {}),
- );
+ const hasQueryMode = !!controls.query_mode?.value;
+ const fieldsToOmit = hasQueryMode
+ ? retainQueryModeRequirements(hiddenFormData)
+ : hiddenFormData;
+ const form_data = omit(getFormDataFromControls(controls), fieldsToOmit);
const slice_id = form_data.slice_id ?? slice?.slice_id ?? 0; // 0 - unsaved
chart
form_data.extra_form_data = mergeExtraFormData(
{ ...form_data.extra_form_data },
diff --git a/superset-frontend/src/explore/constants.ts
b/superset-frontend/src/explore/constants.ts
index e2bc7ea04a..cb56e31393 100644
--- a/superset-frontend/src/explore/constants.ts
+++ b/superset-frontend/src/explore/constants.ts
@@ -158,3 +158,11 @@ export const TIME_FILTER_MAP = {
export const POPOVER_INITIAL_HEIGHT = 240;
export const POPOVER_INITIAL_WIDTH = 320;
export const UNSAVED_CHART_ID = 0;
+
+export const QUERY_MODE_REQUISITES = new Set([
+ 'all_columns',
+ 'groupby',
+ 'metrics',
+ 'percent_metrics',
+ 'order_by_cols',
+]);