Migration wizard skeleton setup (#11758)

This commit is contained in:
Amir Omidi
2020-08-11 14:54:40 -07:00
committed by GitHub
parent 3432743f63
commit acd9fc8fd6
5 changed files with 118 additions and 0 deletions

View File

@@ -3,7 +3,11 @@
* 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 {
INIT,
COLLECTING_SOURCE_INFO,
COLLECTION_SOURCE_INFO_ERROR,
TARGET_SELECTION,
@@ -20,3 +24,45 @@ export enum State {
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();
}
}