Skip to content
Snippets Groups Projects
Commit fecf90ff authored by Tania Fecheta's avatar Tania Fecheta
Browse files

refactor(currentUserIsAuthor): refactor currectUserIsAuthor to get authors from fragment

parent e1775400
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
...@@ -80,7 +80,7 @@ export const authorCanViewReportsDetails = ( ...@@ -80,7 +80,7 @@ export const authorCanViewReportsDetails = (
collection = {}, collection = {},
fragmentId, fragmentId,
) => { ) => {
const isAuthor = currentUserIsAuthor(state) const isAuthor = currentUserIsAuthor(state, fragmentId)
return ( return (
authorCanViewReportsDetailsStatuses.includes( authorCanViewReportsDetailsStatuses.includes(
get(collection, 'status', 'draft'), get(collection, 'status', 'draft'),
...@@ -153,7 +153,7 @@ export const canAuthorViewEditorialComments = ( ...@@ -153,7 +153,7 @@ export const canAuthorViewEditorialComments = (
collection = {}, collection = {},
fragmentId, fragmentId,
) => { ) => {
const isAuthor = currentUserIsAuthor(state) const isAuthor = currentUserIsAuthor(state, fragmentId)
return ( return (
isAuthor && isAuthor &&
!cannotAuthorViewEditorialCommentsStatuses.includes( !cannotAuthorViewEditorialCommentsStatuses.includes(
...@@ -251,10 +251,10 @@ export const canMakeRevision = (state, collection = {}, fragment = {}) => { ...@@ -251,10 +251,10 @@ export const canMakeRevision = (state, collection = {}, fragment = {}) => {
) )
} }
export const currentUserIsAuthor = state => { export const currentUserIsAuthor = (state, fragmentId) => {
const authors = state.collections[0].owners.map(e => e.id) const { id: userId } = selectCurrentUser(state)
const user = state.currentUser.user.id const authors = get(state, `fragments.${fragmentId}.authors`, [])
return authors.includes(user) return !!authors.find(a => a.id === userId)
} }
export const getUserPermissions = ({ teams = [] }) => export const getUserPermissions = ({ teams = [] }) =>
......
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