From 8fae6f42bdf061c08c1d5c8cc037ed64678ac6ea Mon Sep 17 00:00:00 2001 From: Brianna Major Date: Tue, 10 Dec 2019 10:54:24 -0500 Subject: [PATCH 1/3] Include wikipedia link for molecules if one is provided Signed-off-by: Brianna Major --- src/components/molecule.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/components/molecule.js b/src/components/molecule.js index 3272788..ff2560a 100644 --- a/src/components/molecule.js +++ b/src/components/molecule.js @@ -2,9 +2,9 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; -import { withStyles, Grid, Card, Typography } from '@material-ui/core'; +import { withStyles, Grid, Card, Typography, Link } from '@material-ui/core'; -import { has } from 'lodash-es'; +import { has, isNil } from 'lodash-es'; import PageHead from './page-head'; import PageBody from './page-body'; @@ -75,6 +75,13 @@ class Molecule extends Component { } } + formatLink = (props) => { + if (!isNil(props.name)) { + return {props.name} + } + return {props.wiki} + } + render = () => { const {molecule, calculations, onCalculationClick, creator, onCreatorClick, classes} = this.props; @@ -95,6 +102,14 @@ class Molecule extends Component { if (has(molecule, 'smiles')) { moleculeProperties.push({label: 'SMILES', value: molecule.smiles}); } + if (has(molecule, 'properties.wiki')) { + moleculeProperties.push({ + label: 'Wikipedia', + value: + {isNil(molecule.name) ? molecule.properties.wiki : molecule.name} + + }); + } const moleculeSection = { label: 'Molecule Properties', From 339ff99aa171151e0334da2c68223c1967f142dc Mon Sep 17 00:00:00 2001 From: Brianna Major Date: Wed, 8 Jan 2020 11:47:18 -0500 Subject: [PATCH 2/3] Update wikipedia key to be 'wikipediaUrl' Signed-off-by: Brianna Major --- src/components/molecule.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/molecule.js b/src/components/molecule.js index ff2560a..09fc17c 100644 --- a/src/components/molecule.js +++ b/src/components/molecule.js @@ -77,9 +77,9 @@ class Molecule extends Component { formatLink = (props) => { if (!isNil(props.name)) { - return {props.name} + return {props.name} } - return {props.wiki} + return Wikipedia Page } render = () => { @@ -102,11 +102,11 @@ class Molecule extends Component { if (has(molecule, 'smiles')) { moleculeProperties.push({label: 'SMILES', value: molecule.smiles}); } - if (has(molecule, 'properties.wiki')) { + if (has(molecule, 'properties.wikipediaUrl')) { moleculeProperties.push({ label: 'Wikipedia', - value: - {isNil(molecule.name) ? molecule.properties.wiki : molecule.name} + value: + {isNil(molecule.name) ? molecule.properties.wikipediaUrl : molecule.name} }); } From d4040a01f53e2ef78d9e760ed7d255c327ba86ff Mon Sep 17 00:00:00 2001 From: Brianna Major Date: Wed, 8 Jan 2020 13:42:35 -0500 Subject: [PATCH 3/3] Call formatLink when displaying Wikipedia link 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 --- src/components/molecule.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/components/molecule.js b/src/components/molecule.js index 09fc17c..52d6499 100644 --- a/src/components/molecule.js +++ b/src/components/molecule.js @@ -76,10 +76,9 @@ class Molecule extends Component { } formatLink = (props) => { - if (!isNil(props.name)) { - return {props.name} - } - return Wikipedia Page + return + {!isNil(props.name) ? props.name : 'Wikipedia Page'} + } render = () => { @@ -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: - {isNil(molecule.name) ? molecule.properties.wikipediaUrl : molecule.name} - + value: this.formatLink(molecule) }); }