Skip to content

✨(front) add calendars reordering + admin & layout fixes#56

Merged
sylvinus merged 3 commits into
mainfrom
reorder
May 29, 2026
Merged

✨(front) add calendars reordering + admin & layout fixes#56
sylvinus merged 3 commits into
mainfrom
reorder

Conversation

@sylvinus
Copy link
Copy Markdown
Member

@sylvinus sylvinus commented May 26, 2026

Summary by CodeRabbit

  • New Features

    • Reorder calendars in the sidebar with move up/down actions; ordering is persisted.
    • Rotate individual channel tokens from the admin change form.
    • Added Work Week (Mon–Fri) calendar view.
  • UI/UX Improvements

    • Improved mobile header layout and centered logo.
    • Enhanced mobile scheduler toolbar and weekday bar behavior; updated mobile “today” styling.
    • Added localized labels for work-week and move actions.
  • Tests

    • Added CalDAV security tests for the calendar-order property.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 26, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 405d8245-a279-4075-b0d0-7959b54b9f22

📥 Commits

Reviewing files that changed from the base of the PR and between f4310b7 and 3d07d31.

📒 Files selected for processing (3)
  • src/frontend/apps/calendars/src/features/calendar/components/scheduler/scheduler-theme.scss
  • src/frontend/apps/calendars/src/features/calendar/services/dav/__tests__/caldav-helpers.test.ts
  • src/frontend/apps/calendars/src/features/calendar/services/dav/caldav-helpers.ts

📝 Walkthrough

Walkthrough

Adds per-channel token rotation in Django admin; supports CalDAV Apple calendar-order end-to-end and UI reordering with move up/down; introduces a work-week scheduler view, mobile rendering/styling tweaks, tests, and translations.

Changes

Backend: Token Rotation Admin and CalDAV Protocol Tests

Layer / File(s) Summary
Token rotation admin view and helper
src/backend/core/admin.py
Extended admin imports; added change_form_template, get_urls() override with POST-only rotate-token route, rotate_token_view() handler, and centralized _rotate_one() helper; refactored bulk regenerate_tokens to reuse the helper.
Token rotation template and form
src/backend/core/templates/admin/core/channel/change_form.html
New admin template extending base form; conditionally renders "Rotate token" inline POST form with CSRF and confirmation prompt.
CalDAV tests and test DB fixture
src/backend/core/tests/test_cross_org_e2e.py, src/backend/core/tests/conftest.py
Added E2E tests verifying PROPPATCH/PROPFIND behavior and overwrite semantics for Apple calendar-order; test truncation fixture now respects CALDAV_DB_SCHEMA via psycopg search_path options.

Frontend: Calendar List Reordering via calendar-order

