[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

@@ -2,16 +2,16 @@
const $ = window.$ = require('jquery');
const FAVESTAR_BASE_URL = '/superset/favstar/slice';
export const SET_FIELD_OPTIONS = 'SET_FIELD_OPTIONS';
export function setFieldOptions(options) {
return { type: SET_FIELD_OPTIONS, options };
}
export const SET_DATASOURCE_TYPE = 'SET_DATASOURCE_TYPE';
export function setDatasourceType(datasourceType) {
return { type: SET_DATASOURCE_TYPE, datasourceType };
}
export const SET_DATASOURCE = 'SET_DATASOURCE';
export function setDatasource(datasource) {
return { type: SET_DATASOURCE, datasource };
}
export const FETCH_STARTED = 'FETCH_STARTED';
export function fetchStarted() {
return { type: FETCH_STARTED };
@@ -27,7 +27,7 @@ export function fetchFailed(error) {
return { type: FETCH_FAILED, error };
}
export function fetchFieldOptions(datasourceId, datasourceType) {
export function fetchDatasourceMetadata(datasourceId, datasourceType) {
return function (dispatch) {
dispatch(fetchStarted());
@@ -38,7 +38,7 @@ export function fetchFieldOptions(datasourceId, datasourceType) {
type: 'GET',
url,
success: (data) => {
dispatch(setFieldOptions(data.field_options));
dispatch(setDatasource(data));
dispatch(fetchSucceeded());
},
error(error) {