{"size": 2330, "ext": "js", "max_stars_repo_path": "com.nokia.as.microfeatures.k8sadmin/cardeploycomposer/src/app/views/pages/functions/LazyRenderer.js", "max_stars_repo_name": "nokia/osgi-microfeatures", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "com.nokia.as.microfeatures.k8sadmin/cardeploycomposer/src/app/views/pages/functions/LazyRenderer.js", "max_issues_repo_name": "nokia/osgi-microfeatures", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "com.nokia.as.microfeatures.k8sadmin/cardeploycomposer/src/app/views/pages/functions/LazyRenderer.js", "max_forks_repo_name": "nokia/osgi-microfeatures", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 34.776119403, "max_line_length": 98, "alphanum_fraction": 0.417167382}
/***************************************************************************
 *                                                                         *
 *                       Copyright (c) 2018, Nokia                         *
 *                                                                         *
 *                         All Rights Reserved                             *
 *                                                                         *
 *         This is unpublished proprietary source code of Nokia.           *
 *        The copyright notice above does not evidence any actual          *
 *              or intended publication of such source code.               *
 *                                                                         *
 ***************************************************************************/
import React, { PureComponent } from 'react';
import Tooltip from '@nokia-csf-uxr/csfWidgets/Tooltip';
import UniqueId from 'lodash/uniqueId';
import PropTypes from 'prop-types';


class LazyRenderer extends PureComponent {
    componentWillMount() {
        this.id = UniqueId("lazystatus-");
    }

    state = {
        tooltip: false
    }

    onMouseEnter = () => {
        this.setState({
            tooltip: true
        });
    }

    renderToolTip() {
        return (
            <Tooltip
                text={this.tooltip}
                target={`#${this.id}-${this.props.rowIndex}`}
                id={`tooltip${this.id}-${this.props.rowIndex}`}
                balloon
            />);
    }

    render() {
        console.log('<LazyRenderer props/>', this.props);
        const { lazy, timeout } = this.props.value;
        const sLazy = (lazy === true)?`Yes / ${timeout} s`:'No';
        this.tooltip = (lazy === true)?'Function Loading Strategy: Lazy':'';

        return (
            <div id={`${this.id}-${this.props.rowIndex}`} /* onMouseEnter={this.onMouseEnter} */ >
                <div>{sLazy}</div>
                { /* this.state.tooltip ? this.renderToolTip() : null */ }
            </div>
        )

    }

}

LazyRenderer.propTypes = {
    rowIndex: PropTypes.number.isRequired,
    value : PropTypes.shape({
        lazy : PropTypes.bool.isRequired,
        timeout : PropTypes.string.isRequired
    }).isRequired
};
export default LazyRenderer;