@@ -56,8 +56,10 @@ export default function addSandboxView(): JSX.Element {
56
56
const [ currentState , setCurrentState ] = React . useState ( {
57
57
action : 'sandboxPageDetectAuthSession' ,
58
58
statusInfo : '' ,
59
+ usePipelineToken : false ,
59
60
consoleDashboard : '' ,
60
61
apiEndpoint : '' ,
62
+ apiEndpointProxy : '' ,
61
63
oauthTokenEndpoint : '' ,
62
64
errorCode : undefined
63
65
} ) ;
@@ -149,7 +151,9 @@ export default function addSandboxView(): JSX.Element {
149
151
action : currentState . action ,
150
152
consoleDashboard : currentState . consoleDashboard ,
151
153
statusInfo : currentState . statusInfo ,
154
+ usePipelineToken : false ,
152
155
apiEndpoint : '' ,
156
+ apiEndpointProxy : '' ,
153
157
oauthTokenEndpoint : '' ,
154
158
errorCode : undefined
155
159
} ) ;
@@ -299,8 +303,10 @@ export default function addSandboxView(): JSX.Element {
299
303
setCurrentState ( {
300
304
action : 'sandboxPageRequestVerificationCode' ,
301
305
statusInfo : '' ,
306
+ usePipelineToken : false ,
302
307
consoleDashboard : '' ,
303
308
apiEndpoint : '' ,
309
+ apiEndpointProxy : '' ,
304
310
oauthTokenEndpoint : '' ,
305
311
errorCode : undefined
306
312
} ) ;
@@ -379,11 +385,27 @@ export default function addSandboxView(): JSX.Element {
379
385
const Provisioned = ( ) => {
380
386
381
387
const handleLoginButton = ( ) => {
382
- postMessage ( 'sandboxLoginUsingDataInClipboard' , { apiEndpointUrl : currentState . apiEndpoint , oauthRequestTokenUrl : `${ currentState . oauthTokenEndpoint } /request` } ) ;
388
+ if ( ! currentState . usePipelineToken ) { // Try loging in using a token from the Clipboard
389
+ postMessage ( 'sandboxLoginUsingDataInClipboard' , {
390
+ apiEndpointUrl : currentState . apiEndpoint ,
391
+ oauthRequestTokenUrl : `${ currentState . oauthTokenEndpoint } /request`
392
+ } ) ;
393
+ } else { // Try loging in using a Pipeline Token
394
+ postMessage ( 'sandboxLoginUsingPipelineToken' , {
395
+ apiEndpointUrl : currentState . apiEndpoint ,
396
+ oauthRequestTokenUrl : `${ currentState . oauthTokenEndpoint } /request` ,
397
+ username : currentState . statusInfo ,
398
+ apiEndpointProxy : currentState . apiEndpointProxy ,
399
+ } ) ;
400
+ }
383
401
} ;
384
402
385
403
const invalidToken = currentState . errorCode === 'invalidToken' ;
386
- const loginSandboxTitle = ! invalidToken ? 'Login to DevSandbox OpenShift cluster with token from clipboard' : 'Token in clipboard is invalid. Select the Get Token option and copy to clipboard' ;
404
+ const loginSandboxTitle = ! invalidToken ?
405
+ currentState . usePipelineToken ?
406
+ 'Login to DevSandbox OpenShift cluster using a service account provided token' :
407
+ 'Login to DevSandbox OpenShift cluster with token from clipboard' :
408
+ 'Token in clipboard is invalid. Select the Get Token option and copy to clipboard' ;
387
409
388
410
return (
389
411
< >
@@ -403,19 +425,29 @@ export default function addSandboxView(): JSX.Element {
403
425
</ Tooltip >
404
426
Your sandbox account has been provisioned and is ready to use.
405
427
</ Typography >
406
- < Typography variant = 'caption' color = 'inherit' display = 'block' style = { { textAlign :'left' , margin : '20px 70px' } } >
407
- Next steps to connect with Developer Sandbox:< br > </ br >
408
- 1. Click on < strong > Get token</ strong > button. In the browser, login using < strong > DevSandbox</ strong > button.< br > </ br >
409
- 2. Click on < strong > Display token</ strong > link and copy token to clipboard.< br > </ br >
410
- 3. Switch back to IDE and press < strong > 'Login To DevSandbox'</ strong > button. This will login you to DevSandbox with token from clipboard.< br > </ br >
411
- 4. Once successfully logged in, start creating applications and deploy on cluster.
412
- </ Typography >
428
+ { ( ! currentState . usePipelineToken ) ? (
429
+ < Typography variant = 'caption' color = 'inherit' display = 'block' style = { { textAlign :'left' , margin : '20px 70px' } } >
430
+ Next steps to connect with Developer Sandbox:< br > </ br >
431
+ 1. Click on < strong > Get token</ strong > button. In the browser, login using < strong > DevSandbox</ strong > button.< br > </ br >
432
+ 2. Click on < strong > Display token</ strong > link and copy token to clipboard.< br > </ br >
433
+ 3. Switch back to IDE and press < strong > 'Login To DevSandbox'</ strong > button. This will login you to DevSandbox with token from clipboard.< br > </ br >
434
+ 4. Once successfully logged in, start creating applications and deploy on cluster.
435
+ </ Typography >
436
+ ) : (
437
+ < Typography variant = 'caption' color = 'inherit' display = 'block' style = { { textAlign :'left' , margin : '20px 70px' } } >
438
+ Next steps to connect with Developer Sandbox:< br > </ br >
439
+ 1. Press < strong > 'Login To DevSandbox'</ strong > button. This will login you to DevSandbox using a service account provided token.< br > </ br >
440
+ 2. Once successfully logged in, start creating applications and deploy on cluster.
441
+ </ Typography >
442
+ ) }
413
443
< Tooltip title = 'Launch your DevSandbox console in browser' placement = 'bottom' >
414
444
< Button variant = 'contained' className = 'button' href = { currentState . consoleDashboard } > Open Dashboard</ Button >
415
445
</ Tooltip >
416
- < Tooltip title = 'Open the DevSandbox console page and copy the login token' placement = 'bottom' >
417
- < Button variant = 'contained' className = 'button' href = { `${ currentState . oauthTokenEndpoint } /request` } > Get token</ Button >
418
- </ Tooltip >
446
+ { ( ! currentState . usePipelineToken ) && (
447
+ < Tooltip title = 'Open the DevSandbox console page and copy the login token' placement = 'bottom' >
448
+ < Button variant = 'contained' className = 'button' href = { `${ currentState . oauthTokenEndpoint } /request` } > Get token</ Button >
449
+ </ Tooltip >
450
+ ) }
419
451
< Tooltip title = { loginSandboxTitle } placement = 'bottom' >
420
452
< div style = { { display : 'inline-block' , margin : '8px 0px 8px 0px' } } > < Button variant = 'contained' className = 'buttonRed' disabled = { invalidToken } onClick = { handleLoginButton } > Login to DevSandbox</ Button > </ div >
421
453
</ Tooltip >
0 commit comments