Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prompt users to sign in to a directory #756

Merged
merged 1 commit into from
Oct 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions src/tree/azure/AzureResourceTreeDataProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { AzureSubscription } from '@microsoft/vscode-azext-azureauth';
import { AzureSubscription, getUnauthenticatedTenants } from '@microsoft/vscode-azext-azureauth';
import { IActionContext, registerEvent } from '@microsoft/vscode-azext-utils';
import * as vscode from 'vscode';
import { ResourceModelBase } from '../../../api/src/index';
Expand Down Expand Up @@ -79,11 +79,21 @@ export class AzureResourceTreeDataProvider extends AzureResourceTreeDataProvider
)];
} else if (await subscriptionProvider.isSignedIn()) {
let subscriptions: AzureSubscription[];

if ((subscriptions = await subscriptionProvider.getSubscriptions(true)).length === 0) {
return [new GenericItem(localize('noSubscriptions', 'Select Subscriptions...'), {
commandId: 'azureResourceGroups.selectSubscriptions'
})]
if (
// If there are no subscriptions at all (ignoring filters) AND if unauthenicated tenants exist
(await subscriptionProvider.getSubscriptions(false)).length === 0 &&
(await getUnauthenticatedTenants(subscriptionProvider)).length > 0
) {
// Subscriptions might exist in an unauthenticated tenant
return [new GenericItem(localize('signInToDirectory', 'Sign in to Directory...'), {
commandId: 'azureResourceGroups.signInToTenant'
})];
} else {
return [new GenericItem(localize('noSubscriptions', 'Select Subscriptions...'), {
commandId: 'azureResourceGroups.selectSubscriptions'
})]
}
} else {
return subscriptions.map(
subscription => new SubscriptionItem(
Expand Down