Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/api-v2' into alex/api-v2-edit-tags
Browse files Browse the repository at this point in the history
  • Loading branch information
alexweininger committed Dec 20, 2022
2 parents 4f40a56 + 18c66ee commit 78eea8c
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 18 deletions.
12 changes: 9 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@
"category": "Azure",
"icon": "$(refresh)"
},
{
"command": "azureResourceGroups.refreshAzureItem",
"title": "%azureResourceGroups.refresh%",
"category": "Azure",
"icon": "$(refresh)"
},
{
"command": "azureResourceGroups.revealResource",
"title": "%azureResourceGroups.revealResource%",
Expand Down Expand Up @@ -319,7 +325,7 @@
"group": "9@1"
},
{
"command": "azureResourceGroups.refresh",
"command": "azureResourceGroups.refreshAzureItem",
"when": "view == azureResourceGroups && viewItem == azureextensionui.azureSubscription",
"group": "9@2"
},
Expand All @@ -339,7 +345,7 @@
"group": "9@2"
},
{
"command": "azureResourceGroups.refresh",
"command": "azureResourceGroups.refreshAzureItem",
"when": "view == azureResourceGroups && viewItem =~ /azureResource/",
"group": "9@3"
},
Expand All @@ -359,7 +365,7 @@
"group": "9@1"
},
{
"command": "azureResourceGroups.refresh",
"command": "azureResourceGroups.refreshAzureItem",
"when": "view == azureResourceGroups && viewItem =~ /group/",
"group": "inline@1"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export class CompatibilityWorkspaceResourceProvider implements V2WorkspaceResour
treeDataProvider: new CompatibleWorkspaceResourceBranchDataProvider('azureWorkspace.loadMore'),
valuesToMask: [],
parent: undefined,
fullId: '', // prevent ids from starting with undefined
} as unknown as AzExtParentTreeItem
);

Expand Down
6 changes: 4 additions & 2 deletions src/commands/registerCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import { AzExtTreeItem, IActionContext, openUrl, registerCommand, registerErrorHandler, registerReportIssueCommand } from '@microsoft/vscode-azext-utils';
import { commands } from 'vscode';
import { ext } from '../extensionVariables';
import { ResourceGroupsItem } from '../tree/v2/ResourceGroupsItem';
import { clearActivities } from './activities/clearActivities';
import { createResource } from './createResource';
import { createResourceGroup } from './createResourceGroup';
Expand All @@ -31,7 +32,8 @@ export function registerCommands(): void {
registerCommand('azureResourceGroups.deleteResourceGroupV2', deleteResourceGroupV2);
registerCommand('azureResourceGroups.loadMore', async (context: IActionContext, node: AzExtTreeItem) => await ext.appResourceTree.loadMore(node, context));
registerCommand('azureResourceGroups.openInPortal', openInPortal);
registerCommand('azureResourceGroups.refresh', ext.actions.refreshAzureTree);
registerCommand('azureResourceGroups.refresh', () => ext.actions.refreshAzureTree()); // don't pass in selected node to always refresh entire tree
registerCommand('azureResourceGroups.refreshAzureItem', (_context, node?: ResourceGroupsItem) => ext.actions.refreshAzureTree(node));
registerCommand('azureResourceGroups.revealResource', revealResource);
registerCommand('azureResourceGroups.selectSubscriptions', () => commands.executeCommand('azure-account.selectSubscriptions'));
registerCommand('azureResourceGroups.viewProperties', viewProperties);
Expand Down Expand Up @@ -66,6 +68,6 @@ export function registerCommands(): void {
await openUrl(url)
});

