<commit_before>import React from 'react';

import ProgressBar from './ProgressBar';

class PromiseContainer extends React.PureComponent {

  constructor(props) {
    super(props);
    this.state = { pending: true };
  }

  componentDidMount() {
    this.load(this.props);
  }

  componentWillReceiveProps(nextProps) {
    if (!Object.keys(nextProps).every(key => nextProps[key] === this.props.key)) {
      this.setState({ pending: true });
      this.load(nextProps);
    }
  }

  load(props) {
    const propKeys = Object.keys(props).filter(key => !PromiseContainer.propTypes.hasOwnProperty(key));
    Promise.all(propKeys.map(key => Promise.resolve(props[key])))
      .then(values => {
        const resolvedProps = {};
        propKeys.forEach((key, i) => resolvedProps[key] = values[i]);
        this.props.onResolve &&
          this.props.onResolve(resolvedProps);
        this.setState({ pending: false, props: resolvedProps });
      })
      .catch(err => {
        this.setState({ pending: false, err: err });
      });
  }

  render() {
    if (this.state.pending) {
      /*
      return (
        <section>
          <div style={{ color: "#c7c7c7" }}>
            <i className="fa fa-spinner fa-pulse fa-3x fa-fw" aria-hidden="true"></i>
            <span className="sr-only">Loading...</span>
          </div>
        </section>
      );
      */
      /*
      return (
        <section>
          <div className="progress">
            <div className="progress-bar progress-bar-striped active"
                 role="progressbar"
                 aria-valuenow="100"
                 aria-valuemin="0"
                 aria-valuemax="100"
                 style={{ width: "100%" }}>
              <span className="sr-only">Loading...</span>
            </div>
          </div>
        </section>
      );
      */
      return (
        <section>
          <ProgressBar/>
        </section>
      );
    }

    if (this.state.err) {<commit_msg>PromiseContainer: wrapper for promises, resolves props which are promises and passes them down to child component.<commit_after>import React from 'react';

import ProgressBar from './ProgressBar';

class PromiseContainer extends React.PureComponent {

  constructor(props) {
    super(props);
    this.state = { pending: true };
  }

  componentDidMount() {
    this.load(this.props);
  }

  componentWillReceiveProps(nextProps) {
    if (!Object.keys(nextProps).every(key => nextProps[key] === this.props.key)) {
      this.setState({ pending: true });
      this.load(nextProps);
    }
  }

  load(props) {
    const propKeys = Object.keys(props).filter(key => !PromiseContainer.propTypes.hasOwnProperty(key));
    Promise.all(propKeys.map(key => Promise.resolve(props[key])))
      .then(values => {
        const resolvedProps = {};
        propKeys.forEach((key, i) => resolvedProps[key] = values[i]);
        this.props.onResolve &&
          this.props.onResolve(resolvedProps);
        this.setState({ pending: false, props: resolvedProps });
      })
      .catch(err => {
        this.setState({ pending: false, err: err });
      });
  }

  render() {
    if (this.state.pending) {
      return (
        <section>
          <ProgressBar/>
        </section>
      );
    }

    if (this.state.err) {
{'fraction_non_alphanumeric': 0.152153987167736, 'fraction_numerical': 0.004277421326000611, 'mean_word_length': 2.2287968441814594, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 37, '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': '1870206', 'n_tokens_mistral': 976, 'n_tokens_neox': 968, 'n_words': 180}