cluedin-widget
Version:
This is the project for creating and managing widgets in CluedIn.
45 lines (33 loc) • 1.27 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.token );
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>
);
}
};