<commit_before>import React, { Component, PropTypes } from 'react';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import { Link } from 'react-router';
import DocumentTitle from 'react-document-title';

import * as ConferenceActions from '../../actions/ConferenceActions';

/* Components */
import MiniConference from '../fragments/MiniConference';

export class ConferencesPage extends Component {
  markConferenceAsActive(id) {
    this.props.actions.conferenceActiveChanged([id]);
  }

  markConferenceAsInactive() {
    this.props.actions.conferenceActiveChanged([]);
  }

  renderAdminMenu() {
    if (this.props.isAdmin) {
      return (
        <div className="btn-group" role="group" aria-label="Actions menu">
          <Link className="btn btn-secondary btn-sm" to="/conference/new">Add conference</Link>
        </div>
      );
    }
  }

  renderConference(conference) {
    return (
      <li className="list-group-item" key={conference.id}
          onMouseOver={this.markConferenceAsActive.bind(this, conference.id)} onMouseOut={this.markConferenceAsInactive.bind(this)}>
        <MiniConference conference={conference}/>
      </li>
    );
  }

  render() {
    const { conferences } = this.props;

    let conferenceProfiles = [];
    for (const id in conferences) {
      conferenceProfiles.push(conferences[id]);
    }

    /*
    conferenceProfiles.sort(sortConferencesByName);
    */
    conferenceProfiles = conferenceProfiles.map(this.renderConference.bind(this));

    return (
      <DocumentTitle title="Conferences | X-Map">
        <article id="ConferencesPage" className="page card">
          <Link to="/" className="close btn btn-sm btn-secondary" title="close page">&times;</Link>

          <header className="card-header">
            <h2 className="card-title">Conferences</h2>
            <p className="text-muted">Listing all conferences</p>
            {this.renderAdminMenu()}
          </header>

          <ul className="list-group list-group-flush">
            {conferenceProfiles}
          </ul>
        </article>
      </DocumentTitle>
    );
  }
}

ConferencesPage.propTypes = {
  actions: PropTypes.object.isRequired,
  conferences: PropTypes.object.isRequired,
  isAdmin: PropTypes.bool.isRequired
};

ConferencesPage.defaultProps = {
  isAdmin: false
};

function mapStateToProps(state) {
  return {
    conferences: state.conferences,
    isAdmin: state.session.isAdmin
  };
}

function mapDispatchToProps(dispatch) {
  return {
    actions: bindActionCreators(ConferenceActions, dispatch)
  };
}

export default connect(mapStateToProps, mapDispatchToProps)(ConferencesPage);<commit_msg>Refactored conference pages with Ramda<commit_after>import React, { Component, PropTypes } from 'react';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import { Link } from 'react-router';
import DocumentTitle from 'react-document-title';
import R from 'ramda';

import * as ConferenceActions from '../../actions/ConferenceActions';

/* Components */
import MiniConference from '../fragments/MiniConference';

export class ConferencesPage extends Component {
  markConferenceAsActive(id) {
    this.props.actions.conferenceActiveChanged([id]);
  }

  markConferenceAsInactive() {
    this.props.actions.conferenceActiveChanged([]);
  }

  renderConference(conference) {
    return (
      <li className="list-group-item" key={conference.id}
          onMouseOver={this.markConferenceAsActive.bind(this, conference.id)} onMouseOut={this.markConferenceAsInactive.bind(this)}>
        <MiniConference conference={conference}/>
      </li>
    );
  }

  render() {
    const conferences = R.compose(
      R.map((team) => this.renderConference(conference)),
//      R.sort(sortTeamsByName),
      R.values
    )(this.props.teams);

    return (
      <DocumentTitle title="Conferences | X-Map">
        <article id="ConferencesPage" className="page card">
          <Link to="/" className="close btn btn-sm btn-secondary" title="close page">&times;</Link>

          <header className="card-header">
            <h2 className="card-title">Conferences</h2>
            <p className="text-muted">Listing all conferences</p>
            {(() => this.props.isAdmin ?
                (<div className="btn-group" role="group" aria-label="Actions menu">
                  <Link className="btn btn-secondary btn-sm" to="/conference/new">Add conference</Link>
                </div>) : ''
            )()}
          </header>
          {(() => conferences.length ?
            <ul className="list-group list-group-flush">{conferences}</ul> :
            <p className="alert">No conferences yet.</p>
          )()}
        </article>
      </DocumentTitle>
    );
  }
}

ConferencesPage.propTypes = {
  actions: PropTypes.object.isRequired,
  conferences: PropTypes.object.isRequired,
  isAdmin: PropTypes.bool.isRequired
};

ConferencesPage.defaultProps = {
  isAdmin: false
};

function mapStateToProps(state) {
  return {
    conferences: state.conferences,
    isAdmin: state.session.isAdmin
  };
}

function mapDispatchToProps(dispatch) {
  return {
    actions: bindActionCreators(ConferenceActions, dispatch)
  };
}

export default connect(mapStateToProps, mapDispatchToProps)(ConferencesPage);
{'fraction_non_alphanumeric': 0.13401283503208758, 'fraction_numerical': 0.0007550018875047187, 'mean_word_length': 3.329248366013072, 'pattern_counts': {'":': 0, '<': 47, '<?xml version=': 0, '>': 50, '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': '6951111', 'n_tokens_mistral': 1545, 'n_tokens_neox': 1536, 'n_words': 286}