diff --git a/src/components/settings/CalendarSettings.tsx b/src/components/settings/CalendarSettings.tsx index 5d575c54..592db790 100644 --- a/src/components/settings/CalendarSettings.tsx +++ b/src/components/settings/CalendarSettings.tsx @@ -7,6 +7,7 @@ import { type TimeFormat, } from '../../stores/settings-store'; import { useLocaleStore } from '../../stores/locale-store'; +import { usePolicyFeature, useSettingLocked } from '../../stores/policy-store'; import { AUTO_TIME_ZONE, getDeviceTimeZone, isValidTimeZone } from '../../lib/calendar-timezone'; import { deviceSyncAvailable } from '../../device-sync/app/available'; import { CALENDAR_AUTHORITY } from '../../device-sync/types'; @@ -49,6 +50,10 @@ export function CalendarSettings() { const birthdayCal = useSettingsStore((s) => s.showBirthdayCalendar); const tasksEnabled = useSettingsStore((s) => s.enableCalendarTasks); const showTasksOnCal = useSettingsStore((s) => s.showTasksOnCalendar); + // An organisation can turn tasks off: the option goes, as in the webmail + // (calendar-settings.tsx), and the policy pins it off. + const tasksAllowed = usePolicyFeature('calendarTasksEnabled'); + const tasksLocked = useSettingLocked('enableCalendarTasks'); // Android with the native module only (#34). const deviceSync = React.useMemo(() => deviceSyncAvailable(), []); @@ -185,17 +190,20 @@ export function CalendarSettings() { /> - - update('enableCalendarTasks', v)} - /> - + {tasksAllowed && ( + + update('enableCalendarTasks', v)} + /> + + )} - {tasksEnabled && ( + {tasksAllowed && tasksEnabled && ( { expect(page).toContain('disabled={themeLocked}'); expect(page).toContain("{themeLocked && ("); }); + + it('hides the tasks option when the organisation turns tasks off, and marks it locked', () => { + const page = settings('CalendarSettings'); + expect(page).toContain("const tasksAllowed = usePolicyFeature('calendarTasksEnabled');"); + expect(page).toContain("const tasksLocked = useSettingLocked('enableCalendarTasks');"); + expect(page).toMatch(/\{tasksAllowed && \(\s*