<commit_before>var React = require('react/addons');
var Router = require('react-router');
var Radial = require('./Radial.react.js');
var SetupStore = require('./SetupStore');
var RetinaImage = require('react-retina-image');
var Header = require('./Header.react');
var Util = require('./Util');
var metrics = require('./Metrics');

var Setup = React.createClass({
  mixins: [ Router.Navigation ],
  getInitialState: function () {
    return {
      progress: 0,
      name: ''
    };
  },
  componentWillMount: function () {
    SetupStore.on(SetupStore.PROGRESS_EVENT, this.update);
    SetupStore.on(SetupStore.STEP_EVENT, this.update);
    SetupStore.on(SetupStore.ERROR_EVENT, this.update);
  },
  componentDidMount: function () {
    this.update();
  },
  componentDidUnmount: function () {
    SetupStore.removeListener(SetupStore.PROGRESS_EVENT, this.update);
    SetupStore.removeListener(SetupStore.STEP_EVENT, this.update);
    SetupStore.removeListener(SetupStore.ERROR_EVENT, this.update);
  },
  handleRetry: function () {
    metrics.track('Retried Setup');
    SetupStore.retry();
  },
  handleOpenWebsite: function () {
    Util.exec(['open', 'https://www.virtualbox.org/wiki/Downloads']);
  },
  update: function () {
    this.setState({
      progress: SetupStore.percent(),
      step: SetupStore.step(),
      error: SetupStore.error(),
      cancelled: SetupStore.cancelled()
    });
  },
  renderContents: function () {
    var img = 'virtualbox.png';
    if (SetupStore.step().name === 'init' || SetupStore.step().name === 'start') {
      img = 'boot2docker.png';
    }
    return (
      <div className="contents">
        <RetinaImage src={img} checkIfRetinaImgExists={false}/>
        <div className="detail">
          <Radial progress={SetupStore.percent()} thick={true} gray={true}/>
        </div>
      </div>
    );
  },
  renderStep: function () {
    return (
      <div className="setup">
        <Header />
        <div className="image">
          {this.renderContents()}
        </div>
        <div className="desc">
          <div className="content">
            <h4>Step {SetupStore.number()} out of {SetupStore.stepCount()}</h4>
            <h1>{SetupStore.step().title}</h1>
            <p>{SetupStore.step().message}</p>
          </div>
        </div>
      </div>
    );
  },
  renderCancelled: function () {
    return (
      <div className="setup">
        <Header />
        <div className="image">
          {this.renderContents()}
        </div>
        <div className="desc">
          <div className="content">
            <h4>Installation Cancelled</h4>
            <h1>Couldn&#39;t Install</h1>
            <p>Kitematic did not receive the administrative privileges required to install or upgrade VirtualBox &amp; Docker.</p>
            <p>Please retry or download &amp; install VirutalBox manually from the <a onClick={this.handleOpenWebsite}>official Oracle website</a>.</p>
            <button className="btn btn-action" onClick={this.handleRetry}>Retry</button>
          </div>
        </div>
      </div>
    );
  },
  renderError: function () {
    return (<commit_msg>Did not => didn't<commit_after>var React = require('react/addons');
var Router = require('react-router');
var Radial = require('./Radial.react.js');
var SetupStore = require('./SetupStore');
var RetinaImage = require('react-retina-image');
var Header = require('./Header.react');
var Util = require('./Util');
var metrics = require('./Metrics');

var Setup = React.createClass({
  mixins: [ Router.Navigation ],
  getInitialState: function () {
    return {
      progress: 0,
      name: ''
    };
  },
  componentWillMount: function () {
    SetupStore.on(SetupStore.PROGRESS_EVENT, this.update);
    SetupStore.on(SetupStore.STEP_EVENT, this.update);
    SetupStore.on(SetupStore.ERROR_EVENT, this.update);
  },
  componentDidMount: function () {
    this.update();
  },
  componentDidUnmount: function () {
    SetupStore.removeListener(SetupStore.PROGRESS_EVENT, this.update);
    SetupStore.removeListener(SetupStore.STEP_EVENT, this.update);
    SetupStore.removeListener(SetupStore.ERROR_EVENT, this.update);
  },
  handleRetry: function () {
    metrics.track('Retried Setup');
    SetupStore.retry();
  },
  handleOpenWebsite: function () {
    Util.exec(['open', 'https://www.virtualbox.org/wiki/Downloads']);
  },
  update: function () {
    this.setState({
      progress: SetupStore.percent(),
      step: SetupStore.step(),
      error: SetupStore.error(),
      cancelled: SetupStore.cancelled()
    });
  },
  renderContents: function () {
    var img = 'virtualbox.png';
    if (SetupStore.step().name === 'init' || SetupStore.step().name === 'start') {
      img = 'boot2docker.png';
    }
    return (
      <div className="contents">
        <RetinaImage src={img} checkIfRetinaImgExists={false}/>
        <div className="detail">
          <Radial progress={SetupStore.percent()} thick={true} gray={true}/>
        </div>
      </div>
    );
  },
  renderStep: function () {
    return (
      <div className="setup">
        <Header />
        <div className="image">
          {this.renderContents()}
        </div>
        <div className="desc">
          <div className="content">
            <h4>Step {SetupStore.number()} out of {SetupStore.stepCount()}</h4>
            <h1>{SetupStore.step().title}</h1>
            <p>{SetupStore.step().message}</p>
          </div>
        </div>
      </div>
    );
  },
  renderCancelled: function () {
    return (
      <div className="setup">
        <Header />
        <div className="image">
          {this.renderContents()}
        </div>
        <div className="desc">
          <div className="content">
            <h4>Installation Cancelled</h4>
            <h1>Couldn&#39;t Install</h1>
            <p>Kitematic didn&#39;t receive the administrative privileges required to install or upgrade VirtualBox &amp; Docker.</p>
            <p>Please retry or download &amp; install VirutalBox manually from the <a onClick={this.handleOpenWebsite}>official Oracle website</a>.</p>
            <button className="btn btn-action" onClick={this.handleRetry}>Retry</button>
          </div>
        </div>
      </div>
    );
  },
  renderError: function () {
    return (
{'fraction_non_alphanumeric': 0.16036983899250756, 'fraction_numerical': 0.004144747329826239, 'mean_word_length': 2.7863608931804467, 'pattern_counts': {'":': 0, '<': 87, '<?xml version=': 0, '>': 88, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4289265', 'n_tokens_mistral': 1862, 'n_tokens_neox': 1864, 'n_words': 363}