<commit_before>import React from 'react';
import autoBind from 'react-autobind';
import bem from 'js/bem';
import {getQuestionDisplayName} from 'js/formUtils';
import {QUESTION_TYPES} from 'js/constants';
import {t} from 'js/utils';

class AssetContentSummary extends React.Component {
  constructor(props){
    super(props);
    autoBind(this);
  }

  componentDidMount() {
    console.debug('AssetContentSummary did mount', this.props);
  }

  renderQuestion(question) {
    if (QUESTION_TYPES.has(question.type)) {
      const typeDef = QUESTION_TYPES.get(question.type);

      return (
        <bem.FormView__cell
          m={['columns', 'padding', 'bordertop']}
          key={question.$kuid}
        >
          <bem.FormView__cell m='column-1'>
            <i className={['fa', 'fa-lg', typeDef.faIcon].join(' ')}/>
            &nbsp;
            {getQuestionDisplayName(question)}
          </bem.FormView__cell>
        </bem.FormView__cell>
      );
    } else {
      return null;
    }
  }

  render() {
    if (!this.props.assetContent) {
      return null;
    }

    return (
      <bem.FormView__cell m='box'>
        {this.props.assetContent.survey.map(this.renderQuestion)}
      </bem.FormView__cell>
    );
  }
}

export default AssetContentSummary;<commit_msg>missed file from last commit<commit_after>import React from 'react';
import autoBind from 'react-autobind';
import bem from 'js/bem';
import {getQuestionDisplayName} from 'js/formUtils';
import {QUESTION_TYPES} from 'js/constants';
import {t} from 'js/utils';

const QUESTION_LIMIT = 8;

class AssetContentSummary extends React.Component {
  constructor(props){
    super(props);
    this.state = {
      isExpanded: false,
      isExpandable: false
    };
    autoBind(this);
  }

  componentDidMount() {
    console.debug('AssetContentSummary did mount', this.props);
    this.setState({
      isExpandable: this.props.assetContent.survey.length > QUESTION_LIMIT
    });
  }

  renderQuestion(question) {
    const typeDef = QUESTION_TYPES.get(question.type);
    return (
      <bem.FormView__cell
        m={['columns', 'padding', 'bordertop']}
        key={question.$kuid}
      >
        <bem.FormView__cell m='column-1'>
          <i className={['fa', 'fa-lg', typeDef.faIcon].join(' ')}/>
          &nbsp;
          {getQuestionDisplayName(question)}
        </bem.FormView__cell>
      </bem.FormView__cell>
    );
  }

  filterRealQuestions(questions) {
    return questions.filter((question) => {
      return QUESTION_TYPES.has(question.type);
    });
  }

  toggleExpanded() {
    this.setState({isExpanded: !this.state.isExpanded});
  }

  render() {
    if (!this.props.assetContent) {
      return null;
    }

    let items = this.filterRealQuestions(this.props.assetContent.survey);
    if (this.state.isExpandable && !this.state.isExpanded) {
      items = items.slice(0, QUESTION_LIMIT);
    }

    return (
      <bem.FormView__cell m='box'>
        {items.map(this.renderQuestion)}

        {this.state.isExpandable &&
          <bem.FormView__cell m={['bordertop', 'toggle-details']}>
            <button onClick={this.toggleExpanded}>
              {this.state.isExpanded ? <i className='k-icon k-icon-up'/> : <i className='k-icon k-icon-down'/>}
              {this.state.isExpanded ? t('Show less') : t('Show more')}
            </button>
          </bem.FormView__cell>
        }
      </bem.FormView__cell>
    );
  }
}

export default AssetContentSummary;
{'fraction_non_alphanumeric': 0.14277473319873088, 'fraction_numerical': 0.0011537352177675222, 'mean_word_length': 2.7901639344262295, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 25, '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': '6714538', 'n_tokens_mistral': 1147, 'n_tokens_neox': 1124, 'n_words': 195}