File tree Expand file tree Collapse file tree 5 files changed +20
-8
lines changed
components/billing/alerts
organization-[organization] Expand file tree Collapse file tree 5 files changed +20
-8
lines changed Original file line number Diff line number Diff line change 24
24
let error = $state <string | null >(null );
25
25
26
26
onMount (() => {
27
- projects = page .data .allProjects ?.projects || [];
27
+ const currentOrgId = page .data .organization ?.$id ;
28
+ projects =
29
+ page .data .currentOrgId === currentOrgId ? page .data .allProjects ?.projects || [] : [];
28
30
});
29
31
30
32
let projectsToArchive = $derived (
71
73
72
74
<Modal bind:show ={showSelectProject } title ={' Manage projects' } onSubmit ={updateSelected }>
73
75
<svelte:fragment slot =" description" >
74
- Choose which two projects to keep. Projects over the limit will be blocked after this date.
76
+ Choose which {$currentPlan ?.projects || 2 } projects to keep. Projects over the limit will be
77
+ blocked after this date.
75
78
</svelte:fragment >
76
79
{#if error }
77
80
<Alert .Inline status ="error" title ="Error" >{error }</Alert .Inline >
Original file line number Diff line number Diff line change 47
47
<Typography .Title size =" l" >Create your project</Typography .Title >
48
48
{/if }
49
49
{#if projectsLimited }
50
- <Alert .Inline status =" warning" title =" You've reached your limit of 2 projects" >
50
+ <Alert .Inline
51
+ status =" warning"
52
+ title ={` You've reached your limit of ${$currentPlan ?.projects || 2 } projects ` }>
51
53
Extra projects are available on paid plans for an additional fee
52
54
<svelte:fragment slot =" actions" >
53
55
<Button
Original file line number Diff line number Diff line change @@ -317,15 +317,18 @@ export function calculateTrialDay(org: Organization) {
317
317
return days ;
318
318
}
319
319
320
- export async function checkForProjectsLimit ( org : Organization , projects : number ) {
320
+ export async function checkForProjectsLimit ( org : Organization , orgProjectCount ? : number ) {
321
321
if ( ! isCloud ) return ;
322
- if ( ! org || ! projects ) return ;
322
+ if ( ! org ) return ;
323
323
const plan = await sdk . forConsole . billing . getOrganizationPlan ( org . $id ) ;
324
324
if ( ! plan ) return ;
325
325
if ( plan . $id !== BillingPlan . FREE ) return ;
326
326
if ( org . projects ?. length > 0 ) return ;
327
327
328
- if ( plan . projects > 0 && projects > plan . projects ) {
328
+ const projectCount = orgProjectCount ;
329
+ if ( projectCount === undefined ) return ;
330
+
331
+ if ( plan . projects > 0 && projectCount > plan . projects ) {
329
332
headerAlert . add ( {
330
333
id : 'projectsLimitReached' ,
331
334
component : ProjectsLimit ,
Original file line number Diff line number Diff line change 297
297
if (currentOrganizationId === org .$id ) return ;
298
298
if (isCloud ) {
299
299
currentOrganizationId = org .$id ;
300
- checkForProjectsLimit (org , data .allProjects ?.projects ?.length || 0 );
300
+ const orgProjectCount =
301
+ data .allProjects && data .currentOrgId === org .$id
302
+ ? data .allProjects .projects .length
303
+ : undefined ;
304
+ checkForProjectsLimit (org , orgProjectCount );
301
305
checkForEnterpriseTrial (org );
302
306
await checkForUsageLimit (org );
303
307
checkForMarkedForDeletion (org );
Original file line number Diff line number Diff line change 167
167
</DropList >
168
168
</div >
169
169
170
- {#if isCloud && $currentPlan ?.projects && $currentPlan ?.projects > 0 && data .organization .projects .length > 0 && data .projects .total > 2 && $canWriteProjects }
170
+ {#if isCloud && $currentPlan ?.projects && $currentPlan ?.projects > 0 && data .organization .projects .length > 0 && data .projects .total > $currentPlan . projects && $canWriteProjects }
171
171
<Alert .Inline
172
172
title ={` ${data .projects .total - data .organization .projects .length } projects will be archived on ${toLocaleDate (billingProjectsLimitDate )} ` }>
173
173
<Typography .Text >
You can’t perform that action at this time.
0 commit comments