From f92bfb78ed74c831597e3d6469d70e542ecf1fed Mon Sep 17 00:00:00 2001 From: Andy Nicholson <intothemist@gmail.com> Date: Tue, 2 Feb 2021 17:10:27 +1100 Subject: [PATCH] fix(*): feedback from @benwh on merge request 164 --- .../component-frontpage/src/Frontpage.js | 22 ++++++------------- .../src/components/ManuscriptPage.js | 4 ++-- package.json | 1 + yarn.lock | 13 +++++++++++ 4 files changed, 23 insertions(+), 17 deletions(-) diff --git a/app/components/component-frontpage/src/Frontpage.js b/app/components/component-frontpage/src/Frontpage.js index a8f56f3847..1d91a328de 100644 --- a/app/components/component-frontpage/src/Frontpage.js +++ b/app/components/component-frontpage/src/Frontpage.js @@ -74,13 +74,11 @@ const Frontpage = ({ history, ...props }) => { <SectionHeader> <Title>{manuscript.meta.title}</Title> </SectionHeader> - <SectionRow key={`manuscript-${manuscript.id}`}> - {manuscript.submission?.abstract ? ( + <SectionRow> + {manuscript.submission?.abstract && ( <h1>Abstract: {manuscript.submission?.abstract}</h1> - ) : ( - <br /> )} - {manuscript.visualAbstract ? ( + {manuscript.visualAbstract && ( <div> <h1>Visual abstract</h1> <VisualAbstract @@ -88,11 +86,9 @@ const Frontpage = ({ history, ...props }) => { src={manuscript.visualAbstract} /> </div> - ) : ( - <br /> )} - {manuscript.files.length > 0 ? ( + {manuscript.files.length > 0 && ( <div> {manuscript.files.map( file => @@ -100,7 +96,7 @@ const Frontpage = ({ history, ...props }) => { file.fileType !== 'visualAbstract' && ( <a href={file.url} - key={`manuscript-${manuscript.id}`} + key={`file-${file.id}`} rel="noopener noreferrer" target="_blank" > @@ -112,7 +108,7 @@ const Frontpage = ({ history, ...props }) => { file => !skipXSweet(file) && ( <Accordion - key={`manuscript-${manuscript.id}`} + key={`file-${file.id}`} label="View Manuscript Text" > <Wax content={manuscript.meta.source} readonly /> @@ -120,11 +116,9 @@ const Frontpage = ({ history, ...props }) => { ), )} </div> - ) : ( - <br /> )} - {manuscript.submission?.links ? ( + {manuscript.submission?.links && ( <div> <h1>Submitted research objects</h1> {manuscript.submission?.links?.map(link => ( @@ -138,8 +132,6 @@ const Frontpage = ({ history, ...props }) => { </a> ))} </div> - ) : ( - <br /> )} </SectionRow> </SectionContent> diff --git a/app/components/component-manuscript/src/components/ManuscriptPage.js b/app/components/component-manuscript/src/components/ManuscriptPage.js index 71be231abb..5a8242b4fe 100644 --- a/app/components/component-manuscript/src/components/ManuscriptPage.js +++ b/app/components/component-manuscript/src/components/ManuscriptPage.js @@ -1,6 +1,6 @@ -import PropTypes from 'prop-types' import React from 'react' import { useQuery, gql } from '@apollo/client' +import ReactRouterPropTypes from 'react-router-prop-types' import Manuscript from './Manuscript' import { Spinner } from '../../../shared' @@ -46,7 +46,7 @@ const ManuscriptPage = ({ match, ...props }) => { }) ManuscriptPage.propTypes = { - match: PropTypes.node.isRequired, + match: ReactRouterPropTypes.match.isRequired, } if (loading) return <Spinner /> diff --git a/package.json b/package.json index 727d7bd498..d56486eec5 100644 --- a/package.json +++ b/package.json @@ -129,6 +129,7 @@ "react-mentions": "3.3.2", "react-moment": "0.9.7", "react-router-dom": "5.2.0", + "react-router-prop-types": "^1.0.5", "react-select1": "npm:react-select@1.3.0", "react-visibility-sensor": "5.1.1", "regenerator-runtime": "^0.13.7", diff --git a/yarn.lock b/yarn.lock index bba4d7cd54..285e3dc167 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2738,6 +2738,11 @@ resolved "https://registry.yarnpkg.com/@types/parse-json/-/parse-json-4.0.0.tgz#2f8bb441434d163b35fb8ffdccd7138927ffb8c0" integrity sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA== +"@types/prop-types@^15.7.3": + version "15.7.3" + resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.3.tgz#2ab0d5da2e5815f94b0b9d4b95d1e5f243ab2ca7" + integrity sha512-KfRL3PuHmqQLOG+2tGpRO26Ctg+Cq1E01D2DMriKEATHgWLfeNDmq9e29Q9WIky0dQ3NPkd1mzYH8Lm936Z9qw== + "@types/qs@*": version "6.9.3" resolved "https://registry.yarnpkg.com/@types/qs/-/qs-6.9.3.tgz#b755a0934564a200d3efdf88546ec93c369abd03" @@ -15203,6 +15208,14 @@ react-router-dom@5.2.0, react-router-dom@^5.0.0: tiny-invariant "^1.0.2" tiny-warning "^1.0.0" +react-router-prop-types@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/react-router-prop-types/-/react-router-prop-types-1.0.5.tgz#2e671d8412a793106bf70dc15c9ecc83ea4bc15b" + integrity sha512-q1xlFU2ol2U5zeVbA5hyBuxD3scHenqgMgCTuJQUanA2SyG8A3Fb1S6DleOo1cnGJB5Q05hnLge64kRj+xsuPA== + dependencies: + "@types/prop-types" "^15.7.3" + prop-types "^15.7.2" + react-router-redux@5.0.0-alpha.9: version "5.0.0-alpha.9" resolved "https://registry.yarnpkg.com/react-router-redux/-/react-router-redux-5.0.0-alpha.9.tgz#825431516e0e6f1fd93b8807f6bd595e23ec3d10" -- GitLab