Skip to content

feat: enable attribute-based assignment for managed event types #22989

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

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

joeauyeung
Copy link
Contributor

feat: enable attribute-based assignment for managed event types

Summary

This PR enables attribute-based user assignment for managed event types, bringing the same functionality that was previously only available for round robin events. Previously, managed events could only use "Assign all team members" or manual host selection, but now they can filter team members based on attributes like skills, location, or other custom properties.

Key Changes:

  • Removed the explicit restriction that prevented managed events from using segment assignment
  • Added assignRRMembersUsingSegment and rrSegmentQueryValue to unlocked managed event type properties
  • Added UI components to configure segment assignment when "Assign all team members" is enabled
  • Updated both child event type creation flows to properly handle segment configuration
  • Fixed various TypeScript type issues related to Prisma schema constraints

Review & Testing Checklist for Human

🔴 High Priority - Must Test:

  • End-to-end flow: Create a managed event type → Enable "Assign all team members" → Configure attribute-based assignment rules → Make a test booking → Verify the correct team member is assigned based on attributes
  • UI Integration: Verify the segment assignment UI appears correctly when toggling "Assign all team members" and matches the existing design patterns in the event type settings
  • Regression testing: Ensure existing managed event functionality still works (creating managed events without segments, manual host assignment, etc.)
  • Type safety: Verify no runtime errors occur during event type creation/updates due to the Prisma type modifications
  • Edge cases: Test what happens when segment rules don't match any team members

Diagram

%%{ init : { "theme" : "default" }}%%
graph TD
    A["EventTeamAssignmentTab.tsx<br/>Event Type Settings UI"]:::major-edit
    B["handleChildrenEventTypes.ts<br/>Child Event Creation Logic"]:::major-edit  
    C["zod-utils.ts<br/>Managed Event Type Schema"]:::major-edit
    D["AddMembersWithSwitch.tsx<br/>Segment UI Component"]:::minor-edit
    E["useCreateEventType.ts<br/>Event Type Hook"]:::minor-edit
    F["teams/index.ts<br/>Team Member Event Updates"]:::major-edit
    G["getRoutedUsers.ts<br/>Booking Assignment Logic"]:::context

    A -->|"Shows segment UI when<br/>assignAllTeamMembers enabled"| D
    A -->|"Uses segment fields from"| C
    B -->|"Creates child events with<br/>segment configuration"| C
    F -->|"Updates existing events<br/>with segment data"| C
    E -->|"Initializes metadata with<br/>unlocked segment fields"| C
    B -->|"Booking flow uses<br/>segment assignment"| G
    F -->|"Booking flow uses<br/>segment assignment"| G

    subgraph Legend
        L1[Major Edit]:::major-edit
        L2[Minor Edit]:::minor-edit  
        L3[Context/No Edit]:::context
    end

    classDef major-edit fill:#90EE90
    classDef minor-edit fill:#87CEEB  
    classDef context fill:#FFFFFF
Loading

Notes

  • Session Info: Requested by @joeauyeung in Devin session: https://app.devin.ai/sessions/e91073230e7e45d0a63525c17da69e42
  • Type Safety: Had to manually exclude several ID fields (userId, parentId, teamId, etc.) from allManagedEventTypeProps to resolve Prisma type conflicts. This required explicitly adding required fields like title, slug, length in the creation logic.
  • Existing Infrastructure: This change leverages the existing attribute assignment system that was already well-developed for round robin events, so the core booking logic should work correctly.
  • UI Pattern: The segment assignment UI follows the same pattern as round robin events - it only appears when "Assign all team members" is enabled, maintaining consistency with existing UX.

- Remove explicit disabling of segment functionality in handleChildrenEventTypes.ts
- Add segment assignment fields to unlocked managed event type properties
- Export MembersSegmentWithToggle component for reuse
- Include segment fields in managed event metadata initialization
- Add segment assignment UI to managed event types when 'Assign all team members' is enabled
- Update teams/index.ts to handle segment assignment for managed events

This allows managed event types to use the same attribute-based user assignment
functionality that was previously only available for round robin events.

Co-Authored-By: joe@cal.com <j.auyeung419@gmail.com>
Copy link
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Copy link
Contributor

coderabbitai bot commented Aug 8, 2025

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch devin/1754679062-managed-event-attribute-assignment

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@keithwillcode keithwillcode added core area: core, team members only enterprise area: enterprise, audit log, organisation, SAML, SSO labels Aug 8, 2025
- Remove fields that are no longer included in Prisma data objects (parentId, profileId, restrictionScheduleId, scheduleId, userId)
- Add explicit title, slug, length fields that are now required
- Update test expectations to match new data structure with assignRRMembersUsingSegment and rrSegmentQueryValue fields
- Fix destructuring patterns to avoid duplicate variable declarations

Co-Authored-By: joe@cal.com <j.auyeung419@gmail.com>
Copy link

vercel bot commented Aug 8, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
cal ⬜️ Ignored (Inspect) Aug 8, 2025 7:37pm
cal-eu ⬜️ Ignored (Inspect) Aug 8, 2025 7:37pm

- Add missing required properties (profileId, scheduleId, restrictionScheduleId) to mockUpdatedEventType
- Remove profileId from destructuring where it doesn't exist in evType object
- Ensure test file passes type checking

Co-Authored-By: joe@cal.com <j.auyeung419@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core area: core, team members only enterprise area: enterprise, audit log, organisation, SAML, SSO
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants