<commit_before>import * as React from 'react'
import { Dispatcher } from '../lib/dispatcher'
import { ButtonGroup } from '../ui/lib/button-group'
import { Button } from '../ui/lib/button'
import { Checkbox, CheckboxValue } from '../ui/lib/checkbox'
import { Dialog, DialogContent, DialogFooter } from '../ui/dialog'

interface IConfirmDialog {
  readonly dispatcher: Dispatcher
  readonly title: string
  readonly message: string
  readonly thisNeedsABetterNameButMyIneptitudePreventsIt?: boolean
  readonly functionToRunWhenThisNeedsABetterNameButMyIneptitudePreventsItIsTrue?: (dontAskAgain: boolean) => void
  readonly onConfirmation: () => void
}

export class ConfirmDialog extends React.Component<IConfirmDialog, void> {
  private cancel = () => {
    this.props.dispatcher.closePopup()
  }

  private onConfirmed = () => {
    this.props.onConfirmation()
    this.props.dispatcher.closePopup()
  }

  private onCheckboxChanged = (event: React.FormEvent<HTMLInputElement>) => {
    const dontAskAgainSelected = event.currentTarget.checked
    const fn = this.props.functionToRunWhenThisNeedsABetterNameButMyIneptitudePreventsItIsTrue

    if (!fn) {
      return
    }

    fn(dontAskAgainSelected)
  }

  private askToNotBeAnnoyed() {
    if (!this.props.thisNeedsABetterNameButMyIneptitudePreventsIt) {
      return null
    }

    return (<commit_msg>Add state to class<commit_after>import * as React from 'react'
import { Dispatcher } from '../lib/dispatcher'
import { ButtonGroup } from '../ui/lib/button-group'
import { Button } from '../ui/lib/button'
import { Checkbox, CheckboxValue } from '../ui/lib/checkbox'
import { Dialog, DialogContent, DialogFooter } from '../ui/dialog'

interface IConfirmDialogProps {
  readonly dispatcher: Dispatcher
  readonly title: string
  readonly message: string
  readonly thisNeedsABetterNameButMyIneptitudePreventsIt?: boolean
  readonly functionToRunWhenThisNeedsABetterNameButMyIneptitudePreventsItIsTrue?: (dontAskAgain: boolean) => void
  readonly onConfirmation: () => void
}

interface IConfirmDialogState {
  readonly dontAskAgain: boolean,
}

export class ConfirmDialog extends React.Component<IConfirmDialogProps, IConfirmDialogState> {
  private cancel = () => {
    this.props.dispatcher.closePopup()
  }

  private onConfirmed = () => {
    this.props.onConfirmation()
    this.props.dispatcher.closePopup()
  }

  private onCheckboxChanged = (event: React.FormEvent<HTMLInputElement>) => {
    const dontAskAgainSelected = event.currentTarget.checked
    const fn = this.props.functionToRunWhenThisNeedsABetterNameButMyIneptitudePreventsItIsTrue

    if (!fn) {
      return
    }

    fn(dontAskAgainSelected)
  }

  private askToNotBeAnnoyed() {
    if (!this.props.thisNeedsABetterNameButMyIneptitudePreventsIt) {
      return null
    }

    return (
{'fraction_non_alphanumeric': 0.10074494501596311, 'fraction_numerical': 0.0, 'mean_word_length': 4.444015444015444, 'pattern_counts': {'":': 0, '<': 7, '<?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': '2825796', 'n_tokens_mistral': 876, 'n_tokens_neox': 840, 'n_words': 176}