john-bodley commented on a change in pull request #8748: [fix] Fixing time
controls when switching datasource types
URL:
https://github.com/apache/incubator-superset/pull/8748#discussion_r353942478
##########
File path: superset/assets/src/explore/reducers/exploreReducer.js
##########
@@ -36,9 +36,31 @@ export default function exploreReducer(state = {}, action) {
};
},
[actions.SET_DATASOURCE]() {
+ const newFormData = {...state.form_data};
+ if (action.datasource.type != state.datasource.type) {
+ if (action.datasource.type == "table") {
+ newFormData.granularity_sqla = action.datasource.granularity_sqla;
+ newFormData.time_grain_sqla = action.datasource.time_grain_sqla;
+ delete newFormData.druid_time_origin;
+ delete newFormData.granularity;
+ } else {
+ newFormData.druid_time_origin = action.datasource.druid_time_origin;
+ newFormData.granularity = action.datasource.granularity;
+ delete newFormData.granularity_sqla;
+ delete newFormData.time_grain_sqla;
+ }
+ }
+ const newState = {
+ ...state,
+ datasource: action.datasource,
+ datasource_id: action.datasource.id,
+ datasource_type: action.datasource.type,
+ };
return {
...state,
Review comment:
No. The `newState` is only required to update the controls.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]