Skip to content

Commit 021a7f7

Browse files
cloud9: show auth wizard instead of webview #3894
- Will now show the auth wizard instead of the auth webview to users when in c9 classic or codecatalyst - There will be no automatic opening of any auth setup when the user is a first time user in c9 - Renamed method to `showManageConnections()` since there are different outcomes depending on the IDE now. Signed-off-by: nkomonen <[email protected]>
1 parent df9fc73 commit 021a7f7

File tree

4 files changed

+25
-14
lines changed

4 files changed

+25
-14
lines changed

src/auth/activation.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ import { fromString } from './providers/credentials'
1111
import { registerCommandsWithVSCode } from '../shared/vscode/commands2'
1212
import { AuthCommandBackend, AuthCommandDeclarations } from './commands'
1313
import { getLogger } from '../shared/logger'
14-
import { isInDevEnv } from '../codecatalyst/utils'
1514
import { ExtensionUse } from './utils'
15+
import { isCloud9 } from '../shared/extensionUtilities'
16+
import { isInDevEnv } from '../codecatalyst/utils'
1617

1718
export async function initialize(
1819
extensionContext: vscode.ExtensionContext,
@@ -41,17 +42,20 @@ export async function initialize(
4142
* Show the Manage Connections page when the extension starts up, if it should be shown.
4243
*/
4344
async function showManageConnectionsOnStartup() {
45+
// Do not show connection management to user in certain scenarios.
46+
let reason: string = ''
4447
if (!ExtensionUse.instance.isFirstUse()) {
45-
getLogger().debug(
46-
'firstStartup: This is not the users first use of the extension, skipping showing Add Connections page.'
47-
)
48-
return
48+
reason = 'This is not the users first use of the extension'
49+
} else if (isInDevEnv()) {
50+
reason = 'The user is in a Dev Evironment'
51+
} else if (isCloud9('any')) {
52+
reason = 'The user is in Cloud9'
4953
}
50-
51-
if (isInDevEnv()) {
52-
getLogger().debug('firstStartup: Detected we are in Dev Env, skipping showing Add Connections page.')
54+
if (reason) {
55+
getLogger().debug(`firstStartup: ${reason}. Skipped showing Add Connections page.`)
5356
return
5457
}
5558

56-
AuthCommandDeclarations.instance.declared.showConnectionsPage.execute('firstStartup')
59+
// Show connection management to user
60+
AuthCommandDeclarations.instance.declared.showManageConnections.execute('firstStartup')
5761
}

src/auth/commands.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,22 @@ import * as vscode from 'vscode'
66
import { CommandDeclarations, Commands } from '../shared/vscode/commands2'
77
import { AuthSource, showAuthWebview } from './ui/vue/show'
88
import { ServiceItemId, isServiceItemId } from './ui/vue/types'
9-
import { showConnectionsPageCommand } from './utils'
9+
import { addConnection, showConnectionsPageCommand } from './utils'
10+
import { isCloud9 } from '../shared/extensionUtilities'
1011

1112
/**
1213
* The methods with backend logic for the Auth commands.
1314
*/
1415
export class AuthCommandBackend {
1516
constructor(private readonly extContext: vscode.ExtensionContext) {}
1617

17-
public showConnectionsPage(source: AuthSource, serviceToShow?: ServiceItemId) {
18+
public showManageConnections(source: AuthSource, serviceToShow?: ServiceItemId) {
19+
// The auth webview page does not make sense to use in C9,
20+
// so show the auth quick pick instead.
21+
if (isCloud9('any')) {
22+
return addConnection.execute()
23+
}
24+
1825
// Edge case where called by vscode UI and non ServiceItemId object
1926
// is passed in.
2027
if (typeof source !== 'string') {
@@ -41,7 +48,7 @@ export class AuthCommandDeclarations implements CommandDeclarations<AuthCommandB
4148
private constructor() {}
4249

4350
public readonly declared = {
44-
showConnectionsPage: Commands.from(AuthCommandBackend).declareShowConnectionsPage({
51+
showManageConnections: Commands.from(AuthCommandBackend).declareShowManageConnections({
4552
id: showConnectionsPageCommand,
4653
}),
4754
} as const

src/codecatalyst/explorer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ async function getLocalCommands(auth: CodeCatalystAuthenticationProvider) {
3535
const docsUrl = isCloud9() ? codecatalyst.docs.cloud9.overview : codecatalyst.docs.vscode.overview
3636
if (!isBuilderIdConnection(auth.activeConnection) || !(await auth.isConnectionOnboarded(auth.activeConnection))) {
3737
return [
38-
AuthCommandDeclarations.instance.declared.showConnectionsPage
38+
AuthCommandDeclarations.instance.declared.showManageConnections
3939
.build('codecatalystDeveloperTools', 'codecatalyst')
4040
.asTreeNode({
4141
label: 'Start',

src/codewhisperer/explorer/codewhispererChildrenNodes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export const createSecurityScanNode = () => {
5959
}
6060

6161
export const createSsoSignIn = () =>
62-
AuthCommandDeclarations.instance.declared.showConnectionsPage
62+
AuthCommandDeclarations.instance.declared.showManageConnections
6363
.build('codewhispererDeveloperTools', 'codewhisperer')
6464
.asTreeNode({
6565
label: localize('AWS.explorerNode.sSoSignInNode.label', 'Start'),

0 commit comments

Comments
 (0)