Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix(calendar): offer guest emails and notices only when others are invited (#8633)

gbirman6a6bbda1b8f4
diff --git a/apps/web/src/features/calendar-view/components/EventGuests.test.tsx b/apps/web/src/features/calendar-view/components/EventGuests.test.tsx
index f5db19c391..eb7645f4bf 100644
--- a/apps/web/src/features/calendar-view/components/EventGuests.test.tsx
+++ b/apps/web/src/features/calendar-view/components/EventGuests.test.tsx
@@ -364,6 +364,21 @@ describe('adding guests from event details', () => {
expect(mocks.success).not.toHaveBeenCalled();
});
+ it('offers no guest addresses to copy or email when the viewer is the only guest', () => {
+ renderGuests(
+ event({
+ isSnapshot: true,
+ viewerCan: { ...MAY_INVITE, inviteGuests: false, rsvp: false },
+ attendees: [attendee({ email: '[email protected]', isSelf: true })],
+ })
+ );
+
+ expect(
+ screen.queryByRole('button', { name: 'Copy guest emails' })
+ ).toBeNull();
+ expect(screen.queryByRole('button', { name: 'Email guests' })).toBeNull();
+ });
+
it('keeps today’s guest actions while guest invites are off', () => {
renderGuests(event(), false);
diff --git a/apps/web/src/features/calendar-view/components/EventGuests.tsx b/apps/web/src/features/calendar-view/components/EventGuests.tsx
index 1c3e231173..80cd2b4838 100644
--- a/apps/web/src/features/calendar-view/components/EventGuests.tsx
+++ b/apps/web/src/features/calendar-view/components/EventGuests.tsx
@@ -224,10 +224,10 @@ function EventInviteGuestsAction(props: {
/**
* The guest-row actions Google Calendar users know: copy every guest's
- * address, start an email to the other guests (hidden when the viewer is the
- * only one), or add guests when the organizer allows it. Emailing closes the
- * details first: closing hands focus back to the calendar chip, and the
- * composer's To field has to win that exchange.
+ * address and start an email to the other guests (both hidden when the
+ * viewer is the only one, as on a snapshot), or add guests when the organizer
+ * allows it. Emailing closes the details first: closing hands focus back to
+ * the calendar chip, and the composer's To field has to win that exchange.
*/
function EventGuestActions(props: {
event: CalendarEvent;
@@ -238,17 +238,17 @@ function EventGuestActions(props: {
return (
<Show when={!props.event.teamProjection}>
- <Button
- label="Copy guest emails"
- variant="ghost"
- size="icon-sm"
- depth={3}
- class="text-ink-muted [&_svg]:size-4"
- onClick={() => copyGuestEmails(guestEmails(props.event.attendees))}
- >
- <CopyIcon />
- </Button>
<Show when={eventEmailRecipients(props.event).length > 0}>
+ <Button
+ label="Copy guest emails"
+ variant="ghost"
+ size="icon-sm"
+ depth={3}
+ class="text-ink-muted [&_svg]:size-4"
+ onClick={() => copyGuestEmails(guestEmails(props.event.attendees))}
+ >
+ <CopyIcon />
+ </Button>
<Button
label="Email guests"
variant="ghost"
diff --git a/apps/web/src/features/calendar-view/components/SelectedEventDetails.test.tsx b/apps/web/src/features/calendar-view/components/SelectedEventDetails.test.tsx
index d10d18a93e..cd460fe0f4 100644
--- a/apps/web/src/features/calendar-view/components/SelectedEventDetails.test.tsx
+++ b/apps/web/src/features/calendar-view/components/SelectedEventDetails.test.tsx
@@ -182,6 +182,19 @@ describe.each([
});
});
+ it('promises no notifications when deleting an event nobody else is on', async () => {
+ const user = userEvent.setup();
+ showDetails(event({ viewerCan: { ...NO_CAPABILITIES, organize: true } }));
+
+ await user.click(
+ await screen.findByRole('button', { name: 'Delete event' })
+ );
+ expect(
+ await screen.findByText('Delete “Projects discussion”?')
+ ).toBeTruthy();
+ expect(screen.queryByText(/Guests will be notified/)).toBeNull();
+ });
+
it('keeps Edit for a guest the organizer does not let modify', async () => {
showDetails(event({ viewerCan: { ...NO_CAPABILITIES, rsvp: true } }));
diff --git a/apps/web/src/features/calendar-view/components/SelectedEventDetails.tsx b/apps/web/src/features/calendar-view/components/SelectedEventDetails.tsx
index 755c02f93a..4abc627905 100644
--- a/apps/web/src/features/calendar-view/components/SelectedEventDetails.tsx
+++ b/apps/web/src/features/calendar-view/components/SelectedEventDetails.tsx
@@ -11,6 +11,7 @@ import {
canDeleteCalendarEvent,
canEditCalendarEvent,
} from '@app/features/calendar/utils/event-interaction';
+import { eventEmailRecipients } from '@app/features/calendar/utils/guest-emails';
import { handleOpenEventOutsidePress } from '@app/features/calendar/utils/open-event-outside-press';
import { TeamEventDetails } from '@app/features/calendar-team/components/team-event-details';
import { EventGuests } from '@app/features/calendar-view/components/EventGuests';
@@ -401,10 +402,15 @@ function DeleteEventDialog(
};
const title = () => props.event.title || 'Untitled event';
- const prompt = () =>
- props.event.isSnapshot
- ? `Delete your copy of “${title()}”? The shared event stays as it is.`
- : `${isRecurring() ? 'Remove' : 'Delete'} “${title()}”? Guests will be notified.`;
+ const prompt = () => {
+ if (props.event.isSnapshot) {
+ return `Delete your copy of “${title()}”? The shared event stays as it is.`;
+ }
+ const question = `${isRecurring() ? 'Remove' : 'Delete'} “${title()}”?`;
+ return eventEmailRecipients(props.event).length > 0
+ ? `${question} Guests will be notified.`
+ : question;
+ };
return (
<DeleteDialog
diff --git a/docs/agent-guide/calendar.md b/docs/agent-guide/calendar.md
index 9aed0f8020..e8927a8f5a 100644
--- a/docs/agent-guide/calendar.md
+++ b/docs/agent-guide/calendar.md
@@ -445,11 +445,12 @@ Test reminder removal as well as changing its time, including a series whose sto
rule contains `INTERVAL=1`, `WKST`, differently ordered weekdays, or a precise `UNTIL`:
an untouched rule must not be reformatted and included in a reminder-only PATCH.
As in Google Calendar, the guests row of the details popover (a bottom sheet on phones)
-carries `Copy guest emails` and `Email guests` icon buttons. Copying puts every guest's
-address on the clipboard, comma-separated. Emailing opens a new email addressed to every
-guest but you — in a split beside the calendar on desktop, as the full-screen composer on
-touch devices, in its own composer even when another one is open — and is hidden when you
-are the only guest.
+carries `Copy guest emails` and `Email guests` icon buttons, both hidden when you are the
+only guest (always so on a snapshot). Copying puts every guest's address on the clipboard,
+comma-separated. Emailing opens a new email addressed to every guest but you — in a split
+beside the calendar on desktop, as the full-screen composer on touch devices, in its own
+composer even when another one is open. Deleting an event asks first, and says guests will be
+notified only when someone besides you is on it.
With the `enable-calendar-guest-invites` flag on, a third icon button, `Add guests`, shows
whenever the event's `viewerCan.inviteGuests` allows it, including for a guest whose
organizer lets guests invite. It opens an editor anchored to the button (a bottom sheet on