All files / javascripts/explorev2/components Options.jsx

0% Statements 0/18
100% Branches 0/0
0% Functions 0/6
0% Lines 0/17
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62                                                                                                                           
import React from 'react';
import SelectArray from './SelectArray';
import { bindActionCreators } from 'redux';
import * as actions from '../actions/exploreActions';
import { connect } from 'react-redux';
import { timestampOptions, rowLimitOptions } from '../constants';
 
const propTypes = {
  actions: React.PropTypes.object,
  timeStampFormat: React.PropTypes.string,
  rowLimit: React.PropTypes.number,
};
 
const defaultProps = {
  timeStampFormat: null,
  rowLimit: null,
};
 
const Options = (props) => {
  const selects = [
    {
      key: 'timeStampFormat',
      title: 'Timestamp Format',
      options: timestampOptions.map((t) => ({ value: t[0], label: t[1] })),
      value: props.timeStampFormat,
      width: '12',
    },
    {
      key: 'rowLimit',
      title: 'Row Limit',
      options: rowLimitOptions.map((r) => ({ value: r, label: r })),
      value: props.rowLimit,
      width: '12',
    }];
  return (
    <div className="panel">
      <div className="panel-header">Options</div>
      <div className="panel-body">
        <SelectArray selectArray={selects} />
      </div>
    </div>
  );
};
 
Options.propTypes = propTypes;
Options.defaultProps = defaultProps;
 
function mapStateToProps(state) {
  return {
    timeStampFormat: state.viz.formData.timeStampFormat,
    rowLimit: state.viz.formData.rowLimit,
  };
}
 
function mapDispatchToProps(dispatch) {
  return {
    actions: bindActionCreators(actions, dispatch),
  };
}
 
export default connect(mapStateToProps, mapDispatchToProps)(Options);