-
Notifications
You must be signed in to change notification settings - Fork 46
Expand file tree
/
Copy pathregisterCommands.ts
More file actions
91 lines (79 loc) · 5.48 KB
/
registerCommands.ts
File metadata and controls
91 lines (79 loc) · 5.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { AzExtTreeItem, IActionContext, isAzExtTreeItem, openUrl, registerCommand, registerErrorHandler, registerReportIssueCommand } from '@microsoft/vscode-azext-utils';
import { commands } from 'vscode';
import { ext } from '../extensionVariables';
import { BranchDataItemWrapper } from '../tree/BranchDataProviderItem';
import { ResourceGroupsItem } from '../tree/ResourceGroupsItem';
import { GroupingItem } from '../tree/azure/GroupingItem';
import { clearActivities } from './activities/clearActivities';
import { createResource } from './createResource';
import { createResourceGroup } from './createResourceGroup';
import { deleteResourceGroupV2 } from './deleteResourceGroup/v2/deleteResourceGroupV2';
import { buildGroupByCommand } from './explorer/groupBy';
import { showGroupOptions } from './explorer/showGroupOptions';
import { getStarted } from './helpAndFeedback/getStarted';
import { reportIssue } from './helpAndFeedback/reportIssue';
import { reviewIssues } from './helpAndFeedback/reviewIssues';
import { installExtension } from './installExtension';
import { openInPortal } from './openInPortal';
import { revealResource } from './revealResource';
import { editTags } from './tags/editTags';
import { viewProperties } from './viewProperties';
export function registerCommands(): void {
// Special-case refresh that ignores the selected/focused node and always refreshes the entire tree. Used by the refresh button in the tree title.
registerCommand('azureResourceGroups.refreshTree', () => ext.actions.refreshAzureTree());
registerCommand('azureWorkspace.refreshTree', () => ext.actions.refreshWorkspaceTree());
// v1.5 client extensions attach these commands to tree item context menus for refreshing their tree items
registerCommand('azureResourceGroups.refresh', async (context, node?: ResourceGroupsItem) => {
await handleAzExtTreeItemRefresh(context, node); // for compatibility with v1.5 client extensions
if (node instanceof GroupingItem) {
ext.actions.refreshAzureTree(node.parent);
} else {
ext.actions.refreshAzureTree(node);
}
});
registerCommand('azureWorkspace.refresh', async (context, node?: ResourceGroupsItem) => {
await handleAzExtTreeItemRefresh(context, node); // for compatibility with v1.5 client extensions
ext.actions.refreshWorkspaceTree(node);
});
registerCommand('azureResourceGroups.createResourceGroup', createResourceGroup);
registerCommand('azureResourceGroups.deleteResourceGroupV2', deleteResourceGroupV2);
registerCommand('azureResourceGroups.loadMore', async (context: IActionContext, node: AzExtTreeItem) => await ext.appResourceTree.loadMore(node, context));
registerCommand('azureResourceGroups.openInPortal', openInPortal);
registerCommand('azureResourceGroups.revealResource', revealResource);
registerCommand('azureResourceGroups.selectSubscriptions', () => commands.executeCommand('azure-account.selectSubscriptions'));
registerCommand('azureResourceGroups.viewProperties', viewProperties);
registerCommand('azureResourceGroups.editTags', editTags);
registerCommand('ms-azuretools.getStarted', getStarted);
registerCommand('ms-azuretools.loadMore', async (context: IActionContext, node: AzExtTreeItem) => await ext.helpTree.loadMore(node, context));
registerCommand('ms-azuretools.reportIssue', reportIssue);
registerCommand('ms-azuretools.reviewIssues', reviewIssues);
registerCommand('ms-azuretools.openWalkthrough', () => commands.executeCommand('workbench.action.openWalkthrough', `ms-azuretools.vscode-azureresourcegroups#azure-get-started`));
// Suppress "Report an Issue" button for all errors in favor of the command
registerErrorHandler(c => c.errorHandling.suppressReportIssue = true);
registerReportIssueCommand('azureResourceGroups.reportIssue');
registerCommand('azureResourceGroups.createResource', createResource);
registerCommand('azureResourceGroups.groupBy.resourceGroup', buildGroupByCommand('resourceGroup'));
registerCommand('azureResourceGroups.groupBy.resourceType', buildGroupByCommand('resourceType'));
registerCommand('azureResourceGroups.groupBy.location', buildGroupByCommand('location'));
registerCommand('azureResourceGroups.groupBy.armTag', buildGroupByCommand('armTag'));
registerCommand('azureResourceGroups.installExtension', installExtension);
registerCommand('azureResourceGroups.clearActivities', clearActivities);
registerCommand('azureResourceGroups.showGroupOptions', showGroupOptions);
registerCommand('azureResourceGroups.openUrl', async (context: IActionContext, url: string) => {
context.telemetry.properties.url = url;
await openUrl(url)
});
registerCommand('azureWorkspace.loadMore', async (context: IActionContext, node: AzExtTreeItem) => await ext.workspaceTree.loadMore(node, context));
}
async function handleAzExtTreeItemRefresh(context: IActionContext, node?: ResourceGroupsItem): Promise<void> {
if (node instanceof BranchDataItemWrapper) {
const item = node.unwrap<AzExtTreeItem | unknown>();
if (isAzExtTreeItem(item)) {
await item.refresh(context);
}
}
}