Bug/schema compare apply confirmation (#5698)

* Ask confirmation before apply

* Adding PR comments
This commit is contained in:
udeeshagautam
2019-05-29 13:30:22 -07:00
committed by GitHub
parent 8e355a14e9
commit 4b1088edbc
2 changed files with 30 additions and 22 deletions

View File

@@ -1,6 +1,6 @@
{ {
"downloadUrl": "https://github.com/Microsoft/sqltoolsservice/releases/download/v{#version#}/microsoft.sqltools.servicelayer-{#fileName#}", "downloadUrl": "https://github.com/Microsoft/sqltoolsservice/releases/download/v{#version#}/microsoft.sqltools.servicelayer-{#fileName#}",
"version": "1.5.0-alpha.96", "version": "1.5.0-alpha.98",
"downloadFileNames": { "downloadFileNames": {
"Windows_86": "win-x86-netcoreapp2.2.zip", "Windows_86": "win-x86-netcoreapp2.2.zip",
"Windows_64": "win-x64-netcoreapp2.2.zip", "Windows_64": "win-x64-netcoreapp2.2.zip",

View File

@@ -13,6 +13,7 @@ import { Telemetry } from './telemetry';
import { getTelemetryErrorType } from './utils'; import { getTelemetryErrorType } from './utils';
const localize = nls.loadMessageBundle(); const localize = nls.loadMessageBundle();
const diffEditorTitle = localize('schemaCompare.ObjectDefinitionsTitle', 'Object Definitions'); const diffEditorTitle = localize('schemaCompare.ObjectDefinitionsTitle', 'Object Definitions');
const applyConfirmation = localize('schemaCompare.ApplyConfirmation', 'Are you sure you want to update the target?');
export class SchemaCompareResult { export class SchemaCompareResult {
private differencesTable: azdata.TableComponent; private differencesTable: azdata.TableComponent;
@@ -182,7 +183,7 @@ export class SchemaCompareResult {
this.deploymentOptions = this.schemaCompareOptionDialog.deploymentOptions; this.deploymentOptions = this.schemaCompareOptionDialog.deploymentOptions;
} }
Telemetry.sendTelemetryEvent('SchemaComparisonStarted'); Telemetry.sendTelemetryEvent('SchemaComparisonStarted');
let service = await SchemaCompareResult.getService('MSSQL'); const service = await SchemaCompareResult.getService('MSSQL');
this.comparisonResult = await service.schemaCompare(this.sourceEndpointInfo, this.targetEndpointInfo, azdata.TaskExecutionMode.execute, this.deploymentOptions); this.comparisonResult = await service.schemaCompare(this.sourceEndpointInfo, this.targetEndpointInfo, azdata.TaskExecutionMode.execute, this.deploymentOptions);
if (!this.comparisonResult || !this.comparisonResult.success) { if (!this.comparisonResult || !this.comparisonResult.success) {
Telemetry.sendTelemetryEventForError('SchemaComparisonFailed', { Telemetry.sendTelemetryEventForError('SchemaComparisonFailed', {
@@ -431,8 +432,8 @@ export class SchemaCompareResult {
'startTime:': Date.now().toString(), 'startTime:': Date.now().toString(),
'operationId': this.comparisonResult.operationId 'operationId': this.comparisonResult.operationId
}); });
let service = await SchemaCompareResult.getService('MSSQL'); const service = await SchemaCompareResult.getService('MSSQL');
let result = await service.schemaCompareGenerateScript(this.comparisonResult.operationId, this.targetEndpointInfo.serverName, this.targetEndpointInfo.databaseName, azdata.TaskExecutionMode.script); const result = await service.schemaCompareGenerateScript(this.comparisonResult.operationId, this.targetEndpointInfo.serverName, this.targetEndpointInfo.databaseName, azdata.TaskExecutionMode.script);
if (!result || !result.success) { if (!result || !result.success) {
Telemetry.sendTelemetryEvent('SchemaCompareGenerateScriptFailed', { Telemetry.sendTelemetryEvent('SchemaCompareGenerateScriptFailed', {
'errorType': getTelemetryErrorType(result.errorMessage), 'errorType': getTelemetryErrorType(result.errorMessage),
@@ -482,13 +483,18 @@ export class SchemaCompareResult {
}, },
}).component(); }).component();
// need only yes button - since the modal dialog has a default cancel
const yesString = localize('schemaCompare.ApplyYes', 'Yes');
this.applyButton.onDidClick(async (click) => { this.applyButton.onDidClick(async (click) => {
vscode.window.showWarningMessage(applyConfirmation, { modal: true }, yesString).then(async (result) => {
if (result === yesString) {
Telemetry.sendTelemetryEvent('SchemaCompareApplyStarted', { Telemetry.sendTelemetryEvent('SchemaCompareApplyStarted', {
'startTime': Date.now().toString(), 'startTime': Date.now().toString(),
'operationId': this.comparisonResult.operationId 'operationId': this.comparisonResult.operationId
}); });
let service = await SchemaCompareResult.getService('MSSQL'); const service = await SchemaCompareResult.getService('MSSQL');
let result = await service.schemaComparePublishChanges(this.comparisonResult.operationId, this.targetEndpointInfo.serverName, this.targetEndpointInfo.databaseName, azdata.TaskExecutionMode.execute); const result = await service.schemaComparePublishChanges(this.comparisonResult.operationId, this.targetEndpointInfo.serverName, this.targetEndpointInfo.databaseName, azdata.TaskExecutionMode.execute);
if (!result || !result.success) { if (!result || !result.success) {
Telemetry.sendTelemetryEvent('SchemaCompareApplyFailed', { Telemetry.sendTelemetryEvent('SchemaCompareApplyFailed', {
'errorType': getTelemetryErrorType(result.errorMessage), 'errorType': getTelemetryErrorType(result.errorMessage),
@@ -501,6 +507,8 @@ export class SchemaCompareResult {
'endTime': Date.now().toString(), 'endTime': Date.now().toString(),
'operationId': this.comparisonResult.operationId 'operationId': this.comparisonResult.operationId
}); });
}
});
}); });
} }
@@ -571,7 +579,7 @@ export class SchemaCompareResult {
private async GetDefaultDeploymentOptions(): Promise<void> { private async GetDefaultDeploymentOptions(): Promise<void> {
// Same as dacfx default options // Same as dacfx default options
let service = await SchemaCompareResult.getService('MSSQL'); const service = await SchemaCompareResult.getService('MSSQL');
let result = await service.schemaCompareGetDefaultOptions(); let result = await service.schemaCompareGetDefaultOptions();
this.deploymentOptions = result.defaultDeploymentOptions; this.deploymentOptions = result.defaultDeploymentOptions;
} }