<commit_before>import { Meteor } from 'meteor/meteor';
import React, { Component } from 'react';
import { PropTypes } from 'prop-types';
import { withRouter } from 'react-router-dom';
import Alert from 'react-bootstrap/lib/Alert';
import ButtonToolbar from 'react-bootstrap/lib/ButtonToolbar';
import ButtonGroup from 'react-bootstrap/lib/ButtonGroup';
import Button from 'react-bootstrap/lib/Button';
import container from '/imports/lib/container';
import Documents from '/imports/api/documents/documents';
import { removeDocument } from '/imports/api/documents/methods';
import NotFound from '/imports/ui/components/notFound';
import Loading from '/imports/ui/components/loading';

class ViewDocument extends Component {
  constructor() {
    super();

    this.state = { handleRemoveError: null};

    this.handleRemove = this.handleRemove.bind(this);
  }

  handleRemove(_id) {
    const { history } = this.props;
    if (confirm('Êtes-vous sûr ? Ceci est définitif !')) {
      removeDocument.call({ _id }, (error) => {
        if (error) {
          this.setState({ handleRemoveError: error.reason });
        } else {
          history.push('/documents');
        }
      });
    }
  }

  render() {
    const { doc, history } = this.props;

    return (
      doc ? (
        <div className="ViewDocument">
          {this.state.handleRemoveError ? (
            <Alert bsStyle="danger">
              {this.state.handleRemoveError}
            </Alert>
          ) : ''}
          <div className="page-header clearfix">
            <h4 className="pull-left">{ doc && doc.title }</h4>
            <ButtonToolbar className="pull-right">
              <ButtonGroup bsSize="small">
                <Button onClick={() => history.push(`/documents/${doc._id}/edit`)}>Modifier</Button>
                <Button onClick={() => this.handleRemove(doc._id)} className="text-danger">Supprimer</Button>
              </ButtonGroup>
            </ButtonToolbar>
          </div>
          { doc && doc.body }
        </div>
      ) : <NotFound />
    );
  }
}

ViewDocument.defaultProps = {
  doc: null,
  history: null,
};

ViewDocument.propTypes = {
  doc: PropTypes.object,
  history: PropTypes.object,
};
<commit_msg>Update Documents, component viewDocument with new API<commit_after>import { Meteor } from 'meteor/meteor';
import React, { Component } from 'react';
import { PropTypes } from 'prop-types';
import { withRouter } from 'react-router-dom';
import Alert from 'react-bootstrap/lib/Alert';
import ButtonToolbar from 'react-bootstrap/lib/ButtonToolbar';
import ButtonGroup from 'react-bootstrap/lib/ButtonGroup';
import Button from 'react-bootstrap/lib/Button';
import container from '/imports/lib/container';
import Documents from '/imports/api/documents/documents';
import NotFound from '/imports/ui/components/notFound';
import Loading from '/imports/ui/components/loading';

class ViewDocument extends Component {
  constructor() {
    super();

    this.state = { handleRemoveError: null};

    this.handleRemove = this.handleRemove.bind(this);
  }

  handleRemove(_id, history) {
    if (confirm('Êtes-vous sûr ? Ceci est définitif !')) {
      Meteor.call('documents.remove', { _id }, (error) => {
        if (error) {
          this.setState({ handleRemoveError: error.reason });
        } else {
          history.push('/documents');
        }
      });
    }
  }

  render() {
    const { doc, history } = this.props;

    return (
      doc ? (
        <div className="ViewDocument">
          {this.state.handleRemoveError ? (
            <Alert bsStyle="danger">
              {this.state.handleRemoveError}
            </Alert>
          ) : ''}
          <div className="page-header clearfix">
            <h4 className="pull-left">{ doc && doc.title }</h4>
            <ButtonToolbar className="pull-right">
              <ButtonGroup bsSize="small">
                <Button onClick={() => history.push(`/documents/${doc._id}/edit`)}>Modifier</Button>
                <Button onClick={() => this.handleRemove(doc._id, history)} className="text-danger">Supprimer</Button>
              </ButtonGroup>
            </ButtonToolbar>
          </div>
          { doc && doc.body }
        </div>
      ) : <NotFound />
    );
  }
}

ViewDocument.defaultProps = {
  doc: null,
  history: null,
};

ViewDocument.propTypes = {
  doc: PropTypes.object,
  history: PropTypes.object,
};

{'fraction_non_alphanumeric': 0.14526028642873381, 'fraction_numerical': 0.0009092975676290066, 'mean_word_length': 2.654485049833887, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 43, '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': '7054710', 'n_tokens_mistral': 1284, 'n_tokens_neox': 1261, 'n_words': 269}