From ee32648bf4c11a5074c7e793e23f24a42c5278cc Mon Sep 17 00:00:00 2001 From: Shane Kilkelly Date: Fri, 22 Sep 2017 15:55:38 +0100 Subject: [PATCH] Order privileges by highest-to-lowest --- .../Collaborators/CollaboratorsHandler.coffee | 13 ++++++------- .../Collaborators/CollaboratorsHandlerTests.coffee | 4 ++-- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/services/web/app/coffee/Features/Collaborators/CollaboratorsHandler.coffee b/services/web/app/coffee/Features/Collaborators/CollaboratorsHandler.coffee index cbe191fc04..969f263a02 100644 --- a/services/web/app/coffee/Features/Collaborators/CollaboratorsHandler.coffee +++ b/services/web/app/coffee/Features/Collaborators/CollaboratorsHandler.coffee @@ -28,18 +28,17 @@ module.exports = CollaboratorsHandler = return callback(error) if error? return callback new Errors.NotFoundError("no project found with id #{project_id}") if !project? members = [] - # Project owner members.push { id: project.owner_ref.toString(), privilegeLevel: PrivilegeLevels.OWNER, source: Sources.OWNER } - # Invited members - for member_id in project.readOnly_refs or [] - members.push { id: member_id.toString(), privilegeLevel: PrivilegeLevels.READ_ONLY, source: Sources.INVITE } + # read-and-write for member_id in project.collaberator_refs or [] members.push { id: member_id.toString(), privilegeLevel: PrivilegeLevels.READ_AND_WRITE, source: Sources.INVITE } - # Token access - for member_id in project.tokenAccessReadOnly_refs or [] - members.push { id: member_id.toString(), privilegeLevel: PrivilegeLevels.READ_ONLY, source: Sources.TOKEN } for member_id in project.tokenAccessReadAndWrite_refs or [] members.push { id: member_id.toString(), privilegeLevel: PrivilegeLevels.READ_AND_WRITE, source: Sources.TOKEN } + # read-only + for member_id in project.readOnly_refs or [] + members.push { id: member_id.toString(), privilegeLevel: PrivilegeLevels.READ_ONLY, source: Sources.INVITE } + for member_id in project.tokenAccessReadOnly_refs or [] + members.push { id: member_id.toString(), privilegeLevel: PrivilegeLevels.READ_ONLY, source: Sources.TOKEN } return callback null, members getMemberIds: (project_id, callback = (error, member_ids) ->) -> diff --git a/services/web/test/UnitTests/coffee/Collaborators/CollaboratorsHandlerTests.coffee b/services/web/test/UnitTests/coffee/Collaborators/CollaboratorsHandlerTests.coffee index 0875640f13..d9506bfddd 100644 --- a/services/web/test/UnitTests/coffee/Collaborators/CollaboratorsHandlerTests.coffee +++ b/services/web/test/UnitTests/coffee/Collaborators/CollaboratorsHandlerTests.coffee @@ -44,10 +44,10 @@ describe "CollaboratorsHandler", -> @callback .calledWith(null, [ { id: "owner-ref", privilegeLevel: "owner", source: 'owner'} - { id: "read-only-ref-1", privilegeLevel: "readOnly", source: 'invite'} - { id: "read-only-ref-2", privilegeLevel: "readOnly", source: 'invite'} { id: "read-write-ref-1", privilegeLevel: "readAndWrite", source: 'invite'} { id: "read-write-ref-2", privilegeLevel: "readAndWrite", source: 'invite' } + { id: "read-only-ref-1", privilegeLevel: "readOnly", source: 'invite'} + { id: "read-only-ref-2", privilegeLevel: "readOnly", source: 'invite'} ]) .should.equal true