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

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