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): dim the locked all-day switch and explain the read-only repeats pill (#8676)

gbirman2b4278761d98
diff --git a/apps/web/src/components/ui/components/ToggleSwitch.docs.tsx b/apps/web/src/components/ui/components/ToggleSwitch.docs.tsx
index 8ecec85fee..5e2449b91a 100644
--- a/apps/web/src/components/ui/components/ToggleSwitch.docs.tsx
+++ b/apps/web/src/components/ui/components/ToggleSwitch.docs.tsx
@@ -39,6 +39,22 @@ function SizesDemo() {
}
// #endregion
+// #region demo:disabled
+function DisabledDemo() {
+ return (
+ <div class="flex flex-wrap items-center gap-6">
+ <ToggleSwitch disabled label="Off" labelClass="text-sm text-ink" />
+ <ToggleSwitch
+ disabled
+ defaultChecked
+ label="On"
+ labelClass="text-sm text-ink"
+ />
+ </div>
+ );
+}
+// #endregion
+
// #region demo:settings-row
function SettingsRowDemo() {
const rows = [
@@ -95,6 +111,13 @@ export default defineDoc({
'`sm` is the default toolbar size; `md` is for settings rows; `xs` is for dense inline chrome.',
render: SizesDemo,
},
+ {
+ id: 'disabled',
+ title: 'Disabled',
+ description:
+ 'A disabled switch dims, label included, and ignores clicks, like a disabled Checkbox.',
+ render: DisabledDemo,
+ },
{
id: 'settings-row',
title: 'Settings row',
diff --git a/apps/web/src/components/ui/components/ToggleSwitch.tsx b/apps/web/src/components/ui/components/ToggleSwitch.tsx
index 1271969d06..694bfd6031 100644
--- a/apps/web/src/components/ui/components/ToggleSwitch.tsx
+++ b/apps/web/src/components/ui/components/ToggleSwitch.tsx
@@ -91,7 +91,10 @@ export const ToggleSwitch = (props: ToggleSwitchProps): JSX.Element => {
return (
<KobalteSwitch
- class={cn('relative inline-flex items-center gap-2', local.class)}
+ class={cn(
+ 'relative inline-flex items-center gap-2 data-disabled:cursor-not-allowed data-disabled:opacity-50',
+ local.class
+ )}
defaultChecked={local.defaultChecked}
onChange={handleChange}
disabled={local.disabled}
diff --git a/apps/web/src/features/calendar/components/composer/EventForm.test.tsx b/apps/web/src/features/calendar/components/composer/EventForm.test.tsx
index 60e780977d..6db4b62db3 100644
--- a/apps/web/src/features/calendar/components/composer/EventForm.test.tsx
+++ b/apps/web/src/features/calendar/components/composer/EventForm.test.tsx
@@ -199,6 +199,22 @@ it('offers no guest permissions without the organizer’s rights', () => {
expect(screen.queryByRole('group', { name: 'Guest permissions' })).toBeNull();
});
+it('describes the read-only repeat rule while an edit targets one occurrence', async () => {
+ const user = userEvent.setup();
+ showForm({ isEdit: true, showRecurringEditNotice: true });
+ const repeats = screen.getByLabelText('Repeats');
+ expect(repeats.getAttribute('aria-describedby')).toBeNull();
+
+ await user.click(screen.getByRole('radio', { name: 'This event' }));
+ expect(repeats.getAttribute('aria-readonly')).toBe('true');
+ const reasonId = repeats.getAttribute('aria-describedby');
+ expect(reasonId && document.getElementById(reasonId)).toBeTruthy();
+
+ await user.click(screen.getByRole('radio', { name: 'All events' }));
+ expect(repeats.getAttribute('aria-describedby')).toBeNull();
+ expect(reasonId && document.getElementById(reasonId)).toBeNull();
+});
+
it('returns guest permissions to the stored ones when an edit targets one occurrence', async () => {
const user = userEvent.setup();
showForm({
diff --git a/apps/web/src/features/calendar/components/composer/EventForm.tsx b/apps/web/src/features/calendar/components/composer/EventForm.tsx
index e232e89844..a96691453b 100644
--- a/apps/web/src/features/calendar/components/composer/EventForm.tsx
+++ b/apps/web/src/features/calendar/components/composer/EventForm.tsx
@@ -98,6 +98,7 @@ export function EventForm(props: EventFormProps) {
const resolveAppLink = useMacroMentionLinkResolver();
const dateRangeErrorId = `event-composer-date-range-error-${formId}`;
+ const recurrenceReasonId = `event-composer-recurrence-reason-${formId}`;
const pastEventWarningId = `event-composer-past-event-warning-${formId}`;
const controller = props.controller;
@@ -128,6 +129,15 @@ export function EventForm(props: EventFormProps) {
const fieldIsDisabled = (field: keyof EventEditorDisabledFields) =>
formIsDisabled() || fieldIsReadOnly(field);
const detailsLocked = () => props.detailsReadOnlyReason !== undefined;
+ // A single occurrence has no repeat rule of its own; like the guest
+ // permissions, the rule belongs to the whole series. A lock already says
+ // why the rule cannot change.
+ const recurrenceScopeReason = () =>
+ editScope() === 'this_event' && !detailsLocked()
+ ? 'The repeat rule applies to all events. Choose All events to change it.'
+ : undefined;
+ const recurrenceDescribedBy = () =>
+ recurrenceScopeReason() ? recurrenceReasonId : undefined;
const capabilities = () => controller.selectedCalendarOption()?.capabilities;
const conferenceLocked = () =>
@@ -292,121 +302,135 @@ export function EventForm(props: EventFormProps) {
</Show>
</div>
- <div class="flex min-w-0 flex-wrap items-center gap-2">
- {/* Read-only on every edit, they open their one value as a list;
- locked, they are as unavailable as the other details. */}
- <LockedField reason={props.detailsReadOnlyReason}>
- <EventComposerKindPill
- eventType={state().eventType}
- onChange={controller.setEventKind}
- disabled={formIsDisabled() || detailsLocked()}
- readOnly={isEdit()}
- />
- </LockedField>
- <LockedField reason={props.detailsReadOnlyReason}>
- <EventComposerCalendarPill
- options={controller.calendarOptions()}
- value={controller.selectedCalendarOption()}
- onChange={(calendarId) =>
- controller.setField('calendarId', calendarId)
- }
- disabled={formIsDisabled() || detailsLocked()}
- readOnly={fieldIsReadOnly('calendar')}
- />
- </LockedField>
- <LockedField reason={props.detailsReadOnlyReason}>
- <EventComposerRecurrencePill
- options={controller.recurrenceOptions()}
- value={controller.selectedRecurrenceOption()}
- onChange={controller.changeRecurrenceChoice}
- disabled={fieldIsDisabled('recurrence')}
- // A single occurrence has no recurrence rule of its own, so the
- // recurrence cannot be edited while the scope is one event.
- readOnly={editScope() === 'this_event'}
- />
- </LockedField>
- <Show when={!isOutOfOffice()}>
- <EventComposerGuestsPill
- options={controller.guestOptions}
- selected={controller.selectedGuests()}
- onChange={controller.setSelectedGuests}
- disabled={formIsDisabled()}
- readOnly={fieldIsReadOnly('guests')}
- readOnlyReason={props.guestsReadOnlyReason}
- guestListHidden={props.guestListHidden}
- currentGuests={
- props.addOnlyGuests ? controller.initialGuests() : undefined
- }
- />
+ <div class="flex min-w-0 flex-col gap-2">
+ <div class="flex min-w-0 flex-wrap items-center gap-2">
+ {/* Read-only on every edit, they open their one value as a list;
+ locked, they are as unavailable as the other details. */}
<LockedField reason={props.detailsReadOnlyReason}>
- <EventComposerConferencePill
- value={state().conference}
- provider={capabilities()?.conferenceProvider}
- macroCallsEnabled={props.macroCallsEnabled}
- canKeepExisting={
- controller.initialConferenceChoice() === 'existing'
- }
- onChange={(conference) =>
- controller.setField('conference', conference)
- }
- disabled={fieldIsDisabled('conference') || conferenceLocked()}
+ <EventComposerKindPill
+ eventType={state().eventType}
+ onChange={controller.setEventKind}
+ disabled={formIsDisabled() || detailsLocked()}
+ readOnly={isEdit()}
/>
</LockedField>
<LockedField reason={props.detailsReadOnlyReason}>
- <EventComposerLocationPill
- value={state().location}
- onChange={(location) =>
- controller.setField('location', location)
+ <EventComposerCalendarPill
+ options={controller.calendarOptions()}
+ value={controller.selectedCalendarOption()}
+ onChange={(calendarId) =>
+ controller.setField('calendarId', calendarId)
}
- disabled={fieldIsDisabled('location')}
+ disabled={formIsDisabled() || detailsLocked()}
+ readOnly={fieldIsReadOnly('calendar')}
/>
</LockedField>
- </Show>
- <Show when={isOutOfOffice()}>
- <Show
- when={capabilities()?.autoDecline !== false}
- fallback={
- <span class="text-xs text-ink-muted">
- Outlook blocks this time. Configure automatic declines in
- Outlook.
- </span>
- }
- >
- <EventComposerDeclinePill
- value={state().outOfOffice}
- onChange={controller.setOutOfOffice}
- disabled={fieldIsDisabled('outOfOffice')}
+ <LockedField reason={props.detailsReadOnlyReason}>
+ <EventComposerRecurrencePill
+ options={controller.recurrenceOptions()}
+ value={controller.selectedRecurrenceOption()}
+ onChange={controller.changeRecurrenceChoice}
+ disabled={fieldIsDisabled('recurrence')}
+ // A single occurrence has no recurrence rule of its own, so the
+ // recurrence cannot be edited while the scope is one event.
+ readOnly={editScope() === 'this_event'}
+ readOnlyReason={recurrenceScopeReason()}
+ describedBy={recurrenceDescribedBy()}
/>
- </Show>
- <Show
- when={
- state().outOfOffice &&
- state().outOfOffice?.autoDeclineMode !== 'decline_none'
- }
- >
- <EventComposerDeclineMessagePill
- value={state().outOfOffice?.declineMessage ?? ''}
- onChange={(declineMessage) =>
- controller.setOutOfOffice({
- autoDeclineMode:
- state().outOfOffice?.autoDeclineMode ?? 'decline_none',
- declineMessage,
- })
+ </LockedField>
+ <Show when={!isOutOfOffice()}>
+ <EventComposerGuestsPill
+ options={controller.guestOptions}
+ selected={controller.selectedGuests()}
+ onChange={controller.setSelectedGuests}
+ disabled={formIsDisabled()}
+ readOnly={fieldIsReadOnly('guests')}
+ readOnlyReason={props.guestsReadOnlyReason}
+ guestListHidden={props.guestListHidden}
+ currentGuests={
+ props.addOnlyGuests ? controller.initialGuests() : undefined
}
- disabled={fieldIsDisabled('outOfOffice')}
/>
+ <LockedField reason={props.detailsReadOnlyReason}>
+ <EventComposerConferencePill
+ value={state().conference}
+ provider={capabilities()?.conferenceProvider}
+ macroCallsEnabled={props.macroCallsEnabled}
+ canKeepExisting={
+ controller.initialConferenceChoice() === 'existing'
+ }
+ onChange={(conference) =>
+ controller.setField('conference', conference)
+ }
+ disabled={
+ fieldIsDisabled('conference') || conferenceLocked()
+ }
+ />
+ </LockedField>
+ <LockedField reason={props.detailsReadOnlyReason}>
+ <EventComposerLocationPill
+ value={state().location}
+ onChange={(location) =>
+ controller.setField('location', location)
+ }
+ disabled={fieldIsDisabled('location')}
+ />
+ </LockedField>
</Show>
+ <Show when={isOutOfOffice()}>
+ <Show
+ when={capabilities()?.autoDecline !== false}
+ fallback={
+ <span class="text-xs text-ink-muted">
+ Outlook blocks this time. Configure automatic declines in
+ Outlook.
+ </span>
+ }
+ >
+ <EventComposerDeclinePill
+ value={state().outOfOffice}
+ onChange={controller.setOutOfOffice}
+ disabled={fieldIsDisabled('outOfOffice')}
+ />
+ </Show>
+ <Show
+ when={
+ state().outOfOffice &&
+ state().outOfOffice?.autoDeclineMode !== 'decline_none'
+ }
+ >
+ <EventComposerDeclineMessagePill
+ value={state().outOfOffice?.declineMessage ?? ''}
+ onChange={(declineMessage) =>
+ controller.setOutOfOffice({
+ autoDeclineMode:
+ state().outOfOffice?.autoDeclineMode ??
+ 'decline_none',
+ declineMessage,
+ })
+ }
+ disabled={fieldIsDisabled('outOfOffice')}
+ />
+ </Show>
+ </Show>
+ <EventComposerRemindersPill
+ minutes={controller.reminderMinutes()}
+ usedSlots={
+ controller.reminderMinutes().length +
+ controller.preservedReminderCount()
+ }
+ canAdd={controller.canAddReminder()}
+ onChange={controller.setReminderMinutes}
+ disabled={fieldIsDisabled('reminders')}
+ />
+ </div>
+ <Show when={recurrenceScopeReason()}>
+ {(reason) => (
+ <p id={recurrenceReasonId} class="text-xs text-ink-muted">
+ {reason()}
+ </p>
+ )}
</Show>
- <EventComposerRemindersPill
- minutes={controller.reminderMinutes()}
- usedSlots={
- controller.reminderMinutes().length +
- controller.preservedReminderCount()
- }
- canAdd={controller.canAddReminder()}
- onChange={controller.setReminderMinutes}
- disabled={fieldIsDisabled('reminders')}
- />
</div>
{/* Outlook has no guest permissions, and an out-of-office event
diff --git a/apps/web/src/features/calendar/components/composer/EventPropertyPills.tsx b/apps/web/src/features/calendar/components/composer/EventPropertyPills.tsx
index 2a1dbbc9a6..c87d96bfca 100644
--- a/apps/web/src/features/calendar/components/composer/EventPropertyPills.tsx
+++ b/apps/web/src/features/calendar/components/composer/EventPropertyPills.tsx
@@ -585,6 +585,10 @@ export interface EventComposerRecurrencePillProps {
onChange: (value: string) => void;
disabled?: boolean;
readOnly?: boolean;
+ /** Why a read-only rule cannot change, shown as a tooltip. */
+ readOnlyReason?: string;
+ /** Id of the line that explains the pill, such as its read-only reason. */
+ describedBy?: string;
hideIcon?: boolean;
}
@@ -604,19 +608,27 @@ export function EventComposerRecurrencePill(
optionDisabled={() => props.readOnly === true}
disabled={props.disabled}
>
- <Select.Trigger
- aria-label="Repeats"
- aria-readonly={props.readOnly || undefined}
- class={cn(PROPERTY_TRIGGER_CLASS, 'max-w-48')}
+ {/* Always wrapped, so the reason coming and going never moves the
+ trigger to a new parent. */}
+ <Tooltip
+ label={props.readOnlyReason ?? ''}
+ disabled={!props.readOnlyReason}
>
- <Show when={!props.hideIcon}>
- <RepeatIcon class="size-3.5 shrink-0 text-ink-extra-muted" />
- </Show>
- <Select.Value<EventComposerSelectOption>>
- {(selectState) => selectState.selectedOption().label}
- </Select.Value>
- <Select.Icon />
- </Select.Trigger>
+ <Select.Trigger
+ aria-label="Repeats"
+ aria-readonly={props.readOnly || undefined}
+ aria-describedby={props.describedBy}
+ class={cn(PROPERTY_TRIGGER_CLASS, 'max-w-48')}
+ >
+ <Show when={!props.hideIcon}>
+ <RepeatIcon class="size-3.5 shrink-0 text-ink-extra-muted" />
+ </Show>
+ <Select.Value<EventComposerSelectOption>>
+ {(selectState) => selectState.selectedOption().label}
+ </Select.Value>
+ <Select.Icon />
+ </Select.Trigger>
+ </Tooltip>
<Select.Content portalScope="local">
<Select.Listbox />
</Select.Content>
diff --git a/apps/web/src/features/scheduling/components/event-types-panel.tsx b/apps/web/src/features/scheduling/components/event-types-panel.tsx
index 76726dfa5b..99154fb3b0 100644
--- a/apps/web/src/features/scheduling/components/event-types-panel.tsx
+++ b/apps/web/src/features/scheduling/components/event-types-panel.tsx
@@ -238,8 +238,7 @@ export function EventTypesPanel(props: {
contextEvent.stopPropagation();
openDrawer(event, rowButton);
}}
- class="min-h-10 min-w-0 rounded-xl px-2 py-1 transition-opacity hover:bg-list-hover focus-within:bg-list-hover"
- classList={{ 'opacity-50': !event.enabled }}
+ class="min-h-10 min-w-0 rounded-xl px-2 py-1 hover:bg-list-hover focus-within:bg-list-hover"
>
<div class="grid min-w-0 grid-cols-[auto_minmax(0,1fr)] items-center gap-x-3 gap-y-2 not-touch:@min-[36rem]/booking-links:grid-cols-[auto_minmax(0,1fr)_auto]">
<ToggleSwitch
@@ -286,7 +285,8 @@ export function EventTypesPanel(props: {
onClick={(click) =>
props.onView(event, click.currentTarget)
}
- class="flex min-w-0 items-center gap-2 rounded-sm text-left outline-none focus-visible:ring-2 focus-visible:ring-accent"
+ class="flex min-w-0 items-center gap-2 rounded-sm text-left outline-none transition-opacity focus-visible:ring-2 focus-visible:ring-accent"
+ classList={{ 'opacity-50': !event.enabled }}
>
<Link
aria-hidden="true"
@@ -301,7 +301,10 @@ export function EventTypesPanel(props: {
</p>
</Show>
</button>
- <div class="col-start-2 flex min-w-0 flex-wrap items-center justify-end gap-2 touch:justify-start touch:pl-6 not-touch:@min-[36rem]/booking-links:col-start-auto">
+ <div
+ class="col-start-2 flex min-w-0 flex-wrap items-center justify-end gap-2 transition-opacity touch:justify-start touch:pl-6 not-touch:@min-[36rem]/booking-links:col-start-auto"
+ classList={{ 'opacity-50': !event.enabled }}
+ >
<Dropdown>
<Dropdown.Trigger
as="button"
diff --git a/docs/agent-guide/calendar.md b/docs/agent-guide/calendar.md
index 5822dc8410..b60b3bd73c 100644
--- a/docs/agent-guide/calendar.md
+++ b/docs/agent-guide/calendar.md
@@ -578,7 +578,7 @@ repeat, conferencing and location controls are disabled, each with the tooltip `
organizer can change this event.`; the same line shows under the pills, which is all a
touch device shows. The event kind and calendar pills, which on any other edit open their one
value as a list, are disabled too. Disabled pills, the date and time pills included, are
-dimmed and show no hover. Notifications stay editable and Save sends only `reminders` (plus any
+dimmed and show no hover; the All day switch is dimmed too. Notifications stay editable and Save sends only `reminders` (plus any
invitation). An editor already open when the organizer turns modifying off follows the
guest's copy once it syncs: the same fields lock, return to the event's own (keeping
notification and guest changes) and a toast shows the line. That guest cannot drag or resize
@@ -602,7 +602,10 @@ defaults (invite others and see the guest list) preselected on a new event and t
`guestPolicy` on an edit. As in Google, checking `Modify event` also checks `Invite others` and
locks it. The row shows on a new event and on an edit whose `viewerCan.setGuestPolicy` is true,
on Google calendars only (the calendar's `capabilities.guestPolicy`); Outlook calendars and
-out-of-office events have none. Like the repeat rule, it is disabled while a recurring edit
+out-of-office events have none. While a recurring edit targets `This event`, the Repeats pill
+opens its list read-only and says why, as a tooltip and under the pills (`The repeat rule
+applies to all events. Choose All events to change it.`). Like the repeat rule, the row is
+disabled while a recurring edit
targets `This event`, since the policy belongs to the whole series, and says so after the
switches (`Guest permissions apply to all events. Choose All events to change them.`);
choosing `This event` returns it to the stored values. Save sends `guestPolicy` only when it