diff --git a/packages/component-faraday-selectors/src/index.js b/packages/component-faraday-selectors/src/index.js index d2f185a9fbddc740533870307d2d9b5653e9b59b..8076ed60d0fd6e3eaa332fe8d483dee94cd2fd22 100644 --- a/packages/component-faraday-selectors/src/index.js +++ b/packages/component-faraday-selectors/src/index.js @@ -80,7 +80,7 @@ export const authorCanViewReportsDetails = ( collection = {}, fragmentId, ) => { - const isAuthor = currentUserIsAuthor(state) + const isAuthor = currentUserIsAuthor(state, fragmentId) return ( authorCanViewReportsDetailsStatuses.includes( get(collection, 'status', 'draft'), @@ -153,7 +153,7 @@ export const canAuthorViewEditorialComments = ( collection = {}, fragmentId, ) => { - const isAuthor = currentUserIsAuthor(state) + const isAuthor = currentUserIsAuthor(state, fragmentId) return ( isAuthor && !cannotAuthorViewEditorialCommentsStatuses.includes( @@ -251,10 +251,10 @@ export const canMakeRevision = (state, collection = {}, fragment = {}) => { ) } -export const currentUserIsAuthor = state => { - const authors = state.collections[0].owners.map(e => e.id) - const user = state.currentUser.user.id - return authors.includes(user) +export const currentUserIsAuthor = (state, fragmentId) => { + const { id: userId } = selectCurrentUser(state) + const authors = get(state, `fragments.${fragmentId}.authors`, []) + return !!authors.find(a => a.id === userId) } export const getUserPermissions = ({ teams = [] }) =>