Refactor to remove controller and static instance (#5735)

This commit is contained in:
Kevin Cunnane
2019-05-29 17:23:23 -07:00
committed by GitHub
parent ea8aa92dd5
commit 6d56701b5b
11 changed files with 134 additions and 167 deletions

View File

@@ -15,7 +15,7 @@ import { azureResource } from '../azure-resource';
import { TreeNode } from '../treeNode';
import { IAzureResourceNodeWithProviderId } from '../interfaces';
import { AzureResourceContainerTreeNodeBase } from './baseTreeNodes';
import { AzureResourceItemType } from '../constants';
import { AzureResourceItemType, AzureResourceServiceNames } from '../constants';
import { IAzureResourceTreeChangeHandler } from './treeChangeHandler';
import { AzureResourceMessageTreeNode } from '../messageTreeNode';
import { AzureResourceErrorMessageUtil } from '../utils';
@@ -39,7 +39,7 @@ export class AzureResourceSubscriptionTreeNode extends AzureResourceContainerTre
public async getChildren(): Promise<TreeNode[]> {
try {
const resourceService = AzureResourceService.getInstance();
const resourceService = this.appContext.getService<AzureResourceService>(AzureResourceServiceNames.resourceService);
const children: IAzureResourceNodeWithProviderId[] = [];
@@ -53,7 +53,7 @@ export class AzureResourceSubscriptionTreeNode extends AzureResourceContainerTre
return children.map((child) => {
// To make tree node's id unique, otherwise, treeModel.js would complain 'item already registered'
child.resourceNode.treeItem.id = `${this._id}.${child.resourceNode.treeItem.id}`;
return new AzureResourceResourceTreeNode(child, this);
return new AzureResourceResourceTreeNode(child, this, this.appContext);
});
}
} catch (error) {

View File

@@ -22,9 +22,7 @@ import { IAzureResourceAccountService } from '../../azureResource/interfaces';
import { AzureResourceServiceNames } from '../constants';
export class AzureResourceTreeProvider implements TreeDataProvider<TreeNode>, IAzureResourceTreeChangeHandler {
public constructor(
public readonly appContext: AppContext
) {
public constructor(public readonly appContext: AppContext) {
}
public async getChildren(element?: TreeNode): Promise<TreeNode[]> {