Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shared calendars shouldn't allow adding attendees if the calendar is not yours #5457

Merged
merged 1 commit into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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 @@
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 @@
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 @@

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
Loading