Skip to content

Commit

Permalink
fix: Error when saving datasource from Explore (apache#20749)
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-s-molina authored Jul 18, 2022
1 parent 510c1c4 commit 92f3621
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
8 changes: 8 additions & 0 deletions superset-frontend/src/explore/actions/exploreActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
13 changes: 13 additions & 0 deletions superset-frontend/src/explore/reducers/exploreReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 92f3621

Please sign in to comment.