From 2161f323c346a07c6b7866a2a3e3fa470fd518fc Mon Sep 17 00:00:00 2001 From: Aasim Khan Date: Fri, 15 Jan 2021 12:58:05 -0800 Subject: [PATCH] Fixing errors in existing migration pages (#13977) * - Adding null checks for onValueChanged - Adding new event for radiobuttons onDIdChangeCheckedState * changing the null checks in checkbox --- .../src/wizard/accountsSelectionPage.ts | 5 +- .../src/wizard/databaseBackupPage.ts | 78 ++++++++++++++----- 2 files changed, 63 insertions(+), 20 deletions(-) diff --git a/extensions/sql-migration/src/wizard/accountsSelectionPage.ts b/extensions/sql-migration/src/wizard/accountsSelectionPage.ts index 96dd4e335b..c304ec47ba 100644 --- a/extensions/sql-migration/src/wizard/accountsSelectionPage.ts +++ b/extensions/sql-migration/src/wizard/accountsSelectionPage.ts @@ -42,7 +42,10 @@ export class AccountsSelectionPage extends MigrationWizardPage { }).component(); this._azureAccountsDropdown.onValueChanged(async (value) => { - this.migrationStateModel.azureAccount = this._accountsMap.get((this._azureAccountsDropdown.value as azdata.CategoryValue).name)!; + if (this._azureAccountsDropdown.value) { + const selectedAccount = (this._azureAccountsDropdown.value as azdata.CategoryValue).name; + this.migrationStateModel.azureAccount = this._accountsMap.get(selectedAccount)!; + } }); const addAccountButton = view.modelBuilder.button() diff --git a/extensions/sql-migration/src/wizard/databaseBackupPage.ts b/extensions/sql-migration/src/wizard/databaseBackupPage.ts index fae7705121..f3b7e7f861 100644 --- a/extensions/sql-migration/src/wizard/databaseBackupPage.ts +++ b/extensions/sql-migration/src/wizard/databaseBackupPage.ts @@ -85,7 +85,11 @@ export class DatabaseBackupPage extends MigrationWizardPage { checked: true }).component(); - networkShareButton.onDidClick((e) => this.toggleNetworkContainerFields(NetworkContainerType.NETWORK_SHARE, this._networkShare)); + networkShareButton.onDidChangeCheckedState((e) => { + if (e) { + this.toggleNetworkContainerFields(NetworkContainerType.NETWORK_SHARE, this._networkShare); + } + }); const blobContainerButton = view.modelBuilder.radioButton() .withProps({ @@ -93,7 +97,11 @@ export class DatabaseBackupPage extends MigrationWizardPage { label: constants.DATABASE_BACKUP_NC_BLOB_STORAGE_RADIO_LABEL, }).component(); - blobContainerButton.onDidClick((e) => this.toggleNetworkContainerFields(NetworkContainerType.BLOB_CONTAINER, this._blob)); + blobContainerButton.onDidChangeCheckedState((e) => { + if (e) { + this.toggleNetworkContainerFields(NetworkContainerType.BLOB_CONTAINER, this._blob); + } + }); const fileShareButton = view.modelBuilder.radioButton() .withProps({ @@ -101,7 +109,11 @@ export class DatabaseBackupPage extends MigrationWizardPage { label: constants.DATABASE_BACKUP_NC_FILE_SHARE_RADIO_LABEL, }).component(); - fileShareButton.onDidClick((e) => this.toggleNetworkContainerFields(NetworkContainerType.FILE_SHARE, this._fileShare)); + fileShareButton.onDidChangeCheckedState((e) => { + if (e) { + this.toggleNetworkContainerFields(NetworkContainerType.FILE_SHARE, this._fileShare); + } + }); const flexContainer = view.modelBuilder.flexContainer().withItems( [ @@ -139,8 +151,10 @@ export class DatabaseBackupPage extends MigrationWizardPage { return true; }).component(); this._fileShareSubscriptionDropdown.onValueChanged(async (value) => { - this._fileShare.subscriptionId = (this._fileShareSubscriptionDropdown.value as azdata.CategoryValue).name; - await this.loadFileShareStorageDropdown(); + if (this._fileShareSubscriptionDropdown.value) { + this._fileShare.subscriptionId = (this._fileShareSubscriptionDropdown.value as azdata.CategoryValue).name; + await this.loadFileShareStorageDropdown(); + } }); const storageAccountLabel = view.modelBuilder.text() @@ -163,8 +177,10 @@ export class DatabaseBackupPage extends MigrationWizardPage { return true; }).component(); this._fileShareStorageAccountDropdown.onValueChanged(async (value) => { - this._fileShare.storageAccountId = (this._fileShareStorageAccountDropdown.value as azdata.CategoryValue).name; - await this.loadFileShareDropdown(); + if (this._fileShareStorageAccountDropdown.value) { + this._fileShare.storageAccountId = (this._fileShareStorageAccountDropdown.value as azdata.CategoryValue).name; + await this.loadFileShareDropdown(); + } }); const fileShareLabel = view.modelBuilder.text() @@ -187,7 +203,9 @@ export class DatabaseBackupPage extends MigrationWizardPage { return true; }).component(); this._fileShareFileShareDropdown.onValueChanged((value) => { - this._fileShare.fileShareId = (this._fileShareFileShareDropdown.value as azdata.CategoryValue).name; + if (this._fileShareFileShareDropdown.value) { + this._fileShare.fileShareId = (this._fileShareFileShareDropdown.value as azdata.CategoryValue).name; + } }); @@ -230,8 +248,10 @@ export class DatabaseBackupPage extends MigrationWizardPage { return true; }).component(); this._blobContainerSubscriptionDropdown.onValueChanged(async (value) => { - this._blob.subscriptionId = (this._blobContainerSubscriptionDropdown.value as azdata.CategoryValue).name; - await this.loadblobStorageDropdown(); + if (this._blobContainerSubscriptionDropdown.value) { + this._blob.subscriptionId = (this._blobContainerSubscriptionDropdown.value as azdata.CategoryValue).name; + await this.loadblobStorageDropdown(); + } }); const storageAccountLabel = view.modelBuilder.text() @@ -254,8 +274,10 @@ export class DatabaseBackupPage extends MigrationWizardPage { return true; }).component(); this._blobContainerStorageAccountDropdown.onValueChanged(async (value) => { - this._blob.storageAccountId = (this._blobContainerStorageAccountDropdown.value as azdata.CategoryValue).name; - await this.loadBlobContainerDropdown(); + if (this._blobContainerStorageAccountDropdown.value) { + this._blob.storageAccountId = (this._blobContainerStorageAccountDropdown.value as azdata.CategoryValue).name; + await this.loadBlobContainerDropdown(); + } }); const containerLabel = view.modelBuilder.text().withProps({ @@ -277,7 +299,9 @@ export class DatabaseBackupPage extends MigrationWizardPage { return true; }).component(); this._blobContainerBlobDropdown.onValueChanged((value) => { - this._blob.containerId = (this._blobContainerBlobDropdown.value as azdata.CategoryValue).name; + if (this._blobContainerBlobDropdown.value) { + this._blob.containerId = (this._blobContainerBlobDropdown.value as azdata.CategoryValue).name; + } }); const flexContainer = view.modelBuilder.flexContainer() @@ -389,8 +413,10 @@ export class DatabaseBackupPage extends MigrationWizardPage { return true; }).component(); this._networkShareContainerSubscriptionDropdown.onValueChanged(async (value) => { - this._networkShare.storageSubscriptionId = (this._networkShareContainerSubscriptionDropdown.value as azdata.CategoryValue).name; - await this.loadNetworkShareStorageDropdown(); + if (this._networkShareContainerSubscriptionDropdown.value) { + this._networkShare.storageSubscriptionId = (this._networkShareContainerSubscriptionDropdown.value as azdata.CategoryValue).name; + await this.loadNetworkShareStorageDropdown(); + } }); const storageAccountLabel = view.modelBuilder.text() @@ -413,7 +439,9 @@ export class DatabaseBackupPage extends MigrationWizardPage { return true; }).component(); this._networkShareContainerStorageAccountDropdown.onValueChanged((value) => { - this._networkShare.storageAccountId = (this._networkShareContainerStorageAccountDropdown.value as azdata.CategoryValue).name; + if (this._networkShareContainerStorageAccountDropdown.value) { + this._networkShare.storageAccountId = (this._networkShareContainerStorageAccountDropdown.value as azdata.CategoryValue).name; + } }); const flexContainer = view.modelBuilder.flexContainer().withItems( @@ -443,7 +471,11 @@ export class DatabaseBackupPage extends MigrationWizardPage { label: constants.DATABASE_BACKUP_EMAIL_NOTIFICATION_CHECKBOX_LABEL }).component(); - emailCheckbox.onChanged((value) => this.migrationStateModel.databaseBackup.emailNotification = value); + emailCheckbox.onChanged((value) => { + if (value !== undefined) { + this.migrationStateModel.databaseBackup.emailNotification = value; + } + }); return { title: constants.DATABASE_BACKUP_EMAIL_NOTIFICATION_LABEL, @@ -466,14 +498,22 @@ export class DatabaseBackupPage extends MigrationWizardPage { this.migrationStateModel.databaseBackup.migrationCutover = MigrationCutover.AUTOMATIC; - automaticButton.onDidClick((e) => this.migrationStateModel.databaseBackup.migrationCutover = MigrationCutover.AUTOMATIC); + automaticButton.onDidChangeCheckedState((e) => { + if (e) { + this.migrationStateModel.databaseBackup.migrationCutover = MigrationCutover.AUTOMATIC; + } + }); const manualButton = view.modelBuilder.radioButton().withProps({ label: constants.DATABASE_BACKUP_MIGRATION_CUTOVER_MANUAL_LABEL, name: buttonGroup }).component(); - manualButton.onDidClick((e) => this.migrationStateModel.databaseBackup.migrationCutover = MigrationCutover.MANUAL); + manualButton.onDidChangeCheckedState((e) => { + if (e) { + this.migrationStateModel.databaseBackup.migrationCutover = MigrationCutover.MANUAL; + } + }); const flexContainer = view.modelBuilder.flexContainer().withItems( [