diff --git a/extensions/import/src/test/wizard/pages/fileConfigPage.test.ts b/extensions/import/src/test/wizard/pages/fileConfigPage.test.ts index 153896d4e0..0b6933e8e6 100644 --- a/extensions/import/src/test/wizard/pages/fileConfigPage.test.ts +++ b/extensions/import/src/test/wizard/pages/fileConfigPage.test.ts @@ -238,7 +238,6 @@ describe('File config page', function () { fileConfigPage = new FileConfigPage(mockFlatFileWizard.object, page, mockImportModel.object, view, TypeMoq.It.isAny()); pages.set(1, fileConfigPage); await fileConfigPage.start(); - fileConfigPage.setupNavigationValidator(); resolve(); }); wizard.generateScriptButton.hidden = true; diff --git a/extensions/import/src/wizard/api/basePage.ts b/extensions/import/src/wizard/api/basePage.ts index 21a1ca9522..4b5563107e 100644 --- a/extensions/import/src/wizard/api/basePage.ts +++ b/extensions/import/src/wizard/api/basePage.ts @@ -40,7 +40,8 @@ export abstract class BasePage { * Sets up a navigation validator. * This will be called right before onPageEnter(). */ - public abstract setupNavigationValidator(): void; + public setupNavigationValidator(): void { + } public async getServerValues(): Promise<{ connection: azdata.connection.Connection, displayName: string, name: string }[]> { let cons = await azdata.connection.getActiveConnections(); diff --git a/extensions/import/src/wizard/pages/fileConfigPage.ts b/extensions/import/src/wizard/pages/fileConfigPage.ts index f8b4d8060b..d191d1b871 100644 --- a/extensions/import/src/wizard/pages/fileConfigPage.ts +++ b/extensions/import/src/wizard/pages/fileConfigPage.ts @@ -129,30 +129,21 @@ export class FileConfigPage extends ImportPage { return true; } - public setupNavigationValidator() { - this.instance.registerNavigationValidator((info) => { - if (this.schemaLoader.loading || this.databaseDropdown.loading) { - return false; - } - return true; - }); - } - private async createServerDropdown(): Promise { this.serverDropdown = this.view.modelBuilder.dropDown().withProps({ required: true }).component(); // Handle server changes - this.serverDropdown.onValueChanged(async () => { - const connectionValue = this.serverDropdown.value as ConnectionDropdownValue; - if (!connectionValue) { - return; + this.serverDropdown.onValueChanged(async (value) => { + if (value.selected) { + const connectionValue = this.serverDropdown.value as ConnectionDropdownValue; + if (!connectionValue) { + return; + } + this.model.server = connectionValue.connection; + await this.populateDatabaseDropdown(); } - this.model.server = connectionValue.connection; - - await this.populateDatabaseDropdown(); - await this.populateSchemaDropdown(); }); return { @@ -179,19 +170,21 @@ export class FileConfigPage extends ImportPage { }).component(); // Handle database changes - this.databaseDropdown.onValueChanged(async () => { - const nameValue = this.databaseDropdown.value as azdata.CategoryValue; - if (!nameValue) { - return; + this.databaseDropdown.onValueChanged(async (value) => { + if (value.selected) { + const nameValue = this.databaseDropdown.value as azdata.CategoryValue; + if (!nameValue) { + return; + } + this.model.database = nameValue.name; + if (!this.model.server) { + return; + } + let connectionProvider = azdata.dataprotocol.getProvider(this.model.server.providerName, azdata.DataProviderType.ConnectionProvider); + let connectionUri = await azdata.connection.getUriForConnection(this.model.server.connectionId); + connectionProvider.changeDatabase(connectionUri, this.model.database); + this.populateSchemaDropdown(); } - this.model.database = nameValue.name; - if (!this.model.server) { - return; - } - let connectionProvider = azdata.dataprotocol.getProvider(this.model.server.providerName, azdata.DataProviderType.ConnectionProvider); - let connectionUri = await azdata.connection.getUriForConnection(this.model.server.connectionId); - connectionProvider.changeDatabase(connectionUri, this.model.database); - this.populateSchemaDropdown(); }); return { @@ -347,12 +340,14 @@ export class FileConfigPage extends ImportPage { }).component(); this.schemaLoader = this.view.modelBuilder.loadingComponent().withItem(this.schemaDropdown).component(); - this.schemaDropdown.onValueChanged(() => { - const schemaValue = this.schemaDropdown.value as azdata.CategoryValue; - if (!schemaValue) { - return; + this.schemaDropdown.onValueChanged((value) => { + if (value.selected) { + const schemaValue = this.schemaDropdown.value as azdata.CategoryValue; + if (!schemaValue) { + return; + } + this.model.schema = schemaValue.name; } - this.model.schema = schemaValue.name; }); diff --git a/extensions/import/src/wizard/pages/modifyColumnsPage.ts b/extensions/import/src/wizard/pages/modifyColumnsPage.ts index 22ae45903f..abb1d356d2 100644 --- a/extensions/import/src/wizard/pages/modifyColumnsPage.ts +++ b/extensions/import/src/wizard/pages/modifyColumnsPage.ts @@ -147,9 +147,9 @@ export class ModifyColumnsPage extends ImportPage { return true; } - public setupNavigationValidator() { + public override setupNavigationValidator() { this.instance.registerNavigationValidator((info) => { - return !this.loading.loading && this.table.data && this.table.data.length > 0; + return this.table.data && this.table.data.length > 0; }); } diff --git a/extensions/import/src/wizard/pages/prosePreviewPage.ts b/extensions/import/src/wizard/pages/prosePreviewPage.ts index 5139e1c5af..1c1180efeb 100644 --- a/extensions/import/src/wizard/pages/prosePreviewPage.ts +++ b/extensions/import/src/wizard/pages/prosePreviewPage.ts @@ -144,12 +144,12 @@ export class ProsePreviewPage extends ImportPage { return true; } - public setupNavigationValidator() { + public override setupNavigationValidator() { this.instance.registerNavigationValidator((info) => { if (info) { // Prose Preview to Modify Columns if (info.lastPage === 1 && info.newPage === 2) { - return !this.loading.loading && this.table.data && this.table.data.length > 0; + return this.table.data && this.table.data.length > 0; } } return !this.loading.loading; diff --git a/extensions/import/src/wizard/pages/summaryPage.ts b/extensions/import/src/wizard/pages/summaryPage.ts index be6c2c5570..c1ed3fbae5 100644 --- a/extensions/import/src/wizard/pages/summaryPage.ts +++ b/extensions/import/src/wizard/pages/summaryPage.ts @@ -85,11 +85,6 @@ export class SummaryPage extends ImportPage { return true; } - public setupNavigationValidator() { - this.instance.registerNavigationValidator((info) => { - return !this.loading.loading; - }); - } private populateTable() { this.table.updateProperties({ diff --git a/src/sql/workbench/browser/modelComponents/dropdown.component.ts b/src/sql/workbench/browser/modelComponents/dropdown.component.ts index dc64c05f95..c4b6b3e973 100644 --- a/src/sql/workbench/browser/modelComponents/dropdown.component.ts +++ b/src/sql/workbench/browser/modelComponents/dropdown.component.ts @@ -113,7 +113,7 @@ export default class DropDownComponent extends ComponentBase !this.required || this.editable || !!this._selectBox.value); } - + this._validations.push(() => !this.loading); this.baseInit(); }