cluedin-widget
Version: 
This project contains all the pages needed for browsing entities and searching them. The aim is to replace the CluedIn.Webapp project with this one when all the pages ( including the Admin page ) will be ported to REACT.
45 lines (33 loc) • 1.28 kB
JSX
import React, { Component } from 'react';
import iso from '../../../iso';
import config from '../../config';
export default class EntityAuthors extends Component {
    buildAuthor( author, index ) {
        const { entity } = this.props;
        const linkUrl = config.location.goToEntity( entity );
        let profileImageContent;
        if ( author.previewImage ) {
            var imageUrl = author.previewImage[ 'attribute-uri' ];
            imageUrl = iso.image.addTokenToImage( imageUrl, config.getCurrentToken() );
            profileImageContent = <img className="cluedIn_entity_authors_author_logo" src={imageUrl}/>
        }
        return (<div key={index} className="cluedIn_entity_authors_author">
            <a href={linkUrl}>{profileImageContent} {author.name}</a>
        </div>);
    }
    buildContent() {
        const { entity } = this.props;
        if ( !entity.data.authors || entity.data.authors.length === 0 ) {
            return (<span>N/A</span>);
        }
        return entity.data.authors.map( this.buildAuthor, this );
    }
    render() {
        let authorsContent = this.buildContent();
        return (
            <div className="cluedIn_entity_authors">
                {authorsContent}
            </div>
        );
    }
};