Skip to content
Snippets Groups Projects
Commit 40b63c8b authored by Audrey Hamelers's avatar Audrey Hamelers
Browse files

#1215

parent a093e0d4
No related branches found
No related tags found
1 merge request!389Dev
...@@ -169,6 +169,7 @@ export const REJECT_MANUSCRIPT = gql` ...@@ -169,6 +169,7 @@ export const REJECT_MANUSCRIPT = gql`
...ManuscriptFragment ...ManuscriptFragment
} }
errors { errors {
type
message message
} }
} }
......
...@@ -64,6 +64,7 @@ export const REVIEW_MANUSCRIPT = gql` ...@@ -64,6 +64,7 @@ export const REVIEW_MANUSCRIPT = gql`
...ManuscriptFragment ...ManuscriptFragment
} }
errors { errors {
type
message message
} }
} }
......
...@@ -23,15 +23,18 @@ import { CREATE_MANUSCRIPT } from './operations' ...@@ -23,15 +23,18 @@ import { CREATE_MANUSCRIPT } from './operations'
const SplitPageShort = styled(SplitPage)` const SplitPageShort = styled(SplitPage)`
min-height: calc(100vh - (${th('gridUnit')} * 20)); min-height: calc(100vh - (${th('gridUnit')} * 20));
` `
const freshState = {
error: null,
id: null,
showInfo: false,
checked: false,
cancelCheck: false,
inEPMC: false,
}
class CreateSetup extends React.Component { class CreateSetup extends React.Component {
state = { state = freshState
message: null,
id: null,
showInfo: false,
checked: false,
cancelCheck: false,
inEPMC: false,
}
manuscriptSetup = async (citationData, component) => { manuscriptSetup = async (citationData, component) => {
if (citationData) { if (citationData) {
const { createNote, createManuscript, history } = component.props const { createNote, createManuscript, history } = component.props
...@@ -40,12 +43,15 @@ class CreateSetup extends React.Component { ...@@ -40,12 +43,15 @@ class CreateSetup extends React.Component {
variables: { data: { ...citation } }, variables: { data: { ...citation } },
}) })
const { manuscript, errors } = created.data.createManuscript const { manuscript, errors } = created.data.createManuscript
const { id, version } = manuscript const { id, version } = manuscript || {}
const route = `/submission/${id}/create` const route = id ? `/submission/${id}/create` : '/create'
if (errors && errors.length > 0) { if (errors && errors.length > 0) {
const { message } = errors[0] const error = errors[0]
component.setState({ message, id }) component.setState({ error, id })
setTimeout(() => history.push(route), 3500) setTimeout(() => {
history.push(route)
if (!id) component.setState(freshState)
}, (id && 3500) || 4000)
} else { } else {
if (note) { if (note) {
await createNote({ await createNote({
...@@ -63,7 +69,7 @@ class CreateSetup extends React.Component { ...@@ -63,7 +69,7 @@ class CreateSetup extends React.Component {
} }
} }
render() { render() {
const { showInfo, id, message, checked, cancelCheck, inEPMC } = this.state const { showInfo, id, error, checked, cancelCheck, inEPMC } = this.state
const { location, history } = this.props const { location, history } = this.props
const enter = location.search.substr(1) const enter = location.search.substr(1)
const preprint = enter === 'preprint' const preprint = enter === 'preprint'
...@@ -96,9 +102,10 @@ class CreateSetup extends React.Component { ...@@ -96,9 +102,10 @@ class CreateSetup extends React.Component {
) : ( ) : (
<div> <div>
<CreateHeader currentStep={0} preprint={preprint} /> <CreateHeader currentStep={0} preprint={preprint} />
{id && ( {error && (
<Notification type="warning"> <Notification type={error.type}>
{message} Redirecting to {id}. {error.message}
{id && ` Redirecting to ${id}.`}
</Notification> </Notification>
)} )}
{!cancelCheck && <H2>Citation information</H2>} {!cancelCheck && <H2>Citation information</H2>}
......
...@@ -31,6 +31,7 @@ export const CREATE_MANUSCRIPT = gql` ...@@ -31,6 +31,7 @@ export const CREATE_MANUSCRIPT = gql`
} }
} }
errors { errors {
type
message message
} }
} }
...@@ -44,6 +45,7 @@ export const SUBMIT_MANUSCRIPT = gql` ...@@ -44,6 +45,7 @@ export const SUBMIT_MANUSCRIPT = gql`
...ManuscriptFragment ...ManuscriptFragment
} }
errors { errors {
type
message message
} }
} }
......
const lodash = require('lodash') const lodash = require('lodash')
const logger = require('@pubsweet/logger')
const { PropManager } = require('../config')
const Journal = require('./data-access') const Journal = require('./data-access')
const empty = { const empty = {
...@@ -25,6 +27,26 @@ const JournalManager = { ...@@ -25,6 +27,26 @@ const JournalManager = {
}, },
selectWithNLM: async nlmId => Journal.selectByNlmId(nlmId), selectWithNLM: async nlmId => Journal.selectByNlmId(nlmId),
searchByTitle: async query => Journal.searchByTitle(query), searchByTitle: async query => Journal.searchByTitle(query),
preprintCheck: async journalId => {
try {
const preprintServers = await PropManager.find('preprintServers')
const journal = await Journal.find(journalId)
const nlmta = journal['meta,nlmta']
const error = [
{
type: 'error',
message:
'Europe PMC plus does not accept preprint submissions. COVID-19 preprints are ingested directly from preprint servers.',
},
]
return preprintServers.value.includes(nlmta) ? error : false
} catch {
logger.error(
'Preprint server list not set; cannot check submission journal status.',
)
return false
}
},
} }
module.exports = JournalManager module.exports = JournalManager
...@@ -133,6 +133,23 @@ exports.seed = async (knex, Promise) => { ...@@ -133,6 +133,23 @@ exports.seed = async (knex, Promise) => {
stopDate: { date: '2021-01-03', time: '00:00:00' }, stopDate: { date: '2021-01-03', time: '00:00:00' },
}), }),
}, },
{
name: 'preprintServers',
description:
'Preprint servers in the NLM Catalog, to refuse manuscript submissions',
schema: JSON.stringify({
type: 'array',
items: { type: 'string', description: 'Server name' },
}),
value: JSON.stringify([
'medRxiv',
'bioRxiv',
'Res Sq',
'SSRN',
'ArXiv',
'ChemRxiv',
]),
},
{ {
name: 'approvedServers', name: 'approvedServers',
description: 'List of preprint servers to skip submission QA', description: 'List of preprint servers to skip submission QA',
......
const logger = require('@pubsweet/logger') const logger = require('@pubsweet/logger')
const rfr = require('rfr') const rfr = require('rfr')
const { ManuscriptManager, OrganizationManager } = rfr('server/xpub-model') const { ManuscriptManager, OrganizationManager, JournalManager } = rfr(
'server/xpub-model',
)
const { addCitation } = rfr('server/xml-validation') const { addCitation } = rfr('server/xml-validation')
const { deleteManifest } = rfr('server/ebi-integration/removeEbi') const { deleteManifest } = rfr('server/ebi-integration/removeEbi')
...@@ -122,6 +124,15 @@ const resolvers = { ...@@ -122,6 +124,15 @@ const resolvers = {
const organizationId = await OrganizationManager.getOrganizationID( const organizationId = await OrganizationManager.getOrganizationID(
data.preprint, data.preprint,
) )
if (!data.preprint && data.journalId) {
const preprintCheck = await JournalManager.preprintCheck(data.journalId)
if (preprintCheck) {
return {
manuscript: null,
errors: preprintCheck,
}
}
}
delete data.preprint delete data.preprint
const dupeCheck = await ManuscriptManager.checkDuplicates( const dupeCheck = await ManuscriptManager.checkDuplicates(
null, null,
...@@ -142,6 +153,7 @@ const resolvers = { ...@@ -142,6 +153,7 @@ const resolvers = {
manuscript: dupeCheck.manuscripts[0], manuscript: dupeCheck.manuscripts[0],
errors: [ errors: [
{ {
type: 'warning',
message: message:
'You already have a manuscript with this citation information.', 'You already have a manuscript with this citation information.',
}, },
......
...@@ -8,6 +8,7 @@ type Older { ...@@ -8,6 +8,7 @@ type Older {
} }
type Error { type Error {
type: String
message: String message: String
} }
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment