@@ -56,8 +56,10 @@ export default function addSandboxView(): JSX.Element {
5656 const [ currentState , setCurrentState ] = React . useState ( {
5757 action : 'sandboxPageDetectAuthSession' ,
5858 statusInfo : '' ,
59+ usePipelineToken : false ,
5960 consoleDashboard : '' ,
6061 apiEndpoint : '' ,
62+ apiEndpointProxy : '' ,
6163 oauthTokenEndpoint : '' ,
6264 errorCode : undefined
6365 } ) ;
@@ -149,7 +151,9 @@ export default function addSandboxView(): JSX.Element {
149151 action : currentState . action ,
150152 consoleDashboard : currentState . consoleDashboard ,
151153 statusInfo : currentState . statusInfo ,
154+ usePipelineToken : false ,
152155 apiEndpoint : '' ,
156+ apiEndpointProxy : '' ,
153157 oauthTokenEndpoint : '' ,
154158 errorCode : undefined
155159 } ) ;
@@ -299,8 +303,10 @@ export default function addSandboxView(): JSX.Element {
299303 setCurrentState ( {
300304 action : 'sandboxPageRequestVerificationCode' ,
301305 statusInfo : '' ,
306+ usePipelineToken : false ,
302307 consoleDashboard : '' ,
303308 apiEndpoint : '' ,
309+ apiEndpointProxy : '' ,
304310 oauthTokenEndpoint : '' ,
305311 errorCode : undefined
306312 } ) ;
@@ -379,11 +385,27 @@ export default function addSandboxView(): JSX.Element {
379385 const Provisioned = ( ) => {
380386
381387 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+ }
383401 } ;
384402
385403 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' ;
387409
388410 return (
389411 < >
@@ -403,19 +425,29 @@ export default function addSandboxView(): JSX.Element {
403425 </ Tooltip >
404426 Your sandbox account has been provisioned and is ready to use.
405427 </ 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+ ) }
413443 < Tooltip title = 'Launch your DevSandbox console in browser' placement = 'bottom' >
414444 < Button variant = 'contained' className = 'button' href = { currentState . consoleDashboard } > Open Dashboard</ Button >
415445 </ 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+ ) }
419451 < Tooltip title = { loginSandboxTitle } placement = 'bottom' >
420452 < div style = { { display : 'inline-block' , margin : '8px 0px 8px 0px' } } > < Button variant = 'contained' className = 'buttonRed' disabled = { invalidToken } onClick = { handleLoginButton } > Login to DevSandbox</ Button > </ div >
421453 </ Tooltip >
0 commit comments