This is an automated email from the ASF dual-hosted git repository.

michaelsmolina pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git


The following commit(s) were added to refs/heads/master by this push:
     new 92f3621c75 fix: Error when saving datasource from Explore (#20749)
92f3621c75 is described below

commit 92f3621c754a4f3ddb99285aad273296be26567e
Author: Michael S. Molina <[email protected]>
AuthorDate: Mon Jul 18 14:35:19 2022 -0300

    fix: Error when saving datasource from Explore (#20749)
---
 superset-frontend/src/explore/actions/exploreActions.ts     |  8 ++++++++
 .../explore/components/controls/DatasourceControl/index.jsx |  2 +-
 superset-frontend/src/explore/reducers/exploreReducer.js    | 13 +++++++++++++
 3 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/superset-frontend/src/explore/actions/exploreActions.ts 
b/superset-frontend/src/explore/actions/exploreActions.ts
index b6f0594ac6..f393c74850 100644
--- a/superset-frontend/src/explore/actions/exploreActions.ts
+++ b/superset-frontend/src/explore/actions/exploreActions.ts
@@ -142,6 +142,14 @@ export function setForceQuery(force: boolean) {
   };
 }
 
+export const SAVE_DATASOURCE = 'SAVE_DATASOURCE';
+export function saveDatasource(datasource: Dataset) {
+  return function (dispatch: Dispatch) {
+    dispatch(setDatasource(datasource));
+    dispatch({ type: SAVE_DATASOURCE, datasource });
+  };
+}
+
 export function changeDatasource(newDatasource: Dataset) {
   return function (dispatch: Dispatch, getState: () => ExplorePageState) {
     const {
diff --git 
a/superset-frontend/src/explore/components/controls/DatasourceControl/index.jsx 
b/superset-frontend/src/explore/components/controls/DatasourceControl/index.jsx
index df97e09099..b313fd7fe6 100644
--- 
a/superset-frontend/src/explore/components/controls/DatasourceControl/index.jsx
+++ 
b/superset-frontend/src/explore/components/controls/DatasourceControl/index.jsx
@@ -170,7 +170,7 @@ class DatasourceControl extends React.PureComponent {
   }
 
   onDatasourceSave = datasource => {
-    this.props.actions.setDatasource(datasource);
+    this.props.actions.saveDatasource(datasource);
     const timeCol = this.props.form_data?.granularity_sqla;
     const { columns } = this.props.datasource;
     const firstDttmCol = columns.find(column => column.is_dttm);
diff --git a/superset-frontend/src/explore/reducers/exploreReducer.js 
b/superset-frontend/src/explore/reducers/exploreReducer.js
index f99ab9437c..93743285c6 100644
--- a/superset-frontend/src/explore/reducers/exploreReducer.js
+++ b/superset-frontend/src/explore/reducers/exploreReducer.js
@@ -50,6 +50,19 @@ export default function exploreReducer(state = {}, action) {
         isDatasourceMetaLoading: true,
       };
     },
+    [actions.SAVE_DATASOURCE]() {
+      return {
+        ...state,
+        datasource: action.datasource,
+        controls: {
+          ...state.controls,
+          datasource: {
+            ...state.controls.datasource,
+            datasource: action.datasource,
+          },
+        },
+      };
+    },
     [actions.UPDATE_FORM_DATA_BY_DATASOURCE]() {
       const newFormData = { ...state.form_data };
       const { prevDatasource, newDatasource } = action;

Reply via email to