<commit_before>import React, { Component } from 'react';
import './AdminSidebar.css';
import { Nav, NavItem, NavLink } from 'reactstrap';
import { NavLink as Link} from 'react-router-dom';
import { connect } from 'react-redux';
import { fetchLessons } from '../../actions';

class AdminSidebar extends Component {
  componentWillMount() {
    this.props.fetchLessons();
  }

  render() {
    let lessons = this.props.lessons.map((lesson) => {
      let url = "/admin/lessons/" + lesson._id;
      return <NavItem key={lesson._id}><NavLink tag={Link} to={url}>{lesson.title}</NavLink></NavItem>
    })
    return (
      <div className="col-sm-3 col-md-2 sidebar">
        <Nav pills vertical>
          <NavItem>
            <NavLink tag={Link} to="/admin/users">Users</NavLink>
          </NavItem>
          <NavItem>
            <NavLink tag={Link} to="/admin/logger">Logger</NavLink>
          </NavItem>
          <NavItem>
            <NavLink tag={Link} to="/admin/questions">All Questions</NavLink>
          </NavItem>
          <NavItem>
            <NavLink tag={Link} to="/admin/lessons/new">New Lesson</NavLink>
          </NavItem>
          <NavItem>
            Lessons
          </NavItem>
          {lessons}
        </Nav>
      </div>
    );
  }
}

const mapStateToProps = state => {
  return {
    lessons: state.lessons.lessons
  }
}

const mapDispatchToProps = dispatch => {
  return {
    fetchLessons : () => {
      dispatch(fetchLessons())
    }
  }
}

export default connect(mapStateToProps, mapDispatchToProps)(AdminSidebar);
<commit_msg>Add progress bar to admin sidebar lessons loading<commit_after>import React, { Component } from 'react';
import './AdminSidebar.css';
import { Nav, NavItem, NavLink, Progress } from 'reactstrap';
import { NavLink as Link} from 'react-router-dom';
import { connect } from 'react-redux';
import { fetchLessons } from '../../actions';

class AdminSidebar extends Component {
  componentWillMount() {
    if(!this.props.lessons.fetched) {
      this.props.fetchLessons();
    }
  }

  render() {
    let lessons;
    if(this.props.lessons.fetching) {
      lessons = (<Progress animated color="muted" value="100"/>);
    } else {
      lessons = this.props.lessons.lessons.map((lesson) => {
        let url = "/admin/lessons/" + lesson._id;
        return <NavItem key={lesson._id}><NavLink tag={Link} to={url}>{lesson.title}</NavLink></NavItem>
      })
    }
    return (
      <div className="col-sm-3 col-md-2 sidebar">
        <Nav pills vertical>
          <NavItem>
            <NavLink tag={Link} to="/admin/users">Users</NavLink>
          </NavItem>
          <NavItem>
            <NavLink tag={Link} to="/admin/logger">Logger</NavLink>
          </NavItem>
          <NavItem>
            <NavLink tag={Link} to="/admin/questions">All Questions</NavLink>
          </NavItem>
          <NavItem>
            <NavLink tag={Link} to="/admin/lessons/new">New Lesson</NavLink>
          </NavItem>
          <NavItem>
            Lessons
          </NavItem>
          {lessons}
        </Nav>
      </div>
    );
  }
}

const mapStateToProps = state => {
  return {
    lessons: state.lessons
  }
}

const mapDispatchToProps = dispatch => {
  return {
    fetchLessons : () => {
      dispatch(fetchLessons())
    }
  }
}

export default connect(mapStateToProps, mapDispatchToProps)(AdminSidebar);

{'fraction_non_alphanumeric': 0.1513353115727003, 'fraction_numerical': 0.0020771513353115725, 'mean_word_length': 2.411943319838057, 'pattern_counts': {'":': 0, '<': 56, '<?xml version=': 0, '>': 64, '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': '3948965', 'n_tokens_mistral': 1053, 'n_tokens_neox': 1047, 'n_words': 213}