<commit_before>/**
 * @license
 * The MIT License (MIT)
 * Copyright 2015 Government of Canada
 *
 * @author
 * <NAME>
 *
 * @exports AnalysisItem
 */

import React from "react";
import CX from "classnames";
import PropTypes from "prop-types";
import { Row, Col, Label } from "react-bootstrap";

import { getTaskDisplayName } from "../../../utils";
import { Icon, RelativeTime } from "../../../base";

const AnalysisItem = (props) => {

    const itemClass = CX("list-group-item spaced", {
        "hoverable": props.ready
    });

    let end;

    if (props.ready) {
        if (props.canModify) {
            end = <Icon name="remove" bsStyle="danger" onClick={props.onRemove} pullRight/>;
        }
    } else {
        end = (
            <strong className="pull-right">
                In Progress
            </strong>
        )
    }

    return (
        <div className={itemClass} onClick={props.onClick}>
            <Row>
                <Col md={3}>
                    <strong>{getTaskDisplayName(props.algorithm)}</strong>
                </Col>
                <Col md={4}>
                    Started <RelativeTime time={props.created_at}/> by {props.user.id}
                </Col>
                <Col md={1}>
                    <Label>{props.index.version}</Label>
                </Col>
                <Col md={4}>
                    {end}
                </Col>
            </Row>
        </div>
    );
};

AnalysisItem.propTypes = {
    index: PropTypes.object,
    user: PropTypes.object,
    algorithm: PropTypes.string,
    created_at: PropTypes.string,
    ready: PropTypes.bool,
    canModify: PropTypes.bool,
    onClick: PropTypes.func,
    onRemove: PropTypes.func
};

export default AnalysisItem;
<commit_msg>Disable click on in-progress analyses (fix #299)<commit_after>/**
 * @license
 * The MIT License (MIT)
 * Copyright 2015 Government of Canada
 *
 * @author
 * <NAME>
 *
 * @exports AnalysisItem
 */

import React from "react";
import CX from "classnames";
import PropTypes from "prop-types";
import { Row, Col, Label } from "react-bootstrap";

import { getTaskDisplayName } from "../../../utils";
import { Icon, RelativeTime } from "../../../base";

const AnalysisItem = (props) => {

    const itemClass = CX("list-group-item spaced", {
        "hoverable": props.ready
    });

    let end;

    if (props.ready) {
        if (props.canModify) {
            end = <Icon name="remove" bsStyle="danger" onClick={props.onRemove} pullRight/>;
        }
    } else {
        end = (
            <strong className="pull-right">
                In Progress
            </strong>
        )
    }

    return (
        <div className={itemClass} onClick={props.ready ? props.onClick: null}>
            <Row>
                <Col md={3}>
                    <strong>{getTaskDisplayName(props.algorithm)}</strong>
                </Col>
                <Col md={4}>
                    Started <RelativeTime time={props.created_at}/> by {props.user.id}
                </Col>
                <Col md={1}>
                    <Label>{props.index.version}</Label>
                </Col>
                <Col md={4}>
                    {end}
                </Col>
            </Row>
        </div>
    );
};

AnalysisItem.propTypes = {
    index: PropTypes.object,
    user: PropTypes.object,
    algorithm: PropTypes.string,
    created_at: PropTypes.string,
    ready: PropTypes.bool,
    canModify: PropTypes.bool,
    onClick: PropTypes.func,
    onRemove: PropTypes.func
};

export default AnalysisItem;

{'fraction_non_alphanumeric': 0.1408410951171324, 'fraction_numerical': 0.005362686988427886, 'mean_word_length': 1.7774294670846396, 'pattern_counts': {'":': 2, '<': 45, '<?xml version=': 0, '>': 47, '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': '2134359', 'n_tokens_mistral': 1039, 'n_tokens_neox': 1004, 'n_words': 242}