-
Notifications
You must be signed in to change notification settings - Fork 1
feat: Upgrade badges inside workflows #17
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
WalkthroughThis change implements team plan upgrade requirements for workflow features across multiple components. A new Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (2)
packages/features/ee/workflows/lib/getOptions.ts (2)
44-52: Consider reusing the existingisFormTriggerhelper.The
isFormSubmittedTriggercheck duplicates logic that already exists inisFormTriggerfromactionHelperFunctions.ts(which checks againstFORM_TRIGGER_WORKFLOW_EVENTS). Consider reusing it for consistency:- const isFormSubmittedTrigger = - triggerEvent === WorkflowTriggerEvents.FORM_SUBMITTED || - triggerEvent === WorkflowTriggerEvents.FORM_SUBMITTED_NO_EVENT; + const isFormSubmittedTrigger = isFormTrigger(triggerEvent);
65-66: Consider defining a proper return type instead of using type assertion.The type assertion
as { label: string; value: any; needsTeamsUpgrade: boolean }could be avoided by defining an explicit interface or type alias for the template option shape.+interface TemplateOption { + label: string; + value: WorkflowTemplates; + needsTeamsUpgrade: boolean; +} + function convertToTemplateOptions( t: TFunction, hasPaidPlan: boolean, templates: readonly WorkflowTemplates[] -) { +): TemplateOption[] { return templates.map((template) => { return { label: t(`${template.toLowerCase()}`), value: template, needsTeamsUpgrade: !hasPaidPlan && template !== WorkflowTemplates.REMINDER, - } as { label: string; value: any; needsTeamsUpgrade: boolean }; + }; }); }
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
packages/features/ee/workflows/components/AddActionDialog.tsx(2 hunks)packages/features/ee/workflows/components/WorkflowDetailsPage.tsx(3 hunks)packages/features/ee/workflows/components/WorkflowStepContainer.tsx(8 hunks)packages/features/ee/workflows/lib/getOptions.ts(3 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/review.mdc)
**/*.ts: Avoid dot-suffixes like.service.tsor.repository.tsfor new files; reserve.test.ts,.spec.ts,.types.tsfor their specific purposes
For Prisma queries: only select data you need usingselectinstead ofincludeto reduce performance overhead and prevent unnecessary data exposure, especially for sensitive fields likecredential.key
Never return thecredential.keyfield from tRPC endpoints or APIs
Check if there's any O(n^2) logic in backend code; aim for O(n log n) or O(n) complexity ideally
Flag excessive Day.js use in performance-critical code. Functions like.add,.diff,.isBefore, and.isAfterare slow in timezone mode. Prefer.utc()for better performance. Where possible, use native Date and direct.valueOf()comparisons in hot paths like loops
When changes to API v2 or v1 are made, ensure there are no breaking changes on existing endpoints. Instead, create newly versioned endpoints with updated functionality while keeping old endpoints functional
Files:
packages/features/ee/workflows/lib/getOptions.ts
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/review.mdc)
**/*.{ts,tsx,js,jsx}: Prefer early returns. It is recommended to throw/return early to ensure null-checks and prevent further nesting
Check if there are circular references introduced. Never allow circular references
Files:
packages/features/ee/workflows/lib/getOptions.tspackages/features/ee/workflows/components/WorkflowDetailsPage.tsxpackages/features/ee/workflows/components/AddActionDialog.tsxpackages/features/ee/workflows/components/WorkflowStepContainer.tsx
⚙️ CodeRabbit configuration file
Flag default exports and encourage named exports. Named exports provide better tree-shaking, easier refactoring, and clearer imports. Exempt main components like pages, layouts, and components that serve as the primary export of a module.
Files:
packages/features/ee/workflows/lib/getOptions.tspackages/features/ee/workflows/components/WorkflowDetailsPage.tsxpackages/features/ee/workflows/components/AddActionDialog.tsxpackages/features/ee/workflows/components/WorkflowStepContainer.tsx
**/*.{ts,tsx,jsx}
📄 CodeRabbit inference engine (.cursor/rules/review.mdc)
Prefer Composition over Prop Drilling. Instead of relying on prop drilling, use React's children feature
Files:
packages/features/ee/workflows/lib/getOptions.tspackages/features/ee/workflows/components/WorkflowDetailsPage.tsxpackages/features/ee/workflows/components/AddActionDialog.tsxpackages/features/ee/workflows/components/WorkflowStepContainer.tsx
**/*.{tsx,jsx}
📄 CodeRabbit inference engine (.cursor/rules/review.mdc)
Always use
t()for text localization in frontend code; direct text embedding should trigger a warning
Files:
packages/features/ee/workflows/components/WorkflowDetailsPage.tsxpackages/features/ee/workflows/components/AddActionDialog.tsxpackages/features/ee/workflows/components/WorkflowStepContainer.tsx
🧬 Code graph analysis (2)
packages/features/ee/workflows/components/WorkflowDetailsPage.tsx (2)
packages/features/billing/hooks/useHasPaidPlan.ts (1)
useHasActiveTeamPlan(41-47)packages/features/ee/workflows/lib/actionHelperFunctions.ts (1)
isFormTrigger(146-148)
packages/features/ee/workflows/components/AddActionDialog.tsx (1)
packages/platform/libraries/index.ts (1)
WorkflowActions(36-36)
🔇 Additional comments (12)
packages/features/ee/workflows/components/AddActionDialog.tsx (2)
43-43: LGTM!The
needsTeamsUpgradeoptional property is correctly added to the interface, aligning with the upgrade badge feature requirements.
174-184: LGTM!The options mapping correctly propagates
needsTeamsUpgradeand theisOptionDisabledcallback properly disables options requiring a team plan upgrade.packages/features/ee/workflows/components/WorkflowDetailsPage.tsx (1)
6-6: LGTM!The import and usage of
useHasActiveTeamPlanhook is correct.Also applies to: 47-47
packages/features/ee/workflows/lib/getOptions.ts (1)
34-34: LGTM!The
hasPaidPlanparameter with a default value offalseis a safe default that ensures upgrade badges are shown when the plan status is unknown.packages/features/ee/workflows/components/WorkflowStepContainer.tsx (8)
104-104: LGTM!The
needsTeamsUpgradeoptional property correctly added to theactionOptionstype withinWorkflowStepProps.
375-376: LGTM!Correctly passing
hasActiveTeamPlantogetWorkflowTriggerOptionsandgetWorkflowTemplateOptionsfor proper upgrade gating.
383-386: LGTM!The
currentStepTemplatederivation from watched steps andisReminderTemplatecheck correctly gate editing capabilities for the free Reminder template.
540-574: LGTM!The refactored trigger handling with explicit
triggerValueextraction improves type safety and ensures consistent usage throughout the onChange handler.
594-601: LGTM!Trigger options correctly mapped with
needsTeamsUpgradeandisOptionDisabledproperly disables options requiring upgrade.
1293-1304: Verify the SMS action exception for template upgrade gating.The
needsTeamsUpgradefor template options is conditionally set tofalsewhen the action is SMS (!isSMSAction(...)). Ensure this exception is intentional and that SMS actions should bypass the team plan requirement for non-Reminder templates.
1338-1338: LGTM!The email subject TextArea is correctly disabled for users without an active team plan unless they're using the free Reminder template.
1369-1372: LGTM!The Editor's editable state correctly allows editing when the user has an active team plan, is using SMS action, or has selected the free Reminder template.
| const needsTeamsUpgrade = isFormTrigger(form.getValues("trigger")) && !hasActiveTeamPlan; | ||
|
|
||
| return { | ||
| ...option, | ||
| label, | ||
| creditsTeamId: teamId, | ||
| isOrganization: isOrg, | ||
| isCalAi: isCalAIAction(option.value), | ||
| needsTeamsUpgrade, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider handling the loading state from useHasActiveTeamPlan.
During the initial load while isPending is true, hasActiveTeamPlan will be falsy, potentially causing a brief flash where upgrade badges appear for users who actually have an active team plan.
Consider destructuring and using isPending to avoid showing upgrade badges during loading:
- const { hasActiveTeamPlan } = useHasActiveTeamPlan();
+ const { hasActiveTeamPlan, isPending } = useHasActiveTeamPlan();
...
- const needsTeamsUpgrade = isFormTrigger(form.getValues("trigger")) && !hasActiveTeamPlan;
+ const needsTeamsUpgrade = isFormTrigger(form.getValues("trigger")) && !isPending && !hasActiveTeamPlan;Committable suggestion skipped: line range outside the PR's diff.
🤖 Prompt for AI Agents
In packages/features/ee/workflows/components/WorkflowDetailsPage.tsx around
lines 89–97, the needsTeamsUpgrade value uses hasActiveTeamPlan which is falsy
while the hook is still loading, causing a flash of upgrade badges; destructure
isPending from useHasActiveTeamPlan and only compute needsTeamsUpgrade when
loading has finished (e.g. set needsTeamsUpgrade = !isPending &&
isFormTrigger(form.getValues("trigger")) && !hasActiveTeamPlan), so while
isPending is true you avoid showing the upgrade badge.
Evaluation PR
This PR was automatically created for evaluation purposes.
Original PR: calcom#24839
Details
Original Description
What does this PR do?
Visual Demo:
For Free Plan Users:
Screenshots:
and
P.S. We can see the ‘Rating’ template here, but it’s only visible on the local server. I guess this is because it’s self-hosted config, we return true for paid and team plans.
And I haven’t made any changes that would show this ‘Rating’ template for non-team members.
I’ve also checked the main branch, and it’s visible there as well.
Video:
Screen.Recording.2025-11-01.at.1.40.49.PM.mov
Summary by cubic
Upgrade badges are added to workflow selects and Free plan users are prevented from choosing form-based triggers and premium templates. Reminder template stays free and editable without a Team plan. Addresses CAL-6670 and calcom#24826.
Written for commit 8cfb324. Summary will update automatically on new commits.
Generated by coderabbit evaluation framework