mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Page changing (#11770)
This commit is contained in:
@@ -13,5 +13,8 @@ export abstract class MigrationWizardPage {
|
|||||||
public getwizardPage(): azdata.window.WizardPage {
|
public getwizardPage(): azdata.window.WizardPage {
|
||||||
return this.wizardPage;
|
return this.wizardPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public abstract async onPageEnter(): Promise<void>;
|
||||||
|
public abstract async onPageLeave(): Promise<void>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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 = 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_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);
|
||||||
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
import * as azdata from 'azdata';
|
import * as azdata from 'azdata';
|
||||||
import { MigrationWizardPage } from '../models/migrationWizardPage';
|
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';
|
import { MigrationStateModel } from '../models/stateMachine';
|
||||||
|
|
||||||
export class SourceConfigurationPage extends MigrationWizardPage {
|
export class SourceConfigurationPage extends MigrationWizardPage {
|
||||||
@@ -29,10 +29,23 @@ export class SourceConfigurationPage extends MigrationWizardPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async registerContent(view: azdata.ModelView) {
|
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(
|
const form = view.modelBuilder.formContainer().withFormItems(
|
||||||
[
|
[
|
||||||
gatheringInfoComponent
|
this.gatheringInfoComponent
|
||||||
],
|
],
|
||||||
{
|
{
|
||||||
titleFontSize: '20px'
|
titleFontSize: '20px'
|
||||||
@@ -42,6 +55,16 @@ export class SourceConfigurationPage extends MigrationWizardPage {
|
|||||||
await view.initializeModel(form);
|
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 {
|
private createGatheringInfoComponent(view: azdata.ModelView): azdata.FormComponent {
|
||||||
let explaination = view.modelBuilder.text().withProperties<azdata.TextComponentProperties>({
|
let explaination = view.modelBuilder.text().withProperties<azdata.TextComponentProperties>({
|
||||||
value: COLLECTING_SOURCE_CONFIGURATIONS_INFO,
|
value: COLLECTING_SOURCE_CONFIGURATIONS_INFO,
|
||||||
@@ -55,4 +78,12 @@ export class SourceConfigurationPage extends MigrationWizardPage {
|
|||||||
title: COLLECTING_SOURCE_CONFIGURATIONS
|
title: COLLECTING_SOURCE_CONFIGURATIONS
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
//#endregion
|
||||||
|
public async onPageEnter(): Promise<void> {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public async onPageLeave(): Promise<void> {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import * as vscode from 'vscode';
|
|||||||
import { MigrationStateModel } from '../models/stateMachine';
|
import { MigrationStateModel } from '../models/stateMachine';
|
||||||
import { SourceConfigurationPage } from './sourceConfigurationPage';
|
import { SourceConfigurationPage } from './sourceConfigurationPage';
|
||||||
import { WIZARD_TITLE } from '../models/strings';
|
import { WIZARD_TITLE } from '../models/strings';
|
||||||
|
import { MigrationWizardPage } from '../models/migrationWizardPage';
|
||||||
|
|
||||||
export class WizardController {
|
export class WizardController {
|
||||||
constructor(private readonly extensionContext: vscode.ExtensionContext) {
|
constructor(private readonly extensionContext: vscode.ExtensionContext) {
|
||||||
@@ -25,12 +26,24 @@ export class WizardController {
|
|||||||
wizard.generateScriptButton.enabled = false;
|
wizard.generateScriptButton.enabled = false;
|
||||||
const sourceConfigurationPage = new SourceConfigurationPage(stateModel);
|
const sourceConfigurationPage = new SourceConfigurationPage(stateModel);
|
||||||
|
|
||||||
wizard.pages = [sourceConfigurationPage.getwizardPage()];
|
const pages: MigrationWizardPage[] = [sourceConfigurationPage];
|
||||||
|
|
||||||
|
wizard.pages = pages.map(p => p.getwizardPage());
|
||||||
|
|
||||||
const wizardSetupPromises: Thenable<void>[] = [];
|
const wizardSetupPromises: Thenable<void>[] = [];
|
||||||
wizardSetupPromises.push(sourceConfigurationPage.registerWizardContent());
|
wizardSetupPromises.push(sourceConfigurationPage.registerWizardContent());
|
||||||
wizardSetupPromises.push(wizard.open());
|
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 Promise.all(wizardSetupPromises);
|
||||||
|
await pages[0].onPageEnter();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user