<commit_before>import React, { PropTypes } from 'react';
import { Cell } from 'fixed-data-table';
import RowImage from './components/RowImage';
import styles from './styles.module.css';

export default class TextCell extends React.Component {
  static propTypes = {
    results: PropTypes.array,
    rowIndex: PropTypes.number,
    field: PropTypes.string,
    formatValueFn: PropTypes.func,
    onClick: PropTypes.func.isRequired,
    width: PropTypes.number.isRequired,
    entitySetId: PropTypes.string,
    propertyTypes: PropTypes.array.isRequired,
    renderImage: PropTypes.bool
  }

  getClassName = () => {
    return (this.props.entitySetId) ? styles.textCell : styles.textCellUnclickable;
  }

  getOnClickFn = () => {
    const { rowIndex, results, entitySetId, propertyTypes } = this.props;
    const rowValues = {};
    propertyTypes.forEach((propertyType) => {
      const fqn = `${propertyType.type.namespace}.${propertyType.type.name}`;
      const value = results[rowIndex][fqn];
      if (value) rowValues[fqn] = value;
    });
    if (this.props.entitySetId) {
      return () => {
        this.props.onClick(results[rowIndex].id, rowValues, entitySetId, propertyTypes);
      };
    }
    return () => {};
  }

  renderImage = () => {
    const { rowIndex, field, results } = this.props;
    let counter = 0;
    const images = results[rowIndex][field].map((imgSrc) => {
      counter += 1;
      return <RowImage key={`${field}-${counter}`} imgSrc={imgSrc} />;
    });
    return <div className={styles.imgDataContainer}>{images}</div>;
  }

  render() {
    const { rowIndex, field, results, width, renderImage } = this.props;<commit_msg>don't try to render image if property type not present<commit_after>import React, { PropTypes } from 'react';
import { Cell } from 'fixed-data-table';
import RowImage from './components/RowImage';
import styles from './styles.module.css';

export default class TextCell extends React.Component {
  static propTypes = {
    results: PropTypes.array,
    rowIndex: PropTypes.number,
    field: PropTypes.string,
    formatValueFn: PropTypes.func,
    onClick: PropTypes.func.isRequired,
    width: PropTypes.number.isRequired,
    entitySetId: PropTypes.string,
    propertyTypes: PropTypes.array.isRequired,
    renderImage: PropTypes.bool
  }

  getClassName = () => {
    return (this.props.entitySetId) ? styles.textCell : styles.textCellUnclickable;
  }

  getOnClickFn = () => {
    const { rowIndex, results, entitySetId, propertyTypes } = this.props;
    const rowValues = {};
    propertyTypes.forEach((propertyType) => {
      const fqn = `${propertyType.type.namespace}.${propertyType.type.name}`;
      const value = results[rowIndex][fqn];
      if (value) rowValues[fqn] = value;
    });
    if (this.props.entitySetId) {
      return () => {
        this.props.onClick(results[rowIndex].id, rowValues, entitySetId, propertyTypes);
      };
    }
    return () => {};
  }

  renderImage = () => {
    const { rowIndex, field, results } = this.props;
    const value = results[rowIndex][field];
    if (!value) return '';
    let counter = 0;
    const images = value.map((imgSrc) => {
      counter += 1;
      return <RowImage key={`${field}-${counter}`} imgSrc={imgSrc} />;
    });
    return <div className={styles.imgDataContainer}>{images}</div>;
  }

  render() {
    const { rowIndex, field, results, width, renderImage } = this.props;
{'fraction_non_alphanumeric': 0.14494875549048317, 'fraction_numerical': 0.001171303074670571, 'mean_word_length': 3.4248704663212437, 'pattern_counts': {'":': 0, '<': 9, '<?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': '3509057', 'n_tokens_mistral': 1031, 'n_tokens_neox': 1038, 'n_words': 224}