Skip to content

Commit

Permalink
Call formatLink when displaying Wikipedia link
Browse files Browse the repository at this point in the history
Fixes broken code where formatLink was no longer beind called. The formatLink
function is now used to return the Wikipedia link with the proper link text.

Signed-off-by: Brianna Major <[email protected]>
  • Loading branch information
bnmajor committed Jan 8, 2020
1 parent 339ff99 commit d4040a0
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/components/molecule.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,9 @@ class Molecule extends Component {
}

formatLink = (props) => {
if (!isNil(props.name)) {
return <a href src={props.wikipediaUrl}>{props.name}</a>
}
return <a href src={props.wikipediaUrl}>Wikipedia Page</a>
return <Link target="_blank" rel="noopener" href={props.wikipediaUrl}>
{!isNil(props.name) ? props.name : 'Wikipedia Page'}
</Link>
}

render = () => {
Expand All @@ -102,12 +101,10 @@ class Molecule extends Component {
if (has(molecule, 'smiles')) {
moleculeProperties.push({label: 'SMILES', value: molecule.smiles});
}
if (has(molecule, 'properties.wikipediaUrl')) {
if (has(molecule, 'wikipediaUrl')) {
moleculeProperties.push({
label: 'Wikipedia',
value: <Link target="_blank" rel="noopener" href={molecule.properties.wikipediaUrl}>
{isNil(molecule.name) ? molecule.properties.wikipediaUrl : molecule.name}
</Link>
value: this.formatLink(molecule)
});
}

Expand Down

0 comments on commit d4040a0

Please sign in to comment.