mirror of
https://github.com/apache/superset.git
synced 2026-04-18 23:55:00 +00:00
Vliu put datasource in store (#1610)
* Move datasource from global store object to form_data * Moved datasource_id and datasource_name to form_data * Refetch defaultFormData when switching datasource * Fixed js tests
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { defaultFormData } from '../stores/store';
|
||||
import * as actions from '../actions/exploreActions';
|
||||
import { addToArr, removeFromArr, alterInArr } from '../../../utils/reducerUtils';
|
||||
|
||||
@@ -47,9 +48,15 @@ export const exploreReducer = function (state, action) {
|
||||
return alterInArr(state, 'filters', action.filter, { value: action.value });
|
||||
},
|
||||
[actions.SET_FIELD_VALUE]() {
|
||||
const newFormData = Object.assign({}, state.viz.form_data);
|
||||
const newFormData = action.key === 'datasource' ?
|
||||
defaultFormData(state.viz.form_data.viz_type) : Object.assign({}, state.viz.form_data);
|
||||
if (action.key === 'datasource') {
|
||||
newFormData.datasource_name = action.label;
|
||||
newFormData.slice_id = state.viz.form_data.slice_id;
|
||||
newFormData.slice_name = state.viz.form_data.slice_name;
|
||||
newFormData.viz_type = state.viz.form_data.viz_type;
|
||||
}
|
||||
newFormData[action.key] = action.value ? action.value : (!state.viz.form_data[action.key]);
|
||||
|
||||
return Object.assign(
|
||||
{},
|
||||
state,
|
||||
|
||||
Reference in New Issue
Block a user