Open Scmp file in Schema Compare extension (#20435)

* Open Scmp file in Schema Compare extension

* Address comments and fix failing test

* Addressed comment
This commit is contained in:
Sakshi Sharma
2022-08-24 09:50:22 -07:00
committed by GitHub
parent 87e406caca
commit dc8d703c25
5 changed files with 32 additions and 2 deletions

View File

@@ -42,6 +42,10 @@
{
"command": "schemaCompare.runComparison",
"title": "%schemaCompare.runComparison%"
},
{
"command": "schemaCompare.openInScmp",
"title": "%schemaCompare.openInScmp%"
}
],
"languages": [
@@ -91,6 +95,17 @@
{
"command": "schemaCompare.runComparison",
"when": "false"
},
{
"command": "schemaCompare.openInScmp",
"when": "false"
}
],
"explorer/context": [
{
"command": "schemaCompare.openInScmp",
"when": "resourceExtname == .scmp",
"group": "navigation"
}
]
}

View File

@@ -2,5 +2,6 @@
"displayName": "SQL Server Schema Compare",
"description": "SQL Server Schema Compare for Azure Data Studio supports comparing the schemas of databases and dacpacs.",
"schemaCompare.start": "Schema Compare",
"schemaCompare.runComparison": "Run Schema Comparison"
"schemaCompare.runComparison": "Run Schema Comparison",
"schemaCompare.openInScmp": "Open in Schema Compare"
}

View File

@@ -10,6 +10,7 @@ import { SchemaCompareMainWindow } from './schemaCompareMainWindow';
export async function activate(extensionContext: vscode.ExtensionContext): Promise<void> {
vscode.commands.registerCommand('schemaCompare.start', async (sourceContext: any, targetContext: any = undefined, comparisonResult: any = undefined) => { await new SchemaCompareMainWindow(undefined, extensionContext, undefined).start(sourceContext, targetContext, comparisonResult); });
vscode.commands.registerCommand('schemaCompare.runComparison', async (source: mssql.SchemaCompareEndpointInfo | undefined, target: mssql.SchemaCompareEndpointInfo | undefined, runComparison: boolean = false, comparisonResult: mssql.SchemaCompareResult | undefined) => { await new SchemaCompareMainWindow(undefined, extensionContext, undefined).launch(source, target, runComparison, comparisonResult); });
vscode.commands.registerCommand('schemaCompare.openInScmp', async (fileUri: vscode.Uri) => { await new SchemaCompareMainWindow(undefined, extensionContext, undefined).openScmpFile(fileUri); });
}
export function deactivate(): void {

View File

@@ -1089,6 +1089,19 @@ export class SchemaCompareMainWindow {
}
let fileUri = fileUris[0];
this.openScmpFile(fileUri, true);
}
/**
* Primary functional entrypoint for opening the schema comparison window with the scmp file Uri provided.
* @param fileUri .scmp file URI to open Schema Compare extension with
* @param callFromWithinSC is the call from openScmp? False by default, since it is one of the direct entry points.
*/
public async openScmpFile(fileUri: vscode.Uri, callFromWithinSC: boolean = false): Promise<void> {
if (!callFromWithinSC) {
//Instantiate and open schema compare window if called from "Open in Schema Compare"
await this.launch(undefined, undefined, false, undefined);
}
const service = await this.getService();
let startTime = Date.now();
const result = await service.schemaCompareOpenScmp(fileUri.fsPath);

View File

@@ -169,7 +169,7 @@ describe('SchemaCompareMainWindow.results @DacFx@', function (): void {
schemaCompareResult.sourceEndpointInfo = setDacpacEndpointInfo(mocksource);
schemaCompareResult.targetEndpointInfo = setDacpacEndpointInfo(mocktarget);
await schemaCompareResult.openScmp();
await schemaCompareResult.openScmpFile(files[0], true);
should(showErrorMessageSpy.calledOnce).be.true();
should.equal(showErrorMessageSpy.getCall(0).args[0], loc.openScmpErrorMessage('error1'));