193193 @keydown.enter =" handleContinueClick()"
194194 />
195195 <h4 class =" start-url-error" >{{ startUrlError }}</h4 >
196+ <h4 class =" start-url-warning" >{{ startUrlWarning }}</h4 >
196197 <div class =" title topMargin" >Region</div >
197198 <div class =" hint" >AWS Region that hosts identity directory</div >
198199 <select
@@ -278,7 +279,7 @@ import { LoginOption } from './types'
278279import { CommonAuthWebview } from ' ./backend'
279280import { WebviewClientFactory } from ' ../../../webviews/client'
280281import { Region } from ' ../../../shared/regions/endpoints'
281- import { ssoUrlFormatRegex , ssoUrlFormatMessage } from ' ../../../auth/sso/constants'
282+ import { ssoUrlFormatRegex , ssoUrlFormatMessage , urlInvalidFormatMessage } from ' ../../../auth/sso/constants'
282283
283284const client = WebviewClientFactory .create <CommonAuthWebview >()
284285
@@ -340,6 +341,7 @@ export default defineComponent({
340341 stage: ' START' as Stage ,
341342 regions: [] as Region [],
342343 startUrlError: ' ' ,
344+ startUrlWarning: ' ' ,
343345 selectedRegion: ' us-east-1' ,
344346 startUrl: ' ' ,
345347 app: this .app ,
@@ -365,7 +367,7 @@ export default defineComponent({
365367
366368 // Pre-select the first available login option
367369 await this .preselectLoginOption ()
368- this .handleUrlInput () // validate the default startUrl
370+ await this .handleUrlInput () // validate the default startUrl
369371 },
370372 methods: {
371373 toggleItemSelection(itemId : number ) {
@@ -475,18 +477,48 @@ export default defineComponent({
475477 this .stage = ' CONNECTED'
476478 }
477479 },
478- handleUrlInput() {
479- if (this .startUrl && ! ssoUrlFormatRegex .test (this .startUrl )) {
480- this .startUrlError = ssoUrlFormatMessage
481- } else if (this .startUrl && this .existingStartUrls .some ((url ) => url === this .startUrl )) {
482- this .startUrlError =
483- ' A connection for this start URL already exists. Sign out before creating a new one.'
484- } else {
485- this .startUrlError = ' '
480+ async handleUrlInput() {
481+ const messages = await resolveStartUrlMessages (this .startUrl , this .existingStartUrls )
482+ this .startUrlError = messages .error
483+ this .startUrlWarning = messages .warning
484+
485+ if (! messages .error && ! messages .warning ) {
486486 void client .storeMetricMetadata ({
487487 credentialStartUrl: this .startUrl ,
488488 })
489489 }
490+
491+ async function resolveStartUrlMessages(
492+ startUrl : string | undefined ,
493+ existingStartUrls : string []
494+ ): Promise <{ warning: string ; error: string }> {
495+ // No URL
496+ if (! startUrl ) {
497+ return { error: ' ' , warning: ' ' }
498+ }
499+
500+ // Validate URL format
501+ if (! ssoUrlFormatRegex .test (startUrl )) {
502+ console .log (' Before Validate' )
503+ if (await client .validateUrl (startUrl )) {
504+ console .log (' After Validate' )
505+ return { error: ' ' , warning: ssoUrlFormatMessage }
506+ } else {
507+ return { error: urlInvalidFormatMessage , warning: ' ' }
508+ }
509+ }
510+
511+ // Ensure that URL does not exist yet
512+ if (existingStartUrls .some ((url ) => url === startUrl )) {
513+ return {
514+ error: ' A connection for this start URL already exists. Sign out before creating a new one.' ,
515+ warning: ' ' ,
516+ }
517+ }
518+
519+ // URL is valid
520+ return { error: ' ' , warning: ' ' }
521+ }
490522 },
491523 handleRegionInput(event : any ) {
492524 void client .storeMetricMetadata ({
@@ -743,6 +775,10 @@ body.vscode-high-contrast:not(body.vscode-high-contrast-light) .regionSelect {
743775 color : #ff0000 ;
744776 font-size : var (--font-size-sm );
745777}
778+ .start-url-warning {
779+ color : #dfe216 ;
780+ font-size : var (--font-size-sm );
781+ }
746782#logo {
747783 fill : var (--vscode-button-foreground );
748784}
0 commit comments