import React from 'react'; import Select from 'react-select'; import { bindActionCreators } from 'redux'; import * as actions from '../actions/exploreActions'; import { connect } from 'react-redux'; import { VIZ_TYPES } from '../constants'; const propTypes = { actions: React.PropTypes.object, datasources: React.PropTypes.array, datasourceId: React.PropTypes.number, datasourceType: React.PropTypes.string, vizType: React.PropTypes.string, }; const defaultProps = { datasources: [], datasourceId: null, datasourceType: null, vizType: null, }; class ChartControl extends React.Component { componentWillMount() { if (this.props.datasourceId) { this.props.actions.setFormOpts(this.props.datasourceId, this.props.datasourceType); } } changeDatasource(datasourceOpt) { const val = (datasourceOpt) ? datasourceOpt.value : null; this.props.actions.setDatasource(val); this.props.actions.resetFormData(); this.props.actions.setFormOpts(val, this.props.datasourceType); } changeViz(opt) { const val = opt ? opt.value : null; this.props.actions.setFormData('vizType', val); } render() { return (
Chart Options
Datasource
); } } ChartControl.propTypes = propTypes; ChartControl.defaultProps = defaultProps; function mapStateToProps(state) { return { datasources: state.datasources, datasourceId: state.datasourceId, datasourceType: state.datasourceType, vizType: state.viz.formData.vizType, }; } function mapDispatchToProps(dispatch) { return { actions: bindActionCreators(actions, dispatch), }; } export default connect(mapStateToProps, mapDispatchToProps)(ChartControl);