From 6831028471299aa5a0f46ee9a36c7589105688c4 Mon Sep 17 00:00:00 2001 From: Alexandru Munteanu <alexandru.munt@gmail.com> Date: Wed, 27 Jun 2018 15:26:23 +0300 Subject: [PATCH] feat(manuscript-statuses): update manuscript statuses and authsome mode --- packages/xpub-faraday/config/authsome-mode.js | 33 +- packages/xpub-faraday/config/default.js | 315 ++++++++++++++++-- 2 files changed, 296 insertions(+), 52 deletions(-) diff --git a/packages/xpub-faraday/config/authsome-mode.js b/packages/xpub-faraday/config/authsome-mode.js index 5e4c53b2b..ca078ea87 100644 --- a/packages/xpub-faraday/config/authsome-mode.js +++ b/packages/xpub-faraday/config/authsome-mode.js @@ -50,7 +50,6 @@ function unauthenticatedUser(operation, object) { return false } -const publicStatusesPermissions = ['author', 'reviewer'] const createPaths = ['/collections', '/collections/:collectionId/fragments'] async function authenticatedUser(user, operation, object, context) { @@ -90,23 +89,6 @@ async function authenticatedUser(user, operation, object, context) { } if (get(object, 'type') === 'collection') { - if (helpers.isOwner({ user, object })) { - if ( - await helpers.hasFragmentInDraft({ - object, - Fragment: context.models.Fragment, - }) - ) { - return { - filter: collection => ({ - ...collection, - status: 'draft', - visibleStatus: statuses.draft.public, - }), - } - } - return true - } return { filter: async collection => { const status = get(collection, 'status') || 'draft' @@ -115,20 +97,17 @@ async function authenticatedUser(user, operation, object, context) { Team: context.models.Team, }) - const collectionPermission = userPermissions.find( + const { role } = userPermissions.find( p => p.objectId === collection.id || collection.fragments.includes(p.objectId), ) - if ( - publicStatusesPermissions.includes( - get(collectionPermission, 'role'), - ) - ) { - collection.visibleStatus = statuses[status].public - } + const visibleStatus = get(statuses, `${status}.${role}.label`) - return collection + return { + ...collection, + visibleStatus, + } }, } } diff --git a/packages/xpub-faraday/config/default.js b/packages/xpub-faraday/config/default.js index 70c2472c5..fdc085fce 100644 --- a/packages/xpub-faraday/config/default.js +++ b/packages/xpub-faraday/config/default.js @@ -91,48 +91,313 @@ module.exports = { ], statuses: { draft: { - public: 'Draft', - private: 'Draft', + importance: 1, + author: { + label: 'Complete Submission', + needsAttention: true, + }, + admin: { + label: 'Complete Submission', + needsAttention: true, + }, + }, + technicalChecks: { + importance: 2, + author: { + label: 'Submitted', + needsAttention: false, + }, + editorInChief: { + label: 'QA', + needsAttention: false, + }, + admin: { + label: 'Approve QA', + needsAttention: true, + }, }, submitted: { - public: 'Submitted', - private: 'Submitted', + importance: 3, + author: { + label: 'Submitted', + needsAttention: false, + }, + editorInChief: { + label: 'Assign HE', + needsAttention: true, + }, + admin: { + label: 'Assign HE', + needsAttention: true, + }, }, heInvited: { - public: 'Submitted', - private: 'Handling Editor Invited', + importance: 4, + author: { + label: 'HE Invited', + needsAttention: false, + }, + handlingEditor: { + label: 'Respond to Invite', + needsAttention: true, + }, + editorInChief: { + label: 'HE Invited', + needsAttention: false, + }, + admin: { + label: 'Respond to Invite', + needsAttention: true, + }, }, heAssigned: { - public: 'Handling Editor Assigned', - private: 'Handling Editor Assigned', + importance: 5, + author: { + label: 'HE Assigned', + needsAttention: false, + }, + handlingEditor: { + label: 'Invite Reviewers', + needsAttention: true, + }, + editorInChief: { + label: 'HE Assigned', + needsAttention: false, + }, + admin: { + label: 'Invite Reviewers', + needsAttention: true, + }, }, reviewersInvited: { - public: 'Reviewers Invited', - private: 'Reviewers Invited', + importance: 6, + author: { + label: 'Reviewers Invited', + needsAttention: false, + }, + handlingEditor: { + label: 'Check Review Process', + needsAttention: true, + }, + editorInChief: { + label: 'Reviewers Invited', + needsAttention: false, + }, + reviewer: { + label: 'Respond to Invite', + needsAttention: true, + }, + admin: { + label: 'Respond to Invite', + needsAttention: true, + }, }, underReview: { - public: 'Under Review', - private: 'Under Review', + importance: 7, + author: { + label: 'Under Review', + needsAttention: false, + }, + handlingEditor: { + label: 'Check Review Process', + needsAttention: true, + }, + editorInChief: { + label: 'Under Review', + needsAttention: false, + }, + reviewer: { + label: 'Complete Review', + needsAttention: true, + }, + admin: { + label: 'Complete Review', + needsAttention: true, + }, }, reviewCompleted: { - public: 'Under Review', - private: 'Review Completed', - }, - pendingApproval: { - public: 'Under Review', - private: 'Pending Approval', + importance: 8, + author: { + label: 'Review Completed', + needsAttention: false, + }, + handlingEditor: { + label: 'Make Decision', + needsAttention: true, + }, + editorInChief: { + label: 'Review Completed', + needsAttention: false, + }, + reviewer: { + label: 'Review Completed', + needsAttention: false, + }, + admin: { + label: 'Make Decision', + needsAttention: true, + }, }, revisionRequested: { - public: 'Revision Requested', - private: 'Revision Requested', + importance: 9, + author: { + label: 'Submit Revision', + needsAttention: true, + }, + handlingEditor: { + label: 'Revision Requested', + needsAttention: false, + }, + editorInChief: { + label: 'Revision Requested', + needsAttention: false, + }, + reviewer: { + label: 'Revision Requested', + needsAttention: false, + }, + admin: { + label: 'Submit Revision', + needsAttention: true, + }, + }, + pendingApproval: { + importance: 10, + author: { + label: 'Pending Approval', + needsAttention: false, + }, + handlingEditor: { + label: 'Pending Approval', + needsAttention: false, + }, + editorInChief: { + label: 'Make Decision', + needsAttention: true, + }, + reviewer: { + label: 'Pending Approval', + needsAttention: false, + }, + admin: { + label: 'Make Decision', + needsAttention: true, + }, }, rejected: { - public: 'Rejected', - private: 'Rejected', + importance: 11, + author: { + label: 'Rejected', + needsAttention: false, + }, + handlingEditor: { + label: 'Rejected', + needsAttention: false, + }, + editorInChief: { + label: 'Rejected', + needsAttention: false, + }, + reviewer: { + label: 'Rejected', + needsAttention: false, + }, + admin: { + label: 'Rejected', + needsAttention: false, + }, + }, + inQA: { + importance: 12, + author: { + label: 'Pending approval', + needsAttention: false, + }, + handlingEditor: { + label: 'QA', + needsAttention: false, + }, + editorInChief: { + label: 'QA', + needsAttention: false, + }, + reviewer: { + label: 'QA', + needsAttention: false, + }, + admin: { + label: 'Approve QA', + needsAttention: true, + }, + }, + accepted: { + importance: 13, + author: { + label: 'Accepted', + needsAttention: false, + }, + handlingEditor: { + label: 'Accepted', + needsAttention: false, + }, + editorInChief: { + label: 'Accepted', + needsAttention: false, + }, + reviewer: { + label: 'Accepted', + needsAttention: false, + }, + admin: { + label: 'Accepted', + needsAttention: false, + }, + }, + withdrawalRequested: { + importance: 14, + author: { + label: 'Withdrawal Requested', + needsAttention: false, + }, + handlingEditor: { + label: 'Withdrawal Requested', + needsAttention: false, + }, + editorInChief: { + label: 'Approve Withdrawal', + needsAttention: true, + }, + reviewer: { + label: 'Withdrawal Requested', + needsAttention: false, + }, + admin: { + label: 'Approve Withdrawal', + needsAttention: true, + }, }, - published: { - public: 'Published', - private: 'Published', + withdrawn: { + importance: 15, + author: { + label: 'Withdrawn', + needsAttention: false, + }, + handlingEditor: { + label: 'Withdrawn', + needsAttention: false, + }, + editorInChief: { + label: 'Withdrawn', + needsAttention: false, + }, + reviewer: { + label: 'Withdrawn', + needsAttention: false, + }, + admin: { + label: 'Withdrawn', + needsAttention: false, + }, }, }, 'manuscript-types': { -- GitLab