<commit_before>import React from 'react';
import DecksActions from '../data/decks-actions';
import Dialog, { DialogTitle, DialogContent, DialogActions } from 'material-ui/Dialog';
import TextField from 'material-ui/TextField';
import Button from 'material-ui/Button';

/**
 * Create deck dialog component.
 */
class CreateDeckDialog extends React.Component {

  constructor(props) {
    super(props);
    this.state = {
      name: '',
      description: ''
    };
  }

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

    return (
      <Dialog open={open} onRequestClose={this.handleCloseRequest.bind(this)}>
        <DialogTitle>
          Create new deck
        </DialogTitle>
        <DialogContent>
          <TextField fullWidth autoFocus required label="Name" value={this.state.name} margin="dense" 
            onChange={this.handleNameTextChange.bind(this)} />
          <TextField fullWidth multiline rows={2}label="Description" value={this.state.description} margin="dense" 
            onChange={this.handleDescriptionTextChange.bind(this)} />
        </DialogContent>
        <DialogActions>
          <Button color="accent" onClick={this.handleCreateDeckButtonClick.bind(this)}>Create</Button>
          <Button onClick={this.handleCancelButtonClick.bind(this)}>Cancel</Button>
        </DialogActions>
      </Dialog>
    );
  }

  handleNameTextChange(e) {
    this.setState({ name: e.target.value });
  }

  handleDescriptionTextChange(e) {
    this.setState({ description: e.target.value });
  }

  handleCloseRequest() {
    if (this.props.onRequestClose)
      this.props.onRequestClose();
  }

  handleCreateDeckButtonClick() {
    const name = this.state.name.trim();
    const description = this.state.description.trim();
    if (name)
      this.createDeck(name, description);
  }

  handleCancelButtonClick() {
    if (this.props.onRequestClose)
      this.props.onRequestClose();
    this.clear();
  }

  createDeck(name, description) {
    DecksActions.addDeck({name, description});
    this.clear();
  }

  clear() {
    this.setState({
      name: '',
      description: ''
    });
  }<commit_msg>Fixed create dialog close bug.<commit_after>import React from 'react';
import DecksActions from '../data/decks-actions';
import CreatingDeckActions from '../data/creating-deck-actions';
import Dialog, { DialogTitle, DialogContent, DialogActions } from 'material-ui/Dialog';
import TextField from 'material-ui/TextField';
import Button from 'material-ui/Button';

/**
 * Create deck dialog component.
 */
class CreateDeckDialog extends React.Component {

  constructor(props) {
    super(props);
    this.state = {
      name: '',
      description: ''
    };
  }

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

    return (
      <Dialog open={open} onRequestClose={this.handleCloseRequest.bind(this)}>
        <DialogTitle>
          Create new deck
        </DialogTitle>
        <DialogContent>
          <TextField fullWidth autoFocus required label="Name" value={this.state.name} margin="dense" 
            onChange={this.handleNameTextChange.bind(this)} />
          <TextField fullWidth multiline rows={2}label="Description" value={this.state.description} margin="dense" 
            onChange={this.handleDescriptionTextChange.bind(this)} />
        </DialogContent>
        <DialogActions>
          <Button color="accent" onClick={this.handleCreateDeckButtonClick.bind(this)}>Create</Button>
          <Button onClick={this.handleCancelButtonClick.bind(this)}>Cancel</Button>
        </DialogActions>
      </Dialog>
    );
  }

  handleNameTextChange(e) {
    this.setState({ name: e.target.value });
  }

  handleDescriptionTextChange(e) {
    this.setState({ description: e.target.value });
  }

  handleCloseRequest() {
    if (this.props.onRequestClose)
      this.props.onRequestClose();
  }

  handleCreateDeckButtonClick() {
    const name = this.state.name.trim();
    const description = this.state.description.trim();
    if (name)
      this.createDeck(name, description);
  }

  handleCancelButtonClick() {
    if (this.props.onRequestClose)
      this.props.onRequestClose();
    this.clear();
  }

  createDeck(name, description) {
    DecksActions.addDeck({name, description});
    CreatingDeckActions.stopDeckCreation();
    this.clear();
  }

  clear() {
    this.setState({
      name: '',
      description: ''
    });
  }
{'fraction_non_alphanumeric': 0.135678391959799, 'fraction_numerical': 0.00045682960255824577, 'mean_word_length': 3.1546489563567364, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 31, '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': '498818', 'n_tokens_mistral': 1278, 'n_tokens_neox': 1254, 'n_words': 231}