<commit_before>import React, { Component, PropTypes } from 'react';
import Snackbar from 'material-ui/lib/snackbar';
import Dialog from 'material-ui/lib/dialog';
import FlatButton from 'material-ui/lib/flat-button';
import Card from 'material-ui/lib/card/card';
import CardHeader from 'material-ui/lib/card/card-header';
import CardText from 'material-ui/lib/card/card-text';

import dateformat from 'dateformat';

import pureRender from 'decorators/pureRender';
import styles from './styles';

@pureRender
export default class ErrorManager extends Component {
  static propTypes = {
    errors: PropTypes.object.isRequired,
    markErrorsAsViewed: PropTypes.func.isRequired,
    clearErrors: PropTypes.func.isRequired,
    timer: PropTypes.number,
  };

  static defaultProps = {
    timer: 4000,
    errors: {},
  };

  constructor(...args) {
    super(...args);
    this.state = {
      dialogOpen: false,
    };
  }

  _handleDetailsTouchTap() {
    this.setState({ dialogOpen: true });
  }

  _handleDialogClose() {
    const { clearErrors } = this.props;

    this.setState({ dialogOpen: false });
    clearErrors();
  }

  _makeSnackbarText() {
    const errors = Object.values(this.props.errors);

    switch (errors.length) {
      case 0:
        return '';
      case 1:
        return errors[0].error.shortError;
      default:
        return 'Multiple Errors';
    }
  }

  render() {
    const { dialogOpen, timer } = this.state;
    const { errors } = this.props;
    const { markErrorsAsViewed } = this.props;

    const shouldDisplaySnack = Object.keys(errors).reduce((cur, e) => (
      cur || errors[e].viewed !== true
    ), false);

    return (
      <div>
        <Snackbar
          open={shouldDisplaySnack}
          message={this._makeSnackbarText()}
          autoHideDuration={timer}
          onRequestClose={markErrorsAsViewed}
          action="details"
          onActionTouchTap={::this._handleDetailsTouchTap}
        />

        <Dialog
          title="Error Details"
          actions={
            <FlatButton
              label="Ok"
              primary
              onTouchTap={::this._handleDialogClose}
            />
          }
          autoScrollBodyContent
          modal={false}
          open={dialogOpen}
          onRequestClose={::this._handleDialogClose}
        >
          <p>
            The following errors happened.
            If you think this is a bug, don't hesitate to create an issue on
            <a href="https://github.com/hourliert/<%= appname %>" target="_blank">the repo page</a>.
          </p>
          <ul style={styles.ul}>
            {Object.keys(errors).map(key => {
              const error = errors[key].error;

              return (
                <Card key={key} style={styles.card}>
                  <CardHeader
                    title={`${dateformat(error.date, 'shortTime')} - ${error.longError}`}
                    actAsExpander
                    showExpandableButton
                  />
                  <CardText expandable>
                    <strong>Action causing the error:</strong> {key}
                  </CardText>
                  <CardText expandable>
                    <strong>Http Status:</strong> {error.message} at {error.url}
                  </CardText>
                  <CardText expandable>
                    <strong>Raw Server Error:</strong> {JSON.stringify(error.serverError)}
                  </CardText>
                  <CardText expandable>
                    <strong>Stack:</strong>:
                    <ul>
                      {
                        error.stack.map((l, i) => <li key={i}>{l}</li>)
                      }
                    </ul>
                  </CardText>
                </Card>
              );
            })}
          </ul>
        </Dialog>
      </div>
    );
  }
}
<commit_msg>Update error manager repo url.<commit_after>import React, { Component, PropTypes } from 'react';
import Snackbar from 'material-ui/lib/snackbar';
import Dialog from 'material-ui/lib/dialog';
import FlatButton from 'material-ui/lib/flat-button';
import Card from 'material-ui/lib/card/card';
import CardHeader from 'material-ui/lib/card/card-header';
import CardText from 'material-ui/lib/card/card-text';

import dateformat from 'dateformat';

import pureRender from 'decorators/pureRender';
import styles from './styles';

@pureRender
export default class ErrorManager extends Component {
  static propTypes = {
    errors: PropTypes.object.isRequired,
    markErrorsAsViewed: PropTypes.func.isRequired,
    clearErrors: PropTypes.func.isRequired,
    timer: PropTypes.number,
  };

  static defaultProps = {
    timer: 4000,
    errors: {},
  };

  constructor(...args) {
    super(...args);
    this.state = {
      dialogOpen: false,
    };
  }

  _handleDetailsTouchTap() {
    this.setState({ dialogOpen: true });
  }

  _handleDialogClose() {
    const { clearErrors } = this.props;

    this.setState({ dialogOpen: false });
    clearErrors();
  }

  _makeSnackbarText() {
    const errors = Object.values(this.props.errors);

    switch (errors.length) {
      case 0:
        return '';
      case 1:
        return errors[0].error.shortError;
      default:
        return 'Multiple Errors';
    }
  }

  render() {
    const { dialogOpen, timer } = this.state;
    const { errors } = this.props;
    const { markErrorsAsViewed } = this.props;

    const shouldDisplaySnack = Object.keys(errors).reduce((cur, e) => (
      cur || errors[e].viewed !== true
    ), false);

    return (
      <div>
        <Snackbar
          open={shouldDisplaySnack}
          message={this._makeSnackbarText()}
          autoHideDuration={timer}
          onRequestClose={markErrorsAsViewed}
          action="details"
          onActionTouchTap={::this._handleDetailsTouchTap}
        />

        <Dialog
          title="Error Details"
          actions={
            <FlatButton
              label="Ok"
              primary
              onTouchTap={::this._handleDialogClose}
            />
          }
          autoScrollBodyContent
          modal={false}
          open={dialogOpen}
          onRequestClose={::this._handleDialogClose}
        >
          <p>
            The following errors happened.
            If you think this is a bug, don't hesitate to create an issue on
            <a href="<%= repourl %>/issues" target="_blank">the repo page</a>.
          </p>
          <ul style={styles.ul}>
            {Object.keys(errors).map(key => {
              const error = errors[key].error;

              return (
                <Card key={key} style={styles.card}>
                  <CardHeader
                    title={`${dateformat(error.date, 'shortTime')} - ${error.longError}`}
                    actAsExpander
                    showExpandableButton
                  />
                  <CardText expandable>
                    <strong>Action causing the error:</strong> {key}
                  </CardText>
                  <CardText expandable>
                    <strong>Http Status:</strong> {error.message} at {error.url}
                  </CardText>
                  <CardText expandable>
                    <strong>Raw Server Error:</strong> {JSON.stringify(error.serverError)}
                  </CardText>
                  <CardText expandable>
                    <strong>Stack:</strong>:
                    <ul>
                      {
                        error.stack.map((l, i) => <li key={i}>{l}</li>)
                      }
                    </ul>
                  </CardText>
                </Card>
              );
            })}
          </ul>
        </Dialog>
      </div>
    );
  }
}

{'fraction_non_alphanumeric': 0.1211256646349371, 'fraction_numerical': 0.001815588120866295, 'mean_word_length': 1.7097680955727337, 'pattern_counts': {'":': 0, '<': 75, '<?xml version=': 0, '>': 81, 'https://': 1, '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': '1074040', 'n_tokens_mistral': 2154, 'n_tokens_neox': 2071, 'n_words': 439}