feat: Add hideCalendarEventDetails option to event types (#16817)

* Add `hideCalendarEventDetails` to DB

Co-authored-by: Alex van Andel <[email protected]>

* Add option to hide calendar event details

* Pass `hideCalendarEventDetails` to event object

* Add to API

* Add to CalendarEvent class

* Pass `hideCalendarEventDetails` to calendar services

* Adjust test

* fix: move `hideCalendarEventDetails` to `api/v2/event-types_2024_06_14` and remove from older versions

- Added `hideCalendarEventDetails` to `api/v2/event-types_2024_06_14`
- Removed `hideCalendarEventDetails` from `api/v1` and `api/v2/event-types_2024_04_15`

* fix: calEventRaw is undefined (use event instead)

* chore: Remove debug artifact

* fix: description id + update to copy

* fix: Attempt at fixing type error

* Add hideCalendarEventDetails to test builder

---------

Co-authored-by: Alex van Andel <[email protected]>
Co-authored-by: Somay Chauhan <[email protected]>
Co-authored-by: Alex van Andel <[email protected]>
This commit is contained in:
authored and GitHub committed 2024-09-26 17:08:25 +00:00
1 parent b6c6e41603
commit ae7fae7da4
29 files changed
+93 -5

No files matched your search

@@ -256,6 +256,9 @@ export default class GoogleCalendarService implements Calendar {
: true,
iCalUID: formattedCalEvent.iCalUID,
};
if (calEventRaw.hideCalendarEventDetails) {
payload.visibility = "private";
}
if (formattedCalEvent.location) {
payload["location"] = getLocation(formattedCalEvent);
@@ -1,4 +1,4 @@
import type { Calendar as OfficeCalendar, User } from "@microsoft/microsoft-graph-types-beta";
import type { Calendar as OfficeCalendar, User, Event } from "@microsoft/microsoft-graph-types-beta";
import type { DefaultBodyType } from "msw";
import dayjs from "@calcom/dayjs";
@@ -266,7 +266,7 @@ export default class Office365CalendarService implements Calendar {
}
private translateEvent = (event: CalendarEvent) => {
return {
const office365Event: Event = {
subject: event.title,
body: {
contentType: "text",
@@ -280,6 +280,7 @@ export default class Office365CalendarService implements Calendar {
dateTime: dayjs(event.endTime).tz(event.organizer.timeZone).format("YYYY-MM-DDTHH:mm:ss"),
timeZone: event.organizer.timeZone,
},
hideAttendees: !event.seatsPerTimeSlot ? false : !event.seatsShowAttendees,
organizer: {
emailAddress: {
address: event.destinationCalendar
@@ -295,7 +296,7 @@ export default class Office365CalendarService implements Calendar {
address: attendee.email,
name: attendee.name,
},
type: "required",
type: "required" as const,
})),
...(event.team?.members
? event.team?.members
@@ -309,13 +310,17 @@ export default class Office365CalendarService implements Calendar {
address: destinationCalendar?.externalId ?? member.email,
name: member.name,
},
type: "required",
type: "required" as const,
};
})
: []),
],
location: event.location ? { displayName: getLocation(event) } : undefined,
};
if (event.hideCalendarEventDetails) {
office365Event.sensitivity = "private";
}
return office365Event;
};
private fetcher = async (endpoint: string, init?: RequestInit | undefined) => {
@@ -146,6 +146,7 @@ export class CalendarEventBuilder implements ICalendarEventBuilder {
metadata: true,
destinationCalendar: true,
hideCalendarNotes: true,
hideCalendarEventDetails: true,
},
});
} catch (error) {
@@ -206,6 +207,12 @@ export class CalendarEventBuilder implements ICalendarEventBuilder {
this.calendarEvent.hideCalendarNotes = hideCalendarNotes;
}
public setHideCalendarEventDetails(
hideCalendarEventDetails: CalendarEventClass["hideCalendarEventDetails"]
) {
this.calendarEvent.hideCalendarEventDetails = hideCalendarEventDetails;
}
public setDescription(description: CalendarEventClass["description"]) {
this.calendarEvent.description = description;
}
@@ -30,6 +30,7 @@ class CalendarEventClass implements CalendarEvent {
cancellationReason?: string | null;
rejectionReason?: string | null;
hideCalendarNotes?: boolean;
hideCalendarEventDetails?: boolean;
additionalNotes?: string | null | undefined;
recurrence?: string;
iCalUID?: string | null;
+1
View File
@@ -101,6 +101,7 @@ const generateIcsString = ({
location: location ?? undefined,
method: "REQUEST",
status,
...(event.hideCalendarEventDetails ? { classification: "PRIVATE" } : {}),
});
if (icsEvent.error) {
throw icsEvent.error;
@@ -898,6 +898,7 @@ async function handler(
conferenceCredentialId,
destinationCalendar,
hideCalendarNotes: eventType.hideCalendarNotes,
hideCalendarEventDetails: eventType.hideCalendarEventDetails,
requiresConfirmation: !isConfirmedByDefault,
eventTypeId: eventType.id,
// if seats are not enabled we should default true
@@ -59,6 +59,7 @@ export const getEventTypesFromDB = async (eventTypeId: number) => {
metadata: true,
destinationCalendar: true,
hideCalendarNotes: true,
hideCalendarEventDetails: true,
seatsPerTimeSlot: true,
recurringEvent: true,
seatsShowAttendees: true,
@@ -138,6 +138,7 @@ export const EventAdvancedTab = ({ eventType, team }: Pick<EventTypeSetupProps,
const seatsLocked = shouldLockDisableProps("seatsPerTimeSlotEnabled");
const requiresBookerEmailVerificationProps = shouldLockDisableProps("requiresBookerEmailVerification");
const hideCalendarNotesLocked = shouldLockDisableProps("hideCalendarNotes");
const hideCalendarEventDetailsLocked = shouldLockDisableProps("hideCalendarEventDetails");
const eventTypeColorLocked = shouldLockDisableProps("eventTypeColor");
const lockTimeZoneToggleOnBookingPageLocked = shouldLockDisableProps("lockTimeZoneToggleOnBookingPage");
@@ -323,6 +324,21 @@ export const EventAdvancedTab = ({ eventType, team }: Pick<EventTypeSetupProps,
/>
)}
/>
<Controller
name="hideCalendarEventDetails"
render={({ field: { value, onChange } }) => (
<SettingsToggle
labelClassName="text-sm"
toggleSwitchAtTheEnd={true}
switchContainerClassName="border-subtle rounded-lg border py-6 px-4 sm:px-6"
title={t("hide_calendar_event_details")}
{...hideCalendarEventDetailsLocked}
description={t("description_hide_calendar_event_details")}
checked={value}
onCheckedChange={(e) => onChange(e)}
/>
)}
/>
<Controller
name="successRedirectUrl"
render={({ field: { value, onChange } }) => (
+1
View File
@@ -162,6 +162,7 @@ export default abstract class BaseCalendarService implements Calendar {
* [UPDATE]: Since we're not using the PUBLISH method to publish the iCalendar event and creating the event directly on iCal,
* this shouldn't be an issue and we should be able to add attendees to the event right here.
*/
...(event.hideCalendarEventDetails ? { classification: "PRIVATE" } : {}),
});
if (error || !iCalString)
+1
View File
@@ -85,6 +85,7 @@ const commons = {
onlyShowFirstAvailableSlot: false,
id: 0,
hideCalendarNotes: false,
hideCalendarEventDetails: false,
recurringEvent: null,
destinationCalendar: null,
team: null,
+1
View File
@@ -55,4 +55,5 @@ export const eventTypeSelect = Prisma.validator<Prisma.EventTypeSelect>()({
bookingLimits: true,
durationLimits: true,
eventTypeColor: true,
hideCalendarEventDetails: true,
});
@@ -447,6 +447,7 @@ export class EventTypeRepository {
requiresBookerEmailVerification: true,
recurringEvent: true,
hideCalendarNotes: true,
hideCalendarEventDetails: true,
disableGuests: true,
minimumBookingNotice: true,
beforeEventBuffer: true,
+1
View File
@@ -109,6 +109,7 @@ export const buildEventType = (eventType?: Partial<EventType>): EventType => {
requiresConfirmationWillBlockSlot: false,
disableGuests: false,
hideCalendarNotes: false,
hideCalendarEventDetails: false,
minimumBookingNotice: 120,
beforeEventBuffer: 0,
afterEventBuffer: 0,
@@ -79,6 +79,7 @@ export const useEventTypeForm = ({
endDate: periodDates.endDate,
},
hideCalendarNotes: eventType.hideCalendarNotes,
hideCalendarEventDetails: eventType.hideCalendarEventDetails,
offsetStart: eventType.offsetStart,
bookingFields: eventType.bookingFields,
periodType: eventType.periodType,
@@ -290,6 +290,10 @@ export class CreateEventTypeInput_2024_06_14 {
@IsOptional()
@IsBoolean()
useDestinationCalendarEmail?: boolean;
@IsOptional()
@IsBoolean()
hideCalendarEventDetails?: boolean;
}
export enum HostPriority {
@@ -282,6 +282,10 @@ export class UpdateEventTypeInput_2024_06_14 {
@IsOptional()
@IsBoolean()
useDestinationCalendarEmail?: boolean;
@IsOptional()
@IsBoolean()
hideCalendarEventDetails?: boolean;
}
@ApiExtraModels(
@@ -333,6 +333,11 @@ class BaseEventTypeOutput_2024_06_14 {
@IsBoolean()
@DocsProperty()
useDestinationCalendarEmail?: boolean;
@IsOptional()
@IsBoolean()
@DocsProperty()
hideCalendarEventDetails?: boolean;
}
export class TeamEventTypeResponseHost extends TeamEventTypeHostInput {
@@ -385,4 +390,9 @@ export class TeamEventTypeOutput_2024_06_14 extends BaseEventTypeOutput_2024_06_
@IsEnum(SchedulingTypeEnum)
@DocsProperty({ enum: SchedulingTypeEnum })
schedulingType!: EventTypesOutputSchedulingType | null;
@IsOptional()
@IsBoolean()
@DocsProperty()
hideCalendarEventDetails?: boolean;
}
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "EventType" ADD COLUMN "hideCalendarEventDetails" BOOLEAN NOT NULL DEFAULT false;
+1
View File
@@ -110,6 +110,7 @@ model EventType {
recurringEvent Json?
disableGuests Boolean @default(false)
hideCalendarNotes Boolean @default(false)
hideCalendarEventDetails Boolean @default(false)
/// @zod.min(0)
minimumBookingNotice Int @default(120)
beforeEventBuffer Int @default(0)
+1
View File
@@ -648,6 +648,7 @@ export const allManagedEventTypeProps: { [k in keyof Omit<Prisma.EventTypeSelect
metadata: true,
children: true,
hideCalendarNotes: true,
hideCalendarEventDetails: true,
minimumBookingNotice: true,
beforeEventBuffer: true,
afterEventBuffer: true,
+1
View File
@@ -189,6 +189,7 @@ export interface CalendarEvent {
cancellationReason?: string | null;
rejectionReason?: string | null;
hideCalendarNotes?: boolean;
hideCalendarEventDetails?: boolean;
recurrence?: string;
recurringEvent?: RecurringEvent | null;
eventTypeId?: number | null;