registerCommand('azureWorkspace.refresh', ext.actions.refreshWorkspaceTree);
registerCommand('azureWorkspace.refresh', () => ext.actions.refreshWorkspaceTree()); // don't pass in selected node to always refresh entire tree
registerCommand('azureWorkspace.loadMore', async (context: IActionContext, node: AzExtTreeItem) => await ext.workspaceTree.loadMore(node, context));
}
11 changes: 6 additions & 5 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { HelpTreeItem } from './tree/HelpTreeItem';
import { AzureResourceBranchDataProviderManager } from './tree/v2/azure/AzureResourceBranchDataProviderManager';
import { DefaultAzureResourceBranchDataProvider } from './tree/v2/azure/DefaultAzureResourceBranchDataProvider';
import { registerAzureTree } from './tree/v2/azure/registerAzureTree';
import { ResourceGroupsItem } from './tree/v2/ResourceGroupsItem';
import { registerWorkspaceTree } from './tree/v2/workspace/registerWorkspaceTree';
import { WorkspaceDefaultBranchDataProvider } from './tree/v2/workspace/WorkspaceDefaultBranchDataProvider';
import { WorkspaceResourceBranchDataProviderManager } from './tree/v2/workspace/WorkspaceResourceBranchDataProviderManager';
Expand All @@ -44,13 +45,13 @@ export async function activateInternal(context: vscode.ExtensionContext, perfSta
registerUIExtensionVariables(ext);
registerAzureUtilsExtensionVariables(ext);

const refreshAzureTreeEmitter = new vscode.EventEmitter<void>();
const refreshAzureTreeEmitter = new vscode.EventEmitter<void | ResourceGroupsItem | ResourceGroupsItem[] | null | undefined>();
context.subscriptions.push(refreshAzureTreeEmitter);
const refreshWorkspaceTreeEmitter = new vscode.EventEmitter<void>();
const refreshWorkspaceTreeEmitter = new vscode.EventEmitter<void | ResourceGroupsItem | ResourceGroupsItem[] | null | undefined>();
context.subscriptions.push(refreshWorkspaceTreeEmitter);

ext.actions.refreshWorkspaceTree = () => refreshWorkspaceTreeEmitter.fire();
ext.actions.refreshAzureTree = () => refreshAzureTreeEmitter.fire();
ext.actions.refreshWorkspaceTree = (data) => refreshWorkspaceTreeEmitter.fire(data);
ext.actions.refreshAzureTree = (data) => refreshAzureTreeEmitter.fire(data);

await callWithTelemetryAndErrorHandling('azureResourceGroups.activate', async (activateContext: IActionContext) => {
activateContext.telemetry.properties.isActivationEvent = 'true';
Expand Down Expand Up @@ -99,7 +100,7 @@ export async function activateInternal(context: vscode.ExtensionContext, perfSta
const workspaceResourceTreeDataProvider = registerWorkspaceTree(context, {
workspaceResourceProviderManager,
workspaceResourceBranchDataProviderManager,
refreshEvent: refreshAzureTreeEmitter.event,
refreshEvent: refreshWorkspaceTreeEmitter.event,
});

const v2ApiFactory: AzureExtensionApiFactory<AzureResourcesApiInternal> = {
Expand Down
5 changes: 3 additions & 2 deletions src/extensionVariables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { AzureResourcesApiInternal } from "../hostapi.v2.internal";
import { ActivityLogTreeItem } from "./activityLog/ActivityLogsTreeItem";
import { TagFileSystem } from "./commands/tags/TagFileSystem";
import { AzureAccountTreeItem } from "./tree/AzureAccountTreeItem";
import { ResourceGroupsItem } from "./tree/v2/ResourceGroupsItem";
import { ExtensionActivationManager } from "./utils/ExtensionActivationManager";

namespace extEmitters {
Expand All @@ -23,8 +24,8 @@ namespace extEvents {
}

export namespace extActions {
export let refreshWorkspaceTree: () => void;
export let refreshAzureTree: () => void;
export let refreshWorkspaceTree: (data?: ResourceGroupsItem | ResourceGroupsItem[] | null | undefined | void) => void;
export let refreshAzureTree: (data?: ResourceGroupsItem | ResourceGroupsItem[] | null | undefined | void) => void;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/tree/v2/ResourceTreeDataProviderBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export abstract class ResourceTreeDataProviderBase extends vscode.Disposable imp
protected readonly itemCache: BranchDataItemCache,
onDidChangeBranchTreeData: vscode.Event<void | ResourceModelBase | ResourceModelBase[] | null | undefined>,
onDidChangeResource: vscode.Event<ResourceBase | undefined>,
onRefresh: vscode.Event<void>,
onRefresh: vscode.Event<void | ResourceGroupsItem | ResourceGroupsItem[] | null | undefined>,
callOnDispose?: () => void) {
super(
() => {
Expand Down Expand Up @@ -55,7 +55,7 @@ export abstract class ResourceTreeDataProviderBase extends vscode.Disposable imp
}
});

this.refreshSubscription = onRefresh(() => this.onDidChangeTreeDataEmitter.fire());
this.refreshSubscription = onRefresh((e) => this.onDidChangeTreeDataEmitter.fire(e));

// TODO: If only individual resources change, just update the tree related to those resources.
this.resourceProviderManagerListener = onDidChangeResource(() => this.onDidChangeTreeDataEmitter.fire());
Expand Down
2 changes: 1 addition & 1 deletion src/tree/v2/azure/AzureResourceTreeDataProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class AzureResourceTreeDataProvider extends ResourceTreeDataProviderBase
constructor(
onDidChangeBranchTreeData: vscode.Event<void | ResourceModelBase | ResourceModelBase[] | null | undefined>,
itemCache: BranchDataItemCache,
onRefresh: vscode.Event<void>,
onRefresh: vscode.Event<void | ResourceGroupsItem | ResourceGroupsItem[] | null | undefined>,
private readonly resourceGroupingManager: AzureResourceGroupingManager,
private readonly resourceProviderManager: AzureResourceProviderManager) {
super(
Expand Down
7 changes: 6 additions & 1 deletion src/tree/v2/azure/registerAzureTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { AzExtTreeItem } from '@microsoft/vscode-azext-utils';
import { AzureResource } from '@microsoft/vscode-azext-utils/hostapi.v2';
import * as vscode from 'vscode';
import { AzureResourceProviderManager } from '../../../api/v2/ResourceProviderManagers';
import { ext } from '../../../extensionVariables';
import { BranchDataItemCache } from '../BranchDataItemCache';
import { ResourceGroupsItem } from '../ResourceGroupsItem';
import { localize } from './../../../utils/localize';
import { AzureResourceBranchDataProviderManager } from './AzureResourceBranchDataProviderManager';
import { AzureResourceGroupingManager } from './AzureResourceGroupingManager';
Expand All @@ -17,7 +20,7 @@ import { createGroupingItemFactory } from './GroupingItem';
interface RegisterAzureTreeOptions {
azureResourceBranchDataProviderManager: AzureResourceBranchDataProviderManager,
azureResourceProviderManager: AzureResourceProviderManager,
refreshEvent: vscode.Event<void>,
refreshEvent: vscode.Event<void | ResourceGroupsItem | ResourceGroupsItem[] | null | undefined>,
}

export function registerAzureTree(context: vscode.ExtensionContext, options: RegisterAzureTreeOptions): AzureResourceTreeDataProvider {
Expand All @@ -43,5 +46,7 @@ export function registerAzureTree(context: vscode.ExtensionContext, options: Reg

treeView.description = localize('remote', 'Remote');

ext.appResourceTreeView = treeView as unknown as vscode.TreeView<AzExtTreeItem>;

return azureResourceTreeDataProvider;
}
2 changes: 1 addition & 1 deletion src/tree/v2/workspace/WorkspaceResourceTreeDataProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { WorkspaceResourceBranchDataProviderManager } from './WorkspaceResourceB
export class WorkspaceResourceTreeDataProvider extends ResourceTreeDataProviderBase {
constructor(
private readonly branchDataProviderManager: WorkspaceResourceBranchDataProviderManager,
onRefresh: vscode.Event<void>,
onRefresh: vscode.Event<void | ResourceGroupsItem | ResourceGroupsItem[] | null | undefined>,
private readonly resourceProviderManager: WorkspaceResourceProviderManager) {
super(
new BranchDataItemCache(),
Expand Down
7 changes: 6 additions & 1 deletion src/tree/v2/workspace/registerWorkspaceTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { AzExtTreeItem } from '@microsoft/vscode-azext-utils';
import * as vscode from 'vscode';
import { WorkspaceResourceProviderManager } from '../../../api/v2/ResourceProviderManagers';
import { ext } from '../../../extensionVariables';
import { ResourceGroupsItem } from '../ResourceGroupsItem';
import { localize } from './../../../utils/localize';
import { WorkspaceResourceBranchDataProviderManager } from './WorkspaceResourceBranchDataProviderManager';
import { WorkspaceResourceTreeDataProvider } from './WorkspaceResourceTreeDataProvider';

interface RegisterWorkspaceTreeOptions {
workspaceResourceBranchDataProviderManager: WorkspaceResourceBranchDataProviderManager,
workspaceResourceProviderManager: WorkspaceResourceProviderManager,
refreshEvent: vscode.Event<void>,
refreshEvent: vscode.Event<void | ResourceGroupsItem | ResourceGroupsItem[] | null | undefined>,
}

export function registerWorkspaceTree(context: vscode.ExtensionContext, options: RegisterWorkspaceTreeOptions): WorkspaceResourceTreeDataProvider {
Expand All @@ -31,5 +34,7 @@ export function registerWorkspaceTree(context: vscode.ExtensionContext, options:

treeView.description = localize('local', 'Local');

ext.workspaceTreeView = treeView as unknown as vscode.TreeView<AzExtTreeItem>;

return workspaceResourceTreeDataProvider;
}

0 comments on commit 78eea8c

Please sign in to comment.