-
Notifications
You must be signed in to change notification settings - Fork 10.2k
feat: implement default filter segments for data tables #22939
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
- Add defaultSegmentId column to UserFilterSegmentPreference table - Support mixed segment ID types (number for user segments, string for default segments) - Add DefaultFilterSegment and CombinedFilterSegment types - Update useSegments hook to handle default segments with date range recalculation - Modify FilterSegmentSelect to group and display default segments separately - Add default segments to bookings view (My Bookings, Upcoming Bookings) - Prevent editing/deleting of default segments in SaveFilterSegmentButton - Update DataTableProvider to support defaultSegments prop - Update parsers and repository to handle mixed segment ID types Implements frontend-only default segments as specified in the requirements. Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>
- Update eslint-config-next and @typescript-eslint packages to latest versions - Fix dependency compatibility issues that were blocking pre-commit hooks Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing Touches🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎ |
- Update SegmentIdentifier to use discriminated union with 'custom' vs 'default' types - Refactor setSegmentId to accept object parameters: { id: string; type: 'default' } | { id: number; type: 'custom' } - Update type definitions with DefaultFilterSegment, CustomFilterSegment, and CombinedFilterSegment - Modify useSegments hook to handle new segment type structure - Update FilterSegmentSelect component to work with discriminated unions - Refactor database preference handling to store segment type alongside ID - Add proper type safety throughout the data flow - Remove description property from DefaultFilterSegment type Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>
…redSegmentId The test was expecting preferredSegmentId to be a number, but after the discriminated union refactor it now returns { id: number, type: 'custom' } for custom segments. Updated the assertion to use toEqual() for deep object comparison. Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>
- Remove null from SegmentIdentifier type definition since null/undefined indicate absence of identifier - Update DataTableProvider and useSegments to handle SegmentIdentifier | null properly - Fix type safety while maintaining discriminated union functionality - Ensure setAndPersistSegmentId accepts null values for clearing segments Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>
…ntification - Update 'my_bookings' to 'default-my_bookings' - Update 'upcoming-bookings' to 'default-upcoming-bookings' - Makes it easier to verify segment type by looking at the ID string - Maintains all existing discriminated union functionality Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>
…refix for segment IDs Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>
… better semantics Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>
…scriminated union Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>
… all component files Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>
…type naming Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>
…:calcom/cal.com into devin/1754492880-default-filter-segments
feat: implement default filter segments for data tables
Summary
This PR implements default filter segments for Cal.com's data table system, allowing users to access pre-defined filter combinations like "My Bookings" and "Upcoming Bookings" without having to create them manually. The implementation supports mixed segment ID types (numeric for user segments, string for default segments) and uses a dual database column approach for preference storage.
Key Changes:
defaultSegmentId
VARCHAR column toUserFilterSegmentPreference
table with constraints ensuring only one segment type per preferenceDefaultFilterSegment
type andCombinedFilterSegment
union type to handle mixed ID types throughout the applicationuseSegments
hook,DataTableProvider
, and repository methods to handle both user and default segmentsFilterSegmentSelect
to group default segments separately with icons, and prevent editing/deleting of default segmentsReview & Testing Checklist for Human
defaultSegmentId
column and constraints were applied correctly, and that existing user preferences still workRecommended Test Plan:
Diagram
Notes
Mixed ID Type Complexity: The most critical aspect to review is the handling of mixed segment ID types (number vs string) throughout the data flow. This required updates to URL parsing, state management, database queries, and UI components.
Frontend-Only Approach: Default segments are defined in component code rather than stored in the database, making them easier to deploy but requiring careful coordination between different views.
Date Range Recalculation: Default segments with relative date ranges (like "upcoming") are recalculated on each render to stay current, which should be monitored for performance impact.
Backward Compatibility: Existing user segments and preferences should continue working unchanged due to the dual-column database approach.
Link to Devin run: https://app.devin.ai/sessions/1c959909a25541de82f2ac0612e08a75
Requested by: @eunjae-lee