<commit_before>const React = require('react')
const mui = require('material-ui')
const times = require('lodash.times')
const {RaisedButton} = mui

import EditableTableEntry from '../EditableTableEntry/EditableTableEntry.jsx';

export default class EditTable extends React.Component {
    constructor(props) {
        super(props);

        this.state = {
            headerColumns: [],
            rows: [],
            onChange: function () {}
        }
    }

  getInitialState() {
    return {
      rows: this.props.rows,
      hoverValue: false,
      currentRow: false
    }
  }

  static contextTypes = {
    muiTheme: React.PropTypes.object.isRequired
  }

  handleRowClick(row) {
      var rows = this.state.rows
      const rowId = row.id;

      // somebody edited a row
      if (rows[rowId].selected)
          this.props.onChange(row);

      rows.forEach((row, i) => {
        if (rowId !== i) row.selected = false
      })

      rows[rowId].selected = !rows[rowId].selected
      this.setState({rows: rows})
  }

  renderHeader() {
    const headerColumns = this.props.headerColumns
    const columns = headerColumns.map((column, id) => {
      return {value: column.value}
    })
    const row = {columns: columns, header: true}

    return (<EditableTableEntry row={row} headerColumns={this.props.headerColumns}/>);
  }


  componentWillReceiveProps(nextProps) {
    this.setState({rows: nextProps.rows});
  }

  render() {
    const self = this
    const style = {<commit_msg>Working edit row<commit_after>const React = require('react')
const mui = require('material-ui')
const times = require('lodash.times')
const {RaisedButton} = mui

import EditableTableEntry from '../EditableTableEntry/EditableTableEntry.jsx';

export default class EditTable extends React.Component {
    constructor(props) {
        super(props);

        this.state = {
            headerColumns: [],
            rows: [],
        }
    }

  getInitialState() {
    return {
      rows: this.props.rows,
      hoverValue: false,
      currentRow: false
    }
  }

  static contextTypes = {
    muiTheme: React.PropTypes.object.isRequired
  }

  handleRowClick(row) {
      var rows = this.state.rows
      const rowId = row.id;

      // somebody edited a row
      if (rows[rowId].selected && this.props.onRowChange)
          this.props.onRowChange(row);

      rows.forEach((row, i) => {
        if (rowId !== i) row.selected = false
      })

      rows[rowId].selected = !rows[rowId].selected
      this.setState({rows: rows})
  }

  renderHeader() {
    const headerColumns = this.props.headerColumns
    const columns = headerColumns.map((column, id) => {
      return {value: column.value}
    })
    const row = {columns: columns, header: true}

    return (<EditableTableEntry row={row} headerColumns={this.props.headerColumns}/>);
  }


  componentWillReceiveProps(nextProps) {
    this.setState({rows: nextProps.rows});
  }

  render() {
    const self = this
    const style = {
{'fraction_non_alphanumeric': 0.1268831603615668, 'fraction_numerical': 0.0, 'mean_word_length': 2.6394640682095005, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '4661921', 'n_tokens_mistral': 914, 'n_tokens_neox': 885, 'n_words': 193}