Skip to content
Snippets Groups Projects
Commit c0018973 authored by Alexandru Munteanu's avatar Alexandru Munteanu
Browse files

fix(manuscript-details): hide reviewers and redirect on network error

parent 1d3f81b3
No related branches found
No related tags found
1 merge request!10Sprint #12
......@@ -76,6 +76,14 @@ export const canSeeEditorialComments = (state, collectionId) => {
const collection = state.collections.find(c => c.id === collectionId)
const isStaff = currentUserIs(state, 'staff')
if (!isStaff) return false
if (editorialStatuses.includes(collection.status)) return false
if (editorialStatuses.includes(get(collection, 'status'))) return false
return true
}
export const getPubsweetError = state => get(state, 'error')
export const canSeeReviewersReports = (state, collectionId) => {
const isHE = isHEToManuscript(state, collectionId)
const isEiC = currentUserIs(state, 'adminEiC')
return isHE || isEiC
}
import React, { Fragment } from 'react'
import { isEmpty } from 'lodash'
import { Redirect } from 'react-router-dom'
import {
Root,
......@@ -26,13 +27,16 @@ const ManuscriptLayout = ({
history,
currentUser,
editorInChief,
pubsweetError,
updateManuscript,
canSeeReviewersReports,
canSeeEditorialComments,
editorialRecommendations,
project = {},
version = {},
}) => (
<Root>
{pubsweetError && <Redirect to="not-found" />}
{!isEmpty(project) && !isEmpty(version) ? (
<Fragment>
<Container flex={3}>
......@@ -54,7 +58,9 @@ const ManuscriptLayout = ({
version={version}
/>
<ManuscriptDetails collection={project} fragment={version} />
<ReviewsAndReports project={project} version={version} />
{canSeeReviewersReports && (
<ReviewsAndReports project={project} version={version} />
)}
{canSeeEditorialComments &&
editorialRecommendations.length > 0 && (
<EditorialComments
......
......@@ -28,7 +28,11 @@ import {
import ManuscriptLayout from './ManuscriptLayout'
import { parseSearchParams, redirectToError } from './utils'
import { canSeeEditorialComments } from '../../../component-faraday-selectors'
import {
getPubsweetError,
canSeeReviewersReports,
canSeeEditorialComments,
} from '../../../component-faraday-selectors'
export default compose(
setDisplayName('ManuscriptPage'),
......@@ -45,10 +49,15 @@ export default compose(
connect(
(state, { match }) => ({
currentUser: selectCurrentUser(state),
pubsweetError: getPubsweetError(state),
handlingEditors: selectHandlingEditors(state),
version: selectFragment(state, match.params.version),
project: selectCollection(state, match.params.project),
editorialRecommendations: selectEditorialRecommendations(state),
canSeeReviewersReports: canSeeReviewersReports(
state,
match.params.project,
),
canSeeEditorialComments: canSeeEditorialComments(
state,
match.params.project,
......
......@@ -12,8 +12,8 @@ const NotFound = ({ history }) => (
The page you are looking for might have been removed, had its name
changed, or is temporarily unavailable.
</H3>
<Button onClick={history.goBack} primary>
Back
<Button onClick={() => history.push('/')} primary>
Go to dashboard
</Button>
</Root>
)
......
......@@ -44,7 +44,7 @@ module.exports = {
'pubsweet-client': {
API_ENDPOINT: '/api',
'login-redirect': '/',
'redux-log': false,
'redux-log': true,
theme: process.env.PUBSWEET_THEME,
},
'mail-transport': {
......
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