From 4d6b2a241d9e75b00dc115e4457987b3b9e51d1a Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 25 Nov 2021 10:55:34 +0100 Subject: [PATCH 1/3] Correctly fall back when default permissions are used Signed-off-by: Joas Schilling --- .../PermissionsEditor/PermissionsEditor.vue | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/components/PermissionsEditor/PermissionsEditor.vue b/src/components/PermissionsEditor/PermissionsEditor.vue index 885013be0..156e17ce0 100644 --- a/src/components/PermissionsEditor/PermissionsEditor.vue +++ b/src/components/PermissionsEditor/PermissionsEditor.vue @@ -147,6 +147,15 @@ export default { }) } else throw Error('you need to fill either the conversationName or the displayName props') }, + + permissionsWithDefault() { + if (this.permissions !== PERMISSIONS.DEFAULT) { + return this.permissions + } + + return PERMISSIONS.MAX_DEFAULT & ~PERMISSIONS.LOBBY_IGNORE + }, + /** * The number of the edited permissions during the editing of the form. * We use this to compare it with the actual permissions of the @@ -167,12 +176,12 @@ export default { * disabled. */ submitButtonDisabled() { - return this.permissions === this.formPermissions + return this.permissionsWithDefault === this.formPermissions }, }, mounted() { - this.writePermissionsToComponent(this.permissions) + this.writePermissionsToComponent(this.permissionsWithDefault) }, methods: { From 5ef31c4c1151456e6090048594f33f3a18561092 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 25 Nov 2021 10:55:53 +0100 Subject: [PATCH 2/3] Enable the form button based on the options that we display at the moment Signed-off-by: Joas Schilling --- src/components/PermissionsEditor/PermissionsEditor.vue | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/PermissionsEditor/PermissionsEditor.vue b/src/components/PermissionsEditor/PermissionsEditor.vue index 156e17ce0..346106bdc 100644 --- a/src/components/PermissionsEditor/PermissionsEditor.vue +++ b/src/components/PermissionsEditor/PermissionsEditor.vue @@ -176,7 +176,11 @@ export default { * disabled. */ submitButtonDisabled() { - return this.permissionsWithDefault === this.formPermissions + return (!!(this.permissionsWithDefault & PERMISSIONS.CALL_START)) === this.callStart + && !!(this.permissionsWithDefault & PERMISSIONS.LOBBY_IGNORE) === this.lobbyIgnore + && !!(this.permissionsWithDefault & PERMISSIONS.PUBLISH_AUDIO) === this.publishAudio + && !!(this.permissionsWithDefault & PERMISSIONS.PUBLISH_VIDEO) === this.publishVideo + && !!(this.permissionsWithDefault & PERMISSIONS.PUBLISH_SCREEN) === this.publishScreen }, }, From 6172d1d4c5d08cdcb68ad9b07a1e14f5d4f477b4 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 25 Nov 2021 11:30:40 +0100 Subject: [PATCH 3/3] Add a test for the default handling Signed-off-by: Joas Schilling --- .../ParticipantPermissionsEditor.spec.js | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/src/components/RightSidebar/Participants/ParticipantsList/Participant/ParticipantPermissionsEditor/ParticipantPermissionsEditor.spec.js b/src/components/RightSidebar/Participants/ParticipantsList/Participant/ParticipantPermissionsEditor/ParticipantPermissionsEditor.spec.js index ad4c2647b..00dec1b60 100644 --- a/src/components/RightSidebar/Participants/ParticipantsList/Participant/ParticipantPermissionsEditor/ParticipantPermissionsEditor.spec.js +++ b/src/components/RightSidebar/Participants/ParticipantsList/Participant/ParticipantPermissionsEditor/ParticipantPermissionsEditor.spec.js @@ -26,7 +26,8 @@ describe('ParticipantPermissionsEditor.vue', () => { participantType: PARTICIPANT.TYPE.USER, attendeePermissions: PARTICIPANT.PERMISSIONS.CALL_START | PARTICIPANT.PERMISSIONS.PUBLISH_AUDIO - | PARTICIPANT.PERMISSIONS.PUBLISH_VIDEO, + | PARTICIPANT.PERMISSIONS.PUBLISH_VIDEO + | PARTICIPANT.PERMISSIONS.CUSTOM, attendeeId: 'alice-attendee-id', status: '', statusIcon: '🌧️', @@ -95,15 +96,30 @@ describe('ParticipantPermissionsEditor.vue', () => { const publishScreenCheckbox = wrapper.findComponent(PermissionsEditor).findComponent({ ref: 'publishScreen' }) expect(publishScreenCheckbox.vm.$options.propsData.checked).toBe(false) }) + + test('Properly renders the checkboxes with default permissions', async () => { + participant.attendeePermissions = PARTICIPANT.PERMISSIONS.DEFAULT + const wrapper = await mountParticipantPermissionsEditor(participant) + const callStartCheckbox = wrapper.findComponent(PermissionsEditor).findComponent({ ref: 'callStart' }) + expect(callStartCheckbox.vm.$options.propsData.checked).toBe(true) + const lobbyIgnoreCheckbox = wrapper.findComponent(PermissionsEditor).findComponent({ ref: 'lobbyIgnore' }) + expect(lobbyIgnoreCheckbox.vm.$options.propsData.checked).toBe(false) + const publishAudioCheckbox = wrapper.findComponent(PermissionsEditor).findComponent({ ref: 'publishAudio' }) + expect(publishAudioCheckbox.vm.$options.propsData.checked).toBe(true) + const publishVideoCheckbox = wrapper.findComponent(PermissionsEditor).findComponent({ ref: 'publishVideo' }) + expect(publishVideoCheckbox.vm.$options.propsData.checked).toBe(true) + const publishScreenCheckbox = wrapper.findComponent(PermissionsEditor).findComponent({ ref: 'publishScreen' }) + expect(publishScreenCheckbox.vm.$options.propsData.checked).toBe(true) + }) }) - describe('Dispatches the aciton to set the right permissions', async () => { + describe('Dispatches the action to set the right permissions', async () => { - test('Dispatches setPermissions with the correct permissions value when a permission is subtracted', async () => { + test('Dispatches setPermissions with the correct permissions value when a permission is added', async () => { const wrapper = await mountParticipantPermissionsEditor(participant) // Add a permission - wrapper.findComponent(PermissionsEditor).setData({ lobbyIgnore: true }) + await wrapper.findComponent(PermissionsEditor).setData({ lobbyIgnore: true }) // Click the submit button await wrapper.findComponent(PermissionsEditor).find({ ref: 'submit' }).trigger('click') @@ -121,11 +137,11 @@ describe('ParticipantPermissionsEditor.vue', () => { ) }) - test('Dispatches setPermissions with the correct permissions value when a permission is added', async () => { + test('Dispatches setPermissions with the correct permissions value when a permission is substracted', async () => { const wrapper = mountParticipantPermissionsEditor(participant) // Remove a permission - wrapper.findComponent(PermissionsEditor).setData({ publishAudio: false }) + await wrapper.findComponent(PermissionsEditor).setData({ publishAudio: false }) // Click the submit button await wrapper.findComponent(PermissionsEditor).find({ ref: 'submit' }).trigger('click')