<commit_before>const React = require('react')
const { func, string } = React.PropTypes
const { injectIntl, defineMessages, intlShape } = require('react-intl')
const { connect } = require('react-redux')

const { getYearsWithData } = require('src/data/modules/timePeriod/type/year')
const timePeriodTypeMessages = require('src/messages/timePeriodTypes')

const {
  getSelectedTimePeriods,
  setTimePeriods
 } = require('src/data/ducks/filters')

const { translateTimePeriod } = require('src/data/modules/timePeriod/translate')

const ButtonSelector = require('src/components/shared/ButtonSelector')

const messages = defineMessages({
  allOption: {
    id: 'app.filters.timePeriod.allOption',
    description: 'Text for button that selects all time periods',
    defaultMessage: 'All'
  }
})

const TimePeriodSelect = React.createClass({
  propTypes: {
    selectedTimePeriod: string,
    setTimePeriods: func,
    intl: intlShape
  },

  allYearsOption () {
    const { intl } = this.props

    return [{
      value: 'all',
      label: intl.formatMessage(messages.allOption)
    }]
  },

  selectableYears () {
    return getYearsWithData().map(year => ({
      value: year,
      label: translateTimePeriod(year)
    }))
  },

  options () {
    return this.allYearsOption().concat(this.selectableYears())
  },

  handleChangeEvent (value) {
    this.props.setTimePeriods([value])
  },

  render () {
    const { intl, selectedTimePeriod } = this.props

    return (
      <ButtonSelector
        handleChangeEvent={this.handleChangeEvent}
        options={this.options()}
        selectedValue={selectedTimePeriod}
        labelText={intl.formatMessage(timePeriodTypeMessages.year.noun)}
      />
    )
  }
})

const mapStateToProps = state => ({
  selectedTimePeriod: getSelectedTimePeriods(state).length > 0 ? getSelectedTimePeriods(state)[0] : ''
})

const mapDispatchToProps = dispatch => ({
  setTimePeriods: value => { dispatch(setTimePeriods(value)) }
})

module.exports = injectIntl(connect(mapStateToProps, mapDispatchToProps)(TimePeriodSelect))<commit_msg>Removed unnecessary intermediate React component TimePeriodSelect.<commit_after>const { injectIntl, defineMessages } = require('react-intl')
const { connect } = require('react-redux')

const { getYearsWithData } = require('src/data/modules/timePeriod/type/year')
const timePeriodTypeMessages = require('src/messages/timePeriodTypes')

const {
  getSelectedTimePeriods,
  setTimePeriods
 } = require('src/data/ducks/filters')

const { translateTimePeriod } = require('src/data/modules/timePeriod/translate')

const ButtonSelector = require('src/components/shared/ButtonSelector')

const messages = defineMessages({
  allOption: {
    id: 'app.filters.timePeriod.allOption',
    description: 'Text for button that selects all time periods',
    defaultMessage: 'All'
  }
})

const allYearsOption = intl => (
  [{
    value: 'all',
    label: intl.formatMessage(messages.allOption)
  }]
)

const selectableYears = () => (
  getYearsWithData().map(year => ({
    value: year,
    label: translateTimePeriod(year)
  }))
)

const getOptions = intl => allYearsOption(intl).concat(selectableYears())

const getSelectedValue = state => (
  getSelectedTimePeriods(state).length > 0 ? getSelectedTimePeriods(state)[0] : ''
)

const getLabelText = intl => (
  intl.formatMessage(timePeriodTypeMessages.year.noun)
)

const mapStateToProps = (state, ownProps) => ({
  options: getOptions(ownProps.intl),
  selectedValue: getSelectedValue(state),
  labelText: getLabelText(ownProps.intl)
})

const mapDispatchToProps = dispatch => ({
  handleChangeEvent: value => { dispatch(setTimePeriods([value])) }
})

module.exports = injectIntl(
  connect(mapStateToProps, mapDispatchToProps)(ButtonSelector)
)
{'fraction_non_alphanumeric': 0.12922994937383428, 'fraction_numerical': 0.0010658140154543032, 'mean_word_length': 4.628185907046476, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4944597', 'n_tokens_mistral': 1147, 'n_tokens_neox': 1132, 'n_words': 199}