<commit_before>import React, {Component, PropTypes} from 'react';
import {Link} from 'react-router';
import BuildStates from '../../constants/BuildStates.js';
import moment from 'moment';
import classNames from 'classnames';
import BuildStateIcon from '../shared/BuildStateIcon.jsx';
import SingularityLink from '../branch-state/shared/SingularityLink.jsx';
import {timestampFormatted, timestampDuration, tableRowBuildState, getTableDurationText} from '../Helpers';
import isDebugMode from '../../utils/isDebugMode';


class RepoBuildModulesTableRow extends Component {

  constructor(props, context) {
    super(props, context);

    this.onTableClick = this.onTableClick.bind(this);
  }

  getRowClassNames(state) {
    if ([BuildStates.SKIPPED, BuildStates.CANCELLED].indexOf(state) > -1) {
      return tableRowBuildState(state);
    }

    return classNames([
      tableRowBuildState(state),
      'clickable-table-row'
    ]);
  }

  onTableClick(e) {
    const {data} = this.props;
    const link = e.target.className;

    if (link === 'build-link') {
      return;
    } else if ([BuildStates.SKIPPED, BuildStates.CANCELLED].indexOf(data.state) === -1) {
      if (!e.metaKey) {
        this.context.router.push(data.blazarPath);
      } else {
        window.open(`${window.config.appRoot}${data.blazarPath}`);
        return;
      }
    }
  }

  renderBuildLink() {
    const {data} = this.props;

    if (data.state === BuildStates.SKIPPED || data.state === BuildStates.CANCELLED) {
      return (
        <span>{data.name}</span>
      );
    }

    return (
      <span>
        <Link className="build-link" to={data.blazarPath}>{data.name}</Link>
      </span>
    );
  }

  renderSingularityLink() {
    const {taskId} = this.props.data;
    if (isDebugMode() && taskId) {
      return (
        <td>
          <SingularityLink taskId={taskId} />
        </td>
      );
    }

    return null;
  }

  renderDuration() {
    const {data} = this.props;

    if (data.state === BuildStates.IN_PROGRESS) {
      data.endTimestamp = moment();
    }

    return getTableDurationText(data.state, timestampDuration(data.startTimestamp, data.endTimestamp));
  }

  render() {
    const {data} = this.props;

    return (
      <tr onClick={this.onTableClick} className={this.getRowClassNames(data.state)}>
        <td className="build-status">
          <BuildStateIcon buildState={data.state} />
        </td>
        <td className="table-cell-link">
          {this.renderBuildLink()}
        </td>
        <td>
          {timestampFormatted(data.startTimestamp)}
        </td>
        <td>
          {this.renderDuration()}
        </td>
        {this.renderSingularityLink()}
        <td>
        </td>
      </tr>
    );
  }

}

RepoBuildModulesTableRow.contextTypes = {
  router: PropTypes.object.isRequired
};
<commit_msg>Fix extra <td> for debug mode<commit_after>import React, {Component, PropTypes} from 'react';
import {Link} from 'react-router';
import BuildStates from '../../constants/BuildStates.js';
import moment from 'moment';
import classNames from 'classnames';
import BuildStateIcon from '../shared/BuildStateIcon.jsx';
import SingularityLink from '../branch-state/shared/SingularityLink.jsx';
import {timestampFormatted, timestampDuration, tableRowBuildState, getTableDurationText} from '../Helpers';
import isDebugMode from '../../utils/isDebugMode';


class RepoBuildModulesTableRow extends Component {

  constructor(props, context) {
    super(props, context);

    this.onTableClick = this.onTableClick.bind(this);
  }

  getRowClassNames(state) {
    if ([BuildStates.SKIPPED, BuildStates.CANCELLED].indexOf(state) > -1) {
      return tableRowBuildState(state);
    }

    return classNames([
      tableRowBuildState(state),
      'clickable-table-row'
    ]);
  }

  onTableClick(e) {
    const {data} = this.props;
    const link = e.target.className;

    if (link === 'build-link') {
      return;
    } else if ([BuildStates.SKIPPED, BuildStates.CANCELLED].indexOf(data.state) === -1) {
      if (!e.metaKey) {
        this.context.router.push(data.blazarPath);
      } else {
        window.open(`${window.config.appRoot}${data.blazarPath}`);
        return;
      }
    }
  }

  renderBuildLink() {
    const {data} = this.props;

    if (data.state === BuildStates.SKIPPED || data.state === BuildStates.CANCELLED) {
      return (
        <span>{data.name}</span>
      );
    }

    return (
      <span>
        <Link className="build-link" to={data.blazarPath}>{data.name}</Link>
      </span>
    );
  }

  renderSingularityLink() {
    const {taskId} = this.props.data;
    if (isDebugMode() && taskId) {
      return (
        <SingularityLink taskId={taskId} />
      );
    }

    return null;
  }

  renderDuration() {
    const {data} = this.props;

    if (data.state === BuildStates.IN_PROGRESS) {
      data.endTimestamp = moment();
    }

    return getTableDurationText(data.state, timestampDuration(data.startTimestamp, data.endTimestamp));
  }

  render() {
    const {data} = this.props;

    return (
      <tr onClick={this.onTableClick} className={this.getRowClassNames(data.state)}>
        <td className="build-status">
          <BuildStateIcon buildState={data.state} />
        </td>
        <td className="table-cell-link">
          {this.renderBuildLink()}
        </td>
        <td>
          {timestampFormatted(data.startTimestamp)}
        </td>
        <td>
          {this.renderDuration()}
        </td>
        <td>
          {this.renderSingularityLink()}
        </td>
      </tr>
    );
  }

}

RepoBuildModulesTableRow.contextTypes = {
  router: PropTypes.object.isRequired
};

{'fraction_non_alphanumeric': 0.1470432480141218, 'fraction_numerical': 0.000706090026478376, 'mean_word_length': 2.7056899934597776, 'pattern_counts': {'":': 0, '<': 46, '<?xml version=': 0, '>': 48, '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': '2498443', 'n_tokens_mistral': 1798, 'n_tokens_neox': 1779, 'n_words': 319}