<commit_before>import React, {PropTypes, Component} from 'react';
import { connect } from 'react-redux';

import NamespaceItem from './NamespaceItem';
import { fetchNamespaces, fetchAndToggleNamespace } from '../../actions/actions';
import {List} from 'material-ui/List';
import AppContainer from '../../containers/AppContainer'
class NamespaceList extends Component {
  constructor(props) {
    super(props);

    this.renderLoading = this.renderLoading.bind(this);
    this.renderList = this.renderList.bind(this);
    this.renderError = this.renderError.bind(this);
  }

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

  renderLoading() {
    return (
      <span>LOADING!</span>
    )
  }

  renderError(error) {
    return (
      <span>ERROR!</span>
    )
  }

  renderList() {
    const {items, fetchAndToggleNamespace} = this.props;

    const style = { //toolbar height is 56px + 8px margin
      overflowY: 'auto',
      height:'calc(100% - 72px)',
      paddingTop:0,
      margin: '8px 5px',
      backgroundColor:AppContainer.theme.palette.primary3Color
    };
    return (
        <List style={style}>
        {Object.keys(items).map((item, index) => (
            <NamespaceItem namespace={items[item]} event={fetchAndToggleNamespace} key={index} />
        ))}
        </List>
    );
  }

  render() {
    const {fetching, error, items} = this.props;

    if(fetching && Object.keys(items).length < 1) {
      return this.renderLoading()
    }

    if(error) {
      return this.renderError();
    }

    return this.renderList();
  }
}


const mapStateToProps = (state) => ({
  items: state.api.namespaces,
  fetching: state.api.fetching,
  error: state.api.error
});

const mapDispatchToProps = (dispatch) => ({
    fetchNamespaces() {
      dispatch(fetchNamespaces());
    },
    fetchAndToggleNamespace(namespace) {
      dispatch(fetchAndToggleNamespace(namespace));
    }
});
export default connect(
  mapStateToProps,
  mapDispatchToProps
)(NamespaceList)
<commit_msg>NamespaceList: render refresh button in error state<commit_after>import React, {PropTypes, Component} from 'react';
import { connect } from 'react-redux';

import NamespaceItem from './NamespaceItem';
import { fetchNamespaces, fetchAndToggleNamespace } from '../../actions/actions';
import {List} from 'material-ui/List';
import AppContainer from '../../containers/AppContainer'
import RaisedButton from 'material-ui/RaisedButton';
import NavigationRefresh from 'material-ui/svg-icons/navigation/refresh'

class NamespaceList extends Component {
  constructor(props) {
    super(props);

    this.renderLoading = this.renderLoading.bind(this);
    this.renderList = this.renderList.bind(this);
    this.renderError = this.renderError.bind(this);
  }

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

  renderLoading() {
    return (
      <span>LOADING!</span>
    )
  }

  renderError(error) {
    return (
      <RaisedButton
          label="Try again"
          icon={<NavigationRefresh/>}
          onClick={this.props.fetchNamespaces}
      />
    )
  }

  renderList() {
    const {items, fetchAndToggleNamespace} = this.props;

    const style = { //toolbar height is 56px + 8px margin
      overflowY: 'auto',
      height:'calc(100% - 72px)',
      paddingTop:0,
      margin: '8px 5px',
      backgroundColor:AppContainer.theme.palette.primary3Color
    };
    return (
        <List style={style}>
        {Object.keys(items).map((item, index) => (
            <NamespaceItem namespace={items[item]} event={fetchAndToggleNamespace} key={index} />
        ))}
        </List>
    );
  }

  render() {
    const {fetching, error, items} = this.props;

    if(fetching && Object.keys(items).length < 1) {
      return this.renderLoading()
    }

    if(error) {
      return this.renderError();
    }

    return this.renderList();
  }
}


const mapStateToProps = (state) => ({
  items: state.api.namespaces,
  fetching: state.api.fetching,
  error: state.api.error
});

const mapDispatchToProps = (dispatch) => ({
    fetchNamespaces() {
      dispatch(fetchNamespaces());
    },
    fetchAndToggleNamespace(namespace) {
      dispatch(fetchAndToggleNamespace(namespace));
    }
});
export default connect(
  mapStateToProps,
  mapDispatchToProps
)(NamespaceList)

{'fraction_non_alphanumeric': 0.1378346915017462, 'fraction_numerical': 0.006053550640279395, 'mean_word_length': 3.1668283220174587, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 23, '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': '2265094', 'n_tokens_mistral': 1322, 'n_tokens_neox': 1282, 'n_words': 252}