@@ -176,6 +176,8 @@ import { getExperimentsClientForBackend } from "@gitpod/gitpod-protocol/lib/expe
176
176
import { BillableSession , BillableSessionRequest } from "@gitpod/gitpod-protocol/lib/usage" ;
177
177
import { WorkspaceClusterImagebuilderClientProvider } from "./workspace-cluster-imagebuilder-client-provider" ;
178
178
import { BillingMode } from "@gitpod/gitpod-protocol/lib/billing-mode" ;
179
+ import { EntitlementService } from "../billing/entitlement-service" ;
180
+ import { WorkspaceClasses } from "./workspace-classes" ;
179
181
180
182
// shortcut
181
183
export const traceWI = ( ctx : TraceContext , wi : Omit < LogContext , "userId" > ) => TraceContext . setOWI ( ctx , wi ) ; // userId is already taken care of in WebsocketConnectionManager
@@ -244,6 +246,8 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
244
246
245
247
@inject ( IDEConfigService ) protected readonly ideConfigService : IDEConfigService ;
246
248
249
+ @inject ( EntitlementService ) protected readonly entitlementService : EntitlementService ;
250
+
247
251
/** Id the uniquely identifies this server instance */
248
252
public readonly uuid : string = uuidv4 ( ) ;
249
253
public readonly clientMetadata : ClientMetadata ;
@@ -3030,6 +3034,19 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
3030
3034
}
3031
3035
3032
3036
async getSupportedWorkspaceClasses ( ctx : TraceContext ) : Promise < SupportedWorkspaceClass [ ] > {
3037
+ let user = this . checkAndBlockUser ( "getSupportedWorkspaceClasses" ) ;
3038
+ let selectedClass : string ;
3039
+ if ( user . additionalData ?. workspaceClasses ?. regular ) {
3040
+ selectedClass =
3041
+ this . config . workspaceClasses . find ( ( c ) => c . id === user . additionalData ?. workspaceClasses ?. regular ) ?. id ??
3042
+ WorkspaceClasses . getDefaultId ( this . config . workspaceClasses ) ;
3043
+ } else {
3044
+ selectedClass = WorkspaceClasses . getDefaultId ( this . config . workspaceClasses ) ;
3045
+ if ( await this . entitlementService . userGetsMoreResources ( user ) ) {
3046
+ selectedClass = WorkspaceClasses . getMoreResourcesIdOrDefault ( this . config . workspaceClasses ) ;
3047
+ }
3048
+ }
3049
+
3033
3050
let classes = this . config . workspaceClasses
3034
3051
. filter ( ( c ) => ! c . deprecated )
3035
3052
. map ( ( c ) => ( {
@@ -3038,7 +3055,7 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
3038
3055
displayName : c . displayName ,
3039
3056
description : c . description ,
3040
3057
powerups : c . powerups ,
3041
- isDefault : c . isDefault ,
3058
+ isSelected : selectedClass === c . id ,
3042
3059
} ) ) ;
3043
3060
3044
3061
return classes ;
0 commit comments