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