Skip to content
Snippets Groups Projects
Commit f599c9c9 authored by Zhan Huang's avatar Zhan Huang
Browse files

388

parent 0345e7ad
No related branches found
No related tags found
2 merge requests!81Dev,!80Shared data model
......@@ -120,7 +120,7 @@ class Review extends React.Component {
banner: false,
showManuscript: false,
showAll: false,
waitingForFinal: false,
waitingForGeneration: false,
}
componentDidMount() {
const hidePopup = document.cookie.split('; ').reduce((r, v) => {
......@@ -146,7 +146,7 @@ class Review extends React.Component {
instruct,
showManuscript,
showAll,
waitingForFinal,
waitingForGeneration,
} = this.state
const { files: allfiles, status, teams } = manuscript
const sourceFile = allfiles.find(f => f.type === 'manuscript')
......@@ -161,19 +161,34 @@ class Review extends React.Component {
const xml = files.find(f => f.type === 'PMC') || null
const final = files.find(f => f.type === 'PMCfinal') || null
const tempHTML = files.find(f => f.type === 'tempHTML') || null
const hasFinal =
final &&
tempHTML &&
final.filename
.split('.')
.slice(0, -1)
.join('.') ===
tempHTML.filename
const pdf4print = files.find(f => f.type === 'pdf4print') || null
const finalFilename = final
? final.filename
.split('.')
.slice(0, -1)
.join('.')
if (waitingForFinal && hasFinal) {
this.setState({ waitingForFinal: false })
: null
const tempHTMLFilename = tempHTML
? tempHTML.filename
.split('.')
.slice(0, -1)
.join('.')
: null
const pdf4printFilename = pdf4print
? pdf4print.filename
.split('.')
.slice(0, -1)
.join('.')
: null
const prod = window.location.hostname.startsWith('beta')
const hasFinal =
finalFilename === tempHTMLFilename &&
(!prod || finalFilename === pdf4printFilename)
if (waitingForGeneration && hasFinal) {
this.setState({ waitingForGeneration: false })
}
const reviewer = teams.find(t => t.role === 'reviewer').teamMembers[0]
if (
......@@ -187,6 +202,9 @@ class Review extends React.Component {
this.props.history.push('/')
return null
}
const generating = !xml || (waitingForGeneration && !hasFinal)
return (
<PreviewPageDiv>
{instruct && (
......@@ -251,7 +269,7 @@ class Review extends React.Component {
>
{(convertXML, { data }) => {
const generatePreviews = async () => {
this.setState({ waitingForFinal: true })
this.setState({ waitingForGeneration: true })
await convertXML({
variables: { id: xml.id },
})
......@@ -260,7 +278,7 @@ class Review extends React.Component {
<React.Fragment>
<Buttons left top>
<Button
disabled={!xml || (waitingForFinal && !hasFinal)}
disabled={generating}
onClick={() => generatePreviews()}
>
Regenerate previews
......@@ -284,7 +302,7 @@ class Review extends React.Component {
/>
<Buttons left top>
<Button
disabled={!xml || (waitingForFinal && !hasFinal)}
disabled={generating}
onClick={() => generatePreviews()}
>
Regenerate previews
......
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