<commit_before>/*** @jsx React.DOM */

var React = require("react");

var AggregateListActions = require("../actions/aggregateListActions");
var DropdownLink = require("./dropdownLink");
var MenuItem = require("./menuItem");

var AssigneeSelector = React.createClass({
  propTypes: {
    aggregate: React.PropTypes.shape({
      id: React.PropTypes.string.isRequired
    }).isRequired,
    memberList: React.PropTypes.instanceOf(Array).isRequired,
  },

  getInitialState: function() {
    return {
      loading: false
    };
  },

  onAssignTo: function(member) {
    this.setState({loading: true});
    AggregateListActions.setAssignedTo(this.props.aggregate.id, member.email, this.onAssignToComplete);
  },

  onAssignToComplete: function() {
    this.setState({loading: false});
  },

  render: function() {
    var agg = this.props.aggregate;

    var className = "user-selector";
    if (!agg.assignedTo) {
      className += " unassigned";
    }

    var memberNodes = [];
    this.props.memberList.forEach(function(item){
      memberNodes.push(
        <MenuItem key={item.id}
                  disabled={!this.state.loading}
                  onSelect={this.onAssignTo.bind(this, item)} >
          <img src={item.avatarUrl} className="avatar" />
          {item.name || item.email}
        </MenuItem>
      );
    }.bind(this));

    return (
      <div className={className}>
        {this.state.loading ?
          <span>LOADING</span>
        :
          <DropdownLink
            className="btn-sm btn-default"
            title={agg.assignedTo ?
              <img src={agg.assignedTo.avatarUrl} className="avatar" />
            :
              <span className="icon-user" />
            }>
            <MenuItem noAnchor={true} key="filter">
              <input type="text" className="form-control input-sm" placeholder="Filter people" />
            </MenuItem>
            {memberNodes}
          </DropdownLink>
        }
      </div>
    );<commit_msg>Add simple clear assignee operation<commit_after>/*** @jsx React.DOM */

var React = require("react");

var AggregateListActions = require("../actions/aggregateListActions");
var DropdownLink = require("./dropdownLink");
var MenuItem = require("./menuItem");

var AssigneeSelector = React.createClass({
  propTypes: {
    aggregate: React.PropTypes.shape({
      id: React.PropTypes.string.isRequired
    }).isRequired,
    memberList: React.PropTypes.instanceOf(Array).isRequired,
  },

  getInitialState: function() {
    return {
      loading: false
    };
  },

  assignTo: function(member) {
    this.setState({loading: true});
    AggregateListActions.setAssignedTo(this.props.aggregate.id, member.email, this.onAssignToComplete);
  },

  clearAssignTo: function(member) {
    this.setState({loading: true});
    AggregateListActions.setAssignedTo(this.props.aggregate.id, '', this.onAssignToComplete);
  },

  onAssignToComplete: function() {
    this.setState({loading: false});
  },

  render: function() {
    var agg = this.props.aggregate;

    var className = "user-selector";
    if (!agg.assignedTo) {
      className += " unassigned";
    }

    var memberNodes = [];
    this.props.memberList.forEach(function(item){
      memberNodes.push(
        <MenuItem key={item.id}
                  disabled={!this.state.loading}
                  onSelect={this.assignTo.bind(this, item)} >
          <img src={item.avatarUrl} className="avatar" />
          {item.name || item.email}
        </MenuItem>
      );
    }.bind(this));

    return (
      <div className={className}>
        {this.state.loading ?
          <span>LOADING</span>
        :
          <DropdownLink
            className="btn-sm btn-default"
            title={agg.assignedTo ?
              <img src={agg.assignedTo.avatarUrl} className="avatar" />
            :
              <span className="icon-user" />
            }>
            <MenuItem noAnchor={true} key="filter">
              <input type="text" className="form-control input-sm" placeholder="Filter people" />
            </MenuItem>
            {agg.assignedTo ?
              <MenuItem key="clear"
                        disabled={!this.state.loading}
                        onSelect={this.clearAssignTo}>
                Clear Assignee
              </MenuItem>
            : ''}
            {memberNodes}
          </DropdownLink>
        }
      </div>
    );
{'fraction_non_alphanumeric': 0.1410693970420933, 'fraction_numerical': 0.0, 'mean_word_length': 2.2635486265775797, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 33, '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': '3870413', 'n_tokens_mistral': 1291, 'n_tokens_neox': 1261, 'n_words': 212}