mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-22 01:25:38 -05:00
skuRecommendationPage & azdata change (#11863)
* skuRecommendationPage * fix
This commit is contained in:
30
extensions/sql-migration/src/models/externalContract.ts
Normal file
30
extensions/sql-migration/src/models/externalContract.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* 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 { SKURecommendation } from './product';
|
||||
|
||||
export interface Base {
|
||||
uuid: string;
|
||||
}
|
||||
|
||||
export interface BaseRequest extends Base { }
|
||||
|
||||
export interface BaseResponse<T> extends Base {
|
||||
error?: string;
|
||||
response: T;
|
||||
}
|
||||
|
||||
export interface GatherInformationRequest extends BaseRequest {
|
||||
connection: azdata.connection.Connection;
|
||||
}
|
||||
|
||||
export interface SKURecommendations {
|
||||
recommendations: SKURecommendation[];
|
||||
}
|
||||
|
||||
export interface GatherInformationResponse extends BaseResponse<SKURecommendations> {
|
||||
}
|
||||
|
||||
@@ -6,9 +6,24 @@
|
||||
import * as azdata from 'azdata';
|
||||
import { MigrationStateModel, StateChangeEvent } from './stateMachine';
|
||||
export abstract class MigrationWizardPage {
|
||||
constructor(protected readonly wizardPage: azdata.window.WizardPage, protected readonly migrationStateModel: MigrationStateModel) { }
|
||||
constructor(private readonly wizard: azdata.window.Wizard, protected readonly wizardPage: azdata.window.WizardPage, protected readonly migrationStateModel: MigrationStateModel) { }
|
||||
|
||||
public abstract async registerWizardContent(): Promise<void>;
|
||||
public registerWizardContent(): Promise<void> {
|
||||
return new Promise<void>(async (resolve, reject) => {
|
||||
this.wizardPage.registerContent(async (view) => {
|
||||
try {
|
||||
await this.registerContent(view);
|
||||
resolve();
|
||||
} catch (ex) {
|
||||
reject(ex);
|
||||
} finally {
|
||||
reject(new Error());
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
protected abstract async registerContent(view: azdata.ModelView): Promise<void>;
|
||||
|
||||
public getwizardPage(): azdata.window.WizardPage {
|
||||
return this.wizardPage;
|
||||
@@ -48,5 +63,19 @@ export abstract class MigrationWizardPage {
|
||||
}
|
||||
|
||||
protected abstract async handleStateChange(e: StateChangeEvent): Promise<void>;
|
||||
|
||||
public canEnter(): Promise<boolean> {
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
|
||||
public canLeave(): Promise<boolean> {
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
|
||||
protected async goToNextPage(): Promise<void> {
|
||||
const current = this.wizard.currentPage;
|
||||
await this.wizard.setCurrentPage(current + 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -2,15 +2,58 @@
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import * as nls from 'vscode-nls';
|
||||
const localize = nls.loadMessageBundle();
|
||||
|
||||
export interface Product {
|
||||
name: string;
|
||||
learnMoreLink: string | undefined;
|
||||
icon: string;
|
||||
export type MigrationProductType = 'AzureSQLMI' | 'AzureSQLVM';
|
||||
export interface MigrationProduct {
|
||||
readonly type: MigrationProductType;
|
||||
}
|
||||
|
||||
export interface Check {
|
||||
|
||||
}
|
||||
|
||||
export interface Checks {
|
||||
// fill some information
|
||||
checks: Check;
|
||||
// If there is not going to be any more information, use Check[] directly
|
||||
}
|
||||
|
||||
export interface Product extends MigrationProduct {
|
||||
readonly name: string;
|
||||
readonly icon: string;
|
||||
readonly learnMoreLink?: string;
|
||||
}
|
||||
|
||||
export class Product implements Product {
|
||||
constructor(public readonly type: MigrationProductType, public readonly name: string, public readonly icon: string, public readonly learnMoreLink?: string) {
|
||||
|
||||
}
|
||||
|
||||
static FromMigrationProduct(migrationProduct: MigrationProduct) {
|
||||
// TODO: populatie from some lookup table;
|
||||
|
||||
const product: Product | undefined = ProductLookupTable[migrationProduct.type];
|
||||
return new Product(migrationProduct.type, product?.name ?? '', product.icon ?? '');
|
||||
}
|
||||
}
|
||||
|
||||
export interface SKURecommendation {
|
||||
product: Product;
|
||||
migratableDatabases: number;
|
||||
totalDatabases: number;
|
||||
product: MigrationProduct;
|
||||
checks: Checks;
|
||||
}
|
||||
|
||||
|
||||
const ProductLookupTable: { [key in MigrationProductType]: Product } = {
|
||||
'AzureSQLMI': {
|
||||
type: 'AzureSQLMI',
|
||||
name: localize('sql.migration.products.azuresqlmi.name', 'Azure Managed Instance (Microsoft managed)'),
|
||||
icon: 'TODO',
|
||||
},
|
||||
'AzureSQLVM': {
|
||||
type: 'AzureSQLVM',
|
||||
name: localize('sql.migration.products.azuresqlvm.name', 'Azure SQL Virtual Machine (Customer managed)'),
|
||||
icon: 'TODO',
|
||||
}
|
||||
};
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
import * as azdata from 'azdata';
|
||||
import * as vscode from 'vscode';
|
||||
import { SKURecommendations } from './externalContract';
|
||||
|
||||
export enum State {
|
||||
INIT,
|
||||
@@ -28,6 +29,7 @@ export interface Model {
|
||||
readonly sourceConnection: azdata.connection.Connection;
|
||||
readonly currentState: State;
|
||||
gatheringInformationError: string | undefined;
|
||||
skuRecommendations: SKURecommendations | undefined;
|
||||
}
|
||||
|
||||
export interface StateChangeEvent {
|
||||
@@ -39,6 +41,7 @@ export class MigrationStateModel implements Model, vscode.Disposable {
|
||||
private _stateChangeEventEmitter = new vscode.EventEmitter<StateChangeEvent>();
|
||||
private _currentState: State;
|
||||
private _gatheringInformationError: string | undefined;
|
||||
private _skuRecommendations: SKURecommendations | undefined;
|
||||
|
||||
constructor(private readonly _sourceConnection: azdata.connection.Connection) {
|
||||
this._currentState = State.INIT;
|
||||
@@ -68,6 +71,14 @@ export class MigrationStateModel implements Model, vscode.Disposable {
|
||||
this._gatheringInformationError = error;
|
||||
}
|
||||
|
||||
public get skuRecommendations(): SKURecommendations | undefined {
|
||||
return this._skuRecommendations;
|
||||
}
|
||||
|
||||
public set skuRecommendations(recommendations: SKURecommendations | undefined) {
|
||||
this._skuRecommendations = recommendations;
|
||||
}
|
||||
|
||||
public get stateChangeEvent(): vscode.Event<StateChangeEvent> {
|
||||
return this._stateChangeEventEmitter.event;
|
||||
}
|
||||
|
||||
@@ -18,12 +18,14 @@ export const COLLECTING_SOURCE_CONFIGURATIONS_ERROR = (error: string = ''): stri
|
||||
return localize('sql.migration.collecting_source_configurations.error', "There was an error when gathering information about your data configuration. {0}", error);
|
||||
};
|
||||
|
||||
export const SKU_RECOMMENDATION_PAGE_TITLE = localize('sql.migration.wizard.sku.title', "Azure SQL Target Selection");
|
||||
export const SKU_RECOMMENDATION_ALL_SUCCESSFUL = (databaseCount: number): string => {
|
||||
return localize('sql.migration.sku.all', "Based on the results of our source configuration scans, all {0} of your databases can be migrated to Azure SQL.", databaseCount);
|
||||
};
|
||||
|
||||
export const SKU_RECOMMENDATION_SOME_SUCCESSFUL = (migratableCount: number, databaseCount: number): string => {
|
||||
return localize('sql.migration.sku.some', "Based on the results of our source configuration scans, {0} out of {1} of your databases can be migrated to Azure SQL.", migratableCount, databaseCount);
|
||||
};
|
||||
|
||||
export const SKU_RECOMMENDATION_NONE_SUCCESSFUL = localize('sql.migration.sku.none', "Based on the results of our source configuration scans, none of your databases can be migrated to Azure SQL.");
|
||||
|
||||
|
||||
export const CONGRATULATIONS = localize('sql.migration.generic.congratulations', "Congratulations");
|
||||
|
||||
Reference in New Issue
Block a user