Resource deployment clean up (#14418)

This commit is contained in:
Charles Gagnon
2021-02-24 12:11:06 -08:00
committed by GitHub
parent 9d827869a1
commit 587ac45418
11 changed files with 43 additions and 38 deletions

View File

@@ -65,9 +65,6 @@ export class DeployAzureSQLDBWizardModel extends ResourceTypeModel {
await this.scriptToNotebook(); await this.scriptToNotebook();
} }
onCancel(): void {
}
private getPages(): ResourceTypePage[] { private getPages(): ResourceTypePage[] {
const pages: ResourceTypePage[] = []; const pages: ResourceTypePage[] = [];
pages.push(new AzureSettingsPage(this)); pages.push(new AzureSettingsPage(this));

View File

@@ -243,7 +243,7 @@ export class AzureSettingsPage extends BasePage {
private async populateAzureSubscriptionsDropdown() { private async populateAzureSubscriptionsDropdown() {
this._azureSubscriptionsDropdown.loading = true; this._azureSubscriptionsDropdown.loading = true;
let subService = await apiService.azurecoreApi; let subService = apiService.azurecoreApi;
let currentAccountDropdownValue = (this._azureAccountsDropdown.value as azdata.CategoryValue); let currentAccountDropdownValue = (this._azureAccountsDropdown.value as azdata.CategoryValue);
if (currentAccountDropdownValue === undefined) { if (currentAccountDropdownValue === undefined) {
this._azureSubscriptionsDropdown.loading = false; this._azureSubscriptionsDropdown.loading = false;

View File

@@ -80,10 +80,6 @@ export class DeployAzureSQLVMWizardModel extends ResourceTypeModel {
await this.scriptToNotebook(); await this.scriptToNotebook();
} }
onCancel(): void {
throw new Error('Method not implemented.');
}
private getPages(): ResourceTypePage[] { private getPages(): ResourceTypePage[] {
const pages: ResourceTypePage[] = []; const pages: ResourceTypePage[] = [];
pages.push(new AzureSettingsPage(this)); pages.push(new AzureSettingsPage(this));

View File

@@ -12,6 +12,8 @@ import * as localizedConstants from '../../../localizedConstants';
import { BasePage } from './basePage'; import { BasePage } from './basePage';
import { DeployAzureSQLVMWizardModel } from '../deployAzureSQLVMWizardModel'; import { DeployAzureSQLVMWizardModel } from '../deployAzureSQLVMWizardModel';
const supportedRegions = ['eastus', 'eastus2', 'westus', 'centralus', 'northcentralus', 'southcentralus', 'northeurope', 'westeurope', 'eastasia', 'southeastasia', 'japaneast', 'japanwest', 'australiaeast', 'australiasoutheast', 'australiacentral', 'brazilsouth', 'southindia', 'centralindia', 'westindia', 'canadacentral', 'canadaeast', 'westus2', 'westcentralus', 'uksouth', 'ukwest', 'koreacentral', 'koreasouth', 'francecentral', 'southafricanorth', 'uaenorth', 'switzerlandnorth', 'germanywestcentral', 'norwayeast'];
export class AzureSettingsPage extends BasePage { export class AzureSettingsPage extends BasePage {
// <- means depends on // <- means depends on
//dropdown for azure accounts //dropdown for azure accounts
@@ -101,6 +103,9 @@ export class AzureSettingsPage extends BasePage {
this._azureAccountsDropdown = view.modelBuilder.dropDown().withProperties({}).component(); this._azureAccountsDropdown = view.modelBuilder.dropDown().withProperties({}).component();
this._azureAccountsDropdown.onValueChanged(async (value) => { this._azureAccountsDropdown.onValueChanged(async (value) => {
if (!this._azureAccountsDropdown.value) {
return;
}
this._model.azureAccount = this._accountsMap.get(value.selected)!; this._model.azureAccount = this._accountsMap.get(value.selected)!;
this.populateAzureSubscriptionsDropdown(); this.populateAzureSubscriptionsDropdown();
}); });
@@ -161,8 +166,10 @@ export class AzureSettingsPage extends BasePage {
private async createAzureSubscriptionsDropdown(view: azdata.ModelView) { private async createAzureSubscriptionsDropdown(view: azdata.ModelView) {
this._azureSubscriptionsDropdown = view.modelBuilder.dropDown().withProperties({}).component(); this._azureSubscriptionsDropdown = view.modelBuilder.dropDown().withProperties({}).component();
this._azureSubscriptionsDropdown.onValueChanged(async (value) => { this._azureSubscriptionsDropdown.onValueChanged(async value => {
if (!this._azureSubscriptionsDropdown.value) {
return;
}
let currentSubscriptionValue = this._azureSubscriptionsDropdown.value as azdata.CategoryValue; let currentSubscriptionValue = this._azureSubscriptionsDropdown.value as azdata.CategoryValue;
this._model.azureSubscription = currentSubscriptionValue.name; this._model.azureSubscription = currentSubscriptionValue.name;
this._model.azureSubscriptionDisplayName = currentSubscriptionValue.displayName; this._model.azureSubscriptionDisplayName = currentSubscriptionValue.displayName;
@@ -180,7 +187,7 @@ export class AzureSettingsPage extends BasePage {
private async populateAzureSubscriptionsDropdown() { private async populateAzureSubscriptionsDropdown() {
this._azureSubscriptionsDropdown.loading = true; this._azureSubscriptionsDropdown.loading = true;
let subService = await apiService.azurecoreApi; let subService = apiService.azurecoreApi;
let currentAccountDropdownValue = (this._azureAccountsDropdown.value as azdata.CategoryValue); let currentAccountDropdownValue = (this._azureAccountsDropdown.value as azdata.CategoryValue);
if (currentAccountDropdownValue === undefined) { if (currentAccountDropdownValue === undefined) {
this._azureSubscriptionsDropdown.loading = false; this._azureSubscriptionsDropdown.loading = false;
@@ -237,7 +244,7 @@ export class AzureSettingsPage extends BasePage {
private async populateResourceGroupDropdown() { private async populateResourceGroupDropdown() {
this._resourceGroupDropdown.loading = true; this._resourceGroupDropdown.loading = true;
let subService = await apiService.azurecoreApi; let subService = apiService.azurecoreApi;
let currentSubscriptionValue = this._azureSubscriptionsDropdown.value as azdata.CategoryValue; let currentSubscriptionValue = this._azureSubscriptionsDropdown.value as azdata.CategoryValue;
if (currentSubscriptionValue === undefined || currentSubscriptionValue.displayName === '') { if (currentSubscriptionValue === undefined || currentSubscriptionValue.displayName === '') {
@@ -275,7 +282,10 @@ export class AzureSettingsPage extends BasePage {
required: true required: true
}).component(); }).component();
this._azureRegionsDropdown.onValueChanged((value) => { this._azureRegionsDropdown.onValueChanged(value => {
if (!this._azureRegionsDropdown.value) {
return;
}
this._model.azureRegion = (this._azureRegionsDropdown.value as azdata.CategoryValue).name; this._model.azureRegion = (this._azureRegionsDropdown.value as azdata.CategoryValue).name;
}); });
} }
@@ -283,15 +293,13 @@ export class AzureSettingsPage extends BasePage {
private async populateAzureRegionsDropdown() { private async populateAzureRegionsDropdown() {
this._azureRegionsDropdown.loading = true; this._azureRegionsDropdown.loading = true;
let supportedRegions = 'eastus, eastus2, westus, centralus, northcentralus, southcentralus, northeurope, westeurope, eastasia, southeastasia, japaneast, japanwest, australiaeast, australiasoutheast, australiacentral, brazilsouth, southindia, centralindia, westindia, canadacentral, canadaeast, westus2, westcentralus, uksouth, ukwest, koreacentral, koreasouth, francecentral, southafricanorth, uaenorth, switzerlandnorth, germanywestcentral, norwayeast';
let supportedRegionsArray = supportedRegions.split(', ');
let url = `https://management.azure.com/subscriptions/${this._model.azureSubscription}/locations?api-version=2020-01-01`; let url = `https://management.azure.com/subscriptions/${this._model.azureSubscription}/locations?api-version=2020-01-01`;
const response = await this._model.getRequest(url, false); const response = await this._model.getRequest(url, false);
response.data.value = response.data.value.sort((a: any, b: any) => (a.displayName > b.displayName) ? 1 : -1); response.data.value = response.data.value.sort((a: any, b: any) => (a.displayName > b.displayName) ? 1 : -1);
this._model.addDropdownValues( this._model.addDropdownValues(
this._azureRegionsDropdown, this._azureRegionsDropdown,
response.data.value.filter((value: any) => { response.data.value.filter((value: any) => {
return supportedRegionsArray.includes(value.name); return supportedRegions.includes(value.name);
}).map((value: any) => { }).map((value: any) => {
return { return {
displayName: value.displayName, displayName: value.displayName,

View File

@@ -124,7 +124,10 @@ export class NetworkSettingsPage extends BasePage {
required: true required: true
}).component(); }).component();
this._virtualNetworkDropdown.onValueChanged((value) => { this._virtualNetworkDropdown.onValueChanged(value => {
if (!this._virtualNetworkDropdown.value) {
return;
}
this._model.virtualNetworkName = (this._virtualNetworkDropdown.value as azdata.CategoryValue).name; this._model.virtualNetworkName = (this._virtualNetworkDropdown.value as azdata.CategoryValue).name;
this.populateSubnetDropdown(); this.populateSubnetDropdown();
}); });
@@ -224,7 +227,10 @@ export class NetworkSettingsPage extends BasePage {
required: true required: true
}).component(); }).component();
this._subnetDropdown.onValueChanged((value) => { this._subnetDropdown.onValueChanged(value => {
if (!this._subnetDropdown.value) {
return;
}
this._model.subnetName = (this._subnetDropdown.value as azdata.CategoryValue).name; this._model.subnetName = (this._subnetDropdown.value as azdata.CategoryValue).name;
}); });
@@ -307,7 +313,10 @@ export class NetworkSettingsPage extends BasePage {
width: constants.standardWidth, width: constants.standardWidth,
}).component(); }).component();
this._publicIpDropdown.onValueChanged((value) => { this._publicIpDropdown.onValueChanged(value => {
if (!this._publicIpDropdown.value) {
return;
}
this._model.publicIpName = (this._publicIpDropdown.value as azdata.CategoryValue).name; this._model.publicIpName = (this._publicIpDropdown.value as azdata.CategoryValue).name;
}); });

View File

@@ -184,7 +184,10 @@ export class VmSettingsPage extends BasePage {
this._vmImageDropdown = view.modelBuilder.dropDown().withProperties({ this._vmImageDropdown = view.modelBuilder.dropDown().withProperties({
}).component(); }).component();
this._vmImageDropdown.onValueChanged((value) => { this._vmImageDropdown.onValueChanged(value => {
if (!this._vmImageDropdown.value) {
return;
}
this._model.vmImage = (this._vmImageDropdown.value as azdata.CategoryValue).name; this._model.vmImage = (this._vmImageDropdown.value as azdata.CategoryValue).name;
this._vmImageSkuDropdown.loading = true; this._vmImageSkuDropdown.loading = true;
this._vmImageVersionDropdown.loading = true; this._vmImageVersionDropdown.loading = true;
@@ -236,7 +239,10 @@ export class VmSettingsPage extends BasePage {
this._vmImageSkuDropdown = view.modelBuilder.dropDown().withProperties({ this._vmImageSkuDropdown = view.modelBuilder.dropDown().withProperties({
}).component(); }).component();
this._vmImageSkuDropdown.onValueChanged((value) => { this._vmImageSkuDropdown.onValueChanged(value => {
if (!this._vmImageSkuDropdown.value) {
return;
}
this._model.vmImageSKU = (this._vmImageSkuDropdown.value as azdata.CategoryValue).name; this._model.vmImageSKU = (this._vmImageSkuDropdown.value as azdata.CategoryValue).name;
this.populateVmImageVersionDropdown(); this.populateVmImageVersionDropdown();
}); });
@@ -274,7 +280,10 @@ export class VmSettingsPage extends BasePage {
this._vmImageVersionDropdown = view.modelBuilder.dropDown().withProperties({ this._vmImageVersionDropdown = view.modelBuilder.dropDown().withProperties({
}).component(); }).component();
this._vmImageVersionDropdown.onValueChanged((value) => { this._vmImageVersionDropdown.onValueChanged(value => {
if (!this._vmImageVersionDropdown.value) {
return;
}
this._model.vmImageVersion = (this._vmImageVersionDropdown.value as azdata.CategoryValue).name; this._model.vmImageVersion = (this._vmImageVersionDropdown.value as azdata.CategoryValue).name;
}); });
} }

View File

@@ -78,8 +78,6 @@ export class DeployClusterWizardModel extends ResourceTypeModel {
await this.scriptToNotebook(); await this.scriptToNotebook();
} }
onCancel(): void { }
constructor(public bdcProvider: BdcWizardDeploymentProvider, wizard: ResourceTypeWizard) { constructor(public bdcProvider: BdcWizardDeploymentProvider, wizard: ResourceTypeWizard) {
super(bdcProvider, wizard); super(bdcProvider, wizard);
this._kubeService = this.wizard._kubeService; this._kubeService = this.wizard._kubeService;

View File

@@ -55,9 +55,6 @@ export class NotebookWizardModel extends ResourceTypeModel {
this.wizard.setPages(this.getPages()); this.wizard.setPages(this.getPages());
} }
public onCancel(): void {
}
/** /**
* Generates the notebook and returns true if generation was done and so the wizard should be closed. * Generates the notebook and returns true if generation was done and so the wizard should be closed.
**/ **/

View File

@@ -51,8 +51,4 @@ export class PageLessDeploymentModel extends ResourceTypeModel {
vscode.commands.executeCommand(provider.command); vscode.commands.executeCommand(provider.command);
} }
} }
onCancel(): void {
}
} }

View File

@@ -15,7 +15,7 @@ export abstract class ResourceTypeModel extends Model {
abstract initialize(initialParams?: InitialVariableValues): void; abstract initialize(initialParams?: InitialVariableValues): void;
abstract onOk(): Promise<void>; abstract onOk(): Promise<void>;
abstract onCancel(): void; public onCancel(): void { }
/** /**
* performs the script generation and returns true if script was generated successfully * performs the script generation and returns true if script was generated successfully
**/ **/

View File

@@ -35,10 +35,6 @@ export class ToolsAndEulaPage extends ResourceTypePage {
private _isInitialized = false; private _isInitialized = false;
private _resourceType: ResourceType; private _resourceType: ResourceType;
public set resourceProvider(provider: DeploymentProvider) {
this.wizard.provider = provider;
}
public get toolsService(): IToolsService { public get toolsService(): IToolsService {
return this.wizard.toolsService; return this.wizard.toolsService;
} }
@@ -190,7 +186,7 @@ export class ToolsAndEulaPage extends ResourceTypePage {
if (this._resourceType.options) { if (this._resourceType.options) {
let resourceTypeOptions: ResourceTypeOptionValue[] = []; let resourceTypeOptions: ResourceTypeOptionValue[] = [];
const optionsTitle = this.view.modelBuilder.text().withProps({ const optionsTitle = this.view.modelBuilder.text().withProps({
value: 'Options', value: loc.optionsText,
CSSStyles: { CSSStyles: {
'font-size': '14px', 'font-size': '14px',
'padding': '0' 'padding': '0'
@@ -308,7 +304,6 @@ export class ToolsAndEulaPage extends ResourceTypePage {
const options = this.getSelectedOptions(); const options = this.getSelectedOptions();
this.resourceProvider = this._resourceType.getProvider(options)!;
return this._resourceType.getProvider(options)!; return this._resourceType.getProvider(options)!;
} }