<commit_before>import React, { PropTypes } from 'react';
import { injectIntl, intlShape } from 'react-intl';
import Dialog from 'material-ui/Dialog';
import FlatButton from 'material-ui/FlatButton';
import formTranslations from 'lib/translations/form';

const buttonStyle = {
  margin: 3,
};

const ConfirmationDialog = ({
  intl,
  open,
  onCancel,
  onConfirm,
  message,
  cancelButtonText,
  confirmButtonText,
  confirmDiscard,
  confirmDelete,
  confirmSubmit,
  disableCancelButton,
  disableConfirmButton,
}) => {
  let confirmationButtonText = intl.formatMessage(formTranslations.continue);
  if (confirmButtonText) {
    confirmationButtonText = confirmButtonText;
  } else if (confirmDelete) {
    confirmationButtonText = intl.formatMessage(formTranslations.delete);
  } else if (confirmDiscard) {
    confirmationButtonText = intl.formatMessage(formTranslations.discard);
  } else if (confirmSubmit) {
    confirmationButtonText = intl.formatMessage(formTranslations.submit);
  }

  let confirmationMessage = intl.formatMessage(formTranslations.areYouSure);
  if (message) {
    confirmationMessage = message;
  } else if (confirmDiscard) {
    confirmationMessage = intl.formatMessage(formTranslations.discardChanges);
  }

  const actions = [
    <FlatButton
      primary
      keyboardFocused
      className="cancel-btn"
      disabled={disableCancelButton}
      onTouchTap={onCancel}
      style={buttonStyle}
      label={cancelButtonText || intl.formatMessage(formTranslations.cancel)}
    />,
    <FlatButton
      primary
      className="confirm-btn"
      disabled={disableConfirmButton}
      onTouchTap={onConfirm}
      style={buttonStyle}
      label={confirmationButtonText}
    />,
  ];

  return (
    <div>
      <Dialog
        {...{ open, actions }}
        modal={false}
        onRequestClose={onCancel}
      >
        { confirmationMessage }
      </Dialog>
    </div>
  );
};

ConfirmationDialog.propTypes = {
  intl: intlShape.isRequired,
  open: PropTypes.bool.isRequired,
  onCancel: PropTypes.func.isRequired,
  onConfirm: PropTypes.func.isRequired,
  message: PropTypes.string,
  cancelButtonText: PropTypes.string,
  confirmButtonText: PropTypes.string,
  confirmDiscard: PropTypes.bool,
  confirmDelete: PropTypes.bool,
  confirmSubmit: PropTypes.bool,
  disableCancelButton: PropTypes.bool,
  disableConfirmButton: PropTypes.bool,
};
<commit_msg>Add confirmation button ref to ConfirmationDialog<commit_after>import React, { PropTypes } from 'react';
import { injectIntl, intlShape } from 'react-intl';
import Dialog from 'material-ui/Dialog';
import FlatButton from 'material-ui/FlatButton';
import formTranslations from 'lib/translations/form';

const buttonStyle = {
  margin: 3,
};

class ConfirmationDialog extends React.Component {
  static propTypes = {
    open: PropTypes.bool.isRequired,
    onCancel: PropTypes.func.isRequired,
    onConfirm: PropTypes.func.isRequired,
    message: PropTypes.string,
    cancelButtonText: PropTypes.string,
    confirmButtonText: PropTypes.string,
    confirmDiscard: PropTypes.bool,
    confirmDelete: PropTypes.bool,
    confirmSubmit: PropTypes.bool,
    disableCancelButton: PropTypes.bool,
    disableConfirmButton: PropTypes.bool,

    intl: intlShape.isRequired,
  }

  render() {
    const {
      intl,
      open,
      onCancel,
      onConfirm,
      message,
      cancelButtonText,
      confirmButtonText,
      confirmDiscard,
      confirmDelete,
      confirmSubmit,
      disableCancelButton,
      disableConfirmButton,
    } = this.props;

    let confirmationButtonText = intl.formatMessage(formTranslations.continue);
    if (confirmButtonText) {
      confirmationButtonText = confirmButtonText;
    } else if (confirmDelete) {
      confirmationButtonText = intl.formatMessage(formTranslations.delete);
    } else if (confirmDiscard) {
      confirmationButtonText = intl.formatMessage(formTranslations.discard);
    } else if (confirmSubmit) {
      confirmationButtonText = intl.formatMessage(formTranslations.submit);
    }

    let confirmationMessage = intl.formatMessage(formTranslations.areYouSure);
    if (message) {
      confirmationMessage = message;
    } else if (confirmDiscard) {
      confirmationMessage = intl.formatMessage(formTranslations.discardChanges);
    }

    const actions = [
      <FlatButton
        primary
        keyboardFocused
        className="cancel-btn"
        disabled={disableCancelButton}
        onTouchTap={onCancel}
        style={buttonStyle}
        label={cancelButtonText || intl.formatMessage(formTranslations.cancel)}
      />,
      <FlatButton
        primary
        className="confirm-btn"
        disabled={disableConfirmButton}
        onTouchTap={onConfirm}
        style={buttonStyle}
        label={confirmationButtonText}
        ref={button => (this.confirmButton = button)}
      />,
    ];

    return (
      <div>
        <Dialog
          {...{ open, actions }}
          modal={false}
          onRequestClose={onCancel}
        >
          { confirmationMessage }
        </Dialog>
      </div>
    );
  }
}

{'fraction_non_alphanumeric': 0.09823529411764706, 'fraction_numerical': 0.000392156862745098, 'mean_word_length': 3.3449744463373086, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 17, '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': '5388359', 'n_tokens_mistral': 1453, 'n_tokens_neox': 1477, 'n_words': 268}