ISSUE-836 Duplicate: carry over source calendar if writable (#837)
This commit is contained in:
@@ -44,6 +44,21 @@ import { buildDelegatedEventURL } from './utils/buildDelegatedEventURL'
|
|||||||
import { Resource } from '@/components/Attendees/ResourceSearch'
|
import { Resource } from '@/components/Attendees/ResourceSearch'
|
||||||
import { EventActions } from './EventActions'
|
import { EventActions } from './EventActions'
|
||||||
|
|
||||||
|
function resolveSourceCalendarId(
|
||||||
|
calId: string | undefined,
|
||||||
|
calList: Record<string, Calendar>,
|
||||||
|
userId: string,
|
||||||
|
defaultCalendarId: string
|
||||||
|
): string {
|
||||||
|
if (!calId) return defaultCalendarId
|
||||||
|
const sourceCalendar = calList[calId]
|
||||||
|
if (!sourceCalendar) return defaultCalendarId
|
||||||
|
const isWritable =
|
||||||
|
sourceCalendar.id?.split('/')[0] === userId ||
|
||||||
|
(sourceCalendar.delegated && sourceCalendar.access?.write)
|
||||||
|
return isWritable ? calId : defaultCalendarId
|
||||||
|
}
|
||||||
|
|
||||||
function EventPopover({
|
function EventPopover({
|
||||||
open,
|
open,
|
||||||
onClose,
|
onClose,
|
||||||
@@ -475,9 +490,9 @@ function EventPopover({
|
|||||||
setEnd('')
|
setEnd('')
|
||||||
}
|
}
|
||||||
|
|
||||||
if (defaultCalendarId) {
|
setCalendarid(
|
||||||
setCalendarid(defaultCalendarId)
|
resolveSourceCalendarId(event.calId, calList, userId, defaultCalendarId)
|
||||||
}
|
)
|
||||||
setRepetition(event.repetition ?? ({} as RepetitionObject))
|
setRepetition(event.repetition ?? ({} as RepetitionObject))
|
||||||
setShowRepeat(event.repetition?.freq ? true : false)
|
setShowRepeat(event.repetition?.freq ? true : false)
|
||||||
setAttendees(
|
setAttendees(
|
||||||
@@ -519,6 +534,8 @@ function EventPopover({
|
|||||||
organizer?.cal_address,
|
organizer?.cal_address,
|
||||||
resolvedCalendarTimezone,
|
resolvedCalendarTimezone,
|
||||||
defaultCalendarId,
|
defaultCalendarId,
|
||||||
|
calList,
|
||||||
|
userId,
|
||||||
resources,
|
resources,
|
||||||
eventAttendees
|
eventAttendees
|
||||||
])
|
])
|
||||||
|
|||||||
Reference in New Issue
Block a user