<commit_before>import React, { Component } from 'react';
import { noop } from 'lodash';
import Button from 'material-ui/Button';
import { DropTarget } from 'react-dnd';
import { string, func, arrayOf, bool } from 'prop-types';
import mime from 'mime-types';
import { NativeTypes } from 'react-dnd-html5-backend';
const { FILE } = NativeTypes;

import styles from './styles.scss';

const boxTarget = {
  drop(props, monitor) {
    const droppedFiles = monitor.getItem().files;
    const allowableDroppedFiles = droppedFiles.filter(f =>
      // only accept dropped files of the correct type.
      props.acceptedFileTypes.includes(f.type)
    );

    if (props.acceptedFileTypes.length) {
      if (allowableDroppedFiles.length) {
        props.onFilesSelected(allowableDroppedFiles);
      }
    } else {
      props.onFilesSelected(droppedFiles);
    }

    const numRejectedFiles = droppedFiles.length - allowableDroppedFiles.length;
    if (numRejectedFiles > 0) {
      props.onFilesRejected(numRejectedFiles);
    }
  }
};

const collect = (connect, monitor) => {
  return {
    connectDropTarget: connect.dropTarget(),
    isOver: monitor.isOver(),
    canDrop: monitor.canDrop()
  };
};

@DropTarget(FILE, boxTarget, collect)
class FileUploader extends Component {
  static propTypes = {
    acceptedFileTypes: arrayOf(string),<commit_msg>fix showing rejected file error when no file restrictions are in place<commit_after>import React, { Component } from 'react';
import { noop } from 'lodash';
import Button from 'material-ui/Button';
import { DropTarget } from 'react-dnd';
import { string, func, arrayOf, bool } from 'prop-types';
import mime from 'mime-types';
import { NativeTypes } from 'react-dnd-html5-backend';
const { FILE } = NativeTypes;

import styles from './styles.scss';

const boxTarget = {
  drop(props, monitor) {
    const droppedFiles = monitor.getItem().files;
    const allowableDroppedFiles = droppedFiles.filter(f =>
      // only accept dropped files of the correct type.
      props.acceptedFileTypes.includes(f.type)
    );

    if (props.acceptedFileTypes.length) {
      if (allowableDroppedFiles.length) {
        props.onFilesSelected(allowableDroppedFiles);
      }

      const numRejectedFiles = droppedFiles.length - allowableDroppedFiles.length;
      if (numRejectedFiles > 0) {
        props.onFilesRejected(numRejectedFiles);
      }
    } else {
      props.onFilesSelected(droppedFiles);
    }
  }
};

const collect = (connect, monitor) => {
  return {
    connectDropTarget: connect.dropTarget(),
    isOver: monitor.isOver(),
    canDrop: monitor.canDrop()
  };
};

@DropTarget(FILE, boxTarget, collect)
class FileUploader extends Component {
  static propTypes = {
    acceptedFileTypes: arrayOf(string),
{'fraction_non_alphanumeric': 0.11534276387377584, 'fraction_numerical': 0.0014508523757707653, 'mean_word_length': 3.738831615120275, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '1921666', 'n_tokens_mistral': 844, 'n_tokens_neox': 829, 'n_words': 200}