Fixing next button on flat file wizard file configuration page (#15988)

* WIP

* Removing unnecessary validations from import extension

* readding abstract method implementation

* Moving setup navigation validator to base class
This commit is contained in:
Aasim Khan
2021-07-06 16:53:44 -07:00
committed by GitHub
parent 48b7d96999
commit 7c68506975
7 changed files with 36 additions and 46 deletions

View File

@@ -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;

View File

@@ -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();

View File

@@ -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<azdata.FormComponent> {
this.serverDropdown = this.view.modelBuilder.dropDown().withProps({
required: true
}).component();
// Handle server changes
this.serverDropdown.onValueChanged(async () => {
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();
await this.populateSchemaDropdown();
}
});
return {
@@ -179,7 +170,8 @@ export class FileConfigPage extends ImportPage {
}).component();
// Handle database changes
this.databaseDropdown.onValueChanged(async () => {
this.databaseDropdown.onValueChanged(async (value) => {
if (value.selected) {
const nameValue = this.databaseDropdown.value as azdata.CategoryValue;
if (!nameValue) {
return;
@@ -192,6 +184,7 @@ export class FileConfigPage extends ImportPage {
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(() => {
this.schemaDropdown.onValueChanged((value) => {
if (value.selected) {
const schemaValue = this.schemaDropdown.value as azdata.CategoryValue;
if (!schemaValue) {
return;
}
this.model.schema = schemaValue.name;
}
});

View File

@@ -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;
});
}

View File

@@ -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;

View File

@@ -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({

View File

@@ -113,7 +113,7 @@ export default class DropDownComponent extends ComponentBase<azdata.DropDownProp
}));
this._validations.push(() => !this.required || this.editable || !!this._selectBox.value);
}
this._validations.push(() => !this.loading);
this.baseInit();
}