-
Notifications
You must be signed in to change notification settings - Fork 183
fix: correct project limit warnings for multi-organization users #2194
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
Conversation
ConsoleProject ID: Sites (2)
Note You can use Avatars API to generate QR code for any text or URLs. |
const orgProjects = await sdk.forConsole.projects.list([ | ||
Query.equal('teamId', page.data.organization.$id), | ||
Query.limit(1000) | ||
]); |
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.
do also not have this same thing on upper level +layout.ts
? lets see which one we can avoid. this is massive data :\
@@ -167,7 +168,7 @@ | |||
</DropList> | |||
</div> | |||
|
|||
{#if isCloud && $currentPlan?.projects && $currentPlan?.projects > 0 && data.organization.projects.length > 0 && data.projects.total > 2 && $canWriteProjects} | |||
{#if isCloud && $currentPlan?.projects && $currentPlan?.projects > 0 && data.organization.projects.length > 0 && data.projects.total > $currentPlan.projects && $canWriteProjects && data.organization.billingPlan === BillingPlan.FREE} |
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.
instead of the free plan check, lets see if the currentPlan.projects
or whatever the variable is. We need to avoid hardcoded billing plan name/id checks.
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.
Pull Request Overview
This PR fixes project limit warnings for users with multiple organizations, ensuring that project limits and related UI elements display correctly based on the current organization's plan rather than showing incorrect information from other organizations.
- Updates project limit validation to use organization-specific project counts instead of global counts
- Modifies the project selection modal to only show projects from the current organization
- Dynamically displays correct project limits in UI messages based on the current plan
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
src/routes/(console)/organization-[organization]/+page.svelte |
Updates alert condition to compare against actual plan project limit instead of hardcoded value |
src/routes/(console)/+layout.svelte |
Adds organization-specific project count validation before calling limit check |
src/lib/stores/billing.ts |
Modifies project limit check to accept optional organization project count parameter |
src/lib/layout/createProject.svelte |
Dynamically displays project limit from current plan instead of hardcoded "2 projects" |
src/lib/components/billing/alerts/selectProjectCloud.svelte |
Filters projects to only show those from current organization and uses dynamic limit text |
const plan = await sdk.forConsole.billing.getOrganizationPlan(org.$id); | ||
if (!plan) return; | ||
if (plan.$id !== BillingPlan.FREE) return; | ||
if (org.projects?.length > 0) return; | ||
|
||
if (plan.projects > 0 && projects > plan.projects) { | ||
let projectCount = orgProjectCount; | ||
if (projectCount === undefined) return; |
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.
Early return when projectCount is undefined may silently skip important project limit checks. Consider logging this condition or providing a fallback mechanism to fetch the project count when it's not provided.
if (projectCount === undefined) return; | |
if (projectCount === undefined) { | |
console.warn('checkForProjectsLimit: projectCount is undefined, attempting to fetch project count for org', org?.$id); | |
try { | |
// Attempt to fetch the project count as a fallback | |
const projectsList = await sdk.forConsole.projects.list([Query.equal('organizationId', org.$id)]); | |
projectCount = projectsList?.total ?? projectsList?.projects?.length ?? 0; | |
} catch (err) { | |
console.error('checkForProjectsLimit: Failed to fetch project count for org', org?.$id, err); | |
return; | |
} | |
} |
Copilot uses AI. Check for mistakes.
projects = page.data.allProjects?.projects || []; | ||
const currentOrgId = page.data.organization?.$id; | ||
projects = | ||
page.data.currentOrgId === currentOrgId ? page.data.allProjects?.projects || [] : []; |
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.
[nitpick] The ternary operator condition could be clearer. Consider extracting this logic into a well-named variable or function to improve readability and make the organization filtering intent more explicit.
page.data.currentOrgId === currentOrgId ? page.data.allProjects?.projects || [] : []; | |
const isCurrentOrganizationSelected = page.data.currentOrgId === currentOrgId; | |
projects = | |
isCurrentOrganizationSelected ? page.data.allProjects?.projects || [] : []; |
Copilot uses AI. Check for mistakes.
What does this PR do?
Fixes issue where users with multiple organizations (Free/Pro/Scale)
saw incorrect project limit warnings and "Manage projects" modal
showing projects from other organizations.
Test Plan
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?
yes