diff --git a/backend/module/eCampApi/config/Rest/campCollaboration.config.php b/backend/module/eCampApi/config/Rest/campCollaboration.config.php index f17cfc10bd..eb21260095 100644 --- a/backend/module/eCampApi/config/Rest/campCollaboration.config.php +++ b/backend/module/eCampApi/config/Rest/campCollaboration.config.php @@ -21,6 +21,7 @@ ->addValidatorInArray([ CampCollaboration::ROLE_MEMBER, CampCollaboration::ROLE_MANAGER, + CampCollaboration::ROLE_GUEST, ]) ) ->buildConfig() diff --git a/backend/module/eCampApi/test/Rest/CampCollaborationTest.php b/backend/module/eCampApi/test/Rest/CampCollaborationTest.php index 2ba0cf7e96..c30f2a8b93 100644 --- a/backend/module/eCampApi/test/Rest/CampCollaborationTest.php +++ b/backend/module/eCampApi/test/Rest/CampCollaborationTest.php @@ -226,10 +226,13 @@ public function testCreateSuccess(): void { $this->assertEquals(CampCollaboration::STATUS_INVITED, $this->getResponseContent()->status); } - public function testCreateOnlyWithEmail(): void { + /** + * @dataProvider getRoles + */ + public function testCreateOnlyWithEmail(string $role): void { $inviteEmail = 'my.mail@fantasy.com'; $this->setRequestContent([ - 'role' => CampCollaboration::ROLE_MEMBER, + 'role' => $role, 'campId' => $this->campCollaboration1->getCamp()->getId(), 'inviteEmail' => $inviteEmail, 'userId' => null, @@ -244,6 +247,10 @@ public function testCreateOnlyWithEmail(): void { $this->assertThat($this->getResponseContent()->_embedded, self::logicalNot(self::classHasAttribute('user'))); } + public static function getRoles(): array { + return [[CampCollaboration::ROLE_GUEST], [CampCollaboration::ROLE_MANAGER], [CampCollaboration::ROLE_MEMBER]]; + } + public function testCreateWithEmailOfExistingUser() { $inviteEmail = 'my.mail@fantasy.com'; $user2 = new User(); diff --git a/backend/module/eCampCore/src/Acl/AclFactory.php b/backend/module/eCampCore/src/Acl/AclFactory.php index 0f27ddb208..8c3de3cdab 100644 --- a/backend/module/eCampCore/src/Acl/AclFactory.php +++ b/backend/module/eCampCore/src/Acl/AclFactory.php @@ -134,7 +134,7 @@ public function __invoke(ContainerInterface $container, $requestedName, array $o Acl::REST_PRIVILEGE_FETCH, AclAssertion::or( new CampIsPrototype(), - new UserIsCollaborator([CampCollaboration::ROLE_MEMBER, CampCollaboration::ROLE_MANAGER]) + new UserIsCollaborator([CampCollaboration::ROLE_MEMBER, CampCollaboration::ROLE_MANAGER, CampCollaboration::ROLE_GUEST]) ) ); $acl->allow( diff --git a/common/locales/en.json b/common/locales/en.json index 3f5bd9d57c..38f18668ff 100644 --- a/common/locales/en.json +++ b/common/locales/en.json @@ -40,7 +40,8 @@ "collaborators": { "invite": "Invite", "manager": "Manager", - "member": "Member" + "member": "Member", + "guest": "Guest" }, "fields": { "addressCity": "City", diff --git a/frontend/src/components/camp/CollaboratorListItem.vue b/frontend/src/components/camp/CollaboratorListItem.vue index 9cee044740..fec49ddf8c 100644 --- a/frontend/src/components/camp/CollaboratorListItem.vue +++ b/frontend/src/components/camp/CollaboratorListItem.vue @@ -30,6 +30,7 @@ :items="[ { key: 'member', translation: $tc('entity.camp.collaborators.member') }, { key: 'manager', translation: $tc('entity.camp.collaborators.manager') }, + { key: 'guest', translation: $tc('entity.camp.collaborators.guest') }, ]" item-value="key" item-text="translation" diff --git a/frontend/src/views/camp/Collaborators.vue b/frontend/src/views/camp/Collaborators.vue index 179b6cd5fe..5787bbefa1 100644 --- a/frontend/src/views/camp/Collaborators.vue +++ b/frontend/src/views/camp/Collaborators.vue @@ -50,6 +50,7 @@ Displays collaborators of a single camp. :items="[ { key: 'member', translation: $tc('entity.camp.collaborators.member') }, { key: 'manager', translation: $tc('entity.camp.collaborators.manager') }, + { key: 'guest', translation: $tc('entity.camp.collaborators.guest') }, ]" item-value="key" item-text="translation" diff --git a/frontend/src/views/camp/__tests__/Admin.spec.js b/frontend/src/views/camp/__tests__/Admin.spec.js index b190c5cf63..2de26ae734 100644 --- a/frontend/src/views/camp/__tests__/Admin.spec.js +++ b/frontend/src/views/camp/__tests__/Admin.spec.js @@ -62,4 +62,25 @@ describe('Admin view', () => { expect(queryByText('components.camp.campDangerzone.title')).not.toBeInTheDocument() expect(queryByText('components.camp.campDangerzone.deleteCamp.title')).not.toBeInTheDocument() }) + + it('doesn\'t show the danger zone when the user has the guest role', async () => { + const { queryByText } = renderWithVuetify(Admin, { + props: { + camp: () => ({ + role: 'guest', + materialLists: () => {}, + _meta: { loading: false } + }) + }, + routes: [], + mocks: { + api: { reload: () => Promise.resolve() }, + $tc: key => key + }, + stubs: ['camp-settings', 'camp-address', 'camp-periods', 'camp-categories', 'camp-material-lists'] + }) + + expect(queryByText('components.camp.campDangerzone.title')).not.toBeInTheDocument() + expect(queryByText('components.camp.campDangerzone.deleteCamp.title')).not.toBeInTheDocument() + }) })