Skip to content
Snippets Groups Projects
Commit d1f3f459 authored by Iosif Boanca's avatar Iosif Boanca
Browse files

fix(Only authors can see Reviewer Reports): Only authors can see Reviewer Reports

parent d211a9cd
No related branches found
No related tags found
3 merge requests!160Update staging with master features,!150Develop,!144fix(Only authors can see Reviewer Reports): Only authors can see Reviewer Reports
...@@ -79,7 +79,7 @@ export const authorCanViewReportsDetails = ( ...@@ -79,7 +79,7 @@ export const authorCanViewReportsDetails = (
collection = {}, collection = {},
fragmentId, fragmentId,
) => { ) => {
const isAuthor = currentUserIsAuthor(state, fragmentId) const isAuthor = currentUserIsAuthor(state)
return ( return (
authorCanViewReportsDetailsStatuses.includes( authorCanViewReportsDetailsStatuses.includes(
get(collection, 'status', 'draft'), get(collection, 'status', 'draft'),
...@@ -152,7 +152,7 @@ export const canAuthorViewEditorialComments = ( ...@@ -152,7 +152,7 @@ export const canAuthorViewEditorialComments = (
collection = {}, collection = {},
fragmentId, fragmentId,
) => { ) => {
const isAuthor = currentUserIsAuthor(state, fragmentId) const isAuthor = currentUserIsAuthor(state)
return ( return (
isAuthor && isAuthor &&
!cannotAuthorViewEditorialCommentsStatuses.includes( !cannotAuthorViewEditorialCommentsStatuses.includes(
...@@ -245,13 +245,10 @@ export const canMakeRevision = (state, collection = {}, fragment = {}) => { ...@@ -245,13 +245,10 @@ export const canMakeRevision = (state, collection = {}, fragment = {}) => {
) )
} }
export const currentUserIsAuthor = (state, id) => { export const currentUserIsAuthor = state => {
const permissions = getUserPermissions(state) const authors = state.collections[0].owners.map(e => e.id)
const user = state.currentUser.user.id
return permissions return authors.includes(user)
.filter(f => f.role === 'author')
.map(p => p.objectId)
.includes(id)
} }
export const getUserPermissions = ({ teams = [] }) => export const getUserPermissions = ({ teams = [] }) =>
......
...@@ -106,7 +106,7 @@ export default compose( ...@@ -106,7 +106,7 @@ export default compose(
reviewers: selectReviewers(state), reviewers: selectReviewers(state),
fetchingReviewers: selectFetchingReviewers(state), fetchingReviewers: selectFetchingReviewers(state),
isReviewer: currentUserIsReviewer(state, version.id), isReviewer: currentUserIsReviewer(state, version.id),
isAuthor: currentUserIsAuthor(state, version.id), isAuthor: currentUserIsAuthor(state),
recommendations: selectReviewRecommendations(state, version.id), recommendations: selectReviewRecommendations(state, version.id),
canViewReports: canViewReports(state, project.id), canViewReports: canViewReports(state, project.id),
}), }),
......
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