Skip to content

Commit e357f6d

Browse files
Add Schema Compare Controller Logic (#18619)
* Set up schema compare page * Localized strings * Add schema compare contracts and endpoints * Add schema compare icons * Use schema compare icon in webview. * Add init logic for SC webview controller * Defines and registers reducers * Remove unwanted change * Define and implement schame compare state provider * Fix controller init logic * Add SQL Projects schema compare entry point * Get full SQL projects path * Setup controller for tests * Add basic test * Add schema compare controller unit tests * Add more tests for SchemaCompare controller tests * Add additional tests to verify results * Code review changes * Add deployment options reducer * Rename reducers to be less redundant * Add doc strings * Code review changes * Fix schema compare docstring * Minor clean up * Clean up pipelines * Skip all tests for now * Add vscodeWrapper to controller * Bring back tests * Bring back all other tests * Set operationId in controller * Code review changes * Consolidate unit tests
1 parent e0e1716 commit e357f6d

File tree

17 files changed

+1499
-2
lines changed

17 files changed

+1499
-2
lines changed

gulpfile.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const gulp = require('gulp');
1+
const gulp = require('gulp');
22
const rename = require('gulp-rename');
33
const ts = require('gulp-typescript');
44
const tsProject = ts.createProject('tsconfig.json');
@@ -190,6 +190,7 @@ async function generateReactWebviewsBundle() {
190190
'queryResult': 'src/reactviews/pages/QueryResult/index.tsx',
191191
'userSurvey': 'src/reactviews/pages/UserSurvey/index.tsx',
192192
'schemaDesigner': 'src/reactviews/pages/SchemaDesigner/index.tsx',
193+
'schemaCompare': 'src/reactviews/pages/SchemaCompare/index.tsx',
193194
},
194195
bundle: true,
195196
outdir: 'out/src/reactviews/assets',

localization/l10n/bundle.l10n.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -808,6 +808,7 @@
808808
]
809809
},
810810
"General": "General",
811+
"Schema Compare": "Schema Compare",
811812
"Azure sign in failed.": "Azure sign in failed.",
812813
"Select subscriptions": "Select subscriptions",
813814
"Error loading Azure subscriptions.": "Error loading Azure subscriptions.",

localization/xliff/vscode-mssql.xlf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,6 +1103,9 @@
11031103
<trans-unit id="++CODE++07b091a3fdc4e4c03cd047b5264e61241f20fe8dbc36a4c796d46cd8dc3e7d03">
11041104
<source xml:lang="en">Schema</source>
11051105
</trans-unit>
1106+
<trans-unit id="++CODE++154e484fc5e1a7cb4991c071caef673c453eaa7dcfef4321db537c576a5c56cf">
1107+
<source xml:lang="en">Schema Compare</source>
1108+
</trans-unit>
11061109
<trans-unit id="++CODE++cce7c24ebb0a14bc98b7d6a3f18ddfe9c893e65adb1a599321b3e0eca3515490">
11071110
<source xml:lang="en">Script As Create</source>
11081111
</trans-unit>
@@ -1803,6 +1806,9 @@
18031806
<trans-unit id="mssql.runQueryHistory">
18041807
<source xml:lang="en">Run Query</source>
18051808
</trans-unit>
1809+
<trans-unit id="mssql.schemaCompare">
1810+
<source xml:lang="en">Schema Compare (Preview)</source>
1811+
</trans-unit>
18061812
<trans-unit id="mssql.scriptAlter">
18071813
<source xml:lang="en">Script as Alter</source>
18081814
</trans-unit>

media/schemaCompare_dark.svg

Lines changed: 1 addition & 0 deletions
Loading

media/schemaCompare_light.svg

Lines changed: 1 addition & 0 deletions
Loading

