diff --git a/extensions/sql-migration/package.json b/extensions/sql-migration/package.json index 32b26a1e92..6b4692c3af 100644 --- a/extensions/sql-migration/package.json +++ b/extensions/sql-migration/package.json @@ -2,7 +2,7 @@ "name": "sql-migration", "displayName": "%displayName%", "description": "%description%", - "version": "1.4.6", + "version": "1.4.7", "publisher": "Microsoft", "preview": false, "license": "https://raw.githubusercontent.com/Microsoft/azuredatastudio/main/LICENSE.txt", diff --git a/extensions/sql-migration/src/api/utils.ts b/extensions/sql-migration/src/api/utils.ts index 43ec3675e7..81e513a45e 100644 --- a/extensions/sql-migration/src/api/utils.ts +++ b/extensions/sql-migration/src/api/utils.ts @@ -241,9 +241,9 @@ export function selectDefaultDropdownValue(dropDown: DropDownComponent, value?: if (value) { const searchValue = value.toLowerCase(); if (useDisplayName) { - selectedIndex = dropDown.values.findIndex((v: any) => (v as CategoryValue)?.displayName?.toLowerCase() === searchValue); + selectedIndex = dropDown.values?.findIndex((v: any) => (v as CategoryValue)?.displayName?.toLowerCase() === searchValue); } else { - selectedIndex = dropDown.values.findIndex((v: any) => (v as CategoryValue)?.name?.toLowerCase() === searchValue); + selectedIndex = dropDown.values?.findIndex((v: any) => (v as CategoryValue)?.name?.toLowerCase() === searchValue); } } else { selectedIndex = -1; @@ -1169,7 +1169,7 @@ export function createRegistrationInstructions(view: ModelView, testConnectionBu }).component(); } -export function clearDropDown(dropDown: DropDownComponent): void { - dropDown.values = []; - dropDown.value = undefined; +export async function clearDropDown(dropDown: DropDownComponent): Promise { + await dropDown.updateProperty('value', undefined); + await dropDown.updateProperty('values', []); } diff --git a/extensions/sql-migration/src/dialog/selectMigrationService/selectMigrationServiceDialog.ts b/extensions/sql-migration/src/dialog/selectMigrationService/selectMigrationServiceDialog.ts index 289711c8ca..6dc5d06f4b 100644 --- a/extensions/sql-migration/src/dialog/selectMigrationService/selectMigrationServiceDialog.ts +++ b/extensions/sql-migration/src/dialog/selectMigrationService/selectMigrationServiceDialog.ts @@ -146,8 +146,10 @@ export class SelectMigrationServiceDialog { this._serviceContext.azureAccount = selectedAccount ? utils.deepClone(selectedAccount) : undefined!; + } else { + this._serviceContext.azureAccount = undefined; } - utils.clearDropDown(this._accountTenantDropdown); + await utils.clearDropDown(this._accountTenantDropdown); await this._populateTentantsDropdown(); })); @@ -194,8 +196,10 @@ export class SelectMigrationServiceDialog { this._serviceContext.tenant = selectedTenant ? utils.deepClone(selectedTenant) : undefined!; + } else { + this._serviceContext.tenant = undefined; } - utils.clearDropDown(this._azureSubscriptionDropdown); + await utils.clearDropDown(this._azureSubscriptionDropdown); await this._populateSubscriptionDropdown(); })); @@ -235,8 +239,10 @@ export class SelectMigrationServiceDialog { this._serviceContext.subscription = selectedSubscription ? utils.deepClone(selectedSubscription) : undefined!; + } else { + this._serviceContext.subscription = undefined; } - utils.clearDropDown(this._azureLocationDropdown); + await utils.clearDropDown(this._azureLocationDropdown); await this._populateLocationDropdown(); })); @@ -264,8 +270,10 @@ export class SelectMigrationServiceDialog { this._serviceContext.location = selectedLocation ? utils.deepClone(selectedLocation) : undefined!; + } else { + this._serviceContext.location = undefined; } - utils.clearDropDown(this._azureResourceGroupDropdown); + await utils.clearDropDown(this._azureResourceGroupDropdown); await this._populateResourceGroupDropdown(); })); @@ -293,8 +301,10 @@ export class SelectMigrationServiceDialog { this._serviceContext.resourceGroup = selectedResourceGroup ? utils.deepClone(selectedResourceGroup) : undefined!; + } else { + this._serviceContext.resourceGroup = undefined; } - utils.clearDropDown(this._azureServiceDropdown); + await utils.clearDropDown(this._azureServiceDropdown); this._populateMigrationServiceDropdown(); })); @@ -322,6 +332,8 @@ export class SelectMigrationServiceDialog { this._serviceContext.migrationService = selectedDms ? utils.deepClone(selectedDms) : undefined!; + } else { + this._serviceContext.migrationService = undefined; } await this._updateButtonState(); })); @@ -353,14 +365,14 @@ export class SelectMigrationServiceDialog { private async _populateAzureAccountsDropdown(): Promise { try { this._azureAccountsDropdown.loading = true; + + await utils.clearDropDown(this._azureAccountsDropdown); this._azureAccounts = await utils.getAzureAccounts(); this._azureAccountsDropdown.values = await utils.getAzureAccountsDropdownValues(this._azureAccounts); - if (this._azureAccountsDropdown.values.length > 0) { - utils.selectDefaultDropdownValue( - this._azureAccountsDropdown, - this._serviceContext.azureAccount?.displayInfo?.userId, - false); - } + utils.selectDefaultDropdownValue( + this._azureAccountsDropdown, + this._serviceContext.azureAccount?.displayInfo?.userId, + false); } catch (error) { logError(TelemetryViews.SelectMigrationServiceDialog, '_populateAzureAccountsDropdown', error); void vscode.window.showErrorMessage( @@ -374,18 +386,17 @@ export class SelectMigrationServiceDialog { private async _populateTentantsDropdown(): Promise { try { this._accountTenantDropdown.loading = true; + this._accountTenants = utils.getAzureTenants(this._serviceContext.azureAccount); this._accountTenantDropdown.values = utils.getAzureTenantsDropdownValues(this._accountTenants); await this._accountTenantFlexContainer.updateCssStyles( this._accountTenants.length > 1 ? STYLE_ShOW : STYLE_HIDE); - if (this._accountTenantDropdown.values.length > 0) { - utils.selectDefaultDropdownValue( - this._accountTenantDropdown, - this._serviceContext.tenant?.id, - false); - } + utils.selectDefaultDropdownValue( + this._accountTenantDropdown, + this._serviceContext.tenant?.id, + false); } catch (error) { logError(TelemetryViews.SelectMigrationServiceDialog, '_populateTentantsDropdown', error); void vscode.window.showErrorMessage( @@ -393,24 +404,21 @@ export class SelectMigrationServiceDialog { error.message); } finally { this._accountTenantDropdown.loading = false; - utils.clearDropDown(this._azureSubscriptionDropdown); - await this._populateSubscriptionDropdown(); } } private async _populateSubscriptionDropdown(): Promise { try { this._azureSubscriptionDropdown.loading = true; + this._subscriptions = await utils.getAzureSubscriptions( this._serviceContext.azureAccount, this._serviceContext.tenant?.id); this._azureSubscriptionDropdown.values = await utils.getAzureSubscriptionsDropdownValues(this._subscriptions); - if (this._azureSubscriptionDropdown.values.length > 0) { - utils.selectDefaultDropdownValue( - this._azureSubscriptionDropdown, - this._serviceContext.subscription?.id, - false); - } + utils.selectDefaultDropdownValue( + this._azureSubscriptionDropdown, + this._serviceContext.subscription?.id, + false); } catch (error) { logError(TelemetryViews.SelectMigrationServiceDialog, '_populateSubscriptionDropdown', error); void vscode.window.showErrorMessage( @@ -424,6 +432,7 @@ export class SelectMigrationServiceDialog { private async _populateLocationDropdown(): Promise { try { this._azureLocationDropdown.loading = true; + this._sqlMigrationServices = await utils.getAzureSqlMigrationServices( this._serviceContext.azureAccount, this._serviceContext.subscription); @@ -431,14 +440,11 @@ export class SelectMigrationServiceDialog { this._serviceContext.azureAccount, this._serviceContext.subscription, this._sqlMigrationServices); - this._azureLocationDropdown.values = utils.getAzureLocationsDropdownValues(this._locations); - if (this._azureLocationDropdown.values.length > 0) { - utils.selectDefaultDropdownValue( - this._azureLocationDropdown, - this._serviceContext.location?.displayName, - true); - } + utils.selectDefaultDropdownValue( + this._azureLocationDropdown, + this._serviceContext.location?.displayName, + true); } catch (error) { logError(TelemetryViews.SelectMigrationServiceDialog, '_populateLocationDropdown', error); void vscode.window.showErrorMessage( @@ -452,19 +458,17 @@ export class SelectMigrationServiceDialog { private async _populateResourceGroupDropdown(): Promise { try { this._azureResourceGroupDropdown.loading = true; + this._resourceGroups = utils.getServiceResourceGroupsByLocation( this._sqlMigrationServices, this._serviceContext.location!); this._azureResourceGroupDropdown.values = utils.getResourceDropdownValues( this._resourceGroups, constants.RESOURCE_GROUP_NOT_FOUND); - - if (this._azureResourceGroupDropdown.values.length > 0) { - utils.selectDefaultDropdownValue( - this._azureResourceGroupDropdown, - this._serviceContext.resourceGroup?.id, - false); - } + utils.selectDefaultDropdownValue( + this._azureResourceGroupDropdown, + this._serviceContext.resourceGroup?.id, + false); } catch (error) { logError(TelemetryViews.SelectMigrationServiceDialog, '_populateResourceGroupDropdown', error); void vscode.window.showErrorMessage( @@ -478,18 +482,16 @@ export class SelectMigrationServiceDialog { private _populateMigrationServiceDropdown(): void { try { this._azureServiceDropdown.loading = true; + this._azureServiceDropdown.values = utils.getAzureResourceDropdownValues( this._sqlMigrationServices, this._serviceContext.location!, this._serviceContext.resourceGroup?.name, constants.SQL_MIGRATION_SERVICE_NOT_FOUND_ERROR); - - if (this._azureServiceDropdown.values.length > 0) { - utils.selectDefaultDropdownValue( - this._azureServiceDropdown, - this._serviceContext?.migrationService?.id, - false); - } + utils.selectDefaultDropdownValue( + this._azureServiceDropdown, + this._serviceContext?.migrationService?.id, + false); } catch (error) { logError(TelemetryViews.SelectMigrationServiceDialog, '_populateMigrationServiceDropdown', error); void vscode.window.showErrorMessage( diff --git a/extensions/sql-migration/src/wizard/integrationRuntimePage.ts b/extensions/sql-migration/src/wizard/integrationRuntimePage.ts index c2f34c98f9..610b173fa8 100644 --- a/extensions/sql-migration/src/wizard/integrationRuntimePage.ts +++ b/extensions/sql-migration/src/wizard/integrationRuntimePage.ts @@ -327,8 +327,7 @@ export class IntergrationRuntimePage extends MigrationWizardPage { } else { this.migrationStateModel._sqlMigrationServiceSubscription = undefined!; } - - utils.clearDropDown(this._resourceGroupDropdown); + await utils.clearDropDown(this._resourceGroupDropdown); await this.loadResourceGroupDropdown(); })); @@ -372,7 +371,7 @@ export class IntergrationRuntimePage extends MigrationWizardPage { else { this.migrationStateModel._sqlMigrationServiceResourceGroup = undefined!; } - utils.clearDropDown(this._dmsDropdown); + await utils.clearDropDown(this._dmsDropdown); this.loadDmsDropdown(); })); diff --git a/extensions/sql-migration/src/wizard/loginMigrationTargetSelectionPage.ts b/extensions/sql-migration/src/wizard/loginMigrationTargetSelectionPage.ts index e684c87e98..03d8a06c7b 100644 --- a/extensions/sql-migration/src/wizard/loginMigrationTargetSelectionPage.ts +++ b/extensions/sql-migration/src/wizard/loginMigrationTargetSelectionPage.ts @@ -377,8 +377,10 @@ export class LoginMigrationTargetSelectionPage extends MigrationWizardPage { this.migrationStateModel._azureAccount = selectedAccount ? utils.deepClone(selectedAccount)! : undefined!; + } else { + this.migrationStateModel._azureAccount = undefined!; } - utils.clearDropDown(this._accountTenantDropdown); + await utils.clearDropDown(this._accountTenantDropdown); await this.populateTenantsDropdown(); })); @@ -430,8 +432,10 @@ export class LoginMigrationTargetSelectionPage extends MigrationWizardPage { this.migrationStateModel._azureTenant = selectedTenant ? utils.deepClone(selectedTenant) : undefined!; + } else { + this.migrationStateModel._azureTenant = undefined!; } - utils.clearDropDown(this._azureSubscriptionDropdown); + await utils.clearDropDown(this._azureSubscriptionDropdown); await this.populateSubscriptionDropdown(); })); @@ -472,9 +476,11 @@ export class LoginMigrationTargetSelectionPage extends MigrationWizardPage { this.migrationStateModel._targetSubscription = (selectedSubscription) ? utils.deepClone(selectedSubscription)! : undefined!; + } else { + this.migrationStateModel._targetSubscription = undefined!; } this.migrationStateModel.refreshDatabaseBackupPage = true; - utils.clearDropDown(this._azureLocationDropdown); + await utils.clearDropDown(this._azureLocationDropdown); await this.populateLocationDropdown(); })); @@ -503,9 +509,11 @@ export class LoginMigrationTargetSelectionPage extends MigrationWizardPage { this.migrationStateModel._location = (selectedLocation) ? utils.deepClone(selectedLocation)! : undefined!; + } else { + this.migrationStateModel._location = undefined!; } this.migrationStateModel.refreshDatabaseBackupPage = true; - utils.clearDropDown(this._azureResourceGroupDropdown); + await utils.clearDropDown(this._azureResourceGroupDropdown); await this.populateResourceGroupDropdown(); })); @@ -732,8 +740,10 @@ export class LoginMigrationTargetSelectionPage extends MigrationWizardPage { this.migrationStateModel._resourceGroup = (selectedResourceGroup) ? utils.deepClone(selectedResourceGroup)! : undefined!; + } else { + this.migrationStateModel._resourceGroup = undefined!; } - utils.clearDropDown(this._azureResourceDropdown); + await utils.clearDropDown(this._azureResourceDropdown); await this.populateResourceInstanceDropdown(); })); diff --git a/extensions/sql-migration/src/wizard/targetSelectionPage.ts b/extensions/sql-migration/src/wizard/targetSelectionPage.ts index 422ca9a317..4526994a2b 100644 --- a/extensions/sql-migration/src/wizard/targetSelectionPage.ts +++ b/extensions/sql-migration/src/wizard/targetSelectionPage.ts @@ -267,12 +267,12 @@ export class TargetSelectionPage extends MigrationWizardPage { this.migrationStateModel._resourceGroup = undefined!; this.migrationStateModel._targetServerInstance = undefined!; - utils.clearDropDown(this._azureAccountsDropdown); - utils.clearDropDown(this._accountTenantDropdown); - utils.clearDropDown(this._azureSubscriptionDropdown); - utils.clearDropDown(this._azureLocationDropdown); - utils.clearDropDown(this._azureResourceGroupDropdown); - utils.clearDropDown(this._azureResourceDropdown); + await utils.clearDropDown(this._azureAccountsDropdown); + await utils.clearDropDown(this._accountTenantDropdown); + await utils.clearDropDown(this._azureSubscriptionDropdown); + await utils.clearDropDown(this._azureLocationDropdown); + await utils.clearDropDown(this._azureResourceGroupDropdown); + await utils.clearDropDown(this._azureResourceDropdown); } await this.populateAzureAccountsDropdown(); @@ -313,8 +313,10 @@ export class TargetSelectionPage extends MigrationWizardPage { this.migrationStateModel._azureAccount = (selectedAccount) ? utils.deepClone(selectedAccount)! : undefined!; + } else { + this.migrationStateModel._azureAccount = undefined!; } - utils.clearDropDown(this._accountTenantDropdown); + await utils.clearDropDown(this._accountTenantDropdown); await this.populateTenantsDropdown(); })); @@ -366,8 +368,10 @@ export class TargetSelectionPage extends MigrationWizardPage { this.migrationStateModel._azureTenant = selectedTenant ? utils.deepClone(selectedTenant) : undefined!; + } else { + this.migrationStateModel._azureTenant = undefined!; } - utils.clearDropDown(this._azureSubscriptionDropdown); + await utils.clearDropDown(this._azureSubscriptionDropdown); await this.populateSubscriptionDropdown(); })); @@ -408,9 +412,11 @@ export class TargetSelectionPage extends MigrationWizardPage { this.migrationStateModel._targetSubscription = (selectedSubscription) ? utils.deepClone(selectedSubscription)! : undefined!; + } else { + this.migrationStateModel._targetSubscription = undefined!; } this.migrationStateModel.refreshDatabaseBackupPage = true; - utils.clearDropDown(this._azureLocationDropdown); + await utils.clearDropDown(this._azureLocationDropdown); await this.populateLocationDropdown(); })); @@ -439,9 +445,11 @@ export class TargetSelectionPage extends MigrationWizardPage { this.migrationStateModel._location = (selectedLocation) ? utils.deepClone(selectedLocation)! : undefined!; + } else { + this.migrationStateModel._location = undefined!; } this.migrationStateModel.refreshDatabaseBackupPage = true; - utils.clearDropDown(this._azureResourceGroupDropdown); + await utils.clearDropDown(this._azureResourceGroupDropdown); await this.populateResourceGroupDropdown(); })); @@ -667,8 +675,10 @@ export class TargetSelectionPage extends MigrationWizardPage { this.migrationStateModel._resourceGroup = (selectedResourceGroup) ? utils.deepClone(selectedResourceGroup)! : undefined!; + } else { + this.migrationStateModel._resourceGroup = undefined!; } - utils.clearDropDown(this._azureResourceDropdown); + await utils.clearDropDown(this._azureResourceDropdown); await this.populateResourceInstanceDropdown(); })); @@ -775,6 +785,8 @@ export class TargetSelectionPage extends MigrationWizardPage { await this._validateFields(); } else { this.migrationStateModel._targetServerInstance = undefined!; + this.migrationStateModel._vmInstanceView = undefined!; + if (isSqlDbTarget) { this._targetUserNameInputBox.value = ''; }