Skip to content

Commit

Permalink
fix subscription filter (#975)
Browse files Browse the repository at this point in the history
Co-authored-by: alexweininger <[email protected]>
  • Loading branch information
motm32 and alexweininger authored Dec 6, 2024
1 parent f61558e commit f264fd8
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/commands/accounts/selectSubscriptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,17 @@ 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.
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);

if (options?.account || options?.tenantId) {

if (options?.account) {
subscriptions = subscriptions.filter(subscription => subscription.account.id === options.account?.id);
}
if (options?.tenantId) {
subscriptions = subscriptions.filter(subscription => subscription.tenantId === options.tenantId);
}
} else {
subscriptions = getTenantFilteredSubscriptions(subscriptions);
}
const duplicates = getDuplicateSubscriptions(subscriptions);

Expand Down Expand Up @@ -110,7 +116,7 @@ async function setSelectedTenantAndSubscriptionIds(tenantAndSubscriptionIds: str
}

// This function is also used to filter subscription tree items in AzureResourceTreeDataProvider
export function getTenantFilteredSubscriptions(allSubscriptions: AzureSubscription[]): AzureSubscription[] | undefined {
export function getTenantFilteredSubscriptions(allSubscriptions: AzureSubscription[]): AzureSubscription[] {
const filteredSubscriptions = allSubscriptions.filter(subscription => !isTenantFilteredOut(subscription.tenantId, subscription.account.id));
return filteredSubscriptions.length > 0 ? filteredSubscriptions : allSubscriptions;
}
Expand Down

0 comments on commit f264fd8

Please sign in to comment.