Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
motm32 committed Dec 6, 2024
2 parents ae8212e + 35c5a2e commit 4246947
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 18 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@
"@azure/ms-rest-js": "^2.7.0",
"@microsoft/vscode-azext-azureauth": "^3.1.0",
"@microsoft/vscode-azext-azureutils": "^3.1.1",
"@microsoft/vscode-azext-utils": "^2.5.11",
"@microsoft/vscode-azext-utils": "^2.5.12",
"buffer": "^6.0.3",
"form-data": "^4.0.1",
"jsonc-parser": "^2.2.1",
Expand Down
29 changes: 20 additions & 9 deletions src/commands/accounts/selectSubscriptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,15 @@ import { settingUtils } from "../../utils/settingUtils";

export interface SelectSubscriptionOptions {
/**
* If provided, only subscriptions in this tenant will be shown in the picker. Only subscriptions shown in the picker will be removed or added to the selected subscriptions setting.
* If provided, only subscriptions in this tenant will be shown in the picker.
*
* Only subscriptions shown in the picker will be removed or added to the selected subscriptions setting.
*/
tenantId?: string;
/**
* TODO: implement filtering at the account level
* If provided, only subscriptions from this account will be shown in the picker.
*
* Only subscriptions shown in the picker will be removed or added to the selected subscriptions setting.
*/
account?: vscode.AuthenticationSessionAccountInformation;
}
Expand All @@ -33,16 +37,22 @@ export async function selectSubscriptions(context: IActionContext, options?: Sel

const subscriptionQuickPickItems: () => Promise<IAzureQuickPickItem<AzureSubscription>[]> = async () => {
// If there are no tenants selected by default all subscriptions will be shown.
const allSubscriptions = await provider.getSubscriptions(false);
const subscriptionsFilteredByTenant = options?.tenantId ? allSubscriptions.filter(subscription => subscription.tenantId === options.tenantId) : allSubscriptions;
const duplicates = getDuplicateSubscriptions(allSubscriptions);
let subscriptions = await provider.getSubscriptions(false);
if (options?.account) {
subscriptions = subscriptions.filter(subscription => subscription.account.id === options.account?.id);
}
if (options?.tenantId) {
subscriptions = subscriptions.filter(subscription => subscription.tenantId === options.tenantId);
}
const duplicates = getDuplicateSubscriptions(subscriptions);

subscriptionsShownInPicker = subscriptionsFilteredByTenant.map(sub => `${sub.tenantId}/${sub.subscriptionId}`);
return subscriptionsFilteredByTenant
.map(subscription => ({
subscriptionsShownInPicker = subscriptions.map(sub => `${sub.tenantId}/${sub.subscriptionId}`);
return subscriptions
.map(subscription => (<IAzureQuickPickItem<AzureSubscription>>{
label: duplicates.includes(subscription) ? subscription.name + ` (${subscription.account?.label})` : subscription.name,
description: subscription.subscriptionId,
data: subscription
data: subscription,
group: subscription.account.label
}))
.sort((a, b) => a.label.localeCompare(b.label));
}
Expand All @@ -54,6 +64,7 @@ export async function selectSubscriptions(context: IActionContext, options?: Sel
return selectedSubscriptionIds.length === 0 || selectedSubscriptionIds.includes((pick as IAzureQuickPickItem<AzureSubscription>).data.subscriptionId);
},
canPickMany: true,
enableGrouping: true,
placeHolder: localize('selectSubscriptions', 'Select Subscriptions')
});

Expand Down
2 changes: 1 addition & 1 deletion src/tree/azure/SubscriptionItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class SubscriptionItem implements ResourceGroupsItem {
this.id = `/accounts/${nonNullValueAndProp(subscription.account, 'id')}/tenants/${subscription.tenantId}/subscriptions/${subscription.subscriptionId}`;
this.description = description ? description : '';

this.portalUrl = createPortalUrl(this.subscription, this.id);
this.portalUrl = createPortalUrl(this.subscription, `/subscriptions/${this.subscription.subscriptionId}`);
}

public readonly portalUrl: vscode.Uri;
Expand Down

0 comments on commit 4246947

Please sign in to comment.