Migrating other deployment wizards to the generic ResourceTypeWizard (#13132)

* SQL VM wizard migration to ResourceType Wizard

* Revert "SQL VM wizard migration to ResourceType Wizard"

This reverts commit e58cd47707a7e2812be20d915f1fe638b96b035f.

* migrated notebook wizard

* SQL VM wizard migration to ResourceType Wizard

* Fixed some imports on SQL VM wizard

* migrated sqldb wizard to generic ResourceTypeWizard

* Added missing import
Solving errors from the merge

* Moved some common functionality into ResourceTypeWizard

* Changed logic of start deployment

* fixed some import after changing files.
This commit is contained in:
Aasim Khan
2020-10-30 12:42:20 -07:00
committed by GitHub
parent 76625012dd
commit 4f96ac46be
28 changed files with 743 additions and 776 deletions

View File

@@ -4,10 +4,10 @@
*--------------------------------------------------------------------------------------------*/
import * as azdata from 'azdata';
import { DeployAzureSQLVMWizard } from '../deployAzureSQLVMWizard';
import * as constants from '../constants';
import { BasePage } from './basePage';
import * as nls from 'vscode-nls';
import { DeployAzureSQLVMWizardModel } from '../deployAzureSQLVMWizardModel';
const localize = nls.loadMessageBundle();
@@ -37,11 +37,11 @@ export class NetworkSettingsPage extends BasePage {
private _form!: azdata.FormContainer;
constructor(wizard: DeployAzureSQLVMWizard) {
constructor(private _model: DeployAzureSQLVMWizardModel) {
super(
constants.NetworkSettingsPageTitle,
constants.NetworkSettingsPageDescription,
wizard
_model.wizard
);
}
@@ -61,13 +61,13 @@ export class NetworkSettingsPage extends BasePage {
.withFormItems(
[
{
component: this.wizard.createFormRowComponent(view, constants.VirtualNetworkDropdownLabel, '', this._virtualNetworkFlexContainer, true)
component: this._model.createFormRowComponent(view, constants.VirtualNetworkDropdownLabel, '', this._virtualNetworkFlexContainer, true)
},
{
component: this.wizard.createFormRowComponent(view, constants.SubnetDropdownLabel, '', this._subnetFlexContainer, true)
component: this._model.createFormRowComponent(view, constants.SubnetDropdownLabel, '', this._subnetFlexContainer, true)
},
{
component: this.wizard.createFormRowComponent(view, constants.PublicIPDropdownLabel, '', this._publicIpFlexContainer, true)
component: this._model.createFormRowComponent(view, constants.PublicIPDropdownLabel, '', this._publicIpFlexContainer, true)
},
{
component: this._vmRDPAllowCheckbox
@@ -88,7 +88,7 @@ export class NetworkSettingsPage extends BasePage {
this.populateVirtualNetworkDropdown();
this.populatePublicIpkDropdown();
this.liveValidation = false;
this.wizard.wizardObject.registerNavigationValidator(async (pcInfo) => {
this._model.wizard.wizardObject.registerNavigationValidator(async (pcInfo) => {
if (pcInfo.newPage < pcInfo.lastPage) {
return true;
}
@@ -103,7 +103,7 @@ export class NetworkSettingsPage extends BasePage {
}
public async onLeave(): Promise<void> {
this.wizard.wizardObject.registerNavigationValidator((pcInfo) => {
this._model.wizard.wizardObject.registerNavigationValidator((pcInfo) => {
return true;
});
}
@@ -125,7 +125,7 @@ export class NetworkSettingsPage extends BasePage {
}).component();
this._virtualNetworkDropdown.onValueChanged((value) => {
this.wizard.model.virtualNetworkName = (this._virtualNetworkDropdown.value as azdata.CategoryValue).name;
this._model.virtualNetworkName = (this._virtualNetworkDropdown.value as azdata.CategoryValue).name;
this.populateSubnetDropdown();
});
@@ -136,7 +136,7 @@ export class NetworkSettingsPage extends BasePage {
}).component();
this._newVirtualNetworkText.onTextChanged((e) => {
this.wizard.model.virtualNetworkName = e;
this._model.virtualNetworkName = e;
this.activateRealTimeFormValidation();
});
@@ -182,28 +182,28 @@ export class NetworkSettingsPage extends BasePage {
let newVirtualNetwork = this._newVirtualNetworkCheckbox.checked;
this.wizard.model.newVirtualNetwork = newVirtualNetwork ? 'True' : 'False';
this._model.newVirtualNetwork = newVirtualNetwork ? 'True' : 'False';
if (newVirtualNetwork) {
this.wizard.changeComponentDisplay(this._virtualNetworkDropdown, 'none');
this.wizard.changeComponentDisplay(this._newVirtualNetworkText, 'block');
this._model.changeComponentDisplay(this._virtualNetworkDropdown, 'none');
this._model.changeComponentDisplay(this._newVirtualNetworkText, 'block');
this._newSubnetCheckbox.enabled = false;
this.wizard.changeComponentDisplay(this._subnetDropdown, 'none');
this.wizard.changeComponentDisplay(this._newsubnetText, 'block');
this.wizard.model.virtualNetworkName = this._newVirtualNetworkText.value!;
this.wizard.model.newSubnet = 'True';
this.wizard.model.subnetName = this._newsubnetText.value!;
this._model.changeComponentDisplay(this._subnetDropdown, 'none');
this._model.changeComponentDisplay(this._newsubnetText, 'block');
this._model.virtualNetworkName = this._newVirtualNetworkText.value!;
this._model.newSubnet = 'True';
this._model.subnetName = this._newsubnetText.value!;
} else {
this.wizard.changeComponentDisplay(this._virtualNetworkDropdown, 'block');
this.wizard.changeComponentDisplay(this._newVirtualNetworkText, 'none');
this._model.changeComponentDisplay(this._virtualNetworkDropdown, 'block');
this._model.changeComponentDisplay(this._newVirtualNetworkText, 'none');
this._newSubnetCheckbox.enabled = true;
this.wizard.changeComponentDisplay(this._subnetDropdown, 'block');
this.wizard.changeComponentDisplay(this._newsubnetText, 'none');
this.wizard.model.virtualNetworkName = (this._virtualNetworkDropdown.value as azdata.CategoryValue).name;
this.wizard.model.newSubnet = this._newSubnetCheckbox.checked! ? 'True' : 'False';
this._model.changeComponentDisplay(this._subnetDropdown, 'block');
this._model.changeComponentDisplay(this._newsubnetText, 'none');
this._model.virtualNetworkName = (this._virtualNetworkDropdown.value as azdata.CategoryValue).name;
this._model.newSubnet = this._newSubnetCheckbox.checked! ? 'True' : 'False';
}
}
@@ -225,7 +225,7 @@ export class NetworkSettingsPage extends BasePage {
}).component();
this._subnetDropdown.onValueChanged((value) => {
this.wizard.model.subnetName = (this._subnetDropdown.value as azdata.CategoryValue).name;
this._model.subnetName = (this._subnetDropdown.value as azdata.CategoryValue).name;
});
this._newsubnetText = view.modelBuilder.inputBox().withProperties(<azdata.InputBoxProperties>{
@@ -235,7 +235,7 @@ export class NetworkSettingsPage extends BasePage {
}).component();
this._newsubnetText.onTextChanged((e) => {
this.wizard.model.subnetName = e;
this._model.subnetName = e;
this.activateRealTimeFormValidation();
});
@@ -278,16 +278,16 @@ export class NetworkSettingsPage extends BasePage {
let newSubnet = this._newSubnetCheckbox.checked!;
this.wizard.model.newSubnet = newSubnet ? 'True' : 'False';
this._model.newSubnet = newSubnet ? 'True' : 'False';
if (newSubnet) {
this.wizard.changeComponentDisplay(this._subnetDropdown, 'none');
this.wizard.changeComponentDisplay(this._newsubnetText, 'block');
this.wizard.model.subnetName = this._newsubnetText.value!;
this._model.changeComponentDisplay(this._subnetDropdown, 'none');
this._model.changeComponentDisplay(this._newsubnetText, 'block');
this._model.subnetName = this._newsubnetText.value!;
} else {
this.wizard.changeComponentDisplay(this._subnetDropdown, 'block');
this.wizard.changeComponentDisplay(this._newsubnetText, 'none');
this.wizard.model.subnetName = (this._subnetDropdown.value as azdata.CategoryValue).name;
this._model.changeComponentDisplay(this._subnetDropdown, 'block');
this._model.changeComponentDisplay(this._newsubnetText, 'none');
this._model.subnetName = (this._subnetDropdown.value as azdata.CategoryValue).name;
}
}
@@ -308,7 +308,7 @@ export class NetworkSettingsPage extends BasePage {
}).component();
this._publicIpDropdown.onValueChanged((value) => {
this.wizard.model.publicIpName = (this._publicIpDropdown.value as azdata.CategoryValue).name;
this._model.publicIpName = (this._publicIpDropdown.value as azdata.CategoryValue).name;
});
this._publicIpNetworkText = view.modelBuilder.inputBox().withProperties(<azdata.InputBoxProperties>{
@@ -317,11 +317,11 @@ export class NetworkSettingsPage extends BasePage {
}).component();
this._publicIpNetworkText.onTextChanged((e) => {
this.wizard.model.publicIpName = e;
this._model.publicIpName = e;
this.activateRealTimeFormValidation();
});
this.wizard.changeComponentDisplay(this._publicIpNetworkText, 'none');
this._model.changeComponentDisplay(this._publicIpNetworkText, 'none');
this._publicIpFlexContainer = view.modelBuilder.flexContainer().withLayout({
flexFlow: 'column',
@@ -362,16 +362,16 @@ export class NetworkSettingsPage extends BasePage {
private toggleNewPublicIp() {
let newPip = this._newPublicIpCheckbox.checked!;
this.wizard.model.newPublicIp = newPip ? 'True' : 'False';
this._model.newPublicIp = newPip ? 'True' : 'False';
if (newPip) {
this.wizard.changeComponentDisplay(this._publicIpDropdown, 'none');
this.wizard.changeComponentDisplay(this._publicIpNetworkText, 'block');
this.wizard.model.publicIpName = this._publicIpNetworkText.value!;
this._model.changeComponentDisplay(this._publicIpDropdown, 'none');
this._model.changeComponentDisplay(this._publicIpNetworkText, 'block');
this._model.publicIpName = this._publicIpNetworkText.value!;
} else {
this.wizard.changeComponentDisplay(this._publicIpDropdown, 'block');
this.wizard.changeComponentDisplay(this._publicIpNetworkText, 'none');
this.wizard.model.publicIpName = (this._publicIpDropdown.value as azdata.CategoryValue).name;
this._model.changeComponentDisplay(this._publicIpDropdown, 'block');
this._model.changeComponentDisplay(this._publicIpNetworkText, 'none');
this._model.publicIpName = (this._publicIpDropdown.value as azdata.CategoryValue).name;
}
}
@@ -380,21 +380,21 @@ export class NetworkSettingsPage extends BasePage {
label: constants.RDPAllowCheckboxLabel,
}).component();
this._vmRDPAllowCheckbox.onChanged((value) => {
this.wizard.model.allowRDP = (value) ? 'True' : 'False';
this._model.allowRDP = (value) ? 'True' : 'False';
});
this.wizard.model.allowRDP = 'False';
this._model.allowRDP = 'False';
}
public async getVirtualNetworks(): Promise<any> {
let url = `https://management.azure.com` +
`/subscriptions/${this.wizard.model.azureSubscription}` +
`/subscriptions/${this._model.azureSubscription}` +
`/providers/Microsoft.Network/virtualNetworks?api-version=2020-05-01`;
let response = await this.wizard.getRequest(url);
let response = await this._model.getRequest(url);
let dropdownValues = response.data.value.filter((value: any) => {
return value.location === this.wizard.model.azureRegion;
return value.location === this._model.azureRegion;
}).map((value: any) => {
let resourceGroupName = value.id.replace(RegExp('^(.*?)/resourceGroups/'), '').replace(RegExp('/providers/.*'), '');
return {
@@ -406,13 +406,13 @@ export class NetworkSettingsPage extends BasePage {
}
public async getSubnets(): Promise<any> {
if (!this.wizard.model.virtualNetworkName) {
if (!this._model.virtualNetworkName) {
return;
}
let url = `https://management.azure.com` +
`${this.wizard.model.virtualNetworkName}` +
`${this._model.virtualNetworkName}` +
`/subnets?api-version=2020-05-01`;
let response = await this.wizard.getRequest(url);
let response = await this._model.getRequest(url);
let dropdownValues = response.data.value.map((value: any) => {
return {
name: value.id,
@@ -424,11 +424,11 @@ export class NetworkSettingsPage extends BasePage {
public async getPips(): Promise<any> {
let url = `https://management.azure.com` +
`/subscriptions/${this.wizard.model.azureSubscription}` +
`/subscriptions/${this._model.azureSubscription}` +
`/providers/Microsoft.Network/publicIPAddresses?api-version=2020-05-01`;
let response = await this.wizard.getRequest(url);
let response = await this._model.getRequest(url);
let dropdownValues = response.data.value.filter((value: any) => {
return value.location === this.wizard.model.azureRegion;
return value.location === this._model.azureRegion;
}).map((value: any) => {
let resourceGroupName = value.id.replace(RegExp('^(.*?)/resourceGroups/'), '').replace(RegExp('/providers/.*'), '');
return {
@@ -441,37 +441,37 @@ export class NetworkSettingsPage extends BasePage {
protected async validatePage(): Promise<string> {
const errorMessages = [];
if (this.wizard.model.newVirtualNetwork === 'True') {
if (this.wizard.model.virtualNetworkName.length < 2 || this.wizard.model.virtualNetworkName.length > 64) {
if (this._model.newVirtualNetwork === 'True') {
if (this._model.virtualNetworkName.length < 2 || this._model.virtualNetworkName.length > 64) {
errorMessages.push(localize('deployAzureSQLVM.VnetNameLengthError', "Virtual Network name must be between 2 and 64 characters long"));
}
} else {
if (this.wizard.model.virtualNetworkName === 'None') {
if (this._model.virtualNetworkName === 'None') {
errorMessages.push(localize('deployAzureSQLVM.NewVnetError', "Create a new virtual network"));
}
}
if (this.wizard.model.newSubnet === 'True') {
if (this.wizard.model.subnetName.length < 1 || this.wizard.model.subnetName.length > 80) {
if (this._model.newSubnet === 'True') {
if (this._model.subnetName.length < 1 || this._model.subnetName.length > 80) {
errorMessages.push(localize('deployAzureSQLVM.SubnetNameLengthError', "Subnet name must be between 1 and 80 characters long"));
}
} else {
if (this.wizard.model.subnetName === 'None') {
if (this._model.subnetName === 'None') {
errorMessages.push(localize('deployAzureSQLVM.NewSubnetError', "Create a new sub network"));
}
}
if (this.wizard.model.newPublicIp === 'True') {
if (this.wizard.model.publicIpName.length < 1 || this.wizard.model.publicIpName.length > 80) {
if (this._model.newPublicIp === 'True') {
if (this._model.publicIpName.length < 1 || this._model.publicIpName.length > 80) {
errorMessages.push(localize('deployAzureSQLVM.PipNameError', "Public IP name must be between 1 and 80 characters long"));
}
} else {
if (this.wizard.model.publicIpName === 'None') {
if (this._model.publicIpName === 'None') {
errorMessages.push(localize('deployAzureSQLVM.NewPipError', "Create a new new public Ip"));
}
}
this.wizard.showErrorMessage(errorMessages.join('\n'));
this._model.wizard.showErrorMessage(errorMessages.join('\n'));
return errorMessages.join('\n');
}