<commit_before>import _ from 'lodash';
import React from 'react';
import { Alignment, ButtonGroup, Divider, Button } from '@blueprintjs/core';
import { compose } from 'redux';
import { connect } from 'react-redux';
import { defineMessages, injectIntl } from 'react-intl';
import { withRouter } from 'react-router';
import queryString from 'query-string';

import { Count, Schema } from 'components/common';
import { selectModel } from 'selectors';


import './SchemaCounts.scss';

const messages = defineMessages({
  addSchemaPlaceholder: {
    id: 'collection.addSchema.placeholder',
    defaultMessage: 'Add new entity type',
  },
});


class SchemaCounts extends React.PureComponent {
  constructor(props) {
    super(props);
    this.handleTabChange = this.handleTabChange.bind(this);
  }

  handleTabChange(type) {
    const { history, location } = this.props;
    const parsedHash = queryString.parse(location.hash);
    parsedHash.type = type;
    parsedHash.mode = 'entities';

    history.push({
      pathname: location.pathname,
      search: "",
      hash: queryString.stringify(parsedHash),
    });
  }

  render() {
    const { activeSchema, visibleCounts, selectableSchemata, showSchemaAdd, intl, onSelect } = this.props;

    return (
      <ButtonGroup vertical minimal className="SchemaCounts">
        {Object.keys(visibleCounts).map(schema => (
          <Button
            key={schema}
            text={<Schema.Label schema={schema} plural />}
            icon={<Schema.Icon schema={schema} />}
            rightIcon={<Count count={visibleCounts[schema]} />}
            onClick={() => onSelect(schema)}
            active={activeSchema === schema}
            alignText={Alignment.LEFT}
            fill
          />
        ))}
        {_.size(visibleCounts) > 0 && showSchemaAdd && <Divider />}
        {showSchemaAdd && (
          <Schema.Select
            onSelect={this.handleTabChange}
            fill
            optionsFilter={schema => selectableSchemata.indexOf(schema.name) !== -1}
          >
            <Button
              text={intl.formatMessage(messages.addSchemaPlaceholder)}
              icon="plus"
              rightIcon="chevron-down"
              alignText={Alignment.LEFT}
              fill
            />
          </Schema.Select>
        )}
      </ButtonGroup>
    );
  }
}

const mapStateToProps = (state, ownProps) => {
  const { activeSchema, filterSchemata, schemaCounts } = ownProps;
  const model = selectModel(state);

  if (activeSchema && !schemaCounts[activeSchema]) {
    schemaCounts[activeSchema] = 0;<commit_msg>Removed unneccesarry handleTabChange function in SchemaCounts component<commit_after>import _ from 'lodash';
import React from 'react';
import { Alignment, ButtonGroup, Divider, Button } from '@blueprintjs/core';
import { compose } from 'redux';
import { connect } from 'react-redux';
import { defineMessages, injectIntl } from 'react-intl';
import { withRouter } from 'react-router';
import queryString from 'query-string';

import { Count, Schema } from 'components/common';
import { selectModel } from 'selectors';


import './SchemaCounts.scss';

const messages = defineMessages({
  addSchemaPlaceholder: {
    id: 'collection.addSchema.placeholder',
    defaultMessage: 'Add new entity type',
  },
});


class SchemaCounts extends React.PureComponent {
  render() {
    const { activeSchema, visibleCounts, selectableSchemata, showSchemaAdd, intl, onSelect } = this.props;

    return (
      <ButtonGroup vertical minimal className="SchemaCounts">
        {Object.keys(visibleCounts).map(schema => (
          <Button
            key={schema}
            text={<Schema.Label schema={schema} plural />}
            icon={<Schema.Icon schema={schema} />}
            rightIcon={<Count count={visibleCounts[schema]} />}
            onClick={() => onSelect(schema)}
            active={activeSchema === schema}
            alignText={Alignment.LEFT}
            fill
          />
        ))}
        {_.size(visibleCounts) > 0 && showSchemaAdd && <Divider />}
        {showSchemaAdd && (
          <Schema.Select
            onSelect={schema => onSelect(schema)}
            fill
            optionsFilter={schema => selectableSchemata.indexOf(schema.name) !== -1}
          >
            <Button
              text={intl.formatMessage(messages.addSchemaPlaceholder)}
              icon="plus"
              rightIcon="chevron-down"
              alignText={Alignment.LEFT}
              fill
            />
          </Schema.Select>
        )}
      </ButtonGroup>
    );
  }
}

const mapStateToProps = (state, ownProps) => {
  const { activeSchema, filterSchemata, schemaCounts } = ownProps;
  const model = selectModel(state);

  if (activeSchema && !schemaCounts[activeSchema]) {
    schemaCounts[activeSchema] = 0;
{'fraction_non_alphanumeric': 0.1261954261954262, 'fraction_numerical': 0.0012474012474012475, 'mean_word_length': 2.6809487375669474, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 34, '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': '120690', 'n_tokens_mistral': 1345, 'n_tokens_neox': 1328, 'n_words': 282}