<commit_before>import * as React from 'react';
import { SearchResult, BlockedHit } from '../../types';
import { ResourceList } from '@shopify/polaris';
import InfoContainer from './InfoContainer';
import CollapsibleInfo from './CollapsibleInfo';

import { truncate } from '../../utils/formatting';
import { qualException } from '../../utils/exceptions';
import { generateBadges } from '../../utils/badges';
import { blockedHitFactory } from '../../utils/blocklist';
import { clickDidNotOccurOnActionButton } from '../../utils/searchCard';

export interface Props {
  readonly hit: SearchResult;
}

export interface OwnProps {
  readonly groupId: string;
}

export interface Handlers {
  readonly onAccept: (hit: SearchResult) => void;
  readonly onToggleExpand: (hit: SearchResult) => void;
  readonly onHide: (hit: BlockedHit) => void;
}

class SearchCard extends React.PureComponent<
  Props & OwnProps & Handlers,
  never
> {
  private handleAccept = () => this.props.onAccept(this.props.hit);
  private handleHide = () =>
    this.props.onHide(blockedHitFactory(this.props.hit));
  private handleExpand = (e: React.MouseEvent<HTMLDivElement>) => {
    if (clickDidNotOccurOnActionButton(e)) {
      this.props.onToggleExpand(this.props.hit);
    }
  };

  private generateActions = () => [
    {
      content: 'Hide',
      accessibilityLabel: 'Hide',
      icon: 'disable',
      onClick: this.handleHide
    },
    {
      content: 'Add',
      accessibilityLabel: 'Add',
      icon: 'add',
      primary: true,
      onClick: this.handleAccept
    }
  ];

  public render() {
    const { hit } = this.props;
    const { qualified, title, requester } = hit;

    return (
      <div>
        <div onClick={this.handleExpand}>
          <ResourceList.Item
            actions={this.generateActions()}
            exceptions={qualException(qualified)}
            badges={generateBadges(requester.turkopticon)}
            attributeOne={truncate(requester.name, 40)}
            attributeTwo={truncate(title, 120)}
            attributeThree={<commit_msg>SearchCards will display different attributeOne if hit is marked as read.<commit_after>import * as React from 'react';
import { SearchResult, BlockedHit } from '../../types';
import { ResourceList } from '@shopify/polaris';
import InfoContainer from './InfoContainer';
import CollapsibleInfo from './CollapsibleInfo';

import { truncate } from '../../utils/formatting';
import { qualException } from '../../utils/exceptions';
import { generateBadges } from '../../utils/badges';
import { blockedHitFactory } from '../../utils/blocklist';
import { clickDidNotOccurOnActionButton } from '../../utils/searchCard';

export interface Props {
  readonly hit: SearchResult;
}

export interface OwnProps {
  readonly groupId: string;
}

export interface Handlers {
  readonly onAccept: (hit: SearchResult) => void;
  readonly onToggleExpand: (hit: SearchResult) => void;
  readonly onHide: (hit: BlockedHit) => void;
}

class SearchCard extends React.PureComponent<
  Props & OwnProps & Handlers,
  never
> {
  static generateAttributeOne = (name: string, markedAsRead?: boolean) =>
    markedAsRead ? truncate(name, 40) : `*NEW* ${truncate(name, 40)}`;

  private handleAccept = () => this.props.onAccept(this.props.hit);
  private handleHide = () =>
    this.props.onHide(blockedHitFactory(this.props.hit));
  private handleExpand = (e: React.MouseEvent<HTMLDivElement>) => {
    if (clickDidNotOccurOnActionButton(e)) {
      this.props.onToggleExpand(this.props.hit);
    }
  };

  private generateActions = () => [
    {
      content: 'Hide',
      accessibilityLabel: 'Hide',
      icon: 'disable',
      onClick: this.handleHide
    },
    {
      content: 'Add',
      accessibilityLabel: 'Add',
      icon: 'add',
      primary: true,
      onClick: this.handleAccept
    }
  ];

  public render() {
    const { hit } = this.props;
    const { qualified, title, requester, markedAsRead } = hit;

    return (
      <div>
        <div onClick={this.handleExpand}>
          <ResourceList.Item
            actions={this.generateActions()}
            exceptions={qualException(qualified)}
            badges={generateBadges(requester.turkopticon)}
            attributeOne={SearchCard.generateAttributeOne(
              requester.name,
              markedAsRead
            )}
            attributeTwo={truncate(title, 120)}
            attributeThree={
{'fraction_non_alphanumeric': 0.13544733861834654, 'fraction_numerical': 0.0027180067950169874, 'mean_word_length': 3.154280338664158, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 26, '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': '810562', 'n_tokens_mistral': 1279, 'n_tokens_neox': 1260, 'n_words': 295}