@@ -12,18 +12,13 @@ import {
1212 WORKSPACE_LIFETIME_LONG ,
1313 MAX_PARALLEL_WORKSPACES_FREE ,
1414 MAX_PARALLEL_WORKSPACES_PAID ,
15- OrganizationSettings ,
1615} from "@gitpod/gitpod-protocol" ;
1716import { AttributionId } from "@gitpod/gitpod-protocol/lib/attribution" ;
1817import { BillingTier } from "@gitpod/gitpod-protocol/lib/protocol" ;
1918import { inject , injectable } from "inversify" ;
2019import { BillingModes } from "./billing-mode" ;
21- import { EntitlementServiceUBP } from "./entitlement-service-ubp" ;
20+ import { EntitlementServiceUBP , LazyOrganizationService } from "./entitlement-service-ubp" ;
2221import { log } from "@gitpod/gitpod-protocol/lib/util/logging" ;
23- import type { OrganizationService } from "../orgs/organization-service" ;
24-
25- export const LazyOrganizationService = Symbol ( "LazyOrganizationService" ) ;
26- export type LazyOrganizationService = ( ) => OrganizationService ;
2722
2823export interface MayStartWorkspaceResult {
2924 hitParallelWorkspaceLimit ?: HitParallelWorkspaceLimit ;
@@ -53,7 +48,6 @@ export interface EntitlementService {
5348 user : User ,
5449 organizationId : string ,
5550 runningInstances : Promise < WorkspaceInstance [ ] > ,
56- organizationSettings ?: OrganizationSettings ,
5751 ) : Promise < MayStartWorkspaceResult > ;
5852
5953 /**
@@ -118,7 +112,6 @@ export class EntitlementServiceImpl implements EntitlementService {
118112 user : User ,
119113 organizationId : string ,
120114 runningInstances : Promise < WorkspaceInstance [ ] > ,
121- organizationSettings ?: OrganizationSettings ,
122115 ) : Promise < MayStartWorkspaceResult > {
123116 try {
124117 const billingMode = await this . billingModes . getBillingMode ( user . id , organizationId ) ;
@@ -127,6 +120,7 @@ export class EntitlementServiceImpl implements EntitlementService {
127120 switch ( billingMode . mode ) {
128121 case "none" :
129122 // the default limit is MAX_PARALLEL_WORKSPACES_PAID, but organizations can set their own different limit
123+ // we use || here because the default value is 0 and we want to use the default limit if the organization limit is not set
130124 const maxParallelRunningWorkspaces =
131125 organizationSettings . maxParallelRunningWorkspaces || MAX_PARALLEL_WORKSPACES_PAID ;
132126 const current = ( await runningInstances ) . filter ( ( i ) => i . status . phase !== "preparing" ) . length ;
@@ -141,7 +135,7 @@ export class EntitlementServiceImpl implements EntitlementService {
141135
142136 return { } ;
143137 case "usage-based" :
144- return this . ubp . mayStartWorkspace ( user , organizationId , runningInstances , organizationSettings ) ;
138+ return this . ubp . mayStartWorkspace ( user , organizationId , runningInstances ) ;
145139 default :
146140 throw new Error ( "Unsupported billing mode: " + ( billingMode as any ) . mode ) ; // safety net
147141 }
0 commit comments