From bf7c86ffe5646a3cef1f868af73ef2a359cdb3b0 Mon Sep 17 00:00:00 2001 From: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com> Date: Wed, 13 Jul 2022 20:16:24 -0400 Subject: [PATCH] Fix Caldav not valid destination calendar and only display calendars that user can edit (#3326) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Default readOnly to false * Display only calendars users can edit * Remove console.log * Remove console.log Co-authored-by: Omar López Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- apps/web/components/DestinationCalendarSelector.tsx | 10 ++++++---- packages/core/CalendarManager.ts | 1 + 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/apps/web/components/DestinationCalendarSelector.tsx b/apps/web/components/DestinationCalendarSelector.tsx index 96f28b1f6d..25f4a7f5ac 100644 --- a/apps/web/components/DestinationCalendarSelector.tsx +++ b/apps/web/components/DestinationCalendarSelector.tsx @@ -61,10 +61,12 @@ const DestinationCalendarSelector = ({ query.data.connectedCalendars.map((selectedCalendar) => ({ key: selectedCalendar.credentialId, label: `${selectedCalendar.integration.title} (${selectedCalendar.primary?.name})`, - options: (selectedCalendar.calendars ?? []).map((cal) => ({ - label: cal.name || "", - value: `${cal.integration}:${cal.externalId}`, - })), + options: (selectedCalendar.calendars ?? []) + .filter((cal) => cal.readOnly === false) + .map((cal) => ({ + label: cal.name || "", + value: `${cal.integration}:${cal.externalId}`, + })), })) ?? []; return (
diff --git a/packages/core/CalendarManager.ts b/packages/core/CalendarManager.ts index eb7f7c2137..a4192f1295 100644 --- a/packages/core/CalendarManager.ts +++ b/packages/core/CalendarManager.ts @@ -44,6 +44,7 @@ export const getConnectedCalendars = async ( const calendars = _(cals) .map((cal) => ({ ...cal, + readOnly: cal.readOnly || false, primary: cal.primary || null, isSelected: selectedCalendars.some((selected) => selected.externalId === cal.externalId), credentialId,