fix: make project limit alert program-aware#2850
Conversation
Console (appwrite/console)Project ID: Tip SSR frameworks are fully supported with configurable build runtimes |
WalkthroughA Svelte component for an organization console page is modified to refine the free-plan alert display logic. An additional guard condition is added that checks if Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/routes/`(console)/organization-[organization]/+page.svelte:
- Around line 222-226: The conditional renders an alert when data.currentPlan
may be undefined because `data.currentPlan?.projects !== 0` is true for
undefined; change the guard to ensure projects is present and non-zero (e.g.,
check `data.currentPlan?.projects` truthiness or explicitly
`data.currentPlan?.projects > 0`) so the Alert.Inline/Tyography.Text never shows
"up to undefined projects"; update the condition in the same expression that
uses isCloud, data.currentPlan?.projects, projectsToArchive.length,
freePlanAlertDismissed and keep dismissFreePlanAlert behavior unchanged.
| {#if isCloud && !data.program && data.currentPlan?.projects !== 0 && projectsToArchive.length === 0 && !freePlanAlertDismissed} | ||
| <Alert.Inline dismissible on:dismiss={dismissFreePlanAlert}> | ||
| <Typography.Text | ||
| >Your Free plan includes up to 2 projects and limited resources. Upgrade to unlock | ||
| more capacity and features.</Typography.Text> | ||
| >Your Free plan includes up to {data.currentPlan?.projects} projects and limited resources. | ||
| Upgrade to unlock more capacity and features.</Typography.Text> |
There was a problem hiding this comment.
Minor: undefined !== 0 is true — the guard doesn't protect against a missing currentPlan.
If data.currentPlan were ever null/undefined, the check data.currentPlan?.projects !== 0 evaluates to undefined !== 0 → true, so the alert would render with the text "up to undefined projects". This is likely safe in practice (cloud layouts should always load currentPlan), but a small tweak makes it more robust:
Suggested defensive tweak
- {`#if` isCloud && !data.program && data.currentPlan?.projects !== 0 && projectsToArchive.length === 0 && !freePlanAlertDismissed}
+ {`#if` isCloud && !data.program && data.currentPlan?.projects && projectsToArchive.length === 0 && !freePlanAlertDismissed}Using truthiness (data.currentPlan?.projects is falsy for both 0 and undefined/null) collapses the two failure modes into one check and avoids rendering "undefined" in the message.
🤖 Prompt for AI Agents
In `@src/routes/`(console)/organization-[organization]/+page.svelte around lines
222 - 226, The conditional renders an alert when data.currentPlan may be
undefined because `data.currentPlan?.projects !== 0` is true for undefined;
change the guard to ensure projects is present and non-zero (e.g., check
`data.currentPlan?.projects` truthiness or explicitly
`data.currentPlan?.projects > 0`) so the Alert.Inline/Tyography.Text never shows
"up to undefined projects"; update the condition in the same expression that
uses isCloud, data.currentPlan?.projects, projectsToArchive.length,
freePlanAlertDismissed and keep dismissFreePlanAlert behavior unchanged.

What does this PR do?
(Provide a description of what this PR does.)
Test Plan
(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work.)
Related PRs and Issues
(If this PR is related to any other PR or resolves any issue or related to any issue link all related PR and issues here.)
Have you read the Contributing Guidelines on issues?
(Write your answer here.)
Summary by CodeRabbit