fix: Visualization settings were lost when editing a datasource from Explore (#10092)

This commit is contained in:
Will Barrett
2020-06-19 12:55:49 -07:00
committed by GitHub
parent 2e76fbb7e5
commit 961b55cfba
2 changed files with 4 additions and 6 deletions

View File

@@ -28,6 +28,7 @@ describe('reducers', () => {
actions.setControlValue('x_axis_label', 'x', []),
);
expect(newState.controls.x_axis_label.value).toBe('x');
expect(newState.form_data.x_axis_label).toBe('x');
});
it('setControlValue works as expected with a checkbox', () => {
const newState = exploreReducer(
@@ -35,5 +36,6 @@ describe('reducers', () => {
actions.setControlValue('show_legend', true, []),
);
expect(newState.controls.show_legend.value).toBe(true);
expect(newState.form_data.show_legend).toBe(true);
});
});

View File

@@ -94,12 +94,8 @@ export default function exploreReducer(state = {}, action) {
};
},
[actions.SET_FIELD_VALUE]() {
let new_form_data = state.form_data;
if (action.controlName === 'viz_type') {
new_form_data = JSON.parse(JSON.stringify(new_form_data));
// Update state's vizType if we are switching to a new visualization
new_form_data.viz_type = action.value;
}
const new_form_data = state.form_data;
new_form_data[action.controlName] = action.value;
// These errors are reported from the Control components
let errors = action.validationErrors || [];