diff --git a/extensions/sql-migration/src/models/migrationWizardPage.ts b/extensions/sql-migration/src/models/migrationWizardPage.ts index 626baa9a41..721419c406 100644 --- a/extensions/sql-migration/src/models/migrationWizardPage.ts +++ b/extensions/sql-migration/src/models/migrationWizardPage.ts @@ -13,5 +13,8 @@ export abstract class MigrationWizardPage { public getwizardPage(): azdata.window.WizardPage { return this.wizardPage; } + + public abstract async onPageEnter(): Promise; + public abstract async onPageLeave(): Promise; } diff --git a/extensions/sql-migration/src/models/strings.ts b/extensions/sql-migration/src/models/strings.ts index 27c527e72e..5e35cc9726 100644 --- a/extensions/sql-migration/src/models/strings.ts +++ b/extensions/sql-migration/src/models/strings.ts @@ -14,3 +14,7 @@ export const SOURCE_CONFIGURATION_PAGE_TITLE = localize('sql.migration.wizard.so export const COLLECTING_SOURCE_CONFIGURATIONS = localize('sql.migration.collecting_source_configurations', "Collecting source configurations"); export const COLLECTING_SOURCE_CONFIGURATIONS_INFO = localize('sql.migration.collecting_source_configurations.info', "We need to collect some information about how your data is configured currently.\nThis may take some time."); +export const COLLECTING_SOURCE_CONFIGURATIONS_ERROR = (error: string = ''): string => { + return localize('sql.migration.collecting_source_configurations.error', "There was an error when gathering information about your data configuration. {0}", error); +}; + diff --git a/extensions/sql-migration/src/wizard/sourceConfigurationPage.ts b/extensions/sql-migration/src/wizard/sourceConfigurationPage.ts index 9338b32cd9..9fb3510168 100644 --- a/extensions/sql-migration/src/wizard/sourceConfigurationPage.ts +++ b/extensions/sql-migration/src/wizard/sourceConfigurationPage.ts @@ -5,7 +5,7 @@ import * as azdata from 'azdata'; import { MigrationWizardPage } from '../models/migrationWizardPage'; -import { SOURCE_CONFIGURATION_PAGE_TITLE, COLLECTING_SOURCE_CONFIGURATIONS, COLLECTING_SOURCE_CONFIGURATIONS_INFO } from '../models/strings'; +import { SOURCE_CONFIGURATION_PAGE_TITLE, COLLECTING_SOURCE_CONFIGURATIONS, COLLECTING_SOURCE_CONFIGURATIONS_INFO, COLLECTING_SOURCE_CONFIGURATIONS_ERROR } from '../models/strings'; import { MigrationStateModel } from '../models/stateMachine'; export class SourceConfigurationPage extends MigrationWizardPage { @@ -29,10 +29,23 @@ export class SourceConfigurationPage extends MigrationWizardPage { } private async registerContent(view: azdata.ModelView) { - const gatheringInfoComponent = this.createGatheringInfoComponent(view); + await this.createGatheringInformationPage(view); + setTimeout(async () => { + console.log('doing it'); + try { + await this.createErrorInInformationGatheringPage(view); + } catch (ex) { + console.log(ex); + } + }, 5000); + } + + private gatheringInfoComponent!: azdata.FormComponent; + private async createGatheringInformationPage(view: azdata.ModelView) { + this.gatheringInfoComponent = this.createGatheringInfoComponent(view); const form = view.modelBuilder.formContainer().withFormItems( [ - gatheringInfoComponent + this.gatheringInfoComponent ], { titleFontSize: '20px' @@ -42,6 +55,16 @@ export class SourceConfigurationPage extends MigrationWizardPage { await view.initializeModel(form); } + // private async createInformationGatheredPage(view: azdata.ModelView){ + + // } + + private async createErrorInInformationGatheringPage(view: azdata.ModelView) { + const component = this.gatheringInfoComponent.component as azdata.TextComponent; + component.value = COLLECTING_SOURCE_CONFIGURATIONS_ERROR('Some error'); + } + + //#region component builders private createGatheringInfoComponent(view: azdata.ModelView): azdata.FormComponent { let explaination = view.modelBuilder.text().withProperties({ value: COLLECTING_SOURCE_CONFIGURATIONS_INFO, @@ -55,4 +78,12 @@ export class SourceConfigurationPage extends MigrationWizardPage { title: COLLECTING_SOURCE_CONFIGURATIONS }; } + //#endregion + public async onPageEnter(): Promise { + + } + + public async onPageLeave(): Promise { + + } } diff --git a/extensions/sql-migration/src/wizard/wizardController.ts b/extensions/sql-migration/src/wizard/wizardController.ts index 528289b3dc..1021783910 100644 --- a/extensions/sql-migration/src/wizard/wizardController.ts +++ b/extensions/sql-migration/src/wizard/wizardController.ts @@ -7,6 +7,7 @@ import * as vscode from 'vscode'; import { MigrationStateModel } from '../models/stateMachine'; import { SourceConfigurationPage } from './sourceConfigurationPage'; import { WIZARD_TITLE } from '../models/strings'; +import { MigrationWizardPage } from '../models/migrationWizardPage'; export class WizardController { constructor(private readonly extensionContext: vscode.ExtensionContext) { @@ -25,12 +26,24 @@ export class WizardController { wizard.generateScriptButton.enabled = false; const sourceConfigurationPage = new SourceConfigurationPage(stateModel); - wizard.pages = [sourceConfigurationPage.getwizardPage()]; + const pages: MigrationWizardPage[] = [sourceConfigurationPage]; + + wizard.pages = pages.map(p => p.getwizardPage()); const wizardSetupPromises: Thenable[] = []; wizardSetupPromises.push(sourceConfigurationPage.registerWizardContent()); wizardSetupPromises.push(wizard.open()); + wizard.onPageChanged(async (pageChangeInfo: azdata.window.WizardPageChangeInfo) => { + const newPage = pageChangeInfo.newPage; + const lastPage = pageChangeInfo.lastPage; + + await pages[lastPage]?.onPageLeave(); + await pages[newPage]?.onPageEnter(); + }); + + await Promise.all(wizardSetupPromises); + await pages[0].onPageEnter(); } }