mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Migration wizard skeleton setup (#11758)
This commit is contained in:
17
extensions/sql-migration/src/models/migrationWizardPage.ts
Normal file
17
extensions/sql-migration/src/models/migrationWizardPage.ts
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
/*---------------------------------------------------------------------------------------------
|
||||||
|
* 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 { MigrationStateModel } from './stateMachine';
|
||||||
|
export abstract class MigrationWizardPage {
|
||||||
|
constructor(protected readonly wizardPage: azdata.window.WizardPage, protected readonly migrationStateModel: MigrationStateModel) { }
|
||||||
|
|
||||||
|
public abstract async registerWizardContent(): Promise<void>;
|
||||||
|
|
||||||
|
public getwizardPage(): azdata.window.WizardPage {
|
||||||
|
return this.wizardPage;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -3,7 +3,11 @@
|
|||||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
import * as azdata from 'azdata';
|
||||||
|
import * as vscode from 'vscode';
|
||||||
|
|
||||||
export enum State {
|
export enum State {
|
||||||
|
INIT,
|
||||||
COLLECTING_SOURCE_INFO,
|
COLLECTING_SOURCE_INFO,
|
||||||
COLLECTION_SOURCE_INFO_ERROR,
|
COLLECTION_SOURCE_INFO_ERROR,
|
||||||
TARGET_SELECTION,
|
TARGET_SELECTION,
|
||||||
@@ -20,3 +24,45 @@ export enum State {
|
|||||||
EXIT,
|
EXIT,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface Model {
|
||||||
|
readonly sourceConnection: azdata.IConnectionProfile;
|
||||||
|
readonly currentState: State;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface StateChangeEvent {
|
||||||
|
oldState: State;
|
||||||
|
newState: State;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class MigrationStateModel implements Model, vscode.Disposable {
|
||||||
|
private _stateChangeEventEmitter = new vscode.EventEmitter<StateChangeEvent>();
|
||||||
|
private _currentState: State;
|
||||||
|
|
||||||
|
constructor(private readonly _sourceConnection: azdata.IConnectionProfile) {
|
||||||
|
this._currentState = State.INIT;
|
||||||
|
}
|
||||||
|
|
||||||
|
public get sourceConnection(): azdata.IConnectionProfile {
|
||||||
|
return this._sourceConnection;
|
||||||
|
}
|
||||||
|
|
||||||
|
public get currentState(): State {
|
||||||
|
return this._currentState;
|
||||||
|
}
|
||||||
|
|
||||||
|
public set currentState(newState: State) {
|
||||||
|
const oldState = this.currentState;
|
||||||
|
|
||||||
|
this._currentState = newState;
|
||||||
|
|
||||||
|
this._stateChangeEventEmitter.fire({ oldState, newState: this.currentState });
|
||||||
|
}
|
||||||
|
|
||||||
|
public get stateChangeEvent(): vscode.Event<StateChangeEvent> {
|
||||||
|
return this._stateChangeEventEmitter.event;
|
||||||
|
}
|
||||||
|
|
||||||
|
dispose() {
|
||||||
|
this._stateChangeEventEmitter.dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
11
extensions/sql-migration/src/models/strings.ts
Normal file
11
extensions/sql-migration/src/models/strings.ts
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
/*---------------------------------------------------------------------------------------------
|
||||||
|
* 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 const WIZARD_TITLE = localize('sql-migration.wizard.title', "SQL Migration Wizard");
|
||||||
|
export const SOURCE_CONFIGURATION_PAGE_TITLE = localize('sql.migration.wizard.source_configuration.title', "SQL Source Configuration");
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
/*---------------------------------------------------------------------------------------------
|
||||||
|
* 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 { MigrationWizardPage } from '../models/migrationWizardPage';
|
||||||
|
import { SOURCE_CONFIGURATION_PAGE_TITLE } from '../models/strings';
|
||||||
|
import { MigrationStateModel } from '../models/stateMachine';
|
||||||
|
|
||||||
|
export class SourceConfigurationPage extends MigrationWizardPage {
|
||||||
|
constructor(migrationStateModel: MigrationStateModel) {
|
||||||
|
super(azdata.window.createWizardPage(SOURCE_CONFIGURATION_PAGE_TITLE), migrationStateModel);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async 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());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private async registerContent(view: azdata.ModelView) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,6 +2,10 @@
|
|||||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
import * as azdata from 'azdata';
|
||||||
|
import { WIZARD_TITLE } from '../models/strings';
|
||||||
|
import { SourceConfigurationPage } from './sourceConfigurationPage';
|
||||||
|
import { MigrationStateModel } from '../models/stateMachine';
|
||||||
|
|
||||||
export class WizardController {
|
export class WizardController {
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -9,6 +13,12 @@ export class WizardController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async openWizard(): Promise<void> {
|
public async openWizard(): Promise<void> {
|
||||||
|
}
|
||||||
|
|
||||||
|
public async createWizard(): Promise<void> {
|
||||||
|
azdata.window.createWizard(WIZARD_TITLE, 'wide');
|
||||||
|
const stateModel = new MigrationStateModel({} as azdata.IConnectionProfile);
|
||||||
|
new SourceConfigurationPage(stateModel);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user