<commit_before>import React, { PropTypes } from 'react';
import FormModal from '../common/modal/FormModal';
import {OverlayTrigger, Tooltip} from 'react-bootstrap';

class ModalButton extends React.Component {

  buttonWithMaybeTooltip() {
    if (this.props.tooltipText) {
      return (
        <OverlayTrigger
          placement="top"
          overlay={<Tooltip id="overlay">{this.props.tooltipText}</Tooltip>}>
          <a onClick={() => this.refs.modal.show()} >{this.props.buttonChildren}</a>
        </OverlayTrigger>
      );
    }
    return <a onClick={() => this.refs.modal.show()} >{this.props.buttonChildren}</a>;
  }

  render() {
    return (
      <span>
        {this.buttonWithMaybeTooltip()}
        <FormModal
          ref="modal"
          action={this.props.action}
          onConfirm={(data) => this.props.onConfirm(data)}
          buttonStyle="danger"
          formElements={this.props.formElements}>
          {this.props.children}
        </FormModal>
      </span>
    );
  }
}

ModalButton.propTypes = {
  buttonChildren: PropTypes.node.isRequired,
  action: PropTypes.string.isRequired,
  onConfirm: PropTypes.func.isRequired,
  children: PropTypes.node.isRequired,
  tooltipText: PropTypes.string,
  formElements: PropTypes.arrayOf(PropTypes.shape({
    name: PropTypes.string.isRequired,
    type: PropTypes.string.isRequired,
    label: PropTypes.string
  }))
};

export default ModalButton;<commit_msg>Make ModalButton functional<commit_after>import React, { PropTypes } from 'react';
import FormModal from '../common/modal/FormModal';
import {OverlayTrigger, Tooltip} from 'react-bootstrap';

const ModalButton = (props) => {
  let buttonWithMaybeTooltip;
  let modal;
  if (props.tooltipText) {
    buttonWithMaybeTooltip = (
      <OverlayTrigger
        placement="top"
        overlay={<Tooltip id="overlay">{props.tooltipText}</Tooltip>}>
        <a onClick={() => modal.show()} >{props.buttonChildren}</a>
      </OverlayTrigger>
    );
  } else {
    buttonWithMaybeTooltip = <a onClick={() => modal.show()} >{props.buttonChildren}</a>;
  }
  return (
    <span>
      {buttonWithMaybeTooltip}
      <FormModal
        ref={modalRef => { modal = modalRef; }}
        action={props.action}
        onConfirm={(data) => props.onConfirm(data)}
        buttonStyle="danger"
        formElements={props.formElements}>
        {props.children}
      </FormModal>
    </span>
  );
};

ModalButton.propTypes = {
  buttonChildren: PropTypes.node.isRequired,
  action: PropTypes.string.isRequired,
  onConfirm: PropTypes.func.isRequired,
  children: PropTypes.node.isRequired,
  tooltipText: PropTypes.string,
  formElements: PropTypes.arrayOf(PropTypes.shape({
    name: PropTypes.string.isRequired,
    type: PropTypes.string.isRequired,
    label: PropTypes.string
  }))
};

export default ModalButton;
{'fraction_non_alphanumeric': 0.14069644741470277, 'fraction_numerical': 0.0, 'mean_word_length': 3.2638680659670163, 'pattern_counts': {'":': 0, '<': 27, '<?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': '250818', 'n_tokens_mistral': 831, 'n_tokens_neox': 862, 'n_words': 149}