add loading indicators to schema compare dialog (#13189)

This commit is contained in:
Kim Santiago
2020-11-02 17:50:28 -08:00
committed by GitHub
parent f792684763
commit ba80000e27

View File

@@ -200,30 +200,22 @@ export class SchemaCompareDialog {
this.dialog.okButton.enabled = await this.shouldEnableOkayButton(); this.dialog.okButton.enabled = await this.shouldEnableOkayButton();
}); });
this.sourceServerComponent = await this.createSourceServerDropdown(); this.sourceServerComponent = this.createSourceServerDropdown();
await this.populateServerDropdown(false);
this.sourceDatabaseComponent = await this.createSourceDatabaseDropdown(); this.sourceDatabaseComponent = this.createSourceDatabaseDropdown();
if ((this.sourceServerDropdown.value as ConnectionDropdownValue)) {
await this.populateDatabaseDropdown((this.sourceServerDropdown.value as ConnectionDropdownValue).connection, false);
}
this.targetServerComponent = await this.createTargetServerDropdown(); this.targetServerComponent = this.createTargetServerDropdown();
await this.populateServerDropdown(true);
this.targetDatabaseComponent = await this.createTargetDatabaseDropdown(); this.targetDatabaseComponent = this.createTargetDatabaseDropdown();
if ((this.targetServerDropdown.value as ConnectionDropdownValue)) {
await this.populateDatabaseDropdown((this.targetServerDropdown.value as ConnectionDropdownValue).connection, true);
}
this.sourceDacpacComponent = await this.createFileBrowser(false, this.schemaCompareMainWindow.sourceEndpointInfo); this.sourceDacpacComponent = this.createFileBrowser(false, this.schemaCompareMainWindow.sourceEndpointInfo);
this.targetDacpacComponent = await this.createFileBrowser(true, this.schemaCompareMainWindow.targetEndpointInfo); this.targetDacpacComponent = this.createFileBrowser(true, this.schemaCompareMainWindow.targetEndpointInfo);
let sourceRadioButtons = await this.createSourceRadiobuttons(); let sourceRadioButtons = this.createSourceRadiobuttons();
let targetRadioButtons = await this.createTargetRadiobuttons(); let targetRadioButtons = this.createTargetRadiobuttons();
this.sourceNoActiveConnectionsText = await this.createNoActiveConnectionsText(); this.sourceNoActiveConnectionsText = this.createNoActiveConnectionsText();
this.targetNoActiveConnectionsText = await this.createNoActiveConnectionsText(); this.targetNoActiveConnectionsText = this.createNoActiveConnectionsText();
let sourceComponents = []; let sourceComponents = [];
let targetComponents = []; let targetComponents = [];
@@ -483,6 +475,9 @@ export class SchemaCompareDialog {
} }
}); });
// don't await so that dialog loading won't be blocked. Dropdown will show loading indicator until it is populated
this.populateServerDropdown(false);
return { return {
component: this.sourceServerDropdown, component: this.sourceServerDropdown,
title: loc.ServerDropdownLabel title: loc.ServerDropdownLabel
@@ -509,6 +504,9 @@ export class SchemaCompareDialog {
} }
}); });
// don't await so that dialog loading won't be blocked. Dropdown will show loading indicator until it is populated
this.populateServerDropdown(true);
return { return {
component: this.targetServerDropdown, component: this.targetServerDropdown,
title: loc.ServerDropdownLabel title: loc.ServerDropdownLabel
@@ -516,8 +514,9 @@ export class SchemaCompareDialog {
} }
protected async populateServerDropdown(isTarget: boolean): Promise<void> { protected async populateServerDropdown(isTarget: boolean): Promise<void> {
let currentDropdown = isTarget ? this.targetServerDropdown : this.sourceServerDropdown; const currentDropdown = isTarget ? this.targetServerDropdown : this.sourceServerDropdown;
let values = await this.getServerValues(isTarget); currentDropdown.loading = true;
const values = await this.getServerValues(isTarget);
if (values && values.length > 0) { if (values && values.length > 0) {
await currentDropdown.updateProperties({ await currentDropdown.updateProperties({
@@ -525,6 +524,8 @@ export class SchemaCompareDialog {
value: values[0] value: values[0]
}); });
} }
currentDropdown.loading = false;
} }
protected async getServerValues(isTarget: boolean): Promise<{ connection: azdata.connection.ConnectionProfile, displayName: string, name: string }[]> { protected async getServerValues(isTarget: boolean): Promise<{ connection: azdata.connection.ConnectionProfile, displayName: string, name: string }[]> {
@@ -630,7 +631,8 @@ export class SchemaCompareDialog {
} }
protected async populateDatabaseDropdown(connectionProfile: azdata.connection.ConnectionProfile, isTarget: boolean): Promise<void> { protected async populateDatabaseDropdown(connectionProfile: azdata.connection.ConnectionProfile, isTarget: boolean): Promise<void> {
let currentDropdown = isTarget ? this.targetDatabaseDropdown : this.sourceDatabaseDropdown; const currentDropdown = isTarget ? this.targetDatabaseDropdown : this.sourceDatabaseDropdown;
currentDropdown.loading = true;
await currentDropdown.updateProperties({ values: [], value: null }); await currentDropdown.updateProperties({ values: [], value: null });
let values = []; let values = [];
@@ -647,6 +649,8 @@ export class SchemaCompareDialog {
value: values[0], value: values[0],
}); });
} }
currentDropdown.loading = false;
} }
protected async getDatabaseValues(connectionId: string, isTarget: boolean): Promise<string[]> { protected async getDatabaseValues(connectionId: string, isTarget: boolean): Promise<string[]> {