-
Notifications
You must be signed in to change notification settings - Fork 32
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
Add Tenant view telemetry and sign in button on tenant view #979
Changes from 2 commits
e503627
35c5a2e
ae8212e
4246947
3f8080c
38671a8
b786c17
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import { AzureSubscriptionProvider, getConfiguredAuthProviderId } from '@microsoft/vscode-azext-azureauth'; | ||
import { nonNullProp, nonNullValueAndProp } from '@microsoft/vscode-azext-utils'; | ||
import { callWithTelemetryAndErrorHandling, IActionContext, nonNullProp, nonNullValueAndProp } from '@microsoft/vscode-azext-utils'; | ||
import { ResourceModelBase } from 'api/src'; | ||
import * as vscode from 'vscode'; | ||
import { TenantResourceProviderManager } from '../../api/ResourceProviderManagers'; | ||
|
@@ -43,36 +43,39 @@ export class TenantResourceTreeDataProvider extends ResourceTreeDataProviderBase | |
} | ||
|
||
async onGetChildren(element?: ResourceGroupsItem | undefined): Promise<ResourceGroupsItem[] | null | undefined> { | ||
if (element) { | ||
return await element.getChildren(); | ||
} else { | ||
const subscriptionProvider = await getAzureSubscriptionProvider(this); | ||
const children: ResourceGroupsItem[] = await OnGetChildrenBase(subscriptionProvider); | ||
return await callWithTelemetryAndErrorHandling('tenantResourceTreeDataProvider.onGetChildren', async (context: IActionContext) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nathan might have input here, but do we want to expose our implementation details in telemetry? A better name might be |
||
if (element) { | ||
return await element.getChildren(); | ||
} else { | ||
const subscriptionProvider = await getAzureSubscriptionProvider(this); | ||
const children: ResourceGroupsItem[] = await OnGetChildrenBase(subscriptionProvider); | ||
|
||
if (children.length === 0) { | ||
const accounts = await vscode.authentication.getAccounts(getConfiguredAuthProviderId()); | ||
for (const account of accounts) { | ||
const tenants = await subscriptionProvider.getTenants(account); | ||
const tenantItems: ResourceGroupsItem[] = []; | ||
for await (const tenant of tenants) { | ||
const isSignedIn = await subscriptionProvider.isSignedIn(nonNullProp(tenant, 'tenantId'), account); | ||
tenantItems.push(new TenantTreeItem(tenant, account, { | ||
contextValue: isSignedIn ? 'tenantName' : 'tenantNameNotSignedIn', | ||
checkboxState: (!isSignedIn || isTenantFilteredOut(nonNullProp(tenant, 'tenantId'), account.id)) ? | ||
vscode.TreeItemCheckboxState.Unchecked : vscode.TreeItemCheckboxState.Checked, | ||
description: tenant.tenantId | ||
if (children.length === 0) { | ||
const accounts = await vscode.authentication.getAccounts(getConfiguredAuthProviderId()); | ||
context.telemetry.properties.accountCount = accounts.length.toString(); | ||
for (const account of accounts) { | ||
const tenants = await subscriptionProvider.getTenants(account); | ||
const tenantItems: ResourceGroupsItem[] = []; | ||
for await (const tenant of tenants) { | ||
const isSignedIn = await subscriptionProvider.isSignedIn(nonNullProp(tenant, 'tenantId'), account); | ||
tenantItems.push(new TenantTreeItem(tenant, account, { | ||
contextValue: isSignedIn ? 'tenantName' : 'tenantNameNotSignedIn', | ||
checkboxState: (!isSignedIn || isTenantFilteredOut(nonNullProp(tenant, 'tenantId'), account.id)) ? | ||
vscode.TreeItemCheckboxState.Unchecked : vscode.TreeItemCheckboxState.Checked, | ||
description: tenant.tenantId | ||
})); | ||
} | ||
|
||
children.push(new GenericItem(nonNullValueAndProp(account, 'label'), { | ||
children: tenantItems, | ||
iconPath: new vscode.ThemeIcon('account'), | ||
contextValue: 'accountName', | ||
collapsibleState: vscode.TreeItemCollapsibleState.Expanded, | ||
})); | ||
} | ||
|
||
children.push(new GenericItem(nonNullValueAndProp(account, 'label'), { | ||
children: tenantItems, | ||
iconPath: new vscode.ThemeIcon('account'), | ||
contextValue: 'accountName', | ||
collapsibleState: vscode.TreeItemCollapsibleState.Expanded, | ||
})); | ||
} | ||
return children; | ||
} | ||
return children; | ||
} | ||
}); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -56,8 +56,10 @@ async function updateTenantsSetting(_context: IActionContext, tenants: vscode.Tr | |||||
|
||||||
for (const [tenantTreeItem, state] of tenants.items) { | ||||||
if (state === vscode.TreeItemCheckboxState.Unchecked) { | ||||||
_context.telemetry.properties.uncheckedTenant = 'true'; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We use this now so remove the underscore.
Suggested change
|
||||||
unselectedTenantsSet.add(getKeyForTenant(tenantTreeItem.tenantId, tenantTreeItem.account.id)); | ||||||
} else if (state === vscode.TreeItemCheckboxState.Checked) { | ||||||
_context.telemetry.properties.checkedTenant = 'true'; | ||||||
const treeItem = await tenantTreeItem.getTreeItem(); | ||||||
if (treeItem?.contextValue === 'tenantNameNotSignedIn') { | ||||||
await vscode.commands.executeCommand('azureTenantsView.signInToTenant', tenantTreeItem); | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we prefix this command like:
azureTenantsView.logInButton
?