From b636a3b8a96875509b826033e6c326726a613045 Mon Sep 17 00:00:00 2001 From: Eric Jizba Date: Thu, 12 Jul 2018 12:24:31 -0700 Subject: [PATCH] Moving deployment confirmation to before showing 'Deploying...' (#521) It just makes more sense to ask for confirmation before changing the node state to 'Deploying...' and before showing the long running notification. Also before the dialog to 'default' to this going forward --- package.json | 2 +- src/commands/deploy.ts | 13 +++++++++++-- src/constants.ts | 6 ++++++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index f69f6e08..51a23dcb 100644 --- a/package.json +++ b/package.json @@ -728,7 +728,7 @@ "portfinder": "^1.0.13", "request": "^2.83.0", "request-promise": "^4.2.2", - "vscode-azureappservice": "~0.18.0", + "vscode-azureappservice": "~0.19.0", "vscode-azureextensionui": "~0.16.0", "vscode-azurekudu": "~0.1.6", "vscode-debugadapter": "^1.24.0", diff --git a/src/commands/deploy.ts b/src/commands/deploy.ts index 81fbf216..e396882d 100644 --- a/src/commands/deploy.ts +++ b/src/commands/deploy.ts @@ -11,7 +11,7 @@ import * as path from 'path'; import { join } from 'path'; import * as vscode from 'vscode'; import * as appservice from 'vscode-azureappservice'; -import { IActionContext, IAzureNode, IAzureQuickPickItem, IAzureTreeItem, parseError, TelemetryProperties, UserCancelledError } from 'vscode-azureextensionui'; +import { DialogResponses, IActionContext, IAzureNode, IAzureQuickPickItem, IAzureTreeItem, parseError, TelemetryProperties, UserCancelledError } from 'vscode-azureextensionui'; import * as constants from '../constants'; import { SiteTreeItem } from '../explorer/SiteTreeItem'; import { WebAppTreeItem } from '../explorer/WebAppTreeItem'; @@ -115,6 +115,15 @@ export async function deploy(context: IActionContext, target?: vscode.Uri | IAzu await node.treeItem.enableScmDoBuildDuringDeploy(fsPath, constants.runtimes[siteConfig.linuxFxVersion.substring(0, siteConfig.linuxFxVersion.indexOf('|'))], context.properties); } } + + if (confirmDeployment && siteConfig.scmType !== constants.ScmType.LocalGit && siteConfig !== constants.ScmType.GitHub) { + const warning: string = `Are you sure you want to deploy to "${node.treeItem.client.fullName}"? This will overwrite any previous deployment and cannot be undone.`; + context.properties.cancelStep = 'confirmDestructiveDeployment'; + const deployButton: vscode.MessageItem = { title: 'Deploy' }; + await ext.ui.showWarningMessage(warning, { modal: true }, deployButton, DialogResponses.cancel); + context.properties.cancelStep = ''; + } + if (!defaultWebAppToDeploy && currentWorkspace && (isPathEqual(currentWorkspace.uri.fsPath, fsPath) || isSubpath(currentWorkspace.uri.fsPath, fsPath))) { // tslint:disable-next-line:no-floating-promises node.treeItem.promptToSaveDeployDefaults(node, currentWorkspace.uri.fsPath, fsPath, context.properties); @@ -122,7 +131,7 @@ export async function deploy(context: IActionContext, target?: vscode.Uri | IAzu cancelWebsiteValidation(node.treeItem); await node.runWithTemporaryDescription("Deploying...", async () => { // tslint:disable-next-line:no-non-null-assertion - await appservice.deploy(node!.treeItem.client, fsPath, constants.extensionPrefix, confirmDeployment, context.properties); + await appservice.deploy(node!.treeItem.client, fsPath, constants.extensionPrefix, context.properties); }); // Don't wait validateWebSite(correlationId, node.treeItem).then( diff --git a/src/constants.ts b/src/constants.ts index 193ab0b1..149dadf0 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -33,3 +33,9 @@ export enum configurationSettings { advancedCreation = 'advancedCreation', defaultWebAppToDeploy = 'defaultWebAppToDeploy' } + +export enum ScmType { + None = 'None', // default scmType + LocalGit = 'LocalGit', + GitHub = 'GitHub' +}