<commit_before>import React from 'react';
import OldTable from '../common/OldTable';

const MachinesPage = React.createClass({

  propTypes: {
    error: React.PropTypes.string,
    header: React.PropTypes.string.isRequired, // Eg. 'Slaves', 'Racks'
    states: React.PropTypes.arrayOf(React.PropTypes.shape({
      stateName: React.PropTypes.string.isRequired, // Eg. 'Active', 'Frozen', etc
      stateTableColumnMetadata: React.PropTypes.arrayOf(React.PropTypes.shape({
        data: React.PropTypes.string,
        className: React.PropTypes.string,
        doSort: React.PropTypes.func,
        sortable: React.PropTypes.boolean,
        sortAttr: React.PropTypes.string
      })).isRequired,
      // Host info, in a format that can be passed into a table
      hostsInState: React.PropTypes.arrayOf(React.PropTypes.shape({
        dataId: React.PropTypes.string.isRequired,
        className: React.PropTypes.string,
        data: React.PropTypes.arrayOf(React.PropTypes.shape({
          component: React.PropTypes.func.isRequired,
          prop: React.PropTypes.object,
          id: React.PropTypes.string,
          className: React.PropTypes.string
        })).isRequired
      })).isRequired,
      emptyTableMessage: React.PropTypes.string.isRequired
    })).isRequired
  },

  renderState(state, key) {
    return (
    <div key={key}>
      <h2> {state.stateName} </h2>
      <OldTable
        noPages = {true}
        tableClassOpts = "table-striped"
        columnHeads = {state.stateTableColumnMetadata}
        tableRows = {state.hostsInState}
        emptyTableMessage = {state.emptyTableMessage}
      />
    </div>
    );
  },

  renderError() {
    return (this.props.error &&
      <p className="alert alert-danger">
        {this.props.error}
      </p>
    );
  },

  render() {
    return (
    <div>
      {this.renderError()}
      <h1> {this.props.header} </h1>
      {this.props.states.map(this.renderState)}
    </div>
    );
  },
});


export default MachinesPage;<commit_msg>Make MachinesPage a functional component<commit_after>import React from 'react';
import OldTable from '../common/OldTable';

function MachinesPage (props) {
  function renderState(state, key) {
    return (
    <div key={key}>
      <h2> {state.stateName} </h2>
      <OldTable
        noPages = {true}
        tableClassOpts = "table-striped"
        columnHeads = {state.stateTableColumnMetadata}
        tableRows = {state.hostsInState}
        emptyTableMessage = {state.emptyTableMessage}
      />
    </div>
    );
  }

  return (
    <div>
      {props.error &&
        <p className="alert alert-danger">
          {props.error}
        </p>
      }
      <h1> {props.header} </h1>
      {props.states.map(renderState)}
    </div>
  );
}

MachinesPage.propTypes = {
  error: React.PropTypes.string,
  header: React.PropTypes.string.isRequired, // Eg. 'Slaves', 'Racks'
  states: React.PropTypes.arrayOf(React.PropTypes.shape({
    stateName: React.PropTypes.string.isRequired, // Eg. 'Active', 'Frozen', etc
    stateTableColumnMetadata: React.PropTypes.arrayOf(React.PropTypes.shape({
      data: React.PropTypes.string,
      className: React.PropTypes.string,
      doSort: React.PropTypes.func,
      sortable: React.PropTypes.boolean,
      sortAttr: React.PropTypes.string
    })).isRequired,
    // Host info, in a format that can be passed into a table
    hostsInState: React.PropTypes.arrayOf(React.PropTypes.shape({
      dataId: React.PropTypes.string.isRequired,
      className: React.PropTypes.string,
      data: React.PropTypes.arrayOf(React.PropTypes.shape({
        component: React.PropTypes.func.isRequired,
        prop: React.PropTypes.object,
        id: React.PropTypes.string,
        className: React.PropTypes.string
      })).isRequired
    })).isRequired,
    emptyTableMessage: React.PropTypes.string.isRequired
  })).isRequired
};

export default MachinesPage;
{'fraction_non_alphanumeric': 0.1289002557544757, 'fraction_numerical': 0.0020460358056265983, 'mean_word_length': 2.746168582375479, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, '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': '5446947', 'n_tokens_mistral': 1214, 'n_tokens_neox': 1212, 'n_words': 226}