From dabaa7900e1d428b11f105631b7c35965e4d1eaa Mon Sep 17 00:00:00 2001 From: Iosif Boanca <iosif.boanca@thinslices.com> Date: Thu, 18 Oct 2018 13:21:04 +0300 Subject: [PATCH] canAuthorViewEditorialComments added --- .../component-faraday-selectors/src/index.js | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/packages/component-faraday-selectors/src/index.js b/packages/component-faraday-selectors/src/index.js index fcdffadd5..1b60986bd 100644 --- a/packages/component-faraday-selectors/src/index.js +++ b/packages/component-faraday-selectors/src/index.js @@ -108,6 +108,29 @@ export const canEICViewEditorialComments = (state, collection = {}) => { return isEIC && canEICViewEditorialCommentsStatuses.includes(status) } +const cannotAuthorViewEditorialCommentsStatuses = [ + 'draft', + 'technicalChecks', + 'submitted', + 'heInvited', + 'heAssigned', + 'reviewersInvited', +] + +export const canAuthorViewEditorialComments = ( + state, + collection = {}, + fragmentId, +) => { + const isAuthor = currentUserIsAuthor(state, fragmentId) + return ( + isAuthor && + !cannotAuthorViewEditorialCommentsStatuses.includes( + get(collection, 'status', 'draft'), + ) + ) +} + export const canViewEditorialComments = ( state, collection = {}, -- GitLab