Skip to content

Commit

Permalink
Fix remaining issues from #707 (#728)
Browse files Browse the repository at this point in the history
  • Loading branch information
bwateratmsft authored Jul 26, 2023
1 parent cd14e8a commit ea3c668
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 23 deletions.
20 changes: 9 additions & 11 deletions package-lock.json

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

6 changes: 1 addition & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -384,10 +384,6 @@
}
],
"commandPalette": [
{
"command": "azureResourceGroups.logIn",
"when": "isWeb"
},
{
"command": "azureResourceGroups.showGroupOptions",
"when": "never"
Expand Down Expand Up @@ -614,7 +610,7 @@
"@azure/arm-resources": "^5.2.0",
"@azure/arm-resources-profile-2020-09-01-hybrid": "^2.1.0",
"@azure/arm-subscriptions": "^5.1.0",
"@microsoft/vscode-azext-azureauth": "^1.0.0",
"@microsoft/vscode-azext-azureauth": "^1.1.2",
"@microsoft/vscode-azext-azureutils": "^2.0.0",
"@microsoft/vscode-azext-utils": "^2.0.0",
"buffer": "^6.0.3",
Expand Down
18 changes: 15 additions & 3 deletions src/commands/accounts/logIn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,20 @@
import { IActionContext } from '@microsoft/vscode-azext-utils';
import { ext } from '../../extensionVariables';

let _isLoggingIn: boolean = false;

export async function logIn(_context: IActionContext): Promise<void> {
const provider = await ext.subscriptionProviderFactory();
await provider.signIn();
ext.actions.refreshAzureTree();
try {
const provider = await ext.subscriptionProviderFactory();
_isLoggingIn = true;
ext.actions.refreshAzureTree(); // Refresh to cause the "logging in" spinner to show
await provider.signIn();
} finally {
_isLoggingIn = false;
ext.actions.refreshAzureTree(); // Refresh now that sign in is complete
}
}

export function isLoggingIn(): boolean {
return _isLoggingIn;
}
2 changes: 1 addition & 1 deletion src/commands/accounts/selectSubscriptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export async function selectSubscriptions(context: IActionContext): Promise<void
subscriptionQuickPickItems(),
{
isPickSelected: (pick) => {
return selectedSubscriptionIds.includes((pick as IAzureQuickPickItem<AzureSubscription>).data.subscriptionId);
return selectedSubscriptionIds.length === 0 || selectedSubscriptionIds.includes((pick as IAzureQuickPickItem<AzureSubscription>).data.subscriptionId);
},
canPickMany: true,
placeHolder: localize('selectSubscriptions', 'Select Subscriptions')
Expand Down
11 changes: 10 additions & 1 deletion src/tree/azure/AzureResourceTreeDataProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { IActionContext, registerEvent } from '@microsoft/vscode-azext-utils';
import * as vscode from 'vscode';
import { ResourceModelBase } from '../../../api/src/index';
import { AzureResourceProviderManager } from '../../api/ResourceProviderManagers';
import { isLoggingIn } from '../../commands/accounts/logIn';
import { showHiddenTypesSettingKey } from '../../constants';
import { ext } from '../../extensionVariables';
import { localize } from '../../utils/localize';
Expand Down Expand Up @@ -68,7 +69,15 @@ export class AzureResourceTreeDataProvider extends AzureResourceTreeDataProvider
const subscriptionProvider = await this.getAzureSubscriptionProvider();

if (subscriptionProvider) {
if (await subscriptionProvider.isSignedIn()) {
if (isLoggingIn()) {
return [new GenericItem(
localize('signingIn', 'Waiting for Azure sign-in...'),
{
commandId: 'azureResourceGroups.logIn',
iconPath: new vscode.ThemeIcon('loading~spin')
}
)];
} else if (await subscriptionProvider.isSignedIn()) {
let subscriptions: AzureSubscription[];

if ((subscriptions = await subscriptionProvider.getSubscriptions(true)).length === 0) {
Expand Down
2 changes: 0 additions & 2 deletions src/tree/azure/AzureResourceTreeDataProviderBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ export abstract class AzureResourceTreeDataProviderBase extends ResourceTreeData
// This event gets HEAVILY spammed and needs to be debounced
// Suppress additional messages for 1 second after the first one
this.notifyTreeDataChanged();
} else {
console.log("Too soon, ignoring this event");
}
}
});
Expand Down

0 comments on commit ea3c668

Please sign in to comment.