<commit_before>/**
*
* AttributeRow
*
*/

import React from 'react';
import { FormattedMessage } from 'react-intl';
import { capitalize } from 'lodash';
import PopUpWarning from 'components/PopUpWarning';
import IcoBoolean from '../../assets/images/icon_boolean.svg';
import IcoDate from '../../assets/images/icon_date.svg';
import IcoImage from '../../assets/images/icon_image.svg';
import IcoNumber from '../../assets/images/icon_number.svg';
import IcoJson from '../../assets/images/icon_json.svg';
import IcoRelation from '../../assets/images/icon_relation.svg';
import IcoString from '../../assets/images/icon_string.svg';
import IcoText from '../../assets/images/icon_text.svg';
import styles from './styles.scss';

/* eslint-disable jsx-a11y/no-static-element-interactions */
class AttributeRow extends React.Component { // eslint-disable-line react/prefer-stateless-function
  constructor(props) {
    super(props);
    this.asset = {
      'boolean': IcoBoolean,
      'date': IcoDate,
      'media': IcoImage,
      'number': IcoNumber,
      'json': IcoJson,
      'relation': IcoRelation,
      'string': IcoString,
      'text': IcoText,
    };
    this.state = {
      showWarning: false,
    };
  }

  edit = (e) => {
    e.preventDefault();
    this.props.handleEdit(this.props.row.name);
  }

  delete = () => {
    this.props.handleDelete(this.props.row.name);
    this.setState({ showWarning: false });
  }

  showModalWarning = (e) => {
    e.preventDefault();
    e.stopPropagation();
    this.setState({ showWarning: !this.state.showWarning });
  }
  toggleModalWarning = () => {
    // e.preventDefault();
    // e.stopPropagation()
    this.setState({ showWarning: !this.state.showWarning });
  }

  renderAttributesBox = () => {
    const attributeType = this.props.row.params.type || 'relation';
    const src = this.asset[attributeType];
    return <img src={src} role="presentation" />;
  }

  render() {
    const relationType = capitalize(this.props.row.params.type)
    || <div><FormattedMessage id="modelPage.attribute.relationWith" /> <span style={{ fontStyle: 'italic' }}>{capitalize(this.props.row.params.target)}</span></div>;

    const relationStyle = !this.props.row.params.type ? styles.relation : '';
    return (
      <li className={`${styles.attributeRow} ${relationStyle}`} onClick={this.edit}>
        <div className={styles.flex}>
          <div className={styles.nameContainer}>
            {this.renderAttributesBox()}
            <div>{this.props.row.name}</div>
          </div>
          <div className={styles.relationContainer}>{relationType}</div>
          <div className={styles.mainField}>n temporary</div>
          <div className={styles.icoContainer}>
            <div className="ico">
              <i className="fa fa-pencil ico" onClick={this.edit} role="button" /><commit_msg>Remove temporary text in AttributeRow<commit_after>/**
*
* AttributeRow
*
*/

import React from 'react';
import { FormattedMessage } from 'react-intl';
import { capitalize } from 'lodash';
import PopUpWarning from 'components/PopUpWarning';
import IcoBoolean from '../../assets/images/icon_boolean.svg';
import IcoDate from '../../assets/images/icon_date.svg';
import IcoImage from '../../assets/images/icon_image.svg';
import IcoNumber from '../../assets/images/icon_number.svg';
import IcoJson from '../../assets/images/icon_json.svg';
import IcoRelation from '../../assets/images/icon_relation.svg';
import IcoString from '../../assets/images/icon_string.svg';
import IcoText from '../../assets/images/icon_text.svg';
import styles from './styles.scss';

/* eslint-disable jsx-a11y/no-static-element-interactions */
class AttributeRow extends React.Component { // eslint-disable-line react/prefer-stateless-function
  constructor(props) {
    super(props);
    this.asset = {
      'boolean': IcoBoolean,
      'date': IcoDate,
      'media': IcoImage,
      'number': IcoNumber,
      'json': IcoJson,
      'relation': IcoRelation,
      'string': IcoString,
      'text': IcoText,
    };
    this.state = {
      showWarning: false,
    };
  }

  edit = (e) => {
    e.preventDefault();
    this.props.handleEdit(this.props.row.name);
  }

  delete = () => {
    this.props.handleDelete(this.props.row.name);
    this.setState({ showWarning: false });
  }

  showModalWarning = (e) => {
    e.preventDefault();
    e.stopPropagation();
    this.setState({ showWarning: !this.state.showWarning });
  }
  toggleModalWarning = () => {
    // e.preventDefault();
    // e.stopPropagation()
    this.setState({ showWarning: !this.state.showWarning });
  }

  renderAttributesBox = () => {
    const attributeType = this.props.row.params.type || 'relation';
    const src = this.asset[attributeType];
    return <img src={src} role="presentation" />;
  }

  render() {
    const relationType = capitalize(this.props.row.params.type)
    || <div><FormattedMessage id="modelPage.attribute.relationWith" /> <span style={{ fontStyle: 'italic' }}>{capitalize(this.props.row.params.target)}</span></div>;

    const relationStyle = !this.props.row.params.type ? styles.relation : '';
    return (
      <li className={`${styles.attributeRow} ${relationStyle}`} onClick={this.edit}>
        <div className={styles.flex}>
          <div className={styles.nameContainer}>
            {this.renderAttributesBox()}
            <div>{this.props.row.name}</div>
          </div>
          <div className={styles.relationContainer}>{relationType}</div>
          <div className={styles.mainField}></div>
          <div className={styles.icoContainer}>
            <div className="ico">
              <i className="fa fa-pencil ico" onClick={this.edit} role="button" />
{'fraction_non_alphanumeric': 0.16856892010535557, 'fraction_numerical': 0.0007023705004389816, 'mean_word_length': 3.200589970501475, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 51, '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': '5455835', 'n_tokens_mistral': 1724, 'n_tokens_neox': 1740, 'n_words': 323}