<commit_before>import React, { Component, PropTypes } from 'react'
import { connect } from 'react-redux'
import { Grid, Row, Col } from 'react-flexbox-grid'
import { Card, CardTitle, CardText } from 'material-ui/Card'
import MetaPayload from '../MetaPayload/MetaPayload'
import EvaluationLink from '../EvaluationLink/EvaluationLink'
import JobLink from '../JobLink/JobLink'

const evaluationProps = [
  'ID',
  'Status',
  'StatusDescription',
  'NextEval',
  'PreviousEval',
  'Priority',
  'Type',
  'JobID',
  'TriggeredBy'
]

class EvaluationInfo extends Component {
  render () {
    const evaluation = this.props.evaluation
    const evalValues = {}

    evaluationProps.map((evalProp) => {
      evalValues[evalProp] = evaluation[evalProp] ? evaluation[evalProp] : '-'
      return null
    })

    evalValues.JobID = <JobLink jobId={ evaluation.JobID } />

    if (evaluation.PreviousEval) {
      evalValues.PreviousEval = <EvaluationLink evaluationId={ evaluation.PreviousEval } />
    }
    if (evaluation.NextEval) {
      evalValues.NextEval = <EvaluationLink evaluationId={ evaluation.NextEval } />
    }

    return (
      <Grid fluid style={{ padding: 0 }}>
        <Row>
          <Col key='properties-pane' xs={ 12 } sm={ 12 } md={ 12 } lg={ 12 }>
            <Card>
              <CardTitle title='Evaluation Properties' />
              <CardText>
                <MetaPayload metaBag={ evalValues } sortKeys={ false } />
              </CardText>
            </Card>
          </Col>
        </Row>
      </Grid>
    )
  }
}


function mapStateToProps ({ evaluation }) {
  return { evaluation }
}

EvaluationInfo.propTypes = {
  evaluation: PropTypes.object.isRequired
}

export default connect(mapStateToProps)(EvaluationInfo)<commit_msg>Correctly refresh the content when switching on prev/next evaluation<commit_after>import React, { Component, PropTypes } from 'react'
import { connect } from 'react-redux'
import { Grid, Row, Col } from 'react-flexbox-grid'
import { Card, CardTitle, CardText } from 'material-ui/Card'
import MetaPayload from '../MetaPayload/MetaPayload'
import EvaluationLink from '../EvaluationLink/EvaluationLink'
import JobLink from '../JobLink/JobLink'
import { WATCH_EVAL, UNWATCH_EVAL } from '../../sagas/event'

const evaluationProps = [
  'ID',
  'Status',
  'StatusDescription',
  'NextEval',
  'PreviousEval',
  'Priority',
  'Type',
  'JobID',
  'TriggeredBy'
]

class EvaluationInfo extends Component {

  shouldComponentUpdate(nextProps) {
    if (this.props.params.evalId !== nextProps.routeParams.evalId) {
      this.props.dispatch({ type: UNWATCH_EVAL, payload: this.props.params.evalId })
      this.props.dispatch({ type: WATCH_EVAL, payload: nextProps.routeParams.evalId})
    }
    return true;
  }

  render () {
    const evaluation = this.props.evaluation
    const evalValues = {}

    evaluationProps.map((evalProp) => {
      evalValues[evalProp] = evaluation[evalProp] ? evaluation[evalProp] : '-'
      return null
    })

    evalValues.JobID = <JobLink jobId={ evaluation.JobID } />

    if (evaluation.PreviousEval) {
      evalValues.PreviousEval = <EvaluationLink evaluationId={ evaluation.PreviousEval } />
    }
    if (evaluation.NextEval) {
      evalValues.NextEval = <EvaluationLink evaluationId={ evaluation.NextEval } />
    }

    return (
      <Grid fluid style={{ padding: 0 }}>
        <Row>
          <Col key='properties-pane' xs={ 12 } sm={ 12 } md={ 12 } lg={ 12 }>
            <Card>
              <CardTitle title='Evaluation Properties' />
              <CardText>
                <MetaPayload metaBag={ evalValues } sortKeys={ false } />
              </CardText>
            </Card>
          </Col>
        </Row>
      </Grid>
    )
  }
}


function mapStateToProps ({ evaluation }) {
  return { evaluation }
}

EvaluationInfo.propTypes = {
  dispatch: PropTypes.func.isRequired,
  evaluation: PropTypes.object.isRequired,
  params: PropTypes.object.isRequired,
}

export default connect(mapStateToProps)(EvaluationInfo)
{'fraction_non_alphanumeric': 0.1297539149888143, 'fraction_numerical': 0.0044742729306487695, 'mean_word_length': 2.9762845849802373, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 35, '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': '2977841', 'n_tokens_mistral': 1217, 'n_tokens_neox': 1177, 'n_words': 272}