<commit_before>import React from 'react';
import { connect } from 'react-redux';
import request from 'superagent';
import { displayRepos , GET_REPOS } from '../components/github';
import { fetchResource, resourceFetchSucceeded, resourceFetchFailed } from '../resource-manager';

const getAllReposForUser = (user) => {
  return dispatch => {
    dispatch(fetchResource(GET_REPOS));
    request.get(`https://api.github.com/users/${user}/repos`)
      .end((err, res) => {
        if (err || !res.ok) {
          dispatch(resourceFetchFailed(GET_REPOS, err));
        } else {
          dispatch(displayRepos(res.body));
          dispatch(resourceFetchSucceeded(GET_REPOS));
        }
      });
  }
};

class GithubRepoList extends React.Component {
  constructor(props) {
    super(props);
  }

  componentDidMount() {
    this.props.dispatch(getAllReposForUser('crevax'));
  }

  render() {
    let repos = this.props.repos.map((repo, idx) => {
      return (
        <div key={idx}>
          <h3>{ repo.name }</h3>
        </div>
      )
    });

    return (
      <div className='github-repo-list'>
        <h2>Crevax</h2>
        { repos }
      </div>
    )
  }
}

function select(state) {
  return {
    repos: state.repos
  }
}

export default connect(select)(GithubRepoList);<commit_msg>Track resource fetch status withing Github list component and display loader when applicable<commit_after>import React from 'react';
import { connect } from 'react-redux';
import request from 'superagent';
import { displayRepos , GET_REPOS } from '../components/github';
import { fetchResource, resourceFetchSucceeded, resourceFetchFailed } from '../resource-manager';
import { Loader } from '../components/animation';

const getAllReposForUser = (user) => {
  return dispatch => {
    dispatch(fetchResource(GET_REPOS));
    request.get(`https://api.github.com/users/${user}/repos`)
      .end((err, res) => {
        if (err || !res.ok) {
          dispatch(resourceFetchFailed(GET_REPOS, err));
        } else {
          dispatch(displayRepos(res.body));
          dispatch(resourceFetchSucceeded(GET_REPOS));
        }
      });
  }
};

class GithubRepoList extends React.Component {
  constructor(props) {
    super(props);
  }

  componentDidMount() {
    this.props.dispatch(getAllReposForUser('crevax'));
  }

  render() {
    if (!this.props.resourceFetchStatus.hasOwnProperty(GET_REPOS)
      || this.props.resourceFetchStatus[GET_REPOS].progress === "BUSY")
    {
      return <Loader />
    }
    let repos = this.props.repos.map((repo, idx) => {
      return (
        <div key={idx}>
          <h3>{ repo.name }</h3>
        </div>
      )
    });

    return (
      <div className='github-repo-list'>
        <h2>Crevax</h2>
        { repos }
      </div>
    )
  }
}

function select(state) {
  return {
    repos: state.repos,
    resourceFetchStatus: state.resourceFetchStatus
  }
}

export default connect(select)(GithubRepoList);
{'fraction_non_alphanumeric': 0.14692908042076688, 'fraction_numerical': 0.0027146250424160165, 'mean_word_length': 2.858638743455497, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 28, 'https://': 2, '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': '7133330', 'n_tokens_mistral': 935, 'n_tokens_neox': 919, 'n_words': 171}