mirror of https://github.com/apache/superset.git
[fix] Fixing time controls when switching datasource types (#8748)
* [fix] Fixing time controls when switching datasource types * Update exploreReducer.js * Update exploreReducer.js * Fix linting
This commit is contained in:
parent
e127579fc8
commit
e72533506b
|
@ -36,9 +36,30 @@ export default function exploreReducer(state = {}, action) {
|
|||
};
|
||||
},
|
||||
[actions.SET_DATASOURCE]() {
|
||||
return {
|
||||
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 {
|
||||
...newState,
|
||||
form_data: newFormData,
|
||||
controls: getControlsState(newState, newFormData),
|
||||
};
|
||||
},
|
||||
[actions.FETCH_DATASOURCES_STARTED]() {
|
||||
|
|
Loading…
Reference in New Issue