Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
cb30533
Set up schema compare page
lewis-sanchez Jan 17, 2025
8d061b9
Localized strings
lewis-sanchez Jan 17, 2025
ac6c44b
Add schema compare contracts and endpoints
lewis-sanchez Jan 17, 2025
f64c1f9
Add schema compare icons
lewis-sanchez Jan 17, 2025
6cd7f33
Use schema compare icon in webview.
lewis-sanchez Jan 17, 2025
2fb9256
Add init logic for SC webview controller
lewis-sanchez Jan 27, 2025
8d68dfb
Defines and registers reducers
lewis-sanchez Jan 28, 2025
c8ad560
Merge branch 'main' into lewissanchez/feat/schemaCompare
lewis-sanchez Jan 29, 2025
c526d32
Remove unwanted change
lewis-sanchez Jan 29, 2025
2d4e878
Define and implement schame compare state provider
lewis-sanchez Jan 29, 2025
e9b1fb3
Fix controller init logic
lewis-sanchez Jan 30, 2025
71dc730
Add SQL Projects schema compare entry point
lewis-sanchez Jan 30, 2025
88f6be6
Get full SQL projects path
lewis-sanchez Feb 1, 2025
cdbc5dc
Setup controller for tests
lewis-sanchez Feb 3, 2025
e039089
Add basic test
lewis-sanchez Feb 4, 2025
722f683
Add schema compare controller unit tests
lewis-sanchez Feb 5, 2025
7666686
Add more tests for SchemaCompare controller tests
lewis-sanchez Feb 5, 2025
d396aa4
Add additional tests to verify results
lewis-sanchez Feb 5, 2025
eaff4b8
Code review changes
lewis-sanchez Feb 9, 2025
4d68783
Add deployment options reducer
lewis-sanchez Feb 9, 2025
aa55223
Rename reducers to be less redundant
lewis-sanchez Feb 9, 2025
187bc54
Add doc strings
lewis-sanchez Feb 9, 2025
ebc6f2d
Code review changes
lewis-sanchez Feb 11, 2025
846e30a
Fix schema compare docstring
lewis-sanchez Feb 11, 2025
5eff020
Minor clean up
lewis-sanchez Feb 11, 2025
7876c42
Merge branch 'main' into lewissanchez/feat/schemaCompare
lewis-sanchez Feb 11, 2025
005b9c6
Clean up pipelines
lewis-sanchez Feb 11, 2025
094ad5b
Skip all tests for now
lewis-sanchez Feb 11, 2025
7992641
Add vscodeWrapper to controller
lewis-sanchez Feb 11, 2025
a287782
Bring back tests
lewis-sanchez Feb 11, 2025
d6620c4
Bring back all other tests
lewis-sanchez Feb 11, 2025
ff80374
Set operationId in controller
lewis-sanchez Feb 11, 2025
d226cab
Code review changes
lewis-sanchez Feb 11, 2025
060382e
Consolidate unit tests
lewis-sanchez Feb 11, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const gulp = require('gulp');
const gulp = require('gulp');
const rename = require('gulp-rename');
const ts = require('gulp-typescript');
const tsProject = ts.createProject('tsconfig.json');
Expand Down Expand Up @@ -190,6 +190,7 @@ async function generateReactWebviewsBundle() {
'queryResult': 'src/reactviews/pages/QueryResult/index.tsx',
'userSurvey': 'src/reactviews/pages/UserSurvey/index.tsx',
'schemaDesigner': 'src/reactviews/pages/SchemaDesigner/index.tsx',
'schemaCompare': 'src/reactviews/pages/SchemaCompare/index.tsx',
},
bundle: true,
outdir: 'out/src/reactviews/assets',
Expand Down
1 change: 1 addition & 0 deletions localization/l10n/bundle.l10n.json
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,7 @@
]
},
"General": "General",
"Schema Compare": "Schema Compare",
"Azure sign in failed.": "Azure sign in failed.",
"Select subscriptions": "Select subscriptions",
"Error loading Azure subscriptions.": "Error loading Azure subscriptions.",
Expand Down
6 changes: 6 additions & 0 deletions localization/xliff/vscode-mssql.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -1103,6 +1103,9 @@
<trans-unit id="++CODE++07b091a3fdc4e4c03cd047b5264e61241f20fe8dbc36a4c796d46cd8dc3e7d03">
<source xml:lang="en">Schema</source>
</trans-unit>
<trans-unit id="++CODE++154e484fc5e1a7cb4991c071caef673c453eaa7dcfef4321db537c576a5c56cf">
<source xml:lang="en">Schema Compare</source>
</trans-unit>
<trans-unit id="++CODE++cce7c24ebb0a14bc98b7d6a3f18ddfe9c893e65adb1a599321b3e0eca3515490">
<source xml:lang="en">Script As Create</source>
</trans-unit>
Expand Down Expand Up @@ -1803,6 +1806,9 @@
<trans-unit id="mssql.runQueryHistory">
<source xml:lang="en">Run Query</source>
</trans-unit>
<trans-unit id="mssql.schemaCompare">
<source xml:lang="en">Schema Compare (Preview)</source>
</trans-unit>
<trans-unit id="mssql.scriptAlter">
<source xml:lang="en">Script as Alter</source>
</trans-unit>
Expand Down
1 change: 1 addition & 0 deletions media/schemaCompare_dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions media/schemaCompare_light.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,14 @@
"when": "view == objectExplorer && config.mssql.enableRichExperiences && viewItem =~ /\\bfilterable=true\\b.*\\bhasFilters=true\\b/",
"group": "inline@2"
},
{
"command": "mssql.schemaCompare",
"when": "view == objectExplorer && config.mssql.enableRichExperiences && viewItem =~ /\\btype=(disconnectedServer|Server|Database)\\b/"
},
{
"command": "mssql.schemaCompare",
"when": "view == dataworkspace.views.main && config.mssql.enableRichExperiences && viewItem =~ /^(databaseProject.itemType.project|databaseProject.itemType.legacyProject)$/"
},
{
"command": "mssql.filterNode",
"when": "view == objectExplorer && config.mssql.enableRichExperiences && viewItem =~ /\\bfilterable=true\\b.*\\bhasFilters=false\\b/"
Expand Down Expand Up @@ -524,6 +532,10 @@
"command": "mssql.objectExplorerNewQuery",
"when": "view == objectExplorer && viewItem =~ /\\btype=(disconnectedServer|Server|Database)\\b/"
},
{
"command": "mssql.schemaCompare",
"when": "view == objectExplorer && config.mssql.enableRichExperiences && viewItem =~ /\\btype=(disconnectedServer|Server|Database)\\b/"
},
{
"command": "mssql.removeObjectExplorerNode",
"when": "view == objectExplorer && viewItem =~ /\\btype=(disconnectedServer|Server)\\b/"
Expand Down Expand Up @@ -705,6 +717,11 @@
"title": "%mssql.newQuery%",
"category": "MS SQL"
},
{
"command": "mssql.schemaCompare",
"title": "%mssql.schemaCompare%",
"category": "MS SQL"
},
{
"command": "mssql.rebuildIntelliSenseCache",
"title": "%mssql.rebuildIntelliSenseCache%",
Expand Down
1 change: 1 addition & 0 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"mssql.showGettingStarted":"Getting Started Guide",
"mssql.newQuery":"New Query",
"mssql.objectExplorerNewQuery":"New Query",
"mssql.schemaCompare": "Schema Compare (Preview)",
"mssql.toggleSqlCmd":"Toggle SQLCMD Mode",
"mssql.copyObjectName":"Copy Object Name",
"mssql.addAadAccount":"Add Microsoft Entra Account",
Expand Down
1 change: 1 addition & 0 deletions src/constants/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export const cmdStartQueryHistory = "mssql.startQueryHistoryCapture";
export const cmdPauseQueryHistory = "mssql.pauseQueryHistoryCapture";
export const cmdCommandPaletteQueryHistory = "mssql.commandPaletteQueryHistory";
export const cmdNewQuery = "mssql.newQuery";
export const cmdSchemaCompare = "mssql.schemaCompare";
export const cmdManageConnectionProfiles = "mssql.manageProfiles";
export const cmdClearPooledConnections = "mssql.clearPooledConnections";
export const cmdRebuildIntelliSenseCache = "mssql.rebuildIntelliSenseCache";
Expand Down
4 changes: 4 additions & 0 deletions src/constants/locConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -799,3 +799,7 @@ export class TableDesigner {
public static Columns = l10n.t("Columns");
public static AdvancedOptions = l10n.t("Advanced Options");
}

export class SchemaCompare {
public static Title = l10n.t("Schema Compare");
}
28 changes: 27 additions & 1 deletion src/controllers/mainController.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*---------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
Expand Down Expand Up @@ -63,6 +63,8 @@ import { ObjectExplorerDragAndDropController } from "../objectExplorer/objectExp
import { SchemaDesignerService } from "../services/schemaDesignerService";
import { SchemaDesignerWebviewController } from "../schemaDesigner/schemaDesignerWebviewController";
import store from "../queryResult/singletonStore";
import { SchemaCompareWebViewController } from "../schemaCompare/schemaCompareWebViewController";
import { SchemaCompare } from "../constants/locConstants";

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

if (this.isRichExperiencesEnabled) {
this._context.subscriptions.push(
vscode.commands.registerCommand(
Constants.cmdSchemaCompare,
async (node: any) => this.onSchemaCompare(node),
),
);

this._context.subscriptions.push(
vscode.commands.registerCommand(
Constants.cmdEditConnection,
Expand Down Expand Up @@ -1983,6 +1992,23 @@ export default class MainController implements vscode.Disposable {
return false;
}

public async onSchemaCompare(node: any): Promise<void> {
if (node) {
const result = await this.schemaCompareService.getDefaultOptions();
const schemaCompareWebView = new SchemaCompareWebViewController(
this._context,
this._vscodeWrapper,
node,
this.schemaCompareService,
this._connectionMgr,
result,
SchemaCompare.Title,
);

schemaCompareWebView.revealToForeground();
}
}

/**
* Check if the extension launched file exists.
* This is to detect when we are running in a clean install scenario.
Expand Down
13 changes: 13 additions & 0 deletions src/reactviews/pages/SchemaCompare/SchemaCompare.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

export const SchemaComparePage = () => {
return (
<div>
{/* WIP/Initial Checkin: Page is a work in progress */}
<h1>Schema Compare Page</h1>
</div>
);
};
131 changes: 131 additions & 0 deletions src/reactviews/pages/SchemaCompare/SchemaCompareStateProvider.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import * as sc from "../../../sharedInterfaces/schemaCompare";
import * as mssql from "vscode-mssql";

import { createContext } from "react";
import { useVscodeWebview } from "../../common/vscodeWebviewProvider";

const schemaCompareContext = createContext<sc.SchemaCompareContextProps>(
{} as sc.SchemaCompareContextProps,
);

interface SchemaCompareStateProviderProps {
children: React.ReactNode;
}

const SchemaCompareStateProvider: React.FC<SchemaCompareStateProviderProps> = ({
children,
}) => {
const webViewState = useVscodeWebview<
sc.SchemaCompareWebViewState,
sc.SchemaCompareReducers
>();
const schemaCompareState = webViewState?.state;

return (
<schemaCompareContext.Provider
value={{
state: schemaCompareState,
themeKind: webViewState?.themeKind,
compare: function (
sourceEndpointInfo: mssql.SchemaCompareEndpointInfo,
targetEndpointInfo: mssql.SchemaCompareEndpointInfo,
taskExecutionMode: mssql.TaskExecutionMode,
deploymentOptions: mssql.DeploymentOptions,
): void {
webViewState?.extensionRpc.action("compare", {
sourceEndpointInfo: sourceEndpointInfo,
targetEndpointInfo: targetEndpointInfo,
taskExecutionMode: taskExecutionMode,
deploymentOptions: deploymentOptions,
});
},
generateScript: function (
targetServerName: string,
targetDatabaseName: string,
taskExecutionMode: mssql.TaskExecutionMode,
): void {
webViewState?.extensionRpc.action("generateScript", {
targetServerName: targetServerName,
targetDatabaseName: targetDatabaseName,
taskExecutionMode: taskExecutionMode,
});
},
publishDatabaseChanges: function (
targetServerName: string,
targetDatabaseName: string,
taskExecutionMode: mssql.TaskExecutionMode,
): void {
webViewState?.extensionRpc.action(
"publishDatabaseChanges",
{
targetServerName: targetServerName,
targetDatabaseName: targetDatabaseName,
taskExecutionMode: taskExecutionMode,
},
);
},
publishProjectChanges: function (
targetProjectPath: string,
targetFolderStructure: mssql.ExtractTarget,
taskExecutionMode: mssql.TaskExecutionMode,
): void {
webViewState?.extensionRpc.action("publishProjectChanges", {
targetProjectPath: targetProjectPath,
targetFolderStructure: targetFolderStructure,
taskExecutionMode: taskExecutionMode,
});
},
getDefaultOptions: function (): void {
webViewState?.extensionRpc.action("getDefaultOptions", {});
},
includeExcludeNode: function (
diffEntry: mssql.DiffEntry,
includeRequest: boolean,
taskExecutionMode: mssql.TaskExecutionMode,
): void {
webViewState?.extensionRpc.action("includeExcludeNode", {
diffEntry: diffEntry,
includeRequest: includeRequest,
taskExecutionMode: taskExecutionMode,
});
},
openScmp: function (filePath: string): void {
webViewState?.extensionRpc.action("openScmp", {
filePath: filePath,
});
},
saveScmp: function (
sourceEndpointInfo: mssql.SchemaCompareEndpointInfo,
targetEndpointInfo: mssql.SchemaCompareEndpointInfo,
taskExecutionMode: mssql.TaskExecutionMode,
deploymentOptions: mssql.DeploymentOptions,
scmpFilePath: string,
excludedSourceObjects: mssql.SchemaCompareObjectId[],
excludedTargetObjects: mssql.SchemaCompareObjectId[],
): void {
webViewState?.extensionRpc.action("saveScmp", {
sourceEndpointInfo: sourceEndpointInfo,
targetEndpointInfo: targetEndpointInfo,
taskExecutionMode: taskExecutionMode,
deploymentOptions: deploymentOptions,
scmpFilePath: scmpFilePath,
excludedSourceObjects: excludedSourceObjects,
excludedTargetObjects: excludedTargetObjects,
});
},
cancel: function (): void {
webViewState?.extensionRpc.action("cancel", {});
},
}}
>
{children}
</schemaCompareContext.Provider>
);
};

export { SchemaCompareStateProvider };
18 changes: 18 additions & 0 deletions src/reactviews/pages/SchemaCompare/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import ReactDOM from "react-dom/client";
import "../../index.css";
import { VscodeWebviewProvider } from "../../common/vscodeWebviewProvider";
import { SchemaComparePage } from "./SchemaCompare";
import { SchemaCompareStateProvider } from "./SchemaCompareStateProvider";

ReactDOM.createRoot(document.getElementById("root")!).render(
<VscodeWebviewProvider>
<SchemaCompareStateProvider>
<SchemaComparePage />
</SchemaCompareStateProvider>
</VscodeWebviewProvider>,
);
Loading
Loading