Skip to content

Commit 6e2e826

Browse files
authored
fix(ooo): make show note publicly consistent across all booking views (calcom#25827)
- Update weekly view to display OOO when showNotePublicly is true - Update column view to include days with public notes in schedule - Add notes and showNotePublicly props to weekly view calendar - Disable show note publicly checkbox when notes field is empty
1 parent 84a4dd4 commit 6e2e826

4 files changed

Lines changed: 20 additions & 4 deletions

File tree

packages/features/calendars/weeklyview/components/event/Empty.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export function AvailableCellsForDay({ timezone, availableSlots, day, startHour
7878
const lastSlot = slotsForToday[lastSlotIndex];
7979
startEndTimeDuration = dayjs(lastSlot.end).diff(dayjs(firstSlot.start), "minutes");
8080

81-
if (firstSlot.toUser == null) {
81+
if (firstSlot.toUser == null && !firstSlot.showNotePublicly) {
8282
return null;
8383
}
8484

@@ -108,6 +108,8 @@ export function AvailableCellsForDay({ timezone, availableSlots, day, startHour
108108
toUser={firstSlot?.toUser}
109109
reason={firstSlot?.reason}
110110
emoji={firstSlot?.emoji}
111+
notes={firstSlot?.notes}
112+
showNotePublicly={firstSlot?.showNotePublicly}
111113
borderDashed={false}
112114
date={dateFormatted}
113115
className="pb-0"

packages/features/calendars/weeklyview/types/state.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ type TimeRangeExtended = TimeRange & {
5858
toUser?: IToUser;
5959
reason?: string;
6060
emoji?: string;
61+
notes?: string | null;
62+
showNotePublicly?: boolean;
6163
};
6264

6365
export type CalendarAvailableTimeslots = {

packages/features/schedules/lib/use-schedule/useNonEmptyScheduleDays.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export const getNonEmptyScheduleDays = (slots?: Slots) => {
88
const nonEmptyDays: string[] = [];
99

1010
Object.keys(slots).forEach((date) => {
11-
if (slots[date].some((slot) => !(slot?.away && !slot.toUser) && slots[date].length > 0)) {
11+
if (slots[date].some((slot) => !(slot?.away && !slot.toUser && !slot.showNotePublicly) && slots[date].length > 0)) {
1212
nonEmptyDays.push(date);
1313
}
1414
});

packages/features/settings/outOfOffice/CreateOrEditOutOfOfficeModal.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ export const CreateOrEditOutOfOfficeEntryModal = ({
162162

163163
const watchedTeamUserId = watch("toTeamUserId");
164164
const watchForUserId = watch("forUserId");
165+
const watchedNotes = watch("notes");
166+
const hasValidNotes = Boolean(watchedNotes?.trim());
165167

166168
const createOrEditOutOfOfficeEntry = trpc.viewer.ooo.outOfOfficeCreateOrUpdate.useMutation({
167169
onSuccess: () => {
@@ -345,7 +347,11 @@ export const CreateOrEditOutOfOfficeEntryModal = ({
345347
placeholder={t("additional_notes")}
346348
{...register("notes")}
347349
onChange={(e) => {
348-
setValue("notes", e?.target.value);
350+
const newNotes = e?.target.value;
351+
setValue("notes", newNotes);
352+
if (!newNotes?.trim()) {
353+
setValue("showNotePublicly", false);
354+
}
349355
}}
350356
/>
351357
<Controller
@@ -358,8 +364,14 @@ export const CreateOrEditOutOfOfficeEntryModal = ({
358364
data-testid="show-note-publicly-checkbox"
359365
checked={value ?? false}
360366
onCheckedChange={onChange}
367+
disabled={!hasValidNotes}
361368
/>
362-
<label htmlFor="show-note-publicly" className="text-emphasis ml-2 cursor-pointer text-sm">
369+
<label
370+
htmlFor="show-note-publicly"
371+
className={classNames(
372+
"ml-2 text-sm",
373+
hasValidNotes ? "text-emphasis cursor-pointer" : "text-muted cursor-not-allowed"
374+
)}>
363375
{t("show_note_publicly_description")}
364376
</label>
365377
</div>

0 commit comments

Comments
 (0)