diff --git a/auth/CHANGELOG.md b/auth/CHANGELOG.md index 912c8b7a3c..bd87c0ab1b 100644 --- a/auth/CHANGELOG.md +++ b/auth/CHANGELOG.md @@ -1,5 +1,8 @@ # Change Log +## 4.0.3 - 2024-12-20 +* [#1862](https://github.com/microsoft/vscode-azuretools/pull/1862) Display account name on duplicate tenant picks + ## 4.0.2 - 2024-12-19 * [#1861](https://github.com/microsoft/vscode-azuretools/pull/1861) Remove unecessary if statement diff --git a/auth/package-lock.json b/auth/package-lock.json index b9b4615b65..aeda7c189c 100644 --- a/auth/package-lock.json +++ b/auth/package-lock.json @@ -1,12 +1,12 @@ { "name": "@microsoft/vscode-azext-azureauth", - "version": "4.0.2", + "version": "4.0.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@microsoft/vscode-azext-azureauth", - "version": "4.0.2", + "version": "4.0.3", "license": "MIT", "dependencies": { "@azure/arm-resources-subscriptions": "^2.1.0", diff --git a/auth/package.json b/auth/package.json index 80ade4b935..1e40948707 100644 --- a/auth/package.json +++ b/auth/package.json @@ -1,7 +1,7 @@ { "name": "@microsoft/vscode-azext-azureauth", "author": "Microsoft Corporation", - "version": "4.0.2", + "version": "4.0.3", "description": "Azure authentication helpers for Visual Studio Code", "tags": [ "azure", diff --git a/auth/src/signInToTenant.ts b/auth/src/signInToTenant.ts index a8554c1612..693b5844a1 100644 --- a/auth/src/signInToTenant.ts +++ b/auth/src/signInToTenant.ts @@ -34,12 +34,20 @@ interface TenantQuickPickItem extends vscode.QuickPickItem { async function getPicks(subscriptionProvider: AzureSubscriptionProvider): Promise { const unauthenticatedTenants = await getUnauthenticatedTenants(subscriptionProvider); + const duplicateTenants: Set = new Set( + unauthenticatedTenants + .filter((tenant, index, self) => index !== self.findIndex(t => t.tenantId === tenant.tenantId)) + .map(tenant => tenant.tenantId) + ); + const isDuplicate = (tenantId: string) => duplicateTenants.has(tenantId); + const picks: TenantQuickPickItem[] = unauthenticatedTenants // eslint-disable-next-line @typescript-eslint/no-non-null-assertion .sort((a, b) => (a.displayName!).localeCompare(b.displayName!)) .map(tenant => ({ label: tenant.displayName ?? '', - description: tenant.tenantId ?? '', + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + description: `${tenant.tenantId!}${isDuplicate(tenant.tenantId!) ? ` (${tenant.account.label})` : ''}`, detail: tenant.defaultDomain ?? '', tenant, })); diff --git a/auth/src/utils/getUnauthenticatedTenants.ts b/auth/src/utils/getUnauthenticatedTenants.ts index 80b21cba98..1c660435f4 100644 --- a/auth/src/utils/getUnauthenticatedTenants.ts +++ b/auth/src/utils/getUnauthenticatedTenants.ts @@ -3,15 +3,15 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import type { TenantIdDescription } from "@azure/arm-resources-subscriptions"; import type { AzureSubscriptionProvider } from "../AzureSubscriptionProvider"; +import type { AzureTenant } from "../AzureTenant"; /** * @returns list of tenants that VS Code doesn't have sessions for */ -export async function getUnauthenticatedTenants(subscriptionProvider: AzureSubscriptionProvider): Promise { +export async function getUnauthenticatedTenants(subscriptionProvider: AzureSubscriptionProvider): Promise { const tenants = await subscriptionProvider.getTenants(); - const unauthenticatedTenants: TenantIdDescription[] = []; + const unauthenticatedTenants: AzureTenant[] = []; for await (const tenant of tenants) { if (!await subscriptionProvider.isSignedIn(tenant.tenantId, tenant.account)) { unauthenticatedTenants.push(tenant);