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

export default class FilePreview extends Component {

  handleClickDelete(path) {
    const { onClickDelete } = this.props;
    const confirm = window.confirm("Are you sure that you want to delete this file?");
    if (confirm) {
      const filename = path.substring(path.lastIndexOf('/') + 1);
      onClickDelete(filename);
    }
  }

  render() {
    const { file } = this.props;
    const extension = file.extname.substring(1);
    const image = /png|jpg|gif|jpeg/.test(extension);
    return (
      <div className="file-preview">
        <a href={file.path} target="_blank">
        {
          image && <img src={`data:image/${extension};base64,${file.encoded_content}`} />
        }
        {
          !image &&
          <div><i className="fa fa-file-text-o" aria-hidden="true"></i></div>
        }
        </a>
        <span className="filename">{file.path}</span>
        <button onClick={() => this.handleClickDelete(file.path)} className="delete" title="Delete file">x</button>
      </div>
    );
  }
}

FilePreview.propTypes = {
  file: PropTypes.object.isRequired,
  onClickDelete: PropTypes.func.isRequired<commit_msg>show filename when deleting a static file<commit_after>import React, { Component, PropTypes } from 'react';

export default class FilePreview extends Component {

  handleClickDelete(path) {
    const { onClickDelete } = this.props;
    const filename = path.substring(path.lastIndexOf('/') + 1);
    const confirm = window.confirm(`Are you sure that you want to delete "${filename}"?`);
    if (confirm) {
      onClickDelete(filename);
    }
  }

  render() {
    const { file } = this.props;
    const extension = file.extname.substring(1);
    const image = /png|jpg|gif|jpeg/.test(extension);
    return (
      <div className="file-preview">
        <a href={file.path} target="_blank">
        {
          image && <img src={`data:image/${extension};base64,${file.encoded_content}`} />
        }
        {
          !image &&
          <div><i className="fa fa-file-text-o" aria-hidden="true"></i></div>
        }
        </a>
        <span className="filename">{file.path}</span>
        <button onClick={() => this.handleClickDelete(file.path)} className="delete" title="Delete file">x</button>
      </div>
    );
  }
}

FilePreview.propTypes = {
  file: PropTypes.object.isRequired,
  onClickDelete: PropTypes.func.isRequired
{'fraction_non_alphanumeric': 0.15601965601965603, 'fraction_numerical': 0.003276003276003276, 'mean_word_length': 2.9150641025641026, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 31, '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': '1366553', 'n_tokens_mistral': 723, 'n_tokens_neox': 728, 'n_words': 152}