mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Add migration service calls to migration wizard (#12090)
* Hook up migration apis WIP * WIP 2 * WIP 3 * Fix build breaks * Break 2 * WIP 4 * SKU recommendation page work * WIP 5 * A few minor fixes * Merge main * Add back assessment dialog * Address feedback Co-authored-by: Amir Omidi <amomidi@microsoft.com>
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
|
||||
import * as azdata from 'azdata';
|
||||
import * as vscode from 'vscode';
|
||||
import * as mssql from '../../../mssql';
|
||||
import { SKURecommendations } from './externalContract';
|
||||
|
||||
export enum State {
|
||||
@@ -42,10 +43,12 @@ export class MigrationStateModel implements Model, vscode.Disposable {
|
||||
private _currentState: State;
|
||||
private _gatheringInformationError: string | undefined;
|
||||
private _skuRecommendations: SKURecommendations | undefined;
|
||||
private _assessmentResults: mssql.SqlMigrationAssessmentResultItem[] | undefined;
|
||||
|
||||
constructor(
|
||||
private readonly _extensionContext: vscode.ExtensionContext,
|
||||
private readonly _sourceConnection: azdata.connection.Connection
|
||||
private readonly _sourceConnection: azdata.connection.Connection,
|
||||
public readonly migrationService: mssql.ISqlMigrationService
|
||||
) {
|
||||
this._currentState = State.INIT;
|
||||
}
|
||||
@@ -66,6 +69,14 @@ export class MigrationStateModel implements Model, vscode.Disposable {
|
||||
this._stateChangeEventEmitter.fire({ oldState, newState: this.currentState });
|
||||
}
|
||||
|
||||
public get assessmentResults(): mssql.SqlMigrationAssessmentResultItem[] | undefined {
|
||||
return this._assessmentResults;
|
||||
}
|
||||
|
||||
public set assessmentResults(assessmentResults: mssql.SqlMigrationAssessmentResultItem[] | undefined) {
|
||||
this._assessmentResults = assessmentResults;
|
||||
}
|
||||
|
||||
public get gatheringInformationError(): string | undefined {
|
||||
return this._gatheringInformationError;
|
||||
}
|
||||
|
||||
133
extensions/sql-migration/src/wizard/assessmentResultsDialog.ts
Normal file
133
extensions/sql-migration/src/wizard/assessmentResultsDialog.ts
Normal file
@@ -0,0 +1,133 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as azdata from 'azdata';
|
||||
import * as mssql from '../../../mssql';
|
||||
import { MigrationStateModel } from '../models/stateMachine';
|
||||
|
||||
export class AssessmentResultsDialog {
|
||||
|
||||
private static readonly OkButtonText: string = 'OK';
|
||||
private static readonly CancelButtonText: string = 'Cancel';
|
||||
|
||||
// protected _onSuccess: vscode.EventEmitter<T> = new vscode.EventEmitter<T>();
|
||||
protected _isOpen: boolean = false;
|
||||
// public readonly onSuccess: vscode.Event<T> = this._onSuccess.event;
|
||||
public dialog: azdata.window.Dialog | undefined;
|
||||
|
||||
private assessmentTable: azdata.TableComponent | undefined;
|
||||
|
||||
// Dialog Name for Telemetry
|
||||
public dialogName: string | undefined;
|
||||
|
||||
constructor(public ownerUri: string, public model: MigrationStateModel, public title: string) {
|
||||
}
|
||||
|
||||
protected async updateModel(): Promise<void> {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
protected async initializeDialog(dialog: azdata.window.Dialog): Promise<void> {
|
||||
dialog.registerContent(async view => {
|
||||
this.assessmentTable = view.modelBuilder.table()
|
||||
.withProperties({
|
||||
columns: [
|
||||
'Target',
|
||||
'Target Name',
|
||||
'Rule ID',
|
||||
'Rule Name',
|
||||
'Description',
|
||||
'Impacted Objects'
|
||||
],
|
||||
data: [],
|
||||
height: 700,
|
||||
width: 1100
|
||||
}).component();
|
||||
|
||||
let formModel = view.modelBuilder.formContainer()
|
||||
.withFormItems([
|
||||
{
|
||||
components: [{
|
||||
component: this.assessmentTable,
|
||||
title: 'Results',
|
||||
layout: {
|
||||
info: 'Assessment Results'
|
||||
}
|
||||
}],
|
||||
title: 'Assessment Results'
|
||||
}]).withLayout({ width: '100%' }).component();
|
||||
|
||||
await view.initializeModel(formModel);
|
||||
|
||||
let data = this.convertAssessmentToData(this.model.assessmentResults);
|
||||
this.assessmentTable.data = data;
|
||||
});
|
||||
}
|
||||
|
||||
private convertAssessmentToData(assessments: mssql.SqlMigrationAssessmentResultItem[] | undefined): Array<string | number>[] {
|
||||
let result: Array<string | number>[] = [];
|
||||
if (assessments) {
|
||||
assessments.forEach(assessment => {
|
||||
if (assessment.impactedObjects && assessment.impactedObjects.length > 0) {
|
||||
assessment.impactedObjects.forEach(impactedObject => {
|
||||
this.addAssessmentColumn(result, assessment, impactedObject);
|
||||
});
|
||||
} else {
|
||||
this.addAssessmentColumn(result, assessment, undefined);
|
||||
}
|
||||
});
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private addAssessmentColumn(
|
||||
result: Array<string | number>[],
|
||||
assessment: mssql.SqlMigrationAssessmentResultItem,
|
||||
impactedObject: mssql.SqlMigrationImpactedObjectInfo | undefined): void {
|
||||
let cols = [];
|
||||
cols.push(assessment.appliesToMigrationTargetPlatform);
|
||||
cols.push(assessment.displayName);
|
||||
cols.push(assessment.checkId);
|
||||
cols.push(assessment.rulesetName);
|
||||
cols.push(assessment.description);
|
||||
cols.push(impactedObject?.name ?? '');
|
||||
result.push(cols);
|
||||
}
|
||||
|
||||
public async openDialog(dialogName?: string) {
|
||||
if (!this._isOpen) {
|
||||
this._isOpen = true;
|
||||
this.dialog = azdata.window.createModelViewDialog(this.title, this.title, true);
|
||||
|
||||
// await this.model.initialize();
|
||||
|
||||
await this.initializeDialog(this.dialog);
|
||||
|
||||
this.dialog.okButton.label = AssessmentResultsDialog.OkButtonText;
|
||||
this.dialog.okButton.onClick(async () => await this.execute());
|
||||
|
||||
this.dialog.cancelButton.label = AssessmentResultsDialog.CancelButtonText;
|
||||
this.dialog.cancelButton.onClick(async () => await this.cancel());
|
||||
|
||||
azdata.window.openDialog(this.dialog);
|
||||
}
|
||||
}
|
||||
|
||||
protected async execute() {
|
||||
this.updateModel();
|
||||
// await this.model.save();
|
||||
this._isOpen = false;
|
||||
// this._onSuccess.fire(this.model);
|
||||
}
|
||||
|
||||
protected async cancel() {
|
||||
this._isOpen = false;
|
||||
}
|
||||
|
||||
|
||||
public get isOpen(): boolean {
|
||||
return this._isOpen;
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import { MigrationStateModel, StateChangeEvent } from '../models/stateMachine';
|
||||
import { Product, ProductLookupTable } from '../models/product';
|
||||
import { SKU_RECOMMENDATION_PAGE_TITLE, SKU_RECOMMENDATION_CHOOSE_A_TARGET } from '../models/strings';
|
||||
import { Disposable } from 'vscode';
|
||||
import { AssessmentResultsDialog } from './assessmentResultsDialog';
|
||||
|
||||
export class SKURecommendationPage extends MigrationWizardPage {
|
||||
// For future reference: DO NOT EXPOSE WIZARD DIRECTLY THROUGH HERE.
|
||||
@@ -30,14 +31,30 @@ export class SKURecommendationPage extends MigrationWizardPage {
|
||||
this.igComponent = this.createStatusComponent(view); // The first component giving basic information
|
||||
this.detailsComponent = this.createDetailsComponent(view); // The details of what can be moved
|
||||
this.chooseTargetComponent = this.createChooseTargetComponent(view);
|
||||
|
||||
|
||||
const assessmentLink = view.modelBuilder.hyperlink()
|
||||
.withProperties<azdata.HyperlinkComponentProperties>({
|
||||
label: 'View Assessment Results',
|
||||
url: ''
|
||||
}).component();
|
||||
assessmentLink.onDidClick(async () => {
|
||||
let dialog = new AssessmentResultsDialog('ownerUri', this.migrationStateModel, 'Assessment Dialog');
|
||||
dialog.openDialog();
|
||||
});
|
||||
|
||||
const assessmentFormLink = {
|
||||
title: '',
|
||||
component: assessmentLink,
|
||||
};
|
||||
|
||||
this.view = view;
|
||||
|
||||
|
||||
const form = view.modelBuilder.formContainer().withFormItems(
|
||||
[
|
||||
this.igComponent,
|
||||
this.detailsComponent,
|
||||
this.chooseTargetComponent
|
||||
this.chooseTargetComponent,
|
||||
assessmentFormLink
|
||||
]
|
||||
);
|
||||
|
||||
@@ -95,7 +112,7 @@ export class SKURecommendationPage extends MigrationWizardPage {
|
||||
rbg.component().cards.push({
|
||||
id: product.name,
|
||||
icon: imagePath,
|
||||
label: 'Some Label'
|
||||
label: product.name
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -32,12 +32,16 @@ export class SourceConfigurationPage extends MigrationWizardPage {
|
||||
).component();
|
||||
|
||||
await view.initializeModel(form);
|
||||
|
||||
let connectionUri: string = await azdata.connection.getUriForConnection(this.migrationStateModel.sourceConnection.connectionId);
|
||||
this.migrationStateModel.migrationService.getAssessments(connectionUri).then(results => {
|
||||
if (results) {
|
||||
this.migrationStateModel.assessmentResults = results.items;
|
||||
this.migrationStateModel.currentState = State.TARGET_SELECTION;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// private async createInformationGatheredPage(view: azdata.ModelView){
|
||||
|
||||
// }
|
||||
|
||||
private async enterErrorState() {
|
||||
const component = this.gatheringInfoComponent.component as azdata.TextComponent;
|
||||
component.value = COLLECTING_SOURCE_CONFIGURATIONS_ERROR(this.migrationStateModel.gatheringInformationError);
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import * as azdata from 'azdata';
|
||||
import * as vscode from 'vscode';
|
||||
import * as mssql from '../../../mssql';
|
||||
import { MigrationStateModel } from '../models/stateMachine';
|
||||
import { SourceConfigurationPage } from './sourceConfigurationPage';
|
||||
import { WIZARD_TITLE } from '../models/strings';
|
||||
@@ -17,10 +18,12 @@ export class WizardController {
|
||||
}
|
||||
|
||||
public async openWizard(profile: azdata.connection.Connection): Promise<void> {
|
||||
const stateModel = new MigrationStateModel(this.extensionContext, profile);
|
||||
this.extensionContext.subscriptions.push(stateModel);
|
||||
|
||||
this.createWizard(stateModel);
|
||||
const api = (await vscode.extensions.getExtension(mssql.extension.name)?.activate()) as mssql.IExtension;
|
||||
if (api) {
|
||||
const stateModel = new MigrationStateModel(this.extensionContext, profile, api.sqlMigration);
|
||||
this.extensionContext.subscriptions.push(stateModel);
|
||||
this.createWizard(stateModel);
|
||||
}
|
||||
}
|
||||
|
||||
private async createWizard(stateModel: MigrationStateModel): Promise<void> {
|
||||
|
||||
Reference in New Issue
Block a user