Skip to content

Commit f013fd1

Browse files
codecatalyst: Bad auth state when adding connection + skip onboarding (#4150)
Problem: When a user connects to CC but skips the prompt to onboard a space, things appear to fail to the user even though things are fine. They will see a cancelled error under the Builder ID button and a "Sign in" node on the CodeCatalyst tree view. Solution: We ignore the error that gets raised if they cancel and successfully add the connection. Also if they require onboarding we will show them the "You must onboard" node instead of the incorrect "You must sign in" node that we are currently showing. When they click this node it will open the CodeCatalyst page in the browser that guides them to onboard. Signed-off-by: nkomonen <[email protected]>
1 parent 24e6326 commit f013fd1

File tree

2 files changed

+33
-8
lines changed

2 files changed

+33
-8
lines changed

src/auth/ui/vue/show.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,15 @@ export class AuthWebview extends VueWebview {
228228
await setupFunc()
229229
return
230230
} catch (e) {
231+
if (e instanceof ToolkitError && e.code === 'NotOnboarded') {
232+
/**
233+
* Connection is fine, they just skipped onboarding so not an actual error.
234+
*
235+
* The error comes from user cancelling prompt by {@link CodeCatalystAuthenticationProvider.promptOnboarding()}
236+
*/
237+
return
238+
}
239+
231240
if (
232241
CancellationError.isUserCancelled(e) ||
233242
(e instanceof ToolkitError && (CancellationError.isUserCancelled(e.cause) || e.cancelled === true))

src/codecatalyst/explorer.ts

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,38 @@ const reauth = Commands.register(
3030
}
3131
)
3232

33+
const onboardCommand = Commands.register(
34+
'_aws.codecatalyst.onboard',
35+
async (authProvider: CodeCatalystAuthenticationProvider) => {
36+
authProvider.promptOnboarding()
37+
}
38+
)
39+
3340
async function getLocalCommands(auth: CodeCatalystAuthenticationProvider) {
3441
const docsUrl = isCloud9() ? codecatalyst.docs.cloud9.overview : codecatalyst.docs.vscode.overview
35-
if (
36-
!auth.activeConnection ||
37-
!auth.isConnectionValid() ||
38-
!(await auth.isConnectionOnboarded(auth.activeConnection))
39-
) {
42+
const learnMoreNode = learnMoreCommand.build(docsUrl).asTreeNode({
43+
label: 'Learn more about CodeCatalyst',
44+
iconPath: getIcon('vscode-question'),
45+
})
46+
47+
if (!auth.activeConnection || !auth.isConnectionValid()) {
4048
return [
4149
showManageConnections.build(placeholder, 'codecatalystDeveloperTools', 'codecatalyst').asTreeNode({
4250
label: 'Sign in to get started',
4351
iconPath: getIcon('vscode-account'),
4452
}),
45-
learnMoreCommand.build(docsUrl).asTreeNode({
46-
label: 'Learn more about CodeCatalyst',
47-
iconPath: getIcon('vscode-question'),
53+
learnMoreNode,
54+
]
55+
}
56+
57+
// We are connected but not onboarded, so show them button to onboard
58+
if (!(await auth.isConnectionOnboarded(auth.activeConnection))) {
59+
return [
60+
onboardCommand.build(auth).asTreeNode({
61+
label: 'Onboard CodeCatalyst to get started',
62+
iconPath: getIcon('vscode-account'),
4863
}),
64+
learnMoreNode,
4965
]
5066
}
5167

0 commit comments

Comments
 (0)