[exploreV2] mapStateToProps for fields (#1882)

* Controls support for mapStateToProps

* Binding methods in the constructor

* Adressing comments

* Fixing tests
This commit is contained in:
Maxime Beauchemin
2017-01-06 12:38:44 -08:00
committed by GitHub
parent 9a62d94630
commit 222671675c
11 changed files with 193 additions and 217 deletions

View File

@@ -39,25 +39,9 @@ export const exploreReducer = function (state, action) {
return Object.assign({}, state,
{ saveModalAlert: `fetching dashboards failed for ${action.userId}` });
},
[actions.SET_FIELD_OPTIONS]() {
const newState = Object.assign({}, state);
const optionsByFieldName = action.options;
const fieldNames = Object.keys(optionsByFieldName);
fieldNames.forEach((fieldName) => {
if (fieldName === 'filterable_cols') {
newState.filterColumnOpts = optionsByFieldName[fieldName];
} else {
newState.fields[fieldName].choices = optionsByFieldName[fieldName];
if (fieldName === 'metric' && state.viz.form_data.viz_type === 'dual_line') {
newState.fields.metric_2.choices = optionsByFieldName[fieldName];
}
}
});
return Object.assign({}, state, newState);
[actions.SET_DATASOURCE]() {
return Object.assign({}, state, { datasource: action.datasource });
},
[actions.SET_FILTER_COLUMN_OPTS]() {
return Object.assign({}, state, { filterColumnOpts: action.filterColumnOpts });
},