3
3
* SPDX-License-Identifier: Apache-2.0
4
4
*/
5
5
6
- import * as nls from 'vscode-nls'
7
- const localize = nls . loadMessageBundle ( )
8
-
9
6
import * as vscode from 'vscode'
10
7
import { getLogger } from '../../shared/logger'
11
8
import { getStartUrl } from './getStartUrl'
@@ -14,13 +11,12 @@ import { AuthUtil, isUpgradeableConnection } from './authUtil'
14
11
import { failedToConnectAwsBuilderId } from '../models/constants'
15
12
import { isValidResponse } from '../../shared/wizards/wizard'
16
13
import { CancellationError } from '../../shared/utilities/timeoutUtils'
17
- import { codicon , getIcon } from '../../shared/icons'
18
- import { DataQuickPickItem } from '../../shared/ui/pickerPrompter'
19
- import { getIdeProperties } from '../../shared/extensionUtilities'
20
14
import { isUserCancelledError , ToolkitError } from '../../shared/errors'
21
15
import { createCommonButtons } from '../../shared/ui/buttons'
22
16
import { Auth } from '../../credentials/auth'
23
17
import { showViewLogsMessage } from '../../shared/utilities/messages'
18
+ import { createBuilderIdItem , createIamItem , createSsoItem } from '../../credentials/auth'
19
+ import { telemetry } from '../../shared/telemetry/telemetry'
24
20
25
21
export const showConnectionPrompt = async ( ) => {
26
22
const currentConn = Auth . instance . activeConnection
@@ -39,15 +35,14 @@ export const showConnectionPrompt = async () => {
39
35
}
40
36
}
41
37
42
- const resp = await showQuickPick (
43
- [ createCodeWhispererBuilderIdItem ( ) , createCodeWhispererSsoItem ( ) , createCodeWhispererIamItem ( ) ] ,
44
- {
45
- title : 'CodeWhisperer: Add Connection to AWS' ,
46
- placeholder : 'Select a connection option to start using CodeWhisperer' ,
47
- buttons : createCommonButtons ( ) as vscode . QuickInputButton [ ] ,
48
- }
49
- )
38
+ const resp = await showQuickPick ( [ createBuilderIdItem ( ) , createSsoItem ( ) , createCodeWhispererIamItem ( ) ] , {
39
+ title : 'CodeWhisperer: Add Connection to AWS' ,
40
+ placeholder : 'Select a connection option to start using CodeWhisperer' ,
41
+ buttons : createCommonButtons ( ) as vscode . QuickInputButton [ ] ,
42
+ } )
43
+
50
44
if ( ! isValidResponse ( resp ) ) {
45
+ telemetry . ui_click . emit ( { elementId : 'connection_optionescapecancel' } )
51
46
throw new CancellationError ( 'user' )
52
47
}
53
48
switch ( resp ) {
@@ -73,32 +68,11 @@ async function awsIdSignIn() {
73
68
await vscode . commands . executeCommand ( 'aws.codeWhisperer.enableCodeSuggestions' )
74
69
}
75
70
76
- export const createCodeWhispererBuilderIdItem = ( ) =>
77
- ( {
78
- label : codicon `${ getIcon ( 'vscode-person' ) } ${ localize (
79
- 'aws.auth.builderIdItem.label' ,
80
- 'Use a personal email to sign up and sign in with AWS Builder ID'
81
- ) } `,
82
- data : 'builderId' ,
83
- detail : 'Create or sign in with AWS Builder ID - a new, personal profile for builders.' ,
84
- } as DataQuickPickItem < 'builderId' > )
71
+ export const createCodeWhispererIamItem = ( ) => {
72
+ const item = createIamItem ( )
73
+ item . detail = 'Not supported by CodeWhisperer.'
74
+ item . description = 'not supported'
75
+ item . invalidSelection = true
85
76
86
- export const createCodeWhispererSsoItem = ( ) =>
87
- ( {
88
- label : codicon `${ getIcon ( 'vscode-organization' ) } ${ localize (
89
- 'aws.auth.ssoItem.label' ,
90
- 'Connect using {0} IAM Identity Center' ,
91
- getIdeProperties ( ) . company
92
- ) } `,
93
- data : 'sso' ,
94
- detail : "Sign in to your company's IAM Identity Center access portal login page." ,
95
- } as DataQuickPickItem < 'sso' > )
96
-
97
- export const createCodeWhispererIamItem = ( ) =>
98
- ( {
99
- label : codicon `${ getIcon ( 'vscode-key' ) } ${ localize ( 'aws.auth.iamItem.label' , 'Use IAM Credentials' ) } ` ,
100
- data : 'iam' ,
101
- detail : 'Not supported by CodeWhisperer.' ,
102
- description : 'not supported' ,
103
- invalidSelection : true ,
104
- } as DataQuickPickItem < 'iam' > )
77
+ return item
78
+ }
0 commit comments