<commit_before>'use strict';

import React from 'react';
import _ from 'underscore';
import { Button } from 'react-bootstrap';
import { console, object, Schemas, fileUtil, DateUtility } from './../util';
import { FormattedInfoBlock } from './components';
import DefaultItemView, { OverViewBodyItem } from './DefaultItemView';



export default class ProtocolView extends DefaultItemView {

    getTabViewContents(){

        var initTabs = [];

        initTabs.push(ProtocolViewOverview.getTabObject(this.props));

        return initTabs.concat(this.getCommonTabs()); // Add remainder of common tabs (Details, Attribution)
    }

}


class ProtocolViewOverview extends React.PureComponent {

    /**
     * Get overview tab object for tabpane.
     *
     * @param {{ context: Object, schemas: Object|null }} props - Object containing Protocol Item context/result and schemas.
     */
    static getTabObject(props){
        return {
            'tab' : <span><i className="icon icon-file-text icon-fw"/> Overview</span>,
            'key' : 'protocol-info',
            //'disabled' : !Array.isArray(context.experiments),
            'content' : (
                <div className="overflow-hidden">
                    <h3 className="tab-section-title">
                        <span>Overview</span>
                    </h3>
                    <hr className="tab-section-title-horiz-divider"/>
                    <ProtocolViewOverview context={props.context} schemas={props.schemas} />
                </div>
            )
        };
    }

    render(){
        const { context, schemas } = this.props;
        const tips = object.tipsFromSchema(schemas || Schemas.get(), context);
        const result = context;

        return (
            <div className="row overview-blocks">

                <OverViewBodyItem {...{ result, tips }} property='protocol_type' fallbackTitle="Protocol Type" wrapInColumn />

                <OverViewBodyItem {...{ result, tips }} property='protocol_classification' fallbackTitle="Protocol Classification" wrapInColumn />

                <ItemFileAttachment context={result} tips={tips} wrapInColumn includeTitle />

            </div>
        );

    }

}


export class ItemFileAttachment extends React.PureComponent {

    static defaultProps = {
        'required' : false,
        'includeTitle' : false,
        'itemType' : 'Protocol',
        'property' : "attachment",
        'btnSize' : null
    };

    wrapInColumn(){
        var wrapInColumn = this.props.wrapInColumn;
        if (!wrapInColumn) return arguments;
        return (<commit_msg>Added url display to Protocol item page overview tab<commit_after>'use strict';

import React from 'react';
import _ from 'underscore';
import { Button } from 'react-bootstrap';
import { console, object, Schemas, fileUtil, DateUtility } from './../util';
import { FormattedInfoBlock } from './components';
import DefaultItemView, { OverViewBodyItem } from './DefaultItemView';



export default class ProtocolView extends DefaultItemView {

    getTabViewContents(){

        var initTabs = [];

        initTabs.push(ProtocolViewOverview.getTabObject(this.props));

        return initTabs.concat(this.getCommonTabs()); // Add remainder of common tabs (Details, Attribution)
    }

}


class ProtocolViewOverview extends React.PureComponent {

    /**
     * Get overview tab object for tabpane.
     *
     * @param {{ context: Object, schemas: Object|null }} props - Object containing Protocol Item context/result and schemas.
     */
    static getTabObject(props){
        return {
            'tab' : <span><i className="icon icon-file-text icon-fw"/> Overview</span>,
            'key' : 'protocol-info',
            //'disabled' : !Array.isArray(context.experiments),
            'content' : (
                <div className="overflow-hidden">
                    <h3 className="tab-section-title">
                        <span>Overview</span>
                    </h3>
                    <hr className="tab-section-title-horiz-divider"/>
                    <ProtocolViewOverview context={props.context} schemas={props.schemas} />
                </div>
            )
        };
    }

    render(){
        const { context, schemas } = this.props;
        const tips = object.tipsFromSchema(schemas || Schemas.get(), context);
        const result = context;

        return (
            <div className="container">
                <div className="row overview-blocks">
                    <OverViewBodyItem {...{ result, tips }} property='protocol_type' fallbackTitle="Protocol Type" wrapInColumn="col-xs-6 col-md-4 mb-3" />
                    <OverViewBodyItem {...{ result, tips }} property='protocol_classification' fallbackTitle="Protocol Classification" wrapInColumn />
                    <ItemFileAttachment context={result} tips={tips} wrapInColumn includeTitle />
                </div>
                <div className="row overview-blocks">
                    <OverViewBodyItem {...{ result, tips }} property="url" fallbackTitle="External Link" wrapInColumn="col-md-6" titleRenderFxn={OverViewBodyItem.titleRenderPresets.url_string} hideIfNoValue />
                </div>
            </div>
        );

    }

}


export class ItemFileAttachment extends React.PureComponent {

    static defaultProps = {
        'required' : false,
        'includeTitle' : false,
        'itemType' : 'Protocol',
        'property' : "attachment",
        'btnSize' : null
    };

    wrapInColumn(){
        var wrapInColumn = this.props.wrapInColumn;
        if (!wrapInColumn) return arguments;
        return (
{'fraction_non_alphanumeric': 0.1205547652916074, 'fraction_numerical': 0.001422475106685633, 'mean_word_length': 2.301056338028169, 'pattern_counts': {'":': 0, '<': 40, '<?xml version=': 0, '>': 40, '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': '6885861', 'n_tokens_mistral': 1514, 'n_tokens_neox': 1443, 'n_words': 348}