From 0c1b16d4fbd85287bdc0b9b0b654ca272f44bb39 Mon Sep 17 00:00:00 2001 From: Kim Santiago <31145923+kisantia@users.noreply.github.com> Date: Tue, 16 Feb 2021 10:23:22 -0800 Subject: [PATCH] fix dacpac dropdowns selecting first db in dropdown instead of right clicked db (#14285) --- .../dacpac/src/wizard/api/dacFxConfigPage.ts | 18 ++++++++++++++---- .../src/wizard/dataTierApplicationWizard.ts | 2 +- .../src/wizard/pages/deployConfigPage.ts | 9 +++++++-- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/extensions/dacpac/src/wizard/api/dacFxConfigPage.ts b/extensions/dacpac/src/wizard/api/dacFxConfigPage.ts index 3307851cf7..f9e0f45ee3 100644 --- a/extensions/dacpac/src/wizard/api/dacFxConfigPage.ts +++ b/extensions/dacpac/src/wizard/api/dacFxConfigPage.ts @@ -40,8 +40,13 @@ export abstract class DacFxConfigPage extends BasePage { // Handle server changes this.serverDropdown.onValueChanged(async () => { - this.model.server = (this.serverDropdown.value as ConnectionDropdownValue).connection; - this.model.serverName = (this.serverDropdown.value as ConnectionDropdownValue).displayName; + const serverDropdownValue = this.serverDropdown.value as ConnectionDropdownValue; + if (!serverDropdownValue) { + return; + } + + this.model.server = serverDropdownValue.connection; + this.model.serverName = serverDropdownValue.displayName; if (this.databaseDropdown) { await this.populateDatabaseDropdown(); } else { @@ -98,8 +103,13 @@ export abstract class DacFxConfigPage extends BasePage { }).component(); // Handle database changes - this.databaseDropdown.onValueChanged(async () => { - this.model.database = this.databaseDropdown.value; + this.databaseDropdown.onValueChanged(() => { + const databaseDropdownValue = this.databaseDropdown.value; + if (!databaseDropdownValue) { + return; + } + + this.model.database = databaseDropdownValue as string; this.fileTextBox.value = this.generateFilePathFromDatabaseAndTimestamp(); this.model.filePath = this.fileTextBox.value; }); diff --git a/extensions/dacpac/src/wizard/dataTierApplicationWizard.ts b/extensions/dacpac/src/wizard/dataTierApplicationWizard.ts index a46398294c..3413ebdb1a 100644 --- a/extensions/dacpac/src/wizard/dataTierApplicationWizard.ts +++ b/extensions/dacpac/src/wizard/dataTierApplicationWizard.ts @@ -297,7 +297,7 @@ export class DataTierApplicationWizard { private cancelDataTierApplicationWizard(): void { TelemetryReporter.createActionEvent(TelemetryViews.DataTierApplicationWizard, 'WizardCanceled') .withAdditionalProperties({ - isPotentialDataLoss: this.model.potentialDataLoss.toString() + isPotentialDataLoss: this.model.potentialDataLoss?.toString() }).send(); } diff --git a/extensions/dacpac/src/wizard/pages/deployConfigPage.ts b/extensions/dacpac/src/wizard/pages/deployConfigPage.ts index 8a2f596875..a361016d6b 100644 --- a/extensions/dacpac/src/wizard/pages/deployConfigPage.ts +++ b/extensions/dacpac/src/wizard/pages/deployConfigPage.ts @@ -141,8 +141,13 @@ export class DeployConfigPage extends DacFxConfigPage { }).component(); //Handle database changes - this.databaseDropdown.onValueChanged(async () => { - this.model.database = (this.databaseDropdown.value).name; + this.databaseDropdown.onValueChanged(() => { + const databaseDropdownValue = this.databaseDropdown.value as azdata.CategoryValue; + if (!databaseDropdownValue) { + return; + } + + this.model.database = databaseDropdownValue.name; }); this.databaseLoader = this.view.modelBuilder.loadingComponent().withItem(this.databaseDropdown).withProperties({