From a47b209a3ed5300ba56f243b48dd7c2d9003afa0 Mon Sep 17 00:00:00 2001 From: HuihuiWu-Microsoft <73154171+HuihuiWu-Microsoft@users.noreply.github.com> Date: Wed, 20 Nov 2024 13:43:58 +0800 Subject: [PATCH] feat: show progress bar when switching is not finished (#12753) * feat: show progress bar when switching is not finished * fix: update string per comment --- packages/vscode-extension/package.nls.json | 2 ++ .../src/handlers/accounts/switchTenantHandler.ts | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/packages/vscode-extension/package.nls.json b/packages/vscode-extension/package.nls.json index f7f217d21d..5376902e26 100644 --- a/packages/vscode-extension/package.nls.json +++ b/packages/vscode-extension/package.nls.json @@ -101,6 +101,8 @@ "teamstoolkit.commands.selectTutorials.title": "View How-to Guides", "teamstoolkit.commands.switchTenant.m365.title": "Switch between your available tenants for Microsoft 365 account", "teamstoolkit.commands.switchTenant.azure.title": "Switch between your available tenants for Azure account", + "teamstoolkit.commands.switchTenant.progressbar.title": "Switch tenant", + "teamstoolkit.commands.switchTenant.progressbar.detail": "Teams Toolkit is now switching to the newly selected tenant.", "teamstoolkit.commands.signOut.title": "Sign Out", "teamstoolkit.commands.checkCopilotAccess.title": "Check Copilot Access", "teamstoolkit.commands.updateManifest.title": "Update Teams App", diff --git a/packages/vscode-extension/src/handlers/accounts/switchTenantHandler.ts b/packages/vscode-extension/src/handlers/accounts/switchTenantHandler.ts index a9cbd8a3c7..bcc543a137 100644 --- a/packages/vscode-extension/src/handlers/accounts/switchTenantHandler.ts +++ b/packages/vscode-extension/src/handlers/accounts/switchTenantHandler.ts @@ -41,7 +41,14 @@ export async function onSwitchM365Tenant(...args: unknown[]): Promise { }; const result = await VS_CODE_UI.selectOption(config); if (result.isOk()) { + const progressHandler = VS_CODE_UI.createProgressBar( + localize("teamstoolkit.commands.switchTenant.progressbar.title"), + 1 + ); + await progressHandler.start(); + await progressHandler.next(localize("teamstoolkit.commands.switchTenant.progressbar.detail")); const switchRes = await M365TokenInstance.switchTenant(result.value.result as string); + await progressHandler.end(switchRes.isOk()); if (switchRes.isOk()) { ExtTelemetry.sendTelemetryEvent(TelemetryEvent.SwitchTenant, { [TelemetryProperty.AccountType]: AccountType.M365, @@ -100,7 +107,14 @@ export async function onSwitchAzureTenant(...args: unknown[]): Promise { const result = await VS_CODE_UI.selectOption(config); let error: any; if (result.isOk()) { + const progressHandler = VS_CODE_UI.createProgressBar( + localize("teamstoolkit.commands.switchTenant.progressbar.title"), + 1 + ); + await progressHandler.start(); + await progressHandler.next(localize("teamstoolkit.commands.switchTenant.progressbar.detail")); const switchRes = await azureAccountManager.switchTenant(result.value.result as string); + await progressHandler.end(switchRes.isOk()); if (switchRes.isOk()) { ExtTelemetry.sendTelemetryEvent(TelemetryEvent.SwitchTenant, { [TelemetryProperty.AccountType]: AccountType.Azure,