diff --git a/package.json b/package.json index d62e7e6d0..c91e52351 100644 --- a/package.json +++ b/package.json @@ -77,6 +77,13 @@ "microsoft.web/sites" ] }, + "azure": { + "branches": [ + { + "type": "AppServices" + } + ] + }, "commands": [ { "command": "appService.CreateWebApp", @@ -345,12 +352,12 @@ "view/item/context": [ { "command": "appService.CreateWebApp", - "when": "view == azureResourceGroups && viewItem =~ /azureResourceTypeGroup.*microsoft.web/sites(?!/)/", + "when": "view == azureResourceGroups && viewItem =~ /appservices/i && viewItem =~ /azureResourceTypeGroup/i", "group": "1_subscriptionGeneralCommands@1" }, { "command": "appService.CreateWebAppAdvanced", - "when": "view == azureResourceGroups && viewItem =~ /azureResourceTypeGroup.*microsoft.web/sites(?!/)/", + "when": "view == azureResourceGroups && viewItem =~ /appservices/i && viewItem =~ /azureResourceTypeGroup/i", "group": "1_subscriptionGeneralCommands@2" }, { diff --git a/src/commands/createSlot.ts b/src/commands/createSlot.ts index 4f6b5dc73..e21ca0036 100644 --- a/src/commands/createSlot.ts +++ b/src/commands/createSlot.ts @@ -31,10 +31,10 @@ export async function createSlot(context: IActionContext, node?: DeploymentSlots if (siteConfig.scmType !== ScmType.None) { switch (siteConfig.scmType) { case ScmType.LocalGit: - await editScmType(context, createdSlot, ScmType.LocalGit, false); + await editScmType(context, createdSlot, undefined, ScmType.LocalGit, false); break; case ScmType.GitHub: - await editScmType(context, createdSlot, ScmType.GitHub, false); + await editScmType(context, createdSlot, undefined, ScmType.GitHub, false); break; default: break; diff --git a/src/commands/createWebApp/createWebApp.ts b/src/commands/createWebApp/createWebApp.ts index df58b7181..1e57e44eb 100644 --- a/src/commands/createWebApp/createWebApp.ts +++ b/src/commands/createWebApp/createWebApp.ts @@ -18,7 +18,7 @@ import { getCreatedWebAppMessage, showCreatedWebAppMessage } from "./showCreated import { WebAppStackStep } from "./stacks/WebAppStackStep"; import { WebAppCreateStep } from "./WebAppCreateStep"; -export async function createWebApp(context: IActionContext & Partial, node?: SubscriptionTreeItemBase | undefined, suppressCreatedWebAppMessage: boolean = false): Promise { +export async function createWebApp(context: IActionContext & Partial, node?: SubscriptionTreeItemBase | undefined, _nodes?: (SubscriptionTreeItemBase | undefined)[], suppressCreatedWebAppMessage: boolean = false): Promise { if (!node) { node = await ext.rgApi.tree.showTreeItemPicker(SubscriptionTreeItemBase.contextValue, context); } diff --git a/src/commands/deployments/connectToGitHub.ts b/src/commands/deployments/connectToGitHub.ts index de8f22cd9..b56a0216c 100644 --- a/src/commands/deployments/connectToGitHub.ts +++ b/src/commands/deployments/connectToGitHub.ts @@ -23,5 +23,5 @@ export async function connectToGitHub(context: IActionContext, target?: GenericT node = target.parent; } - await editScmType(context, node, ScmType.GitHub); + await editScmType(context, node, undefined, ScmType.GitHub); } diff --git a/src/commands/deployments/editScmType.ts b/src/commands/deployments/editScmType.ts index a0a867747..226974e56 100644 --- a/src/commands/deployments/editScmType.ts +++ b/src/commands/deployments/editScmType.ts @@ -11,7 +11,7 @@ import { ext } from "../../extensionVariables"; import { ResolvedWebAppResource } from "../../tree/ResolvedWebAppResource"; import { SiteTreeItem } from "../../tree/SiteTreeItem"; -export async function editScmType(context: IActionContext, node?: SiteTreeItem | DeploymentsTreeItem, newScmType?: ScmType, showToast?: boolean): Promise { +export async function editScmType(context: IActionContext, node?: SiteTreeItem | DeploymentsTreeItem, _nodes?: (SiteTreeItem | DeploymentsTreeItem)[], newScmType?: ScmType, showToast?: boolean): Promise { if (!node) { node = await ext.rgApi.pickAppResource(context, { filter: webAppFilter, diff --git a/src/commands/installCosmosDBExtension.ts b/src/commands/installCosmosDBExtension.ts index da8383894..6682083b5 100644 --- a/src/commands/installCosmosDBExtension.ts +++ b/src/commands/installCosmosDBExtension.ts @@ -3,11 +3,12 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { AzExtTreeItem, IActionContext } from '@microsoft/vscode-azext-utils'; +import { AzExtTreeItem, IActionContext, nonNullValue } from '@microsoft/vscode-azext-utils'; import { CosmosDBTreeItem } from '../tree/CosmosDBTreeItem'; import { installExtension } from '../utils/installExtension'; -export async function installCosmosDBExtension(context: IActionContext, treeItem: AzExtTreeItem): Promise { +export async function installCosmosDBExtension(context: IActionContext, node?: AzExtTreeItem): Promise { + const treeItem = nonNullValue(node); const extensionId: string = 'ms-azuretools.vscode-cosmosdb'; if (await installExtension(extensionId)) { if (treeItem.parent) { diff --git a/src/commands/openInPortal.ts b/src/commands/openInPortal.ts index 7b271cf33..2f14100bf 100644 --- a/src/commands/openInPortal.ts +++ b/src/commands/openInPortal.ts @@ -5,12 +5,13 @@ import { DeploymentsTreeItem, DeploymentTreeItem } from "@microsoft/vscode-azext-azureappservice"; import { openInPortal as uiOpenInPortal } from '@microsoft/vscode-azext-azureutils'; -import { AzExtTreeItem, IActionContext } from "@microsoft/vscode-azext-utils"; +import { AzExtTreeItem, IActionContext, nonNullValue } from "@microsoft/vscode-azext-utils"; import { DeploymentSlotsTreeItem } from "../tree/DeploymentSlotsTreeItem"; import { matchContextValue } from "../utils/contextUtils"; import { nonNullProp } from "../utils/nonNull"; -export async function openInPortal(context: IActionContext, node: AzExtTreeItem): Promise { +export async function openInPortal(context: IActionContext, treeItem?: AzExtTreeItem): Promise { + const node = nonNullValue(treeItem); if (matchContextValue(node.contextValue, [DeploymentSlotsTreeItem.contextValue])) { // the deep link for slots does not follow the conventional pattern of including its parent in the path name so this is how we extract the slot's id await uiOpenInPortal(node, `${nonNullProp(node, 'parent').id}/deploymentSlotsV2`); diff --git a/src/commands/registerCommands.ts b/src/commands/registerCommands.ts index db1ed183a..80a47f0ed 100644 --- a/src/commands/registerCommands.ts +++ b/src/commands/registerCommands.ts @@ -5,7 +5,7 @@ import { AppSettingTreeItem, registerSiteCommand } from '@microsoft/vscode-azext-azureappservice'; import { openInPortal as uiOpenInPortal } from '@microsoft/vscode-azext-azureutils'; -import { AzExtTreeItem, IActionContext, registerCommand } from '@microsoft/vscode-azext-utils'; +import { AzExtTreeItem, IActionContext, nonNullValue, registerCommandWithTreeNodeUnwrapping, unwrapArgs } from '@microsoft/vscode-azext-utils'; import { ext } from '../extensionVariables'; import { DeploymentSlotsNATreeItem, ScaleUpTreeItem } from '../tree/DeploymentSlotsTreeItem'; import { addAppSetting } from './appSettings/addAppSetting'; @@ -47,47 +47,47 @@ import { swapSlots } from './swapSlots'; import { viewProperties } from './viewProperties'; export function registerCommands(): void { - registerCommand('appService.AddAzureDatabasesConnection', addCosmosDBConnection); - registerCommand('appService.appSettings.Add', addAppSetting); - registerCommand('appService.appSettings.Delete', deleteAppSetting); - registerCommand('appService.appSettings.Download', downloadAppSettings); - registerCommand('appService.appSettings.Edit', editAppSetting); - registerCommand('appService.appSettings.Rename', renameAppSetting); - registerCommand('appService.appSettings.ToggleSlotSetting', toggleSlotSetting); - registerCommand('appService.appSettings.Upload', uploadAppSettings); - registerCommand('appService.Browse', browseWebsite); - registerCommand('appService.ConfigureDeploymentSource', editScmType); - registerCommand('appService.connectToGitHub', connectToGitHub); - registerCommand('appService.CreateSlot', createSlot); - registerCommand('appService.CreateWebApp', createWebApp); - registerCommand('appService.CreateWebAppAdvanced', createWebAppAdvanced); - registerCommand('appService.Delete', deleteWebApp); - registerCommand('appService.DeploymentScript', generateDeploymentScript); - registerCommand('appService.DisconnectRepo', disconnectRepo); - registerCommand('appService.EnableFileLogging', enableFileLogging); - registerCommand('appService.InstallCosmosDBExtension', installCosmosDBExtension); - registerCommand('appService.LoadMore', async (actionContext: IActionContext, node: AzExtTreeItem) => await ext.rgApi.tree.loadMore(node, actionContext)); - registerCommand('appService.openFile', showFile, 500); - registerCommand('appService.OpenInPortal', openInPortal); - registerCommand('appService.Refresh', async (actionContext: IActionContext, node?: AzExtTreeItem) => await ext.rgApi.tree.refresh(actionContext, node)); - registerCommand('appService.RemoveCosmosDBConnection', removeCosmosDBConnection); - registerCommand('appService.Restart', restartWebApp); - registerCommand('appService.RevealConnection', revealConnection); - registerCommand('appService.RevealConnectionInAppSettings', revealConnectionInAppSettings); - registerCommand('appService.ScaleUp', async (_context: IActionContext, node: DeploymentSlotsNATreeItem | ScaleUpTreeItem) => await uiOpenInPortal(node, node.scaleUpId)); - registerCommand('appService.showOutputChannel', () => { ext.outputChannel.show(); }); - registerCommand('appService.Start', startWebApp); - registerCommand('appService.StartRemoteDebug', startRemoteDebug); - registerCommand('appService.StartSsh', startSsh); - registerCommand('appService.startStreamingLogs', startStreamingLogs); - registerCommand('appService.Stop', stopWebApp); - registerCommand('appService.StopLogStream', stopStreamingLogs); - registerCommand('appService.SwapSlots', swapSlots); - registerCommand('appService.toggleAppSettingVisibility', async (actionContext: IActionContext, node: AppSettingTreeItem) => { await node.toggleValueVisibility(actionContext); }, 250); - registerCommand('appService.ViewCommitInGitHub', viewCommitInGitHub); - registerCommand('appService.ViewProperties', viewProperties); - registerSiteCommand('appService.Deploy', deploy); - registerSiteCommand('appService.DeploySlot', deploySlot); - registerSiteCommand('appService.Redeploy', redeployDeployment); - registerSiteCommand('appService.viewDeploymentLogs', viewDeploymentLogs); + registerCommandWithTreeNodeUnwrapping('appService.AddAzureDatabasesConnection', addCosmosDBConnection); + registerCommandWithTreeNodeUnwrapping('appService.appSettings.Add', addAppSetting); + registerCommandWithTreeNodeUnwrapping('appService.appSettings.Delete', deleteAppSetting); + registerCommandWithTreeNodeUnwrapping('appService.appSettings.Download', downloadAppSettings); + registerCommandWithTreeNodeUnwrapping('appService.appSettings.Edit', editAppSetting); + registerCommandWithTreeNodeUnwrapping('appService.appSettings.Rename', renameAppSetting); + registerCommandWithTreeNodeUnwrapping('appService.appSettings.ToggleSlotSetting', toggleSlotSetting); + registerCommandWithTreeNodeUnwrapping('appService.appSettings.Upload', uploadAppSettings); + registerCommandWithTreeNodeUnwrapping('appService.Browse', browseWebsite); + registerCommandWithTreeNodeUnwrapping('appService.ConfigureDeploymentSource', editScmType); + registerCommandWithTreeNodeUnwrapping('appService.connectToGitHub', connectToGitHub); + registerCommandWithTreeNodeUnwrapping('appService.CreateSlot', createSlot); + registerCommandWithTreeNodeUnwrapping('appService.CreateWebApp', createWebApp); + registerCommandWithTreeNodeUnwrapping('appService.CreateWebAppAdvanced', createWebAppAdvanced); + registerCommandWithTreeNodeUnwrapping('appService.Delete', deleteWebApp); + registerCommandWithTreeNodeUnwrapping('appService.DeploymentScript', generateDeploymentScript); + registerCommandWithTreeNodeUnwrapping('appService.DisconnectRepo', disconnectRepo); + registerCommandWithTreeNodeUnwrapping('appService.EnableFileLogging', enableFileLogging); + registerCommandWithTreeNodeUnwrapping('appService.InstallCosmosDBExtension', installCosmosDBExtension); + registerCommandWithTreeNodeUnwrapping('appService.LoadMore', async (actionContext: IActionContext, node?: AzExtTreeItem) => await ext.rgApi.tree.loadMore(nonNullValue(node), actionContext)); + registerCommandWithTreeNodeUnwrapping('appService.openFile', showFile, 500); + registerCommandWithTreeNodeUnwrapping('appService.OpenInPortal', openInPortal); + registerCommandWithTreeNodeUnwrapping('appService.Refresh', async (actionContext: IActionContext, node?: AzExtTreeItem) => await ext.rgApi.tree.refresh(actionContext, node)); + registerCommandWithTreeNodeUnwrapping('appService.RemoveCosmosDBConnection', removeCosmosDBConnection); + registerCommandWithTreeNodeUnwrapping('appService.Restart', restartWebApp); + registerCommandWithTreeNodeUnwrapping('appService.RevealConnection', revealConnection); + registerCommandWithTreeNodeUnwrapping('appService.RevealConnectionInAppSettings', revealConnectionInAppSettings); + registerCommandWithTreeNodeUnwrapping('appService.ScaleUp', async (_context: IActionContext, node?: DeploymentSlotsNATreeItem | ScaleUpTreeItem) => await uiOpenInPortal(nonNullValue(node), nonNullValue(node).scaleUpId)); + registerCommandWithTreeNodeUnwrapping('appService.showOutputChannel', () => { ext.outputChannel.show(); }); + registerCommandWithTreeNodeUnwrapping('appService.Start', startWebApp); + registerCommandWithTreeNodeUnwrapping('appService.StartRemoteDebug', startRemoteDebug); + registerCommandWithTreeNodeUnwrapping('appService.StartSsh', startSsh); + registerCommandWithTreeNodeUnwrapping('appService.startStreamingLogs', startStreamingLogs); + registerCommandWithTreeNodeUnwrapping('appService.Stop', stopWebApp); + registerCommandWithTreeNodeUnwrapping('appService.StopLogStream', stopStreamingLogs); + registerCommandWithTreeNodeUnwrapping('appService.SwapSlots', swapSlots); + registerCommandWithTreeNodeUnwrapping('appService.toggleAppSettingVisibility', async (actionContext: IActionContext, node?: AppSettingTreeItem) => { await nonNullValue(node).toggleValueVisibility(actionContext); }, 250); + registerCommandWithTreeNodeUnwrapping('appService.ViewCommitInGitHub', viewCommitInGitHub); + registerCommandWithTreeNodeUnwrapping('appService.ViewProperties', viewProperties); + registerSiteCommand('appService.Deploy', unwrapArgs(deploy)); + registerSiteCommand('appService.DeploySlot', unwrapArgs(deploySlot)); + registerSiteCommand('appService.Redeploy', unwrapArgs(redeployDeployment)); + registerSiteCommand('appService.viewDeploymentLogs', unwrapArgs(viewDeploymentLogs)); } diff --git a/src/commands/viewProperties.ts b/src/commands/viewProperties.ts index 542652f47..3e90656cb 100644 --- a/src/commands/viewProperties.ts +++ b/src/commands/viewProperties.ts @@ -7,7 +7,8 @@ import { IActionContext, nonNullValue, openReadOnlyJson } from '@microsoft/vscod import { localize } from '../localize'; import { SiteTreeItem } from '../tree/SiteTreeItem'; -export async function viewProperties(context: IActionContext, node: SiteTreeItem): Promise { +export async function viewProperties(context: IActionContext, treeItem?: SiteTreeItem): Promise { + const node = nonNullValue(treeItem); const client = await node.site.createClient(context); await node.runWithTemporaryDescription(context, localize('retrievingProps', 'Retrieving properties...'), async () => { // `siteConfig` already exists on `node.site`, but has very limited properties for some reason. We want to get the full site config diff --git a/src/extension.ts b/src/extension.ts index e56e5e1a5..e211a56ad 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -5,7 +5,7 @@ import { registerAppServiceExtensionVariables } from '@microsoft/vscode-azext-azureappservice'; import { registerAzureUtilsExtensionVariables } from '@microsoft/vscode-azext-azureutils'; -import { callWithTelemetryAndErrorHandling, createApiProvider, createAzExtOutputChannel, createExperimentationService, IActionContext, registerErrorHandler, registerReportIssueCommand, registerUIExtensionVariables } from '@microsoft/vscode-azext-utils'; +import { AzExtResourceType, callWithTelemetryAndErrorHandling, createApiProvider, createAzExtOutputChannel, createExperimentationService, IActionContext, registerErrorHandler, registerReportIssueCommand, registerUIExtensionVariables } from '@microsoft/vscode-azext-utils'; import { AzureExtensionApi, AzureExtensionApiProvider } from '@microsoft/vscode-azext-utils/api'; import * as vscode from 'vscode'; import { AppServiceFileSystem } from './AppServiceFileSystem'; @@ -44,7 +44,7 @@ export async function activateInternal( ext.experimentationService = await createExperimentationService(context); ext.rgApi = await getResourceGroupsApi(); - ext.rgApi.registerApplicationResourceResolver('ms-azuretools.vscode-azureappservice', new WebAppResolver()); + ext.rgApi.registerApplicationResourceResolver(AzExtResourceType.AppServices, new WebAppResolver()); ext.fileSystem = new AppServiceFileSystem(ext.rgApi.tree); context.subscriptions.push(vscode.workspace.registerFileSystemProvider(AppServiceFileSystem.scheme, ext.fileSystem));