Skip to content

Commit

Permalink
Shared calendars shouldn't allow adding attendees if the calendar is …
Browse files Browse the repository at this point in the history
…not yours

Signed-off-by: greta <[email protected]>
  • Loading branch information
GretaD committed Sep 7, 2023
1 parent a371db2 commit 8d2f0fb
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
16 changes: 13 additions & 3 deletions src/components/Editor/Invitees/InviteesList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,24 @@

<template>
<div>
<InviteesListSearch v-if="!isReadOnly && hasUserEmailAddress"
<InviteesListSearch v-if="!isReadOnly && !isSharedWithMe && hasUserEmailAddress"
:already-invited-emails="alreadyInvitedEmails"
@add-attendee="addAttendee" />
<OrganizerListItem v-if="hasOrganizer"
:is-read-only="isReadOnly"
:is-read-only="isReadOnly || isSharedWithMe"
:organizer="calendarObjectInstance.organizer" />
<InviteesListItem v-for="invitee in inviteesWithoutOrganizer"
:key="invitee.email"
:attendee="invitee"
:is-read-only="isReadOnly"
:is-read-only="isReadOnly || isSharedWithMe"
:organizer-display-name="organizerDisplayName"
@remove-attendee="removeAttendee" />
<NoAttendeesView v-if="isReadOnly && isListEmpty"
:message="noInviteesMessage" />
<NoAttendeesView v-if="!isReadOnly && isListEmpty && hasUserEmailAddress"
:message="noInviteesMessage" />
<NoAttendeesView v-if="isSharedWithMe"
:message="noOwnerMessage" />
<OrganizerNoEmailError v-if="!isReadOnly && isListEmpty && !hasUserEmailAddress" />

<div class="invitees-list-button-group">
Expand Down Expand Up @@ -101,6 +103,10 @@ export default {
type: Object,
required: true,
},
isSharedWithMe: {
type: Boolean,

Check warning on line 107 in src/components/Editor/Invitees/InviteesList.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Editor/Invitees/InviteesList.vue#L106-L107

Added lines #L106 - L107 were not covered by tests
required: true,
},

Check warning on line 109 in src/components/Editor/Invitees/InviteesList.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Editor/Invitees/InviteesList.vue#L109

Added line #L109 was not covered by tests
},
data() {
return {
Expand All @@ -115,6 +121,9 @@ export default {
noInviteesMessage() {
return this.$t('calendar', 'No attendees yet')
},
noOwnerMessage() {
return this.$t('calendar', 'You don\'t own this calendar, so you cannot add attendees to this event')
},

Check warning on line 126 in src/components/Editor/Invitees/InviteesList.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Editor/Invitees/InviteesList.vue#L125-L126

Added lines #L125 - L126 were not covered by tests
invitees() {
return this.calendarObjectInstance.attendees.filter(attendee => {
return !['RESOURCE', 'ROOM'].includes(attendee.attendeeProperty.userType)
Expand All @@ -136,6 +145,7 @@ export default {
hasOrganizer() {
return this.calendarObjectInstance.organizer !== null
},
organizerDisplayName() {
return organizerDisplayName(this.calendarObjectInstance.organizer)
},
Expand Down
12 changes: 12 additions & 0 deletions src/mixins/EditorMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,18 @@ export default {

return calendar.readOnly
},
isSharedWithMe() {
if (!this.calendarObject) {
return true

Check warning on line 219 in src/mixins/EditorMixin.js

View check run for this annotation

Codecov / codecov/patch

src/mixins/EditorMixin.js#L217-L219

Added lines #L217 - L219 were not covered by tests
}

const calendar = this.$store.getters.getCalendarById(this.calendarObject.calendarId)
if (!calendar) {
return true

Check warning on line 224 in src/mixins/EditorMixin.js

View check run for this annotation

Codecov / codecov/patch

src/mixins/EditorMixin.js#L222-L224

Added lines #L222 - L224 were not covered by tests
}

return calendar.isSharedWithMe

Check warning on line 227 in src/mixins/EditorMixin.js

View check run for this annotation

Codecov / codecov/patch

src/mixins/EditorMixin.js#L227

Added line #L227 was not covered by tests
},
/**
* Returns whether the user is an attendee of the event
*
Expand Down
3 changes: 2 additions & 1 deletion src/views/EditSidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,8 @@
<div class="app-sidebar-tab__content">
<InviteesList v-if="!isLoading"
:calendar-object-instance="calendarObjectInstance"
:is-read-only="isReadOnly" />
:is-read-only="isReadOnly"
:is-shared-with-me="isSharedWithMe" />
</div>
<SaveButtons v-if="showSaveButtons"
class="app-sidebar-tab__buttons"
Expand Down

0 comments on commit 8d2f0fb

Please sign in to comment.