@@ -9,7 +9,7 @@ import * as grpc from '@grpc/grpc-js';
9
9
import * as fs from 'fs' ;
10
10
import * as os from 'os' ;
11
11
import * as uuid from 'uuid' ;
12
- import { GitpodPluginModel , GitpodExtensionContext , setupGitpodContext , registerTasks , registerIpcHookCli } from 'gitpod-shared' ;
12
+ import { GitpodPluginModel , GitpodExtensionContext , setupGitpodContext , registerTasks , registerIpcHookCli , ExperimentalSettings } from 'gitpod-shared' ;
13
13
import { GetTokenRequest } from '@gitpod/supervisor-api-grpc/lib/token_pb' ;
14
14
import { PortsStatus , ExposedPortInfo , PortsStatusRequest , PortsStatusResponse , PortVisibility , OnPortExposedAction } from '@gitpod/supervisor-api-grpc/lib/status_pb' ;
15
15
import { TunnelVisiblity , TunnelPortRequest , RetryAutoExposeRequest , CloseTunnelRequest } from '@gitpod/supervisor-api-grpc/lib/port_pb' ;
@@ -516,8 +516,8 @@ function getNonce() {
516
516
517
517
interface PortItem { port : GitpodWorkspacePort ; isWebview ?: boolean }
518
518
519
- function registerPorts ( context : GitpodExtensionContext ) : void {
520
- const isPortsViewExperimentEnable = vscode . workspace . getConfiguration ( 'gitpod.experimental.portsView' ) . get < boolean > ( 'enabled' ) ;
519
+ async function registerPorts ( context : GitpodExtensionContext ) : Promise < void > {
520
+ const isPortsViewExperimentEnable = await getPortsViewExperimentEnable ( ) ;
521
521
522
522
const portMap = new Map < number , GitpodWorkspacePort > ( ) ;
523
523
const tunnelMap = new Map < number , vscode . TunnelDescription > ( ) ;
@@ -577,6 +577,18 @@ function registerPorts(context: GitpodExtensionContext): void {
577
577
}
578
578
} ) ;
579
579
}
580
+
581
+ const packageJSON = context . extension . packageJSON ;
582
+ const experiments = new ExperimentalSettings ( packageJSON . configcatKey , packageJSON . version , context . logger ) ;
583
+ context . subscriptions . push ( experiments ) ;
584
+
585
+ const isSaaSGitpod = context . info . getGitpodHost ( ) === 'https://gitpod.io' ;
586
+ async function getPortsViewExperimentEnable ( ) : Promise < boolean > {
587
+ return isSaaSGitpod
588
+ ? ( await experiments . get < boolean > ( 'gitpod.experimental.portsView.enabled' , ( await context . user ) . id ) ) !
589
+ : vscode . workspace . getConfiguration ( 'gitpod' ) . get < boolean > ( 'experimental.portsView.enabled' ) ! ;
590
+ }
591
+
580
592
context . subscriptions . push ( observePortsStatus ( ) ) ;
581
593
context . subscriptions . push ( vscode . commands . registerCommand ( 'gitpod.resolveExternalPort' , ( portNumber : number ) => {
582
594
// eslint-disable-next-line no-async-promise-executor
@@ -657,7 +669,7 @@ function registerPorts(context: GitpodExtensionContext): void {
657
669
658
670
const portsStatusBarItem = vscode . window . createStatusBarItem ( vscode . StatusBarAlignment . Right ) ;
659
671
context . subscriptions . push ( portsStatusBarItem ) ;
660
- function updateStatusBar ( ) : void {
672
+ async function updateStatusBar ( ) : Promise < void > {
661
673
const exposedPorts : number [ ] = [ ] ;
662
674
663
675
for ( const port of portMap . values ( ) ) {
@@ -679,8 +691,8 @@ function registerPorts(context: GitpodExtensionContext): void {
679
691
680
692
portsStatusBarItem . text = text ;
681
693
portsStatusBarItem . tooltip = tooltip ;
682
- const isPortsViewExperimentEnable = vscode . workspace . getConfiguration ( 'gitpod.experimental.portsView' ) . get < boolean > ( 'enabled' ) ;
683
- portsStatusBarItem . command = isPortsViewExperimentEnable ? 'gitpod.portsView.focus' : 'gitpod.ports.reveal' ;
694
+
695
+ portsStatusBarItem . command = ( await getPortsViewExperimentEnable ( ) ) ? 'gitpod.portsView.focus' : 'gitpod.ports.reveal' ;
684
696
portsStatusBarItem . show ( ) ;
685
697
}
686
698
updateStatusBar ( ) ;
@@ -820,11 +832,11 @@ function registerPorts(context: GitpodExtensionContext): void {
820
832
vscode . commands . executeCommand ( 'gitpod.api.connectLocalApp' , apiPort ) ;
821
833
}
822
834
} ) ) ;
823
- vscode . workspace . onDidChangeConfiguration ( ( e : vscode . ConfigurationChangeEvent ) => {
835
+ vscode . workspace . onDidChangeConfiguration ( async ( e : vscode . ConfigurationChangeEvent ) => {
824
836
if ( ! e . affectsConfiguration ( 'gitpod.experimental.portsView.enabled' ) ) {
825
837
return ;
826
838
}
827
- const isPortsViewExperimentEnable = vscode . workspace . getConfiguration ( 'gitpod.experimental.portsView' ) . get < boolean > ( 'enabled' ) ;
839
+ const isPortsViewExperimentEnable = await getPortsViewExperimentEnable ( ) ;
828
840
vscode . commands . executeCommand ( 'setContext' , 'gitpod.portsView.visible' , isPortsViewExperimentEnable ) ;
829
841
gitpodWorkspaceTreeDataProvider . updateIsPortsViewExperimentEnable ( isPortsViewExperimentEnable ?? false ) ;
830
842
updateStatusBar ( ) ;
0 commit comments