[SQL Migration] Refactor resource selection filtering logic + misc UI improvements (#19152)

* WIP

* WIP

* WIP

* Fix location dropdown not working properly

* Clean up comments

* Switch button order in selectMigrationServiceDialog

* Vbump to 1.0.1

* Refactor to avoid duplicate API calls

* Add null checks

* Fix migration status dialog not sorting migrations properly

* Address comments, remove unnecessary code

* Address comments - separate util methods by resource type, use logError instead of console.log

* Remove unused methods

* Fix DMS creation on newly created resource group

* Fix stale account behavior

* Address comments - remove telemetry context from util method calls

* Clean up imports

* Fix dashboard service monitoring not working

* Fix null reference on database backup page, and resources not updating properly when location is changed

* Fix dashboard not auto selecting DMS after migration started

* Add null checks
This commit is contained in:
Raymond Truong
2022-05-03 16:22:47 -04:00
committed by GitHub
parent 8cc66dade3
commit b36ee9318f
12 changed files with 909 additions and 1081 deletions

View File

@@ -15,7 +15,7 @@ import { IconPathHelper } from '../../constants/iconPathHelper';
import { CreateResourceGroupDialog } from '../createResourceGroup/createResourceGroupDialog';
import { createAuthenticationKeyTable } from '../../wizard/integrationRuntimePage';
import * as EventEmitter from 'events';
import { clearDialogMessage } from '../../api/utils';
import * as utils from '../../api/utils';
import * as styles from '../../constants/styles';
export class CreateSqlMigrationServiceDialog {
@@ -44,7 +44,8 @@ export class CreateSqlMigrationServiceDialog {
private _view!: azdata.ModelView;
private _createdMigrationService!: SqlMigrationService;
private _selectedResourceGroup!: string;
private _resourceGroups!: azureResource.AzureResourceResourceGroup[];
private _selectedResourceGroup!: azureResource.AzureResourceResourceGroup;
private _testConnectionButton!: azdata.window.Button;
private _doneButtonEvent: EventEmitter = new EventEmitter();
@@ -79,11 +80,11 @@ export class CreateSqlMigrationServiceDialog {
const subscription = this._model._targetSubscription;
const resourceGroup = (this.migrationServiceResourceGroupDropdown.value as azdata.CategoryValue)?.name;
const resourceGroup = this._selectedResourceGroup;
const location = this._model._targetServerInstance.location;
const serviceName = this.migrationServiceNameText.value;
const formValidationErrors = this.validateCreateServiceForm(subscription, resourceGroup, location, serviceName);
const formValidationErrors = this.validateCreateServiceForm(subscription, resourceGroup.name, location, serviceName);
if (formValidationErrors.length > 0) {
this.setDialogMessage(formValidationErrors);
@@ -93,12 +94,12 @@ export class CreateSqlMigrationServiceDialog {
}
try {
clearDialogMessage(this._dialogObject);
utils.clearDialogMessage(this._dialogObject);
this._selectedResourceGroup = resourceGroup;
this._createdMigrationService = await createSqlMigrationService(
this._model._azureAccount,
subscription,
resourceGroup,
resourceGroup.name,
location,
serviceName!,
this._model._sessionId);
@@ -203,7 +204,7 @@ export class CreateSqlMigrationServiceDialog {
this._isBlobContainerUsed = this._model._databaseBackup.networkContainerType === NetworkContainerType.BLOB_CONTAINER;
return new Promise((resolve) => {
this._doneButtonEvent.once('done', (createdDms: SqlMigrationService, selectedResourceGroup: string) => {
this._doneButtonEvent.once('done', (createdDms: SqlMigrationService, selectedResourceGroup: azureResource.AzureResourceResourceGroup) => {
azdata.window.closeDialog(this._dialogObject);
resolve(
{
@@ -256,6 +257,16 @@ export class CreateSqlMigrationServiceDialog {
}
}).component();
this._disposables.push(
this.migrationServiceResourceGroupDropdown.onValueChanged(async (value) => {
if (value && value !== 'undefined') {
const selectedResourceGroup = this._resourceGroups.find(rg => rg.name === value || constants.NEW_RESOURCE_GROUP(rg.name) === value);
this._selectedResourceGroup = (selectedResourceGroup)
? selectedResourceGroup
: undefined!;
}
}));
const migrationServiceNameLabel = this._view.modelBuilder.text().withProps({
value: constants.NAME,
description: constants.MIGRATION_SERVICE_NAME_INFO,
@@ -277,6 +288,8 @@ export class CreateSqlMigrationServiceDialog {
const createResourceGroupDialog = new CreateResourceGroupDialog(this._model._azureAccount, this._model._targetSubscription, this._model._targetServerInstance.location);
const createdResourceGroup = await createResourceGroupDialog.initialize();
if (createdResourceGroup) {
this._resourceGroups.push(createdResourceGroup);
this._selectedResourceGroup = createdResourceGroup;
this.migrationServiceResourceGroupDropdown.loading = true;
(<azdata.CategoryValue[]>this.migrationServiceResourceGroupDropdown.values).unshift({
displayName: constants.NEW_RESOURCE_GROUP(createdResourceGroup.name),
@@ -376,12 +389,9 @@ export class CreateSqlMigrationServiceDialog {
private async populateResourceGroups(): Promise<void> {
this.migrationServiceResourceGroupDropdown.loading = true;
try {
this.migrationServiceResourceGroupDropdown.values = (await this._model.getAzureResourceGroupDropdownValues(this._model._targetSubscription)).map(v => {
return {
name: v.displayName,
displayName: v.displayName
};
});
this._resourceGroups = await utils.getAllResourceGroups(this._model._azureAccount, this._model._targetSubscription);
this.migrationServiceResourceGroupDropdown.values = await utils.getAzureResourceGroupsDropdownValues(this._resourceGroups);
const selectedResourceGroupValue = this.migrationServiceResourceGroupDropdown.values.find(v => v.name.toLowerCase() === this._resourceGroupPreset.toLowerCase());
this.migrationServiceResourceGroupDropdown.value = (selectedResourceGroupValue) ? selectedResourceGroupValue : this.migrationServiceResourceGroupDropdown.values[0];
} finally {
@@ -496,7 +506,7 @@ export class CreateSqlMigrationServiceDialog {
let migrationServiceStatus!: SqlMigrationService;
for (let i = 0; i < maxRetries; i++) {
try {
clearDialogMessage(this._dialogObject);
utils.clearDialogMessage(this._dialogObject);
migrationServiceStatus = await getSqlMigrationService(
this._model._azureAccount,
subscription,
@@ -649,5 +659,5 @@ export class CreateSqlMigrationServiceDialog {
export interface CreateSqlMigrationServiceDialogResult {
service: SqlMigrationService,
resourceGroup: string
resourceGroup: azureResource.AzureResourceResourceGroup
}