in ui/src/tree/AzureAccountTreeItemBase.ts [69:148]
public async loadMoreChildrenImpl(_clearCache: boolean, context: types.IActionContext): Promise<AzExtTreeItem[]> {
let azureAccount: AzureAccountResult = await this._azureAccountTask;
if (typeof azureAccount === 'string') {
// Refresh the AzureAccount, to handle Azure account extension installation after the previous refresh
this._azureAccountTask = this.loadAzureAccount(this._testAccount);
azureAccount = await this._azureAccountTask;
}
if (typeof azureAccount === 'string') {
context.telemetry.properties.accountStatus = azureAccount;
const label: string = azureAccount === 'notInstalled' ?
localize('installAzureAccount', 'Install Azure Account Extension...') :
localize('updateAzureAccount', 'Update Azure Account Extension to at least version "{0}"...', minAccountExtensionVersion);
const iconPath: types.TreeItemIconPath = new ThemeIcon('warning');
const result: AzExtTreeItem = new GenericTreeItem(this, { label, commandId: extensionOpenCommand, contextValue: 'azureAccount' + azureAccount, includeInTreeItemPicker: true, iconPath });
result.commandArgs = [azureAccountExtensionId];
return [result];
}
context.telemetry.properties.accountStatus = azureAccount.status;
const existingSubscriptions: SubscriptionTreeItemBase[] = this._subscriptionTreeItems ? this._subscriptionTreeItems : [];
this._subscriptionTreeItems = [];
const contextValue: string = 'azureCommand';
if (azureAccount.status === 'Initializing' || azureAccount.status === 'LoggingIn') {
return [new GenericTreeItem(this, {
label: azureAccount.status === 'Initializing' ? localize('loadingTreeItem', 'Loading...') : localize('signingIn', 'Waiting for Azure sign-in...'),
commandId: signInCommandId,
contextValue,
id: signInCommandId,
iconPath: new ThemeIcon('loading~spin')
})];
} else if (azureAccount.status === 'LoggedOut') {
return [
new GenericTreeItem(this, { label: signInLabel, commandId: signInCommandId, contextValue, id: signInCommandId, iconPath: new ThemeIcon('sign-in'), includeInTreeItemPicker: true }),
new GenericTreeItem(this, { label: createAccountLabel, commandId: createAccountCommandId, contextValue, id: createAccountCommandId, iconPath: new ThemeIcon('add'), includeInTreeItemPicker: true })
];
}
await azureAccount.waitForFilters();
if (azureAccount.filters.length === 0) {
return [
new GenericTreeItem(this, { label: selectSubscriptionsLabel, commandId: selectSubscriptionsCommandId, contextValue, id: selectSubscriptionsCommandId, includeInTreeItemPicker: true })
];
} else {
this._subscriptionTreeItems = await Promise.all(azureAccount.filters.map(async (filter: AzureResourceFilter) => {
const existingTreeItem: SubscriptionTreeItemBase | undefined = existingSubscriptions.find(ti => ti.id === filter.subscription.id);
if (existingTreeItem) {
// Return existing treeItem (which might have many 'cached' tree items underneath it) rather than creating a brand new tree item every time
return existingTreeItem;
} else {
addExtensionValueToMask(
filter.subscription.id,
filter.subscription.subscriptionId,
filter.subscription.displayName,
filter.session.userId,
filter.session.tenantId,
filter.session.credentials2.clientId,
filter.session.credentials2.domain
);
// filter.subscription.id is the The fully qualified ID of the subscription (For example, /subscriptions/00000000-0000-0000-0000-000000000000) and should be used as the tree item's id for the purposes of OpenInPortal
// filter.subscription.subscriptionId is just the guid and is used in all other cases when creating clients for managing Azure resources
const subscriptionId: string = nonNullProp(filter.subscription, 'subscriptionId');
return await this.createSubscriptionTreeItem({
credentials: filter.session.credentials2,
subscriptionDisplayName: nonNullProp(filter.subscription, 'displayName'),
subscriptionId,
subscriptionPath: nonNullProp(filter.subscription, 'id'),
tenantId: filter.session.tenantId,
userId: filter.session.userId,
environment: filter.session.environment,
isCustomCloud: filter.session.environment.name === 'AzureCustomCloud'
});
}
}));
return this._subscriptionTreeItems;
}
}