Files
azuredatastudio/extensions/sql-migration/src/models/migrationWizardPage.ts
Aasim Khan d2a525bbbe Adding database backup and accounts page to migration wizard (#13764)
* Added localized strings
Created a db backup page
added radio buttons

* created components for database backup page

* Added account selection page

* Added accounts page

* Some more work done

- Added page validations
- Almost done with db backup except for a few api calls.

* Some more progress
added graph api for storage account

* Finished hooking up all the endpoints on db page.

* Some code fixed and refactoring

* Fixed a ton of validation bugs

* Added common localized strings to the constants file

* some code cleanup

* changed method name to makeHttpGetRequest

* change http result class name

* Added return types and return values to the functions

* removed void returns

* Added more return types and values

* Storing accounts in the map with ids as key
Fixed a bug in case of no subscriptions found

* cleaning up the code

* Fixed localized strings

* Added comments to get request api
Added validation logic to database backup page
removed unnecessary page validations.

* Added some get resource functions in azure core

* Changed thenable to promise

* Added arm calls for file shares and blob storage

* Added field specific validation error message

* Added examples in validation error message.

* Fixed some typings and localized string

* Added live validations to dropdowns

* Fixed method name to getSQLVMservers

* Using older storage package

* Update typings/namings (#13767)

* Update typings

* more typings fixes

* switched fileshares and blobcontainers api to http requests

* removed the extra line

* Adding resource graph documentation link as a comment

* remove makeHttpRequest api from azurecore

Co-authored-by: Charles Gagnon <chgagnon@microsoft.com>
2020-12-11 11:54:19 -08:00

86 lines
2.3 KiB
TypeScript

/*---------------------------------------------------------------------------------------------
* 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, StateChangeEvent } from './stateMachine';
export abstract class MigrationWizardPage {
constructor(
protected readonly wizard: azdata.window.Wizard,
protected readonly wizardPage: azdata.window.WizardPage,
protected readonly migrationStateModel: MigrationStateModel
) { }
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;
}
public abstract async onPageEnter(): Promise<void>;
public abstract async onPageLeave(): Promise<void>;
private readonly stateChanges: (() => Promise<void>)[] = [];
protected async onStateChangeEvent(e: StateChangeEvent) {
this.stateChanges.push((): Promise<void> => {
return this.handleStateChange(e);
});
this.enableQueueProcessor();
}
private queueActive = false;
private async enableQueueProcessor(): Promise<void> {
if (this.queueActive) {
return;
}
this.queueActive = true;
while (true) {
const stateChangeFunction = this.stateChanges.shift();
if (!stateChangeFunction) {
break;
}
try {
await stateChangeFunction();
} catch (ex) {
console.error(ex);
}
}
this.queueActive = false;
}
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);
}
}