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 <gretadoci@gmail.com>
  • Loading branch information
GretaD committed Sep 6, 2023
1 parent a371db2 commit 127d2d9
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
14 changes: 11 additions & 3 deletions src/components/Editor/Invitees/InviteesList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@

<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"
Expand Down Expand Up @@ -101,6 +101,10 @@ export default {
type: Object,
required: true,
},
isSharedWithMe: {
type: Boolean,
required: true,
},

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#L105-L107

Added lines #L105 - L107 were not covered by tests
},
data() {
return {
Expand All @@ -115,6 +119,9 @@ export default {
noInviteesMessage() {
return this.$t('calendar', 'No attendees yet')
},
noOwnerMessage() {
return this.$t('calendar', 'You dont own this calendar, so you cannot invite other people')

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

View check run for this annotation

Codecov / codecov/patch

src/components/Editor/Invitees/InviteesList.vue#L122-L123

Added lines #L122 - L123 were not covered by tests
},
invitees() {
return this.calendarObjectInstance.attendees.filter(attendee => {
return !['RESOURCE', 'ROOM'].includes(attendee.attendeeProperty.userType)
Expand All @@ -136,6 +143,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 127d2d9

Please sign in to comment.