package.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,14 @@
422422
"when": "view == objectExplorer && config.mssql.enableRichExperiences && viewItem =~ /\\bfilterable=true\\b.*\\bhasFilters=true\\b/",
423423
"group": "inline@2"
424424
},
425+
{
426+
"command": "mssql.schemaCompare",
427+
"when": "view == objectExplorer && config.mssql.enableRichExperiences && viewItem =~ /\\btype=(disconnectedServer|Server|Database)\\b/"
428+
},
429+
{
430+
"command": "mssql.schemaCompare",
431+
"when": "view == dataworkspace.views.main && config.mssql.enableRichExperiences && viewItem =~ /^(databaseProject.itemType.project|databaseProject.itemType.legacyProject)$/"
432+
},
425433
{
426434
"command": "mssql.filterNode",
427435
"when": "view == objectExplorer && config.mssql.enableRichExperiences && viewItem =~ /\\bfilterable=true\\b.*\\bhasFilters=false\\b/"
@@ -524,6 +532,10 @@
524532
"command": "mssql.objectExplorerNewQuery",
525533
"when": "view == objectExplorer && viewItem =~ /\\btype=(disconnectedServer|Server|Database)\\b/"
526534
},
535+
{
536+
"command": "mssql.schemaCompare",
537+
"when": "view == objectExplorer && config.mssql.enableRichExperiences && viewItem =~ /\\btype=(disconnectedServer|Server|Database)\\b/"
538+
},
527539
{
528540
"command": "mssql.removeObjectExplorerNode",
529541
"when": "view == objectExplorer && viewItem =~ /\\btype=(disconnectedServer|Server)\\b/"
@@ -705,6 +717,11 @@
705717
"title": "%mssql.newQuery%",
706718
"category": "MS SQL"
707719
},
720+
{
721+
"command": "mssql.schemaCompare",
722+
"title": "%mssql.schemaCompare%",
723+
"category": "MS SQL"
724+
},
708725
{
709726
"command": "mssql.rebuildIntelliSenseCache",
710727
"title": "%mssql.rebuildIntelliSenseCache%",

package.nls.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"mssql.showGettingStarted":"Getting Started Guide",
3535
"mssql.newQuery":"New Query",
3636
"mssql.objectExplorerNewQuery":"New Query",
37+
"mssql.schemaCompare": "Schema Compare (Preview)",
3738
"mssql.toggleSqlCmd":"Toggle SQLCMD Mode",
3839
"mssql.copyObjectName":"Copy Object Name",
3940
"mssql.addAadAccount":"Add Microsoft Entra Account",

src/constants/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export const cmdStartQueryHistory = "mssql.startQueryHistoryCapture";
4141
export const cmdPauseQueryHistory = "mssql.pauseQueryHistoryCapture";
4242
export const cmdCommandPaletteQueryHistory = "mssql.commandPaletteQueryHistory";
4343
export const cmdNewQuery = "mssql.newQuery";
44+
export const cmdSchemaCompare = "mssql.schemaCompare";
4445
export const cmdManageConnectionProfiles = "mssql.manageProfiles";
4546
export const cmdClearPooledConnections = "mssql.clearPooledConnections";
4647
export const cmdRebuildIntelliSenseCache = "mssql.rebuildIntelliSenseCache";

src/constants/locConstants.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -799,3 +799,7 @@ export class TableDesigner {
799799
public static Columns = l10n.t("Columns");
800800
public static AdvancedOptions = l10n.t("Advanced Options");
801801
}
802+
803+
export class SchemaCompare {
804+
public static Title = l10n.t("Schema Compare");
805+
}

src/controllers/mainController.ts

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*---------------------------------------------------------------------------------------------
1+
/*---------------------------------------------------------------------------------------------
22
* Copyright (c) Microsoft Corporation. All rights reserved.
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
@@ -63,6 +63,8 @@ import { ObjectExplorerDragAndDropController } from "../objectExplorer/objectExp
6363
import { SchemaDesignerService } from "../services/schemaDesignerService";
6464
import { SchemaDesignerWebviewController } from "../schemaDesigner/schemaDesignerWebviewController";
6565
import store from "../queryResult/singletonStore";
66+
import { SchemaCompareWebViewController } from "../schemaCompare/schemaCompareWebViewController";
67+
import { SchemaCompare } from "../constants/locConstants";
6668

6769
/**
6870
* The main controller class that initializes the extension
@@ -896,6 +898,13 @@ export default class MainController implements vscode.Disposable {
896898
);
897899

898900
if (this.isRichExperiencesEnabled) {
901+
this._context.subscriptions.push(
902+
vscode.commands.registerCommand(
903+
Constants.cmdSchemaCompare,
904+
async (node: any) => this.onSchemaCompare(node),
905+
),
906+
);
907+
899908
this._context.subscriptions.push(
900909
vscode.commands.registerCommand(
901910
Constants.cmdEditConnection,
@@ -1983,6 +1992,23 @@ export default class MainController implements vscode.Disposable {
19831992
return false;
19841993
}
19851994

1995+
public async onSchemaCompare(node: any): Promise<void> {
1996+
if (node) {
1997+
const result = await this.schemaCompareService.getDefaultOptions();
1998+
const schemaCompareWebView = new SchemaCompareWebViewController(
1999+
this._context,
2000+
this._vscodeWrapper,
2001+
node,
2002+
this.schemaCompareService,
2003+
this._connectionMgr,
2004+
result,
2005+
SchemaCompare.Title,
2006+
);
2007+
2008+
schemaCompareWebView.revealToForeground();
2009+
}
2010+
}
2011+
19862012
/**
19872013
* Check if the extension launched file exists.
19882014
* This is to detect when we are running in a clean install scenario.

0 commit comments

Comments
 (0)