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 2424 let error = $state <string | null >(null );
2525
2626 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 || [] : [];
2830 });
2931
3032 let projectsToArchive = $derived (
7173
7274<Modal bind:show ={showSelectProject } title ={' Manage projects' } onSubmit ={updateSelected }>
7375 <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.
7578 </svelte:fragment >
7679 {#if error }
7780 <Alert .Inline status ="error" title ="Error" >{error }</Alert .Inline >
Original file line number Diff line number Diff line change 4747 <Typography .Title size =" l" >Create your project</Typography .Title >
4848 {/if }
4949 {#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 ` }>
5153 Extra projects are available on paid plans for an additional fee
5254 <svelte:fragment slot =" actions" >
5355 <Button
Original file line number Diff line number Diff line change @@ -317,15 +317,18 @@ export function calculateTrialDay(org: Organization) {
317317 return days ;
318318}
319319
320- export async function checkForProjectsLimit ( org : Organization , projects : number ) {
320+ export async function checkForProjectsLimit ( org : Organization , orgProjectCount ? : number ) {
321321 if ( ! isCloud ) return ;
322- if ( ! org || ! projects ) return ;
322+ if ( ! org ) return ;
323323 const plan = await sdk . forConsole . billing . getOrganizationPlan ( org . $id ) ;
324324 if ( ! plan ) return ;
325325 if ( plan . $id !== BillingPlan . FREE ) return ;
326326 if ( org . projects ?. length > 0 ) return ;
327327
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 ) {
329332 headerAlert . add ( {
330333 id : 'projectsLimitReached' ,
331334 component : ProjectsLimit ,
Original file line number Diff line number Diff line change 297297 if (currentOrganizationId === org .$id ) return ;
298298 if (isCloud ) {
299299 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 );
301305 checkForEnterpriseTrial (org );
302306 await checkForUsageLimit (org );
303307 checkForMarkedForDeletion (org );
Original file line number Diff line number Diff line change 167167 </DropList >
168168 </div >
169169
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 }
171171 <Alert .Inline
172172 title ={` ${data .projects .total - data .organization .projects .length } projects will be archived on ${toLocaleDate (billingProjectsLimitDate )} ` }>
173173 <Typography .Text >
You can’t perform that action at this time.
0 commit comments