@@ -32,19 +32,28 @@ import {
32
32
isIamConnection ,
33
33
isSsoConnection ,
34
34
} from '../../connection'
35
- import { tryAddCredentials , signout , showRegionPrompter , promptAndUseConnection , ExtensionUse } from '../../utils'
35
+ import {
36
+ tryAddCredentials ,
37
+ signout ,
38
+ showRegionPrompter ,
39
+ promptAndUseConnection ,
40
+ ExtensionUse ,
41
+ showConnectionsPageCommand ,
42
+ addConnection ,
43
+ } from '../../utils'
36
44
import { Region } from '../../../shared/regions/endpoints'
37
45
import { CancellationError } from '../../../shared/utilities/timeoutUtils'
38
46
import { validateSsoUrl , validateSsoUrlFormat } from '../../sso/validation'
39
47
import { debounce } from '../../../shared/utilities/functionUtils'
40
- import { AuthError , ServiceItemId , userCancelled } from './types'
48
+ import { AuthError , ServiceItemId , isServiceItemId , userCancelled } from './types'
41
49
import { awsIdSignIn } from '../../../codewhisperer/util/showSsoPrompt'
42
50
import { connectToEnterpriseSso } from '../../../codewhisperer/util/getStartUrl'
43
51
import { trustedDomainCancellation } from '../../sso/model'
44
52
import { FeatureId , CredentialSourceId , Result , telemetry } from '../../../shared/telemetry/telemetry'
45
53
import { AuthFormId , isBuilderIdAuth } from './authForms/types'
46
54
import { handleWebviewError } from '../../../webviews/server'
47
55
import { cwQuickPickSource , cwTreeNodeSource } from '../../../codewhisperer/commands/types'
56
+ import { Commands , VsCodeCommandArg , placeholder , vscodeComponent } from '../../../shared/vscode/commands2'
48
57
49
58
export class AuthWebview extends VueWebview {
50
59
public override id : string = 'authWebview'
@@ -712,20 +721,42 @@ const Panel = VueWebview.compilePanel(AuthWebview)
712
721
let activePanel : InstanceType < typeof Panel > | undefined
713
722
let subscriptions : vscode . Disposable [ ] | undefined
714
723
724
+ /**
725
+ * Different places the Add Connection command could be executed from.
726
+ *
727
+ * Useful for telemetry.
728
+ */
715
729
export const AuthSources = {
716
730
addConnectionQuickPick : 'addConnectionQuickPick' ,
717
731
firstStartup : 'firstStartup' ,
718
732
codecatalystDeveloperTools : 'codecatalystDeveloperTools' ,
719
- unknown : 'unknown' ,
733
+ vscodeComponent : vscodeComponent ,
720
734
cwQuickPick : cwQuickPickSource ,
721
- cwTreeNode : cwTreeNodeSource
735
+ cwTreeNode : cwTreeNodeSource ,
736
+ authNode : 'authNode'
722
737
} as const
723
738
724
- export type AuthSource = typeof AuthSources [ keyof typeof AuthSources ]
739
+ export type AuthSource = ( typeof AuthSources ) [ keyof typeof AuthSources ]
740
+
741
+ export const showManageConnections = Commands . declare (
742
+ { id : showConnectionsPageCommand , compositeKey : { 1 : 'source' } } ,
743
+ ( context : vscode . ExtensionContext ) => ( _ : VsCodeCommandArg , source : AuthSource , serviceToShow ?: ServiceItemId ) => {
744
+ // The auth webview page does not make sense to use in C9,
745
+ // so show the auth quick pick instead.
746
+ if ( isCloud9 ( 'any' ) ) {
747
+ return addConnection . execute ( )
748
+ }
725
749
726
- export function isAuthSource ( obj : any ) : obj is AuthSource {
727
- return Object . values ( AuthSources ) . includes ( obj )
728
- }
750
+ if ( _ !== placeholder ) {
751
+ source = 'vscodeComponent'
752
+ }
753
+
754
+ if ( ! isServiceItemId ( serviceToShow ) ) {
755
+ serviceToShow = undefined
756
+ }
757
+ return showAuthWebview ( context , source , serviceToShow )
758
+ }
759
+ )
729
760
730
761
export async function showAuthWebview (
731
762
ctx : vscode . ExtensionContext ,
0 commit comments