Schema Compare cleanup (#11418)

* cleanup async and await stuff

* remove awaits

* remove more awaits
This commit is contained in:
Kim Santiago
2020-07-21 09:47:14 -07:00
committed by GitHub
parent 92c8d890c4
commit d533af3019
6 changed files with 61 additions and 60 deletions

View File

@@ -275,14 +275,14 @@ export class SchemaCompareDialog {
let formModel = this.formBuilder.component();
await view.initializeModel(formModel);
if (this.sourceIsDacpac) {
this.sourceDacpacRadioButton.focus();
await this.sourceDacpacRadioButton.focus();
} else {
this.sourceDatabaseRadioButton.focus();
await this.sourceDatabaseRadioButton.focus();
}
});
}
private async createFileBrowser(view: azdata.ModelView, isTarget: boolean, endpoint: mssql.SchemaCompareEndpointInfo): Promise<azdata.FormComponent> {
private createFileBrowser(view: azdata.ModelView, isTarget: boolean, endpoint: mssql.SchemaCompareEndpointInfo): azdata.FormComponent {
let currentTextbox = isTarget ? this.targetTextBox : this.sourceTextBox;
if (isTarget) {
this.targetFileButton = view.modelBuilder.button().withProperties({
@@ -333,7 +333,7 @@ export class SchemaCompareDialog {
};
}
private async createSourceRadiobuttons(view: azdata.ModelView): Promise<azdata.FormComponent> {
private createSourceRadiobuttons(view: azdata.ModelView): azdata.FormComponent {
this.sourceDacpacRadioButton = view.modelBuilder.radioButton()
.withProperties({
name: 'source',
@@ -389,7 +389,7 @@ export class SchemaCompareDialog {
};
}
private async createTargetRadiobuttons(view: azdata.ModelView): Promise<azdata.FormComponent> {
private createTargetRadiobuttons(view: azdata.ModelView): azdata.FormComponent {
let dacpacRadioButton = view.modelBuilder.radioButton()
.withProperties({
name: 'target',
@@ -461,7 +461,7 @@ export class SchemaCompareDialog {
return !isNullOrUndefined(filename) && await exists(filename) && (filename.toLocaleLowerCase().endsWith('.dacpac'));
}
protected async createSourceServerDropdown(view: azdata.ModelView): Promise<azdata.FormComponent> {
protected createSourceServerDropdown(view: azdata.ModelView): azdata.FormComponent {
this.sourceServerDropdown = view.modelBuilder.dropDown().withProperties(
{
editable: true,
@@ -471,7 +471,7 @@ export class SchemaCompareDialog {
).component();
this.sourceServerDropdown.onValueChanged(async (value) => {
if (this.sourceServerDropdown.values.findIndex(x => this.matchesValue(x, value)) === -1) {
this.sourceDatabaseDropdown.updateProperties({
await this.sourceDatabaseDropdown.updateProperties({
values: [],
value: ' '
});
@@ -487,7 +487,7 @@ export class SchemaCompareDialog {
};
}
protected async createTargetServerDropdown(view: azdata.ModelView): Promise<azdata.FormComponent> {
protected createTargetServerDropdown(view: azdata.ModelView): azdata.FormComponent {
this.targetServerDropdown = view.modelBuilder.dropDown().withProperties(
{
editable: true,
@@ -497,7 +497,7 @@ export class SchemaCompareDialog {
).component();
this.targetServerDropdown.onValueChanged(async (value) => {
if (this.targetServerDropdown.values.findIndex(x => this.matchesValue(x, value)) === -1) {
this.targetDatabaseDropdown.updateProperties({
await this.targetDatabaseDropdown.updateProperties({
values: [],
value: ' '
});
@@ -518,7 +518,7 @@ export class SchemaCompareDialog {
let values = await this.getServerValues(isTarget);
if (values && values.length > 0) {
currentDropdown.updateProperties({
await currentDropdown.updateProperties({
values: values,
value: values[0]
});
@@ -585,7 +585,7 @@ export class SchemaCompareDialog {
return values;
}
protected async createSourceDatabaseDropdown(view: azdata.ModelView): Promise<azdata.FormComponent> {
protected createSourceDatabaseDropdown(view: azdata.ModelView): azdata.FormComponent {
this.sourceDatabaseDropdown = view.modelBuilder.dropDown().withProperties(
{
editable: true,
@@ -604,7 +604,7 @@ export class SchemaCompareDialog {
};
}
protected async createTargetDatabaseDropdown(view: azdata.ModelView): Promise<azdata.FormComponent> {
protected createTargetDatabaseDropdown(view: azdata.ModelView): azdata.FormComponent {
this.targetDatabaseDropdown = view.modelBuilder.dropDown().withProperties(
{
editable: true,
@@ -629,7 +629,7 @@ export class SchemaCompareDialog {
protected async populateDatabaseDropdown(connectionProfile: azdata.connection.ConnectionProfile, isTarget: boolean): Promise<void> {
let currentDropdown = isTarget ? this.targetDatabaseDropdown : this.sourceDatabaseDropdown;
currentDropdown.updateProperties({ values: [], value: null });
await currentDropdown.updateProperties({ values: [], value: null });
let values = [];
try {
@@ -640,7 +640,7 @@ export class SchemaCompareDialog {
console.warn(e);
}
if (values && values.length > 0) {
currentDropdown.updateProperties({
await currentDropdown.updateProperties({
values: values,
value: values[0],
});
@@ -672,7 +672,7 @@ export class SchemaCompareDialog {
return values;
}
protected async createNoActiveConnectionsText(view: azdata.ModelView): Promise<azdata.FormComponent> {
protected createNoActiveConnectionsText(view: azdata.ModelView): azdata.FormComponent {
let noActiveConnectionsText = view.modelBuilder.text().withProperties({ value: loc.NoActiveConnectionsLabel }).component();
return {

View File

@@ -35,19 +35,19 @@ export class SchemaCompareOptionsDialog {
this.optionsModel = new SchemaCompareOptionsModel(defaultOptions);
}
protected async initializeDialog() {
protected initializeDialog(): void {
this.generalOptionsTab = azdata.window.createTab(loc.GeneralOptionsLabel);
this.objectTypesTab = azdata.window.createTab(loc.ObjectTypesOptionsLabel);
await this.initializeSchemaCompareOptionsDialogTab();
await this.initializeSchemaCompareObjectTypesDialogTab();
this.initializeSchemaCompareOptionsDialogTab();
this.initializeSchemaCompareObjectTypesDialogTab();
this.dialog.content = [this.generalOptionsTab, this.objectTypesTab];
}
public async openDialog() {
public openDialog(): void {
let event = null;
this.dialog = azdata.window.createModelViewDialog(loc.OptionsLabel, event);
await this.initializeDialog();
this.initializeDialog();
this.dialog.okButton.label = loc.OkButtonText;
this.dialog.okButton.onClick(async () => await this.execute());
@@ -63,7 +63,7 @@ export class SchemaCompareOptionsDialog {
azdata.window.openDialog(this.dialog);
}
protected async execute() {
protected execute(): void {
this.optionsModel.setDeploymentOptions();
this.optionsModel.setObjectTypeOptions();
this.schemaComparison.setDeploymentOptions(this.deploymentOptions);
@@ -78,26 +78,26 @@ export class SchemaCompareOptionsDialog {
this.disposeListeners();
}
protected async cancel() {
protected cancel(): void {
this.disposeListeners();
}
private async reset() {
private async reset(): Promise<void> {
let service = (vscode.extensions.getExtension(mssql.extension.name).exports as mssql.IExtension).schemaCompare;
let result = await service.schemaCompareGetDefaultOptions();
this.deploymentOptions = result.defaultDeploymentOptions;
this.optionsChanged = true;
this.updateOptionsTable();
await this.updateOptionsTable();
this.optionsFlexBuilder.removeItem(this.optionsTable);
this.optionsFlexBuilder.insertItem(this.optionsTable, 0, { CSSStyles: { 'overflow': 'scroll', 'height': '65vh' } });
this.updateObjectsTable();
await this.updateObjectsTable();
this.objectTypesFlexBuilder.removeItem(this.objectsTable);
this.objectTypesFlexBuilder.addItem(this.objectsTable, { CSSStyles: { 'overflow': 'scroll', 'height': '80vh' } });
}
private async initializeSchemaCompareOptionsDialogTab() {
private initializeSchemaCompareOptionsDialogTab(): void {
this.generalOptionsTab.registerContent(async view => {
this.descriptionHeading = view.modelBuilder.table().withProperties({
@@ -116,17 +116,17 @@ export class SchemaCompareOptionsDialog {
this.optionsTable = view.modelBuilder.table().component();
this.updateOptionsTable();
await this.updateOptionsTable();
this.disposableListeners.push(this.optionsTable.onRowSelected(async () => {
let row = this.optionsTable.selectedRows[0];
let label = this.optionsModel.optionsLabels[row];
this.descriptionText.updateProperties({
await this.descriptionText.updateProperties({
value: this.optionsModel.getDescription(label)
});
}));
this.disposableListeners.push(this.optionsTable.onCellAction(async (rowState) => {
this.disposableListeners.push(this.optionsTable.onCellAction((rowState) => {
let checkboxState = <azdata.ICheckboxCellActionEventArgs>rowState;
if (checkboxState && checkboxState.row !== undefined) {
let label = this.optionsModel.optionsLabels[checkboxState.row];
@@ -144,11 +144,11 @@ export class SchemaCompareOptionsDialog {
this.optionsFlexBuilder.addItem(this.descriptionHeading, { CSSStyles: { 'font-weight': 'bold', 'height': '30px' } });
this.optionsFlexBuilder.addItem(this.descriptionText, { CSSStyles: { 'padding': '4px', 'margin-right': '10px', 'overflow': 'scroll', 'height': '10vh' } });
await view.initializeModel(this.optionsFlexBuilder);
this.optionsTable.focus();
await this.optionsTable.focus();
});
}
private async initializeSchemaCompareObjectTypesDialogTab() {
private initializeSchemaCompareObjectTypesDialogTab(): void {
this.objectTypesTab.registerContent(async view => {
this.objectTypesFlexBuilder = view.modelBuilder.flexContainer()
@@ -157,9 +157,9 @@ export class SchemaCompareOptionsDialog {
}).component();
this.objectsTable = view.modelBuilder.table().component();
this.updateObjectsTable();
await this.updateObjectsTable();
this.disposableListeners.push(this.objectsTable.onCellAction(async (rowState) => {
this.disposableListeners.push(this.objectsTable.onCellAction((rowState) => {
let checkboxState = <azdata.ICheckboxCellActionEventArgs>rowState;
if (checkboxState && checkboxState.row !== undefined) {
let label = this.optionsModel.objectTypeLabels[checkboxState.row];
@@ -180,9 +180,9 @@ export class SchemaCompareOptionsDialog {
}
}
private updateOptionsTable(): void {
private async updateOptionsTable(): Promise<void> {
let data = this.optionsModel.getOptionsData();
this.optionsTable.updateProperties({
await this.optionsTable.updateProperties({
data: data,
columns: [
{
@@ -204,9 +204,9 @@ export class SchemaCompareOptionsDialog {
});
}
private updateObjectsTable(): void {
private async updateObjectsTable(): Promise<void> {
let data = this.optionsModel.getObjectsData();
this.objectsTable.updateProperties({
await this.objectsTable.updateProperties({
data: data,
columns: [
{