Skip to content
Snippets Groups Projects
Commit 37ec6d26 authored by Sebastian Mihalache's avatar Sebastian Mihalache
Browse files

Merge branch 'develop' of gitlab.coko.foundation:xpub/xpub-faraday into develop

parents fb0f44af b74266f2
No related branches found
No related tags found
1 merge request!13Sprint #14
...@@ -50,7 +50,6 @@ function unauthenticatedUser(operation, object) { ...@@ -50,7 +50,6 @@ function unauthenticatedUser(operation, object) {
return false return false
} }
const publicStatusesPermissions = ['author', 'reviewer']
const createPaths = ['/collections', '/collections/:collectionId/fragments'] const createPaths = ['/collections', '/collections/:collectionId/fragments']
async function authenticatedUser(user, operation, object, context) { async function authenticatedUser(user, operation, object, context) {
...@@ -90,23 +89,6 @@ async function authenticatedUser(user, operation, object, context) { ...@@ -90,23 +89,6 @@ async function authenticatedUser(user, operation, object, context) {
} }
if (get(object, 'type') === 'collection') { 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 { return {
filter: async collection => { filter: async collection => {
const status = get(collection, 'status') || 'draft' const status = get(collection, 'status') || 'draft'
...@@ -115,20 +97,17 @@ async function authenticatedUser(user, operation, object, context) { ...@@ -115,20 +97,17 @@ async function authenticatedUser(user, operation, object, context) {
Team: context.models.Team, Team: context.models.Team,
}) })
const collectionPermission = userPermissions.find( const { role } = userPermissions.find(
p => p =>
p.objectId === collection.id || p.objectId === collection.id ||
collection.fragments.includes(p.objectId), collection.fragments.includes(p.objectId),
) )
if ( const visibleStatus = get(statuses, `${status}.${role}.label`)
publicStatusesPermissions.includes(
get(collectionPermission, 'role'),
)
) {
collection.visibleStatus = statuses[status].public
}
return collection return {
...collection,
visibleStatus,
}
}, },
} }
} }
......
...@@ -91,48 +91,313 @@ module.exports = { ...@@ -91,48 +91,313 @@ module.exports = {
], ],
statuses: { statuses: {
draft: { draft: {
public: 'Draft', importance: 1,
private: 'Draft', 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: { submitted: {
public: 'Submitted', importance: 3,
private: 'Submitted', author: {
label: 'Submitted',
needsAttention: false,
},
editorInChief: {
label: 'Assign HE',
needsAttention: true,
},
admin: {
label: 'Assign HE',
needsAttention: true,
},
}, },
heInvited: { heInvited: {
public: 'Submitted', importance: 4,
private: 'Handling Editor Invited', 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: { heAssigned: {
public: 'Handling Editor Assigned', importance: 5,
private: 'Handling Editor Assigned', 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: { reviewersInvited: {
public: 'Reviewers Invited', importance: 6,
private: 'Reviewers Invited', 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: { underReview: {
public: 'Under Review', importance: 7,
private: 'Under Review', 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: { reviewCompleted: {
public: 'Under Review', importance: 8,
private: 'Review Completed', author: {
}, label: 'Review Completed',
pendingApproval: { needsAttention: false,
public: 'Under Review', },
private: 'Pending Approval', 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: { revisionRequested: {
public: 'Revision Requested', importance: 9,
private: 'Revision Requested', 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: { rejected: {
public: 'Rejected', importance: 11,
private: 'Rejected', 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: { withdrawn: {
public: 'Published', importance: 15,
private: 'Published', 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': { 'manuscript-types': {
......
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