fix(ui): Calendar view respects user-selected timezone - #67497
Conversation
Thread selectedTimezone from useTimezone() through the Calendar component tree. Compute date ranges in the selected timezone before converting to UTC for API queries. Group Dag runs by their local date/hour in the selected timezone instead of raw UTC string slicing. Fixes apache#67477
choo121600
left a comment
There was a problem hiding this comment.
The static checks seem to be failing. Could you check it once?
…escript-eslint/max-params
|
the rule requires max 3 params — adding timezone as a positional arg pushed |
|
the |
pierrejeambrun
left a comment
There was a problem hiding this comment.
LGTM, tested and working as expected.
Backport successfully created: v3-2-testNote: As of Merging PRs targeted for Airflow 3.X In matter of doubt please ask in #release-management Slack channel.
|
…67497) (#67954) * fix(ui): make Calendar view respect user-selected timezone Thread selectedTimezone from useTimezone() through the Calendar component tree. Compute date ranges in the selected timezone before converting to UTC for API queries. Group Dag runs by their local date/hour in the selected timezone instead of raw UTC string slicing. Fixes #67477 * fix: refactor calendarUtils params to options objects to satisfy @typescript-eslint/max-params --------- (cherry picked from commit 7d66aa7) Co-authored-by: Anmol Mishra <anmolxlight@gmail.com> Co-authored-by: Anmol Mishra <anmolx.work@gmail.com>
Problem
The Calendar view in the Airflow UI always shows Dag runs in UTC, ignoring the user's selected timezone from the TimezoneContext. Runs are grouped by their raw UTC date/hour via string slicing, and the calendar grid bounds are computed using the browser-local timezone.
Root Cause
The Calendar feature tree had no awareness of
useTimezone()/TimezoneContext:selectedDatedirectly without timezone conversioncreateDailyDataMapandcreateHourlyDataMapusedrun.date.slice(0, 10)/run.date.slice(0, 13)to extract date/hour, ignoring the user's timezonegenerateDailyCalendarDataandgenerateHourlyCalendarDatauseddayjs().year(...)instead ofdayjs().tz(timezone).year(...), computing grid bounds in browser-local timeChanges
calendarUtils.ts— Addeddayjs/plugin/timezoneanddayjs/plugin/utcimports. Threaded atimezone: stringparameter through all exported/internal functions. Replacedrun.date.slice(0, 10)/run.date.slice(0, 13)withdayjs(run.date).tz(timezone).format(...). Grid construction now usesdayjs().tz(timezone)instead of baredayjs().Calendar.tsx— ImporteduseTimezone, added dayjs tz/utc plugins. GetsselectedTimezonefrom context. ComputesstartDate/endDatein the selected timezone viaselectedDate.tz(selectedTimezone, true), then converts to UTC with.utc().format(...)for API queries. Passestimezoneprop to view components andcreateCalendarScale.DailyCalendarView.tsx— Acceptstimezoneprop, passes it togenerateDailyCalendarData.HourlyCalendarView.tsx— Acceptstimezoneprop, passes it togenerateHourlyCalendarData.calendarUtils.test.ts— AllcalculateDataBoundsandcreateCalendarScalecalls updated with"UTC"as the 4th argument.Fixes #67477