<commit_before>'use strict';

import React from 'react';
import FloatingActionButton from 'material-ui/lib/floating-action-button';
import ActionSettings from 'material-ui/lib/svg-icons/action/settings';
import FlatButton from 'material-ui/lib/flat-button';
import Dialog from 'material-ui/lib/dialog';
import SlideList from './SlideListComponent';

require('styles//Settings.scss');

class SettingsComponent extends React.Component {

  constructor(props) {
    super(props);
    this.state = {
      open: false,
      timeout: undefined
    };
  }

  componentDidMount() {
    if(this.props.slides.length === 0) {
      const timeout = setTimeout(() => this.setState({open: true, timeout: undefined}), 750 );
      this.setState({timeout: timeout})
    }
  }

  componentWillReceiveProps(nextProps) {
    clearTimeout(this.state.timeout);
  }

  handleOpen = () => {
    this.setState({
      open: true
    })
  }

  handleClose = () => {
    this.setState({
      open: false
    })
  }

  render() {
    const actions = [
      <FlatButton
        label="Close"
        primary={true}
        onTouchTap={this.handleClose}
      />
    ];

    return (
      <div className="settings-component">
        <FloatingActionButton
          mini={true}
          onTouchTap={this.handleOpen}>
          <ActionSettings />
        </FloatingActionButton>

        <Dialog
          title="Gaiyo settings"
          actions={actions}
          modal={false}
          open={this.state.open}
          onRequestClose={this.handleClose}
          autoScrollBodyContent={true}
        >
          <SlideList
            slides={this.props.slides}
            onDelete={this.props.onDelete}
            onUpdate={this.props.onUpdate}
            onSave={this.props.onSave}/>
        </Dialog>
      </div>
    );
  }
}

SettingsComponent.displayName = 'SettingsComponent';

SettingsComponent.propTypes = {
  slides: React.PropTypes.array.isRequired,
  onSave: React.PropTypes.func.isRequired,
  onDelete: React.PropTypes.func.isRequired,
  onUpdate: React.PropTypes.func.isRequired
};

export default SettingsComponent;
<commit_msg>Refactors magic numbers to constants<commit_after>'use strict';

import React from 'react';
import FloatingActionButton from 'material-ui/lib/floating-action-button';
import ActionSettings from 'material-ui/lib/svg-icons/action/settings';
import FlatButton from 'material-ui/lib/flat-button';
import Dialog from 'material-ui/lib/dialog';
import SlideList from './SlideListComponent';

require('styles//Settings.scss');

class SettingsComponent extends React.Component {

  constructor(props) {
    super(props);
    this.state = {
      open: false,
      timeout: undefined
    };
  }

  componentDidMount() {
    const timeToWaitForDBRead = 750;

    if(this.props.slides.length === 0) {
      const timeout = setTimeout(
        () => this.setState({
          open: true,
          timeout: undefined
        }), timeToWaitForDBRead );
      this.setState({timeout: timeout})
    }
  }

  componentWillReceiveProps(nextProps) {
    clearTimeout(this.state.timeout);
  }

  handleOpen = () => {
    this.setState({
      open: true
    })
  }

  handleClose = () => {
    this.setState({
      open: false
    })
  }

  render() {
    const actions = [
      <FlatButton
        label="Close"
        primary={true}
        onTouchTap={this.handleClose}
      />
    ];

    return (
      <div className="settings-component">
        <FloatingActionButton
          mini={true}
          onTouchTap={this.handleOpen}>
          <ActionSettings />
        </FloatingActionButton>

        <Dialog
          title="Gaiyo settings"
          actions={actions}
          modal={false}
          open={this.state.open}
          onRequestClose={this.handleClose}
          autoScrollBodyContent={true}
        >
          <SlideList
            slides={this.props.slides}
            onDelete={this.props.onDelete}
            onUpdate={this.props.onUpdate}
            onSave={this.props.onSave}/>
        </Dialog>
      </div>
    );
  }
}

SettingsComponent.displayName = 'SettingsComponent';

SettingsComponent.propTypes = {
  slides: React.PropTypes.array.isRequired,
  onSave: React.PropTypes.func.isRequired,
  onDelete: React.PropTypes.func.isRequired,
  onUpdate: React.PropTypes.func.isRequired
};

export default SettingsComponent;

{'fraction_non_alphanumeric': 0.12356979405034325, 'fraction_numerical': 0.0018306636155606408, 'mean_word_length': 2.5450121654501214, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 27, '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': '5507843', 'n_tokens_mistral': 1296, 'n_tokens_neox': 1277, 'n_words': 218}