Layer / File(s) Summary
CalDAV order types and helpers
src/frontend/apps/calendars/src/features/calendar/services/dav/caldav-helpers.ts, src/frontend/apps/calendars/src/features/calendar/services/dav/types/caldav-service.ts
Add order?: number to calendar types; include Apple calendar-order in CALENDAR_PROPS; serialize calendar-order in build XML; add parseCalendarOrder helper.
Service parsing and tests
src/frontend/apps/calendars/src/features/calendar/services/dav/CalDavService.ts, src/frontend/apps/calendars/src/features/calendar/services/dav/__tests__/caldav-helpers.test.ts
Parse calendar-order from PROPFIND into returned calendar order; treat order as updatable in updateCalendar; unit tests for parseCalendarOrder.
Calendar context reordering logic
src/frontend/apps/calendars/src/features/calendar/contexts/CalendarContext.tsx
Add moveCalendar(url, direction) to context API; stable ordering by order with tie-breaker; implement adjacent-swap move that updates backend order values and refreshes on success.
Calendar list UI move controls
src/frontend/apps/calendars/src/features/calendar/components/calendar-list/*
Add optional onMoveUp/onMoveDown props to menu and list items; CalendarList wires moveCalendar, shows error toasts on failure, and conditionally enables move actions at list boundaries.
Internationalization for calendar ordering
src/frontend/apps/calendars/src/features/i18n/translations.json
Add moveUp/moveDown keys for English, French, and Dutch.

Frontend: Scheduler View Updates and Mobile UX Improvements

Layer / File(s) Summary
Scheduler view type and configuration updates
src/frontend/apps/calendars/src/features/calendar/components/scheduler/types.ts, .../hooks/useSchedulerInit.ts, .../SchedulerToolbar.tsx, .../mobile/MobileToolbar.tsx
Replace two-day view with timeGridWorkWeek; update MobileView union; add work-week view option to toolbars and view config.
Mobile scheduler rendering and WeekDayBar
src/frontend/apps/calendars/src/features/calendar/components/scheduler/Scheduler.tsx, .../mobile/WeekDayBar.tsx
Add showWeekDayBar and data-view attribute; render WeekDayBar only for timeGridDay and listWeek; simplify WeekDayBar selection logic and imports.
Mobile styling and header layout
src/frontend/apps/calendars/src/features/calendar/components/scheduler/scheduler-theme.scss, src/frontend/apps/calendars/src/pages/index.scss, src/frontend/apps/calendars/src/features/i18n/translations.json
Add Sass imports and tablet breakpoint; narrow header-hiding rule to header children for timeGridDay; restyle "today" column header with circular background and accessible suffix; center mobile header logo by repositioning toggle and hiding right slot; add workWeek translations in EN/FR/NL.

Sequence Diagram

sequenceDiagram
  participant UI as CalendarList (UI)
  participant Context as CalendarContext
  participant Service as CalDavService
  participant Backend as CalDAV server

  UI->>Context: moveCalendar(calendarUrl, "up"/"down")
  Context->>Service: updateCalendar(url, { order })
  Service->>Backend: PROPPATCH (calendar-order)
  Backend-->>Service: 200/4xx
  Service-->>Context: { success, error? }
  Context-->>UI: refreshCalendars / { success:false, error }
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title mentions calendar reordering and admin & layout fixes, which accurately reflects the main changes across frontend (reordering UI, scheduler views, styling) and backend (admin token rotation, test updates).
Docstring Coverage ✅ Passed Docstring coverage is 85.71% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/backend/core/tests/test_cross_org_e2e.py`:
- Around line 2230-2244: The PROPFIND test uses string assertions and misses
HTTP status checks; update the owner_client.generic call handling to assert
check.status_code (expect 207), parse check.content as XML (e.g., using
ElementTree), locate the A:calendar-order property for cal_url's response, and
assert its text equals "42" (instead of checking for ">42<"), repeating the same
explicit status and XML-value assertions for the similar block referenced at
lines around 2268-2283; reference the owner_client.generic call, the check
response variable, and cal_url when implementing these changes.

In
`@src/frontend/apps/calendars/src/features/calendar/components/scheduler/scheduler-theme.scss`:
- Line 265: Remove the two empty SCSS comment lines (the standalone "//"
occurrences) that are causing stylelint's scss/comment-no-empty rule to fail;
locate the empty comments in scheduler-theme.scss (the standalone // lines
around the existing rule blocks) and either delete them or replace them with
meaningful comments (non-empty text) so the linter no longer flags
scss/comment-no-empty.

In
`@src/frontend/apps/calendars/src/features/calendar/contexts/CalendarContext.tsx`:
- Around line 354-365: In moveCalendar, Promise.all(updates) currently assumes
each caldavService.updateCalendar resolves to success; instead await Promise.all
to get an array of results, inspect each result (the resolved values from
caldavService.updateCalendar) and if any has success: false (or an unexpected
shape) throw or return a failure before calling refreshCalendars; update the
code around the updates variable and the try block (referencing moveCalendar,
caldavService.updateCalendar, and refreshCalendars) to validate every response
and only proceed to refreshCalendars and return { success: true } when all
responses indicate success.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: a4ba5413-c22d-40ff-af4d-c8778af4b13a

📥 Commits

Reviewing files that changed from the base of the PR and between 817cc41 and e290a14.

📒 Files selected for processing (20)
  • src/backend/core/admin.py
  • src/backend/core/templates/admin/core/channel/change_form.html
  • src/backend/core/tests/test_cross_org_e2e.py
  • src/frontend/apps/calendars/src/features/calendar/components/calendar-list/CalendarItemMenu.tsx
  • src/frontend/apps/calendars/src/features/calendar/components/calendar-list/CalendarList.tsx
  • src/frontend/apps/calendars/src/features/calendar/components/calendar-list/CalendarListItem.tsx
  • src/frontend/apps/calendars/src/features/calendar/components/calendar-list/types.ts
  • src/frontend/apps/calendars/src/features/calendar/components/scheduler/Scheduler.tsx
  • src/frontend/apps/calendars/src/features/calendar/components/scheduler/SchedulerToolbar.tsx
  • src/frontend/apps/calendars/src/features/calendar/components/scheduler/hooks/useSchedulerInit.ts
  • src/frontend/apps/calendars/src/features/calendar/components/scheduler/mobile/MobileToolbar.tsx
  • src/frontend/apps/calendars/src/features/calendar/components/scheduler/mobile/WeekDayBar.tsx
  • src/frontend/apps/calendars/src/features/calendar/components/scheduler/scheduler-theme.scss
  • src/frontend/apps/calendars/src/features/calendar/components/scheduler/types.ts
  • src/frontend/apps/calendars/src/features/calendar/contexts/CalendarContext.tsx
  • src/frontend/apps/calendars/src/features/calendar/services/dav/CalDavService.ts
  • src/frontend/apps/calendars/src/features/calendar/services/dav/caldav-helpers.ts
  • src/frontend/apps/calendars/src/features/calendar/services/dav/types/caldav-service.ts
  • src/frontend/apps/calendars/src/features/i18n/translations.json
  • src/frontend/apps/calendars/src/pages/index.scss

Comment thread src/backend/core/tests/test_cross_org_e2e.py Outdated
Comment thread src/frontend/apps/calendars/src/features/calendar/contexts/CalendarContext.tsx Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@src/frontend/apps/calendars/src/features/calendar/components/scheduler/scheduler-theme.scss`:
- Around line 321-332: Update the visually-hidden pseudo-element (&::after) to
replace the deprecated clip declaration: remove clip: rect(0, 0, 0, 0); and add
clip-path: inset(50%); (keep position: absolute, width: 1px, height: 1px,
padding: 0, margin: -1px, overflow: hidden, white-space: nowrap, border: 0 and
content unchanged) so the element remains hidden while using the modern
clip-path approach.

In
`@src/frontend/apps/calendars/src/features/calendar/services/dav/caldav-helpers.ts`:
- Around line 512-520: parseCalendarOrder accepts strings like "10abc" because
it uses Number.parseInt; update parseCalendarOrder to first trim the string and
only parse when the entire trimmed string is an integer (e.g. test with a
full-match regex such as /^\d+$/ or /^[+-]?\d+$/), then convert to number
(Number.parseInt or Number) and return it; otherwise return undefined. Target
the parseCalendarOrder function in caldav-helpers.ts and perform the trim +
full-match check before parsing.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 736f0d8c-324c-4e55-b99d-d2f001ee01d8

📥 Commits

Reviewing files that changed from the base of the PR and between e290a14 and f4310b7.

📒 Files selected for processing (13)
  • src/backend/core/tests/conftest.py
  • src/backend/core/tests/test_cross_org_e2e.py
  • src/frontend/apps/calendars/src/features/calendar/components/calendar-list/CalendarItemMenu.tsx
  • src/frontend/apps/calendars/src/features/calendar/components/calendar-list/CalendarList.tsx
  • src/frontend/apps/calendars/src/features/calendar/components/calendar-list/CalendarListItem.tsx
  • src/frontend/apps/calendars/src/features/calendar/components/calendar-list/types.ts
  • src/frontend/apps/calendars/src/features/calendar/components/scheduler/scheduler-theme.scss
  • src/frontend/apps/calendars/src/features/calendar/components/scheduler/types.ts
  • src/frontend/apps/calendars/src/features/calendar/contexts/CalendarContext.tsx
  • src/frontend/apps/calendars/src/features/calendar/services/dav/CalDavService.ts
  • src/frontend/apps/calendars/src/features/calendar/services/dav/__tests__/caldav-helpers.test.ts
  • src/frontend/apps/calendars/src/features/calendar/services/dav/caldav-helpers.ts
  • src/frontend/apps/calendars/src/pages/index.scss
💤 Files with no reviewable changes (1)
  • src/frontend/apps/calendars/src/features/calendar/components/scheduler/types.ts

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 28, 2026

Actionable comments posted: 0

@sylvinus sylvinus merged commit 44800db into main May 29, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant