<commit_before>import React from 'react';
import ModelStore  from '../../store/model-store';
import ModelController from '../../controllers/components/model';
import { hashHistory } from 'react-router';
import ConfirmModal from '../components/confirm-modal.jsx';
export default class Model extends React.Component {


    constructor(props){
        super(props);
        if (props.model === undefined)
            this.state = {
                model: null,
                needsConfirmationForDelete: false
        };
        else
            this.state = {
                model: props.model,
                needsConfirmationForDelete: false
            };
    }

    componentDidMount(){
        if(this.state.model === null) {
            ModelController.getModel(this.props.params.address).then(() => {
                this.setState({
                    model: ModelStore.getModel()
                });
            });
        }
    }
    showConfirmModal(){
        this.setState({
            needsConfirmationForDelete: true
        });
    }
    confirmDelete(bool){
        if(bool === true) {
            ModelController.deleteModel(this.state.model.address);
        }
        this.setState({
            needsConfirmationForDelete: false
        });
    }
    editModel(){
        hashHistory.push(`/model/edit/${this.state.model.address}`);
    }

    deleteModel() {
        ModelController.deleteModel(this.state.model.address);
    }

    render() {
        if (this.state.model === null)
            return <i>Data is loading...</i>;
        let confirmationText = `Are you sure you want to delete this model(${this.state.model.name})? WARNING: This will delete all
                items associated with this model`;
        return (
            <div className='model'>
                <ConfirmModal
                    message={confirmationText}
                    active={this.state.needsConfirmationForDelete}
                    onSelect={bool => this.confirmDelete(bool)}
                />
                <div className="picArea">
                    <img src="../assets/images/placeholder.jpg"/>
                </div>
                <div className="titleArea">
                    <h2>{this.state.model.name}</h2>
                    <i className="address">{this.state.model.address}</i>
                </div>
                <div className="infoArea">
                    <div className="descriptionArea">
                        <h3>Description</h3>
                        <p>{this.state.model.description}</p>
                    </div>
                    <div className="faultArea">
                        <h3>Fault</h3>
                        {(this.state.model.isFaulty
                                ? <p>{this.state.model.faultDescription}</p>
                                : <p>Model is not faulty.</p><commit_msg>Renders line breaks in model descriptions as `<br/>`<commit_after>import React from 'react';
import ModelStore  from '../../store/model-store';
import ModelController from '../../controllers/components/model';
import { hashHistory } from 'react-router';
import ConfirmModal from '../components/confirm-modal.jsx';
export default class Model extends React.Component {


    constructor(props){
        super(props);
        if (props.model === undefined)
            this.state = {
                model: null,
                needsConfirmationForDelete: false
        };
        else
            this.state = {
                model: props.model,
                needsConfirmationForDelete: false
            };
    }

    componentDidMount(){
        if(this.state.model === null) {
            ModelController.getModel(this.props.params.address).then(() => {
                this.setState({
                    model: ModelStore.getModel()
                });
            });
        }
    }
    showConfirmModal(){
        this.setState({
            needsConfirmationForDelete: true
        });
    }
    confirmDelete(bool){
        if(bool === true) {
            ModelController.deleteModel(this.state.model.address);
        }
        this.setState({
            needsConfirmationForDelete: false
        });
    }
    editModel(){
        hashHistory.push(`/model/edit/${this.state.model.address}`);
    }

    deleteModel() {
        ModelController.deleteModel(this.state.model.address);
    }

    renderDescription() {
        return this.state.model.description.split(/[\r\n]/g).map(line => {
            return <span>{line}<br/></span>
        });
    }

    render() {
        if (this.state.model === null)
            return <i>Data is loading...</i>;
        let confirmationText = `Are you sure you want to delete this model(${this.state.model.name})? WARNING: This will delete all
                items associated with this model`;
        return (
            <div className='model'>
                <ConfirmModal
                    message={confirmationText}
                    active={this.state.needsConfirmationForDelete}
                    onSelect={bool => this.confirmDelete(bool)}
                />
                <div className="picArea">
                    <img src="../assets/images/placeholder.jpg"/>
                </div>
                <div className="titleArea">
                    <h2>{this.state.model.name}</h2>
                    <i className="address">{this.state.model.address}</i>
                </div>
                <div className="infoArea">
                    <div className="descriptionArea">
                        <h3>Description</h3>
                        <p>{this.renderDescription()}</p>
                    </div>
                    <div className="faultArea">
                        <h3>Fault</h3>
                        {(this.state.model.isFaulty
                                ? <p>{this.state.model.faultDescription}</p>
                                : <p>Model is not faulty.</p>
{'fraction_non_alphanumeric': 0.12472573839662447, 'fraction_numerical': 0.0020253164556962027, 'mean_word_length': 1.4805357890330682, 'pattern_counts': {'":': 0, '<': 61, '<?xml version=': 0, '>': 66, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4416091', 'n_tokens_mistral': 1508, 'n_tokens_neox': 1441, 'n_words': 267}