@@ -10,7 +10,7 @@ import ClusterViewLoader from '../webview/cluster/clusterViewLoader';
1010
1111const sandboxAPI = createSandboxAPI ( ) ;
1212
13- class RedHatCloudItem extends vscode . TreeItem {
13+ class RedHatCloudItem extends vscode . TreeItem {
1414
1515}
1616
@@ -23,7 +23,7 @@ class RedHatTreeDataProvier implements vscode.TreeDataProvider<RedHatCloudItem>
2323 }
2424
2525 getChildren ( element ?: RedHatCloudItem ) : vscode . ProviderResult < RedHatCloudItem [ ] > {
26- if ( ! element ) {
26+ if ( ! element ) {
2727 return this . getTopLevelItems ( ) ;
2828 }
2929 return [ ] ;
@@ -39,23 +39,17 @@ class RedHatTreeDataProvier implements vscode.TreeDataProvider<RedHatCloudItem>
3939
4040 private async getTopLevelItems ( ) : Promise < RedHatCloudItem [ ] > {
4141 const sessionCheck = await vscode . authentication . getSession ( 'redhat-account-auth' , [ 'openid' ] , { createIfNone : false } ) ;
42- if ( sessionCheck ) {
43- const sandboxItem = await this . buildSandboxItem ( ) ;
44- sandboxItem . iconPath
45- const openshiftLocal = new RedHatCloudItem ( 'OpenShift Local' ) ;
46- openshiftLocal . tooltip = 'OpenShift Local'
47- openshiftLocal . command = {
48- command :'openshift.local.open.setup' ,
49- title : 'Install OpenShift Local' ,
50- }
51- return [ sandboxItem , openshiftLocal ] ;
42+ if ( sessionCheck ) {
43+ const sandboxItem = await this . buildDevSandboxItem ( ) ;
44+ const openshiftLocalItem = this . buildOpenshiftLocalItem ( ) ;
45+ return [ sandboxItem , openshiftLocalItem ] ;
5246 }
5347 const loginItem = new RedHatCloudItem ( 'Sign in to Red Hat' ) ;
5448 loginItem . iconPath = new vscode . ThemeIcon ( 'account' ) ;
5549 loginItem . tooltip = 'Sign in to Red Hat' ;
5650 loginItem . command = {
57- command : 'cloud.redhat.login' ,
58- title : 'Sign in to Red Hat' ,
51+ command : 'cloud.redhat.login' ,
52+ title : 'Sign in to Red Hat' ,
5953 }
6054
6155 const signUpItem = new RedHatCloudItem ( 'Create Red Hat Account' ) ;
@@ -67,31 +61,45 @@ class RedHatTreeDataProvier implements vscode.TreeDataProvider<RedHatCloudItem>
6761 tooltip : 'Create Red Hat Account'
6862 }
6963 return [ loginItem , signUpItem ] ;
70-
7164 }
7265
73- private async buildSandboxItem ( ) {
74- const signupStatus = await RedHatTreeDataProvier . getSandboxSignupStatus ( )
66+ private async buildDevSandboxItem ( ) {
67+ const signupStatus = await RedHatTreeDataProvier . getSandboxSignupStatus ( ) ;
7568 const sandboxItem = new RedHatCloudItem ( 'Developer Sandbox' ) ;
76- sandboxItem . tooltip = 'Developer Sandbox'
77-
69+ sandboxItem . tooltip = 'Get 30-days free access to a shared OpenShift and Kubernetes cluster.' ;
70+ sandboxItem . iconPath = new vscode . ThemeIcon ( 'vm' ) ;
7871 if ( ! signupStatus ) {
7972 sandboxItem . contextValue = 'openshift.sandbox.status.none' ;
8073 }
8174 else if ( signupStatus . status . ready ) {
8275 sandboxItem . contextValue = 'openshift.sandbox.status.ready' ;
8376 }
77+ sandboxItem . command = {
78+ command : 'openshift.sandbox.open.setup' ,
79+ title : 'Set up Developer Sandbox' ,
80+ }
8481 return sandboxItem ;
8582 }
8683
84+ private buildOpenshiftLocalItem ( ) {
85+ const openshiftLocalItem = new RedHatCloudItem ( 'Openshift Local' ) ;
86+ openshiftLocalItem . tooltip = 'Provision OpenShift 4 cluster to your local computer.' ;
87+ openshiftLocalItem . iconPath = new vscode . ThemeIcon ( 'symbol-folder' ) ;
88+ openshiftLocalItem . command = {
89+ command : 'openshift.local.open.setup' ,
90+ title : 'Install OpenShift Local' ,
91+ }
92+ return openshiftLocalItem ;
93+ }
94+
8795 @vsCommand ( 'openshift.sandbox.signup' )
88- static async signupForSandbox ( ) : Promise < string > {
96+ static async signupForSandbox ( ) : Promise < string > {
8997 const authSession = await vscode . authentication . getSession ( 'redhat-account-auth' , [ 'openid' ] , { createIfNone : false } ) ;
90- if ( authSession ) {
98+ if ( authSession ) {
9199 // eslint-disable-next-line dot-notation
92100 const signupResponse = await sandboxAPI . signUp ( authSession [ 'idToken' ] as string ) ;
93- if ( ! signupResponse ) {
94- return 'Sign up request for OpenShift Sandbox failed, please try again.'
101+ if ( ! signupResponse ) {
102+ return 'Sign up request for OpenShift Sandbox failed, please try again.' ;
95103 }
96104 await RedHatTreeDataProvier . refreshView ( ) ;
97105
@@ -100,13 +108,20 @@ class RedHatTreeDataProvier implements vscode.TreeDataProvider<RedHatCloudItem>
100108
101109 @vsCommand ( 'openshift.local.open.setup' )
102110 static async openCrCWizard ( ) : Promise < void > {
103- await ClusterViewLoader . loadView ( 'Add OpenShift Cluster' , 'crc' ) ;
111+ const webViewPanel : vscode . WebviewPanel = await ClusterViewLoader . loadView ( 'Add OpenShift Cluster' ) ;
112+ await webViewPanel . webview . postMessage ( { action : 'openCluster' , param : 'crc' } ) ;
113+ }
114+
115+ @vsCommand ( 'openshift.sandbox.open.setup' )
116+ static async openSandboxWizard ( ) : Promise < void > {
117+ const webViewPanel : vscode . WebviewPanel = await ClusterViewLoader . loadView ( 'Add OpenShift Cluster' ) ;
118+ await webViewPanel . webview . postMessage ( { action : 'openCluster' , param : 'sandbox' } ) ;
104119 }
105120
106121 @vsCommand ( 'cloud.redhat.login' , false )
107122 static async loginToRedHatCloud ( ) : Promise < void > {
108- const session = await vscode . authentication . getSession ( 'redhat-account-auth' , [ 'openid' ] , { createIfNone : true } ) ;
109- if ( session ) {
123+ const session = await vscode . authentication . getSession ( 'redhat-account-auth' , [ 'openid' ] , { createIfNone : true } ) ;
124+ if ( session ) {
110125 await RedHatTreeDataProvier . refreshView ( ) ;
111126 }
112127 }
@@ -119,36 +134,33 @@ class RedHatTreeDataProvier implements vscode.TreeDataProvider<RedHatCloudItem>
119134 @vsCommand ( 'openshift.sandbox.open.dashboard' , false )
120135 static async openDashboard ( ) : Promise < void > {
121136 const sandboxStatus = await RedHatTreeDataProvier . getSandboxSignupStatus ( ) ;
122- if ( sandboxStatus )
123- {
137+ if ( sandboxStatus ) {
124138 return vscode . commands . executeCommand ( 'vscode.open' , sandboxStatus . consoleURL ) ;
125139 }
126140 }
127141
128- private static async getSandboxSignupStatus ( ) : Promise < SBSignupResponse | undefined > {
142+ private static async getSandboxSignupStatus ( ) : Promise < SBSignupResponse | undefined > {
129143 const authSession = await vscode . authentication . getSession ( 'redhat-account-auth' , [ 'openid' ] , { createIfNone : false } ) ;
130- if ( authSession ) {
144+ if ( authSession ) {
131145 // eslint-disable-next-line dot-notation
132146 return await sandboxAPI . getSignUpStatus ( authSession [ 'idToken' ] as string ) ;
133147 }
134- return undefined
148+ return undefined ;
135149 }
136150 private static async refreshView ( ) {
137151 const cloudExplorer = await k8s . extension . cloudExplorer . v1 ;
138152 if ( cloudExplorer . available ) {
139153 cloudExplorer . api . refresh ( ) ;
140154 }
141155 }
142-
143156}
144157
145158class RedHatCloudProvider implements k8s . CloudExplorerV1 . CloudProvider {
146159 getKubeconfigYaml ( cluster : any ) : Promise < string > {
147160 throw new Error ( 'Method not implemented.' ) ;
148161 }
149- readonly cloudName = 'Red Hat OpenShift'
162+ readonly cloudName = 'Red Hat OpenShift' ;
150163 readonly treeDataProvider = new RedHatTreeDataProvier ( ) ;
151-
152164}
153165
154166export const REDHAT_CLOUD_PROVIDER = new RedHatCloudProvider ( ) ;
0 commit comments