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

import React, { PropTypes } from "react";
import { connect } from "react-redux";
import { Switch, Route, Redirect } from "react-router-dom";
import { LinkContainer } from "react-router-bootstrap";
import { Nav, NavItem } from "react-bootstrap";

import { getVirus } from "../../actions";
import { Flex, FlexItem, Icon, Spinner } from "virtool/js/components/Base";
import IsolateEditor from "./Editor";
import General from "./General";
import AddIsolate from "./AddIsolate";
import Schema from "./Schema";
import History from "./History";

const VirusSection = (props) => (
    <div>
        <General />
        <IsolateEditor />
        <AddIsolate virusId={props.match.params.virusId} />
    </div>
);

VirusSection.propTypes = {
    match: PropTypes.object
};

class VirusDetail extends React.Component {

    static propTypes = {
        match: PropTypes.object,
        history: PropTypes.object,
        detail: PropTypes.object,
        getVirus: PropTypes.func
    };

    componentDidMount () {
        this.props.getVirus(this.props.match.params.virusId)
    }

    render = () => {

        let content;

        if (this.props.detail) {
            const virusId = this.props.detail.id;

            content = (
                <div>
                    <h3 style={{marginBottom: "20px"}}>
                        <Flex alignItems="flex-end">
                            <FlexItem grow={1}>
                                <Flex alignItems="center">
                                    <strong>
                                        {this.props.detail.name}
                                    </strong>
                                    <FlexItem grow={1} pad={5}>
                                        <small className="text-strong">
                                            {this.props.detail.abbreviation}
                                        </small>
                                    </FlexItem>
                                </Flex>
                            </FlexItem>

                            <Icon
                                bsStyle="danger"
                                name="remove"
                                style={{fontSize: "18px"}}
                                onClick={() => window.console.log(this.props.detail.name)}
                            />
                        </Flex>
                    </h3>

                    <Nav bsStyle="tabs">
                        <LinkContainer to={`/viruses/${virusId}/virus`}>
                            <NavItem>
                                Virus
                            </NavItem>
                        </LinkContainer>

                        <LinkContainer to={`/viruses/${virusId}/schema`}>
                            <NavItem>
                                Schema
                            </NavItem>
                        </LinkContainer>

                        <LinkContainer to={`/viruses/${virusId}/history`}>
                            <NavItem>
                                History
                            </NavItem>
                        </LinkContainer>
                    </Nav>

                    <Switch>
                        <Redirect from="/viruses/:virusId" to={`/viruses/${virusId}/virus`} exact />
                        <Route path="/viruses/:virusId/virus" component={VirusSection} />
                        <Route path="/viruses/:virusId/schema" component={Schema} />
                        <Route path="/viruses/:virusId/history" component={History} />
                    </Switch>
                </div>
            );
        } else {
            content = (
                <div className="text-center">
                    <Spinner />
                </div>
            );
        }

        return (
            <div>
                {content}
            </div>
        );
    };
}

const mapStateToProps = (state) => {
    return {
        detail: state.viruses.detail
    };
};

const mapDispatchToProps = (dispatch) => {
    return {
        getVirus: (virusId) => {
            dispatch(getVirus(virusId));
        }
    };
};

const Container = connect(mapStateToProps, mapDispatchToProps)(VirusDetail);

export default Container;
<commit_msg>Add label to VirusDetail for modified viruses<commit_after>/**
 * @license
 * The MIT License (MIT)
 * Copyright 2015 Government of Canada
 *
 * @author
 * <NAME>
 *
 * @exports VirusDetail
 */

import React, { PropTypes } from "react";
import { connect } from "react-redux";
import { Switch, Route, Redirect } from "react-router-dom";
import { LinkContainer } from "react-router-bootstrap";
import { Label, Nav, NavItem } from "react-bootstrap";

import { getVirus } from "../../actions";
import { Flex, FlexItem, Icon, Spinner } from "virtool/js/components/Base";
import IsolateEditor from "./Editor";
import General from "./General";
import AddIsolate from "./AddIsolate";
import Schema from "./Schema";
import History from "./History";

const VirusSection = (props) => (
    <div>
        <General />
        <IsolateEditor />
        <AddIsolate virusId={props.match.params.virusId} />
    </div>
);

VirusSection.propTypes = {
    match: PropTypes.object
};

class VirusDetail extends React.Component {

    static propTypes = {
        match: PropTypes.object,
        history: PropTypes.object,
        detail: PropTypes.object,
        getVirus: PropTypes.func
    };

    componentDidMount () {
        this.props.getVirus(this.props.match.params.virusId)
    }

    render = () => {

        let content;

        if (this.props.detail) {
            const virusId = this.props.detail.id;

            content = (
                <div>
                    <h3 style={{marginBottom: "20px"}}>
                        <Flex alignItems="flex-end">
                            <FlexItem grow={1}>
                                <Flex alignItems="center">
                                    <strong>
                                        {this.props.detail.name}
                                    </strong>
                                    <FlexItem grow={1} pad={5}>
                                        <small className="text-strong">
                                            {this.props.detail.abbreviation}
                                        </small>
                                    </FlexItem>
                                </Flex>
                            </FlexItem>

                            <small>
                                <Label bsStyle="warning" className="with-icon">
                                    <Icon name="flag" />
                                    Modified
                                </Label>
                            </small>

                            <Icon
                                bsStyle="danger"
                                name="remove"
                                style={{fontSize: "18px", paddingLeft: "5px"}}
                                onClick={() => window.console.log(this.props.detail.name)}
                            />
                        </Flex>
                    </h3>

                    <Nav bsStyle="tabs">
                        <LinkContainer to={`/viruses/${virusId}/virus`}>
                            <NavItem>
                                Virus
                            </NavItem>
                        </LinkContainer>

                        <LinkContainer to={`/viruses/${virusId}/schema`}>
                            <NavItem>
                                Schema
                            </NavItem>
                        </LinkContainer>

                        <LinkContainer to={`/viruses/${virusId}/history`}>
                            <NavItem>
                                History
                            </NavItem>
                        </LinkContainer>
                    </Nav>

                    <Switch>
                        <Redirect from="/viruses/:virusId" to={`/viruses/${virusId}/virus`} exact />
                        <Route path="/viruses/:virusId/virus" component={VirusSection} />
                        <Route path="/viruses/:virusId/schema" component={Schema} />
                        <Route path="/viruses/:virusId/history" component={History} />
                    </Switch>
                </div>
            );
        } else {
            content = (
                <div className="text-center">
                    <Spinner />
                </div>
            );
        }

        return (
            <div>
                {content}
            </div>
        );
    };
}

const mapStateToProps = (state) => {
    return {
        detail: state.viruses.detail
    };
};

const mapDispatchToProps = (dispatch) => {
    return {
        getVirus: (virusId) => {
            dispatch(getVirus(virusId));
        }
    };
};

const Container = connect(mapStateToProps, mapDispatchToProps)(VirusDetail);

export default Container;

{'fraction_non_alphanumeric': 0.11503067484662577, 'fraction_numerical': 0.002957931638913234, 'mean_word_length': 1.0658520027155465, 'pattern_counts': {'":': 0, '<': 104, '<?xml version=': 0, '>': 116, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 20, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4223098', 'n_tokens_mistral': 2274, 'n_tokens_neox': 2110, 'n_words': 430}