Adding Integration Runtime Page to Migration extension wizard (#14020)

* - Fixed GetMigrationController
- Added createMigrationController and getControllerAuthKeys API in azure core.
- Added typings for Migration Controller
- Fixed database backup page validation logic
- Added IR page with create controller

* Fixing all the comments from the PR

* Fixed typings
This commit is contained in:
Aasim Khan
2021-01-25 14:46:39 -08:00
committed by GitHub
parent ed26938dc8
commit 42a8680738
12 changed files with 968 additions and 145 deletions

View File

@@ -38,8 +38,6 @@ export class DatabaseBackupPage extends MigrationWizardPage {
private _subscriptionMap: Map<string, Subscription> = new Map();
private _storageAccountMap: Map<string, StorageAccount> = new Map();
private _errors: string[] = [];
constructor(wizard: azdata.window.Wizard, migrationStateModel: MigrationStateModel) {
super(wizard, azdata.window.createWizardPage(constants.DATABASE_BACKUP_PAGE_TITLE), migrationStateModel);
this.wizardPage.description = constants.DATABASE_BACKUP_PAGE_DESCRIPTION;
@@ -139,16 +137,6 @@ export class DatabaseBackupPage extends MigrationWizardPage {
}).component();
this._fileShareSubscriptionDropdown = view.modelBuilder.dropDown().withProps({
required: true,
}).withValidation((c) => {
if (this.migrationStateModel.databaseBackup.networkContainerType === NetworkContainerType.FILE_SHARE) {
if ((<azdata.CategoryValue>c.value).displayName === constants.NO_SUBSCRIPTIONS_FOUND) {
this.addErrorMessage(constants.INVALID_SUBSCRIPTION_ERROR);
return false;
} else {
this.removeErrorMessage(constants.INVALID_SUBSCRIPTION_ERROR);
}
}
return true;
}).component();
this._fileShareSubscriptionDropdown.onValueChanged(async (value) => {
if (this._fileShareSubscriptionDropdown.value) {
@@ -165,16 +153,6 @@ export class DatabaseBackupPage extends MigrationWizardPage {
this._fileShareStorageAccountDropdown = view.modelBuilder.dropDown()
.withProps({
required: true
}).withValidation((c) => {
if (this.migrationStateModel.databaseBackup.networkContainerType === NetworkContainerType.FILE_SHARE) {
if ((<azdata.CategoryValue>c.value).displayName === constants.NO_STORAGE_ACCOUNT_FOUND) {
this.addErrorMessage(constants.INVALID_STORAGE_ACCOUNT_ERROR);
return false;
} else {
this.removeErrorMessage(constants.INVALID_STORAGE_ACCOUNT_ERROR);
}
}
return true;
}).component();
this._fileShareStorageAccountDropdown.onValueChanged(async (value) => {
if (this._fileShareStorageAccountDropdown.value) {
@@ -191,16 +169,6 @@ export class DatabaseBackupPage extends MigrationWizardPage {
this._fileShareFileShareDropdown = view.modelBuilder.dropDown()
.withProps({
required: true
}).withValidation((c) => {
if (this.migrationStateModel.databaseBackup.networkContainerType === NetworkContainerType.FILE_SHARE) {
if ((<azdata.CategoryValue>c.value).displayName === constants.NO_FILESHARES_FOUND) {
this.addErrorMessage(constants.INVALID_FILESHARE_ERROR);
return false;
} else {
this.removeErrorMessage(constants.INVALID_FILESHARE_ERROR);
}
}
return true;
}).component();
this._fileShareFileShareDropdown.onValueChanged((value) => {
if (this._fileShareFileShareDropdown.value) {
@@ -235,17 +203,6 @@ export class DatabaseBackupPage extends MigrationWizardPage {
this._blobContainerSubscriptionDropdown = view.modelBuilder.dropDown()
.withProps({
required: true
}).withValidation((c) => {
if (this.migrationStateModel.databaseBackup.networkContainerType === NetworkContainerType.BLOB_CONTAINER) {
if (
(<azdata.CategoryValue>c.value).displayName === constants.NO_SUBSCRIPTIONS_FOUND) {
this.addErrorMessage(constants.INVALID_SUBSCRIPTION_ERROR);
return false;
} else {
this.removeErrorMessage(constants.INVALID_SUBSCRIPTION_ERROR);
}
}
return true;
}).component();
this._blobContainerSubscriptionDropdown.onValueChanged(async (value) => {
if (this._blobContainerSubscriptionDropdown.value) {
@@ -262,16 +219,6 @@ export class DatabaseBackupPage extends MigrationWizardPage {
this._blobContainerStorageAccountDropdown = view.modelBuilder.dropDown()
.withProps({
required: true
}).withValidation((c) => {
if (this.migrationStateModel.databaseBackup.networkContainerType === NetworkContainerType.BLOB_CONTAINER) {
if ((<azdata.CategoryValue>c.value).displayName === constants.NO_STORAGE_ACCOUNT_FOUND) {
this.addErrorMessage(constants.INVALID_STORAGE_ACCOUNT_ERROR);
return false;
} else {
this.removeErrorMessage(constants.INVALID_STORAGE_ACCOUNT_ERROR);
}
}
return true;
}).component();
this._blobContainerStorageAccountDropdown.onValueChanged(async (value) => {
if (this._blobContainerStorageAccountDropdown.value) {
@@ -287,16 +234,6 @@ export class DatabaseBackupPage extends MigrationWizardPage {
this._blobContainerBlobDropdown = view.modelBuilder.dropDown()
.withProps({
required: true
}).withValidation((c) => {
if (this.migrationStateModel.databaseBackup.networkContainerType === NetworkContainerType.BLOB_CONTAINER) {
if ((<azdata.CategoryValue>c.value).displayName === constants.NO_BLOBCONTAINERS_FOUND) {
this.addErrorMessage(constants.INVALID_BLOBCONTAINER_ERROR);
return false;
} else {
this.removeErrorMessage(constants.INVALID_BLOBCONTAINER_ERROR);
}
}
return true;
}).component();
this._blobContainerBlobDropdown.onValueChanged((value) => {
if (this._blobContainerBlobDropdown.value) {
@@ -339,9 +276,11 @@ export class DatabaseBackupPage extends MigrationWizardPage {
validationErrorMessage: constants.INVALID_NETWORK_SHARE_LOCATION
})
.withValidation((component) => {
if (component.value) {
if (!/^(\\)(\\[\w\.-_]+){2,}(\\?)$/.test(component.value)) {
return false;
if (this.migrationStateModel.databaseBackup.networkContainerType === NetworkContainerType.NETWORK_SHARE) {
if (component.value) {
if (!/^(\\)(\\[\w\.-_]+){2,}(\\?)$/.test(component.value)) {
return false;
}
}
}
return true;
@@ -362,9 +301,11 @@ export class DatabaseBackupPage extends MigrationWizardPage {
validationErrorMessage: constants.INVALID_USER_ACCOUNT
})
.withValidation((component) => {
if (component.value) {
if (!/^[a-zA-Z][a-zA-Z0-9\-\.]{0,61}[a-zA-Z]\\\w[\w\.\- ]*$/.test(component.value)) {
return false;
if (this.migrationStateModel.databaseBackup.networkContainerType === NetworkContainerType.NETWORK_SHARE) {
if (component.value) {
if (!/^[a-zA-Z][a-zA-Z0-9\-\.]{0,61}[a-zA-Z]\\\w[\w\.\- ]*$/.test(component.value)) {
return false;
}
}
}
return true;
@@ -401,16 +342,6 @@ export class DatabaseBackupPage extends MigrationWizardPage {
this._networkShareContainerSubscriptionDropdown = view.modelBuilder.dropDown()
.withProps({
required: true
}).withValidation((c) => {
if (this.migrationStateModel.databaseBackup.networkContainerType === NetworkContainerType.NETWORK_SHARE) {
if ((<azdata.CategoryValue>c.value).displayName === constants.NO_SUBSCRIPTIONS_FOUND) {
this.addErrorMessage(constants.INVALID_SUBSCRIPTION_ERROR);
return false;
} else {
this.removeErrorMessage(constants.INVALID_SUBSCRIPTION_ERROR);
}
}
return true;
}).component();
this._networkShareContainerSubscriptionDropdown.onValueChanged(async (value) => {
if (this._networkShareContainerSubscriptionDropdown.value) {
@@ -427,16 +358,6 @@ export class DatabaseBackupPage extends MigrationWizardPage {
this._networkShareContainerStorageAccountDropdown = view.modelBuilder.dropDown()
.withProps({
required: true
}).withValidation((c) => {
if (this.migrationStateModel.databaseBackup.networkContainerType === NetworkContainerType.NETWORK_SHARE) {
if ((<azdata.CategoryValue>c.value).displayName === constants.NO_STORAGE_ACCOUNT_FOUND) {
this.addErrorMessage(constants.INVALID_STORAGE_ACCOUNT_ERROR);
return false;
} else {
this.removeErrorMessage(constants.INVALID_STORAGE_ACCOUNT_ERROR);
}
}
return true;
}).component();
this._networkShareContainerStorageAccountDropdown.onValueChanged((value) => {
if (this._networkShareContainerStorageAccountDropdown.value) {
@@ -533,6 +454,55 @@ export class DatabaseBackupPage extends MigrationWizardPage {
public async onPageEnter(): Promise<void> {
await this.getSubscriptionValues();
this.wizard.registerNavigationValidator((pageChangeInfo) => {
if (pageChangeInfo.newPage < pageChangeInfo.lastPage) {
return true;
}
const errors: string[] = [];
switch (this.migrationStateModel.databaseBackup.networkContainerType) {
case NetworkContainerType.NETWORK_SHARE:
if ((<azdata.CategoryValue>this._networkShareContainerSubscriptionDropdown.value).displayName === constants.NO_SUBSCRIPTIONS_FOUND) {
errors.push(constants.INVALID_SUBSCRIPTION_ERROR);
}
if ((<azdata.CategoryValue>this._networkShareContainerStorageAccountDropdown.value).displayName === constants.NO_STORAGE_ACCOUNT_FOUND) {
errors.push(constants.INVALID_STORAGE_ACCOUNT_ERROR);
}
break;
case NetworkContainerType.BLOB_CONTAINER:
if ((<azdata.CategoryValue>this._blobContainerSubscriptionDropdown.value).displayName === constants.NO_SUBSCRIPTIONS_FOUND) {
errors.push(constants.INVALID_SUBSCRIPTION_ERROR);
}
if ((<azdata.CategoryValue>this._blobContainerStorageAccountDropdown.value).displayName === constants.NO_STORAGE_ACCOUNT_FOUND) {
errors.push(constants.INVALID_STORAGE_ACCOUNT_ERROR);
}
if ((<azdata.CategoryValue>this._blobContainerBlobDropdown.value).displayName === constants.NO_BLOBCONTAINERS_FOUND) {
errors.push(constants.INVALID_BLOBCONTAINER_ERROR);
}
break;
case NetworkContainerType.FILE_SHARE:
if ((<azdata.CategoryValue>this._fileShareSubscriptionDropdown.value).displayName === constants.NO_SUBSCRIPTIONS_FOUND) {
errors.push(constants.INVALID_SUBSCRIPTION_ERROR);
}
if ((<azdata.CategoryValue>this._fileShareStorageAccountDropdown.value).displayName === constants.NO_STORAGE_ACCOUNT_FOUND) {
errors.push(constants.INVALID_STORAGE_ACCOUNT_ERROR);
}
if ((<azdata.CategoryValue>this._fileShareFileShareDropdown.value).displayName === constants.NO_FILESHARES_FOUND) {
errors.push(constants.INVALID_FILESHARE_ERROR);
}
break;
}
this.wizard.message = {
text: errors.join(EOL),
level: azdata.window.MessageLevel.Error
};
if (errors.length > 0) {
return false;
}
return true;
});
}
public async onPageLeave(): Promise<void> {
@@ -721,22 +691,4 @@ export class DatabaseBackupPage extends MigrationWizardPage {
name: ''
}];
}
private addErrorMessage(message: string) {
if (!this._errors.includes(message)) {
this._errors.push(message);
}
this.wizard.message = {
text: this._errors.join(EOL),
level: azdata.window.MessageLevel.Error
};
}
private removeErrorMessage(message: string) {
this._errors = this._errors.filter(e => e !== message);
this.wizard.message = {
text: this._errors.join(EOL),
level: azdata.window.MessageLevel.Error
};
}
}