mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-08 17:24:01 -05:00
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:
@@ -5,14 +5,14 @@
|
||||
|
||||
import * as azdata from 'azdata';
|
||||
import * as constants from '../constants';
|
||||
import { WizardPageBase } from '../../wizardPageBase';
|
||||
import { DeployAzureSQLVMWizard } from '../deployAzureSQLVMWizard';
|
||||
import { apiService } from '../../../services/apiService';
|
||||
import { azureResource } from 'azureResource';
|
||||
import * as vscode from 'vscode';
|
||||
import * as localizedConstants from '../../../localizedConstants';
|
||||
import { BasePage } from './basePage';
|
||||
import { DeployAzureSQLVMWizardModel } from '../deployAzureSQLVMWizardModel';
|
||||
|
||||
export class AzureSettingsPage extends WizardPageBase<DeployAzureSQLVMWizard> {
|
||||
export class AzureSettingsPage extends BasePage {
|
||||
// <- means depends on
|
||||
//dropdown for azure accounts
|
||||
private _azureAccountsDropdown!: azdata.DropDownComponent;
|
||||
@@ -34,11 +34,11 @@ export class AzureSettingsPage extends WizardPageBase<DeployAzureSQLVMWizard> {
|
||||
|
||||
private _accountsMap!: Map<string, azdata.Account>;
|
||||
private _subscriptionsMap!: Map<string, azureResource.AzureResourceSubscription>;
|
||||
constructor(wizard: DeployAzureSQLVMWizard) {
|
||||
constructor(private _model: DeployAzureSQLVMWizardModel) {
|
||||
super(
|
||||
constants.AzureSettingsPageTitle,
|
||||
'',
|
||||
wizard
|
||||
_model.wizard
|
||||
);
|
||||
this._accountsMap = new Map();
|
||||
this._subscriptionsMap = new Map();
|
||||
@@ -59,19 +59,19 @@ export class AzureSettingsPage extends WizardPageBase<DeployAzureSQLVMWizard> {
|
||||
.withFormItems(
|
||||
[
|
||||
{
|
||||
component: this.wizard.createFormRowComponent(view, constants.AzureAccountDropdownLabel, '', this._azureAccountsDropdown, true)
|
||||
component: this._model.createFormRowComponent(view, constants.AzureAccountDropdownLabel, '', this._azureAccountsDropdown, true)
|
||||
},
|
||||
{
|
||||
component: this.buttonFlexContainer
|
||||
},
|
||||
{
|
||||
component: this.wizard.createFormRowComponent(view, constants.AzureAccountSubscriptionDropdownLabel, '', this._azureSubscriptionsDropdown, true)
|
||||
component: this._model.createFormRowComponent(view, constants.AzureAccountSubscriptionDropdownLabel, '', this._azureSubscriptionsDropdown, true)
|
||||
},
|
||||
{
|
||||
component: this.wizard.createFormRowComponent(view, constants.AzureAccountResourceGroupDropdownLabel, '', this._resourceGroupDropdown, true)
|
||||
component: this._model.createFormRowComponent(view, constants.AzureAccountResourceGroupDropdownLabel, '', this._resourceGroupDropdown, true)
|
||||
},
|
||||
{
|
||||
component: this.wizard.createFormRowComponent(view, constants.AzureAccountRegionDropdownLabel, '', this._azureRegionsDropdown, true)
|
||||
component: this._model.createFormRowComponent(view, constants.AzureAccountRegionDropdownLabel, '', this._azureRegionsDropdown, true)
|
||||
}
|
||||
],
|
||||
{
|
||||
@@ -85,13 +85,13 @@ export class AzureSettingsPage extends WizardPageBase<DeployAzureSQLVMWizard> {
|
||||
}
|
||||
|
||||
public async onEnter(): Promise<void> {
|
||||
this.wizard.wizardObject.registerNavigationValidator((pcInfo) => {
|
||||
this._model.wizard.wizardObject.registerNavigationValidator((pcInfo) => {
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
public async onLeave(): Promise<void> {
|
||||
this.wizard.wizardObject.registerNavigationValidator((pcInfo) => {
|
||||
this._model.wizard.wizardObject.registerNavigationValidator((pcInfo) => {
|
||||
return true;
|
||||
});
|
||||
}
|
||||
@@ -101,7 +101,7 @@ export class AzureSettingsPage extends WizardPageBase<DeployAzureSQLVMWizard> {
|
||||
this._azureAccountsDropdown = view.modelBuilder.dropDown().withProperties({}).component();
|
||||
|
||||
this._azureAccountsDropdown.onValueChanged(async (value) => {
|
||||
this.wizard.model.azureAccount = this._accountsMap.get(value.selected)!;
|
||||
this._model.azureAccount = this._accountsMap.get(value.selected)!;
|
||||
this.populateAzureSubscriptionsDropdown();
|
||||
});
|
||||
|
||||
@@ -132,13 +132,13 @@ export class AzureSettingsPage extends WizardPageBase<DeployAzureSQLVMWizard> {
|
||||
let accounts = await azdata.accounts.getAllAccounts();
|
||||
|
||||
if (accounts.length === 0) {
|
||||
this.wizard.showErrorMessage('Sign in to an Azure account first');
|
||||
this._model.wizard.showErrorMessage('Sign in to an Azure account first');
|
||||
return;
|
||||
} else {
|
||||
this.wizard.showErrorMessage('');
|
||||
this._model.wizard.showErrorMessage('');
|
||||
}
|
||||
|
||||
this.wizard.addDropdownValues(
|
||||
this._model.addDropdownValues(
|
||||
this._azureAccountsDropdown,
|
||||
accounts.map((account): azdata.CategoryValue => {
|
||||
let accountCategoryValue = {
|
||||
@@ -150,7 +150,7 @@ export class AzureSettingsPage extends WizardPageBase<DeployAzureSQLVMWizard> {
|
||||
}),
|
||||
);
|
||||
|
||||
this.wizard.model.azureAccount = accounts[0];
|
||||
this._model.azureAccount = accounts[0];
|
||||
this._azureAccountsDropdown.loading = false;
|
||||
|
||||
await this.populateAzureSubscriptionsDropdown();
|
||||
@@ -162,11 +162,11 @@ export class AzureSettingsPage extends WizardPageBase<DeployAzureSQLVMWizard> {
|
||||
this._azureSubscriptionsDropdown.onValueChanged(async (value) => {
|
||||
|
||||
let currentSubscriptionValue = this._azureSubscriptionsDropdown.value as azdata.CategoryValue;
|
||||
this.wizard.model.azureSubscription = currentSubscriptionValue.name;
|
||||
this.wizard.model.azureSubscriptionDisplayName = currentSubscriptionValue.displayName;
|
||||
this._model.azureSubscription = currentSubscriptionValue.name;
|
||||
this._model.azureSubscriptionDisplayName = currentSubscriptionValue.displayName;
|
||||
|
||||
this.wizard.model.securityToken = await azdata.accounts.getAccountSecurityToken(
|
||||
this.wizard.model.azureAccount,
|
||||
this._model.securityToken = await azdata.accounts.getAccountSecurityToken(
|
||||
this._model.azureAccount,
|
||||
this._subscriptionsMap.get(currentSubscriptionValue.name)?.tenant!,
|
||||
azdata.AzureResource.ResourceManagement
|
||||
);
|
||||
@@ -199,7 +199,7 @@ export class AzureSettingsPage extends WizardPageBase<DeployAzureSQLVMWizard> {
|
||||
}
|
||||
subscriptions.sort((a: any, b: any) => a.name.toLocaleLowerCase().localeCompare(b.name.toLocaleLowerCase()));
|
||||
|
||||
this.wizard.addDropdownValues(
|
||||
this._model.addDropdownValues(
|
||||
this._azureSubscriptionsDropdown,
|
||||
subscriptions.map((subscription: any): azdata.CategoryValue => {
|
||||
let subscriptionCategoryValue = {
|
||||
@@ -211,11 +211,11 @@ export class AzureSettingsPage extends WizardPageBase<DeployAzureSQLVMWizard> {
|
||||
})
|
||||
);
|
||||
|
||||
this.wizard.model.azureSubscription = (this._azureSubscriptionsDropdown.value as azdata.CategoryValue).name;
|
||||
this.wizard.model.azureSubscriptionDisplayName = (this._azureSubscriptionsDropdown.value as azdata.CategoryValue).displayName;
|
||||
this._model.azureSubscription = (this._azureSubscriptionsDropdown.value as azdata.CategoryValue).name;
|
||||
this._model.azureSubscriptionDisplayName = (this._azureSubscriptionsDropdown.value as azdata.CategoryValue).displayName;
|
||||
|
||||
this.wizard.model.securityToken = await azdata.accounts.getAccountSecurityToken(
|
||||
this.wizard.model.azureAccount,
|
||||
this._model.securityToken = await azdata.accounts.getAccountSecurityToken(
|
||||
this._model.azureAccount,
|
||||
this._subscriptionsMap.get((this._azureSubscriptionsDropdown.value as azdata.CategoryValue).name)?.tenant!,
|
||||
azdata.AzureResource.ResourceManagement
|
||||
);
|
||||
@@ -229,7 +229,7 @@ export class AzureSettingsPage extends WizardPageBase<DeployAzureSQLVMWizard> {
|
||||
required: true
|
||||
}).component();
|
||||
this._resourceGroupDropdown.onValueChanged(async (value) => {
|
||||
this.wizard.model.azureResouceGroup = value.selected;
|
||||
this._model.azureResouceGroup = value.selected;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -246,7 +246,7 @@ export class AzureSettingsPage extends WizardPageBase<DeployAzureSQLVMWizard> {
|
||||
return;
|
||||
}
|
||||
let currentSubscription = this._subscriptionsMap.get(currentSubscriptionValue.name);
|
||||
let resourceGroups = (await subService.getResourceGroups(this.wizard.model.azureAccount, currentSubscription, true)).resourceGroups;
|
||||
let resourceGroups = (await subService.getResourceGroups(this._model.azureAccount, currentSubscription, true)).resourceGroups;
|
||||
if (resourceGroups === undefined || resourceGroups.length === 0) {
|
||||
this._resourceGroupDropdown.loading = false;
|
||||
this._resourceGroupDropdown.updateProperties({
|
||||
@@ -264,7 +264,7 @@ export class AzureSettingsPage extends WizardPageBase<DeployAzureSQLVMWizard> {
|
||||
};
|
||||
})
|
||||
});
|
||||
this.wizard.model.azureResouceGroup = (this._resourceGroupDropdown.value as azdata.CategoryValue).name;
|
||||
this._model.azureResouceGroup = (this._resourceGroupDropdown.value as azdata.CategoryValue).name;
|
||||
this._resourceGroupDropdown.loading = false;
|
||||
}
|
||||
|
||||
@@ -274,7 +274,7 @@ export class AzureSettingsPage extends WizardPageBase<DeployAzureSQLVMWizard> {
|
||||
}).component();
|
||||
|
||||
this._azureRegionsDropdown.onValueChanged((value) => {
|
||||
this.wizard.model.azureRegion = (this._azureRegionsDropdown.value as azdata.CategoryValue).name;
|
||||
this._model.azureRegion = (this._azureRegionsDropdown.value as azdata.CategoryValue).name;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -283,10 +283,10 @@ export class AzureSettingsPage extends WizardPageBase<DeployAzureSQLVMWizard> {
|
||||
|
||||
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.wizard.model.azureSubscription}/locations?api-version=2020-01-01`;
|
||||
const response = await this.wizard.getRequest(url, false);
|
||||
let url = `https://management.azure.com/subscriptions/${this._model.azureSubscription}/locations?api-version=2020-01-01`;
|
||||
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);
|
||||
this.wizard.addDropdownValues(
|
||||
this._model.addDropdownValues(
|
||||
this._azureRegionsDropdown,
|
||||
response.data.value.filter((value: any) => {
|
||||
return supportedRegionsArray.includes(value.name);
|
||||
@@ -297,7 +297,7 @@ export class AzureSettingsPage extends WizardPageBase<DeployAzureSQLVMWizard> {
|
||||
};
|
||||
})
|
||||
);
|
||||
this.wizard.model.azureRegion = (this._azureRegionsDropdown.value as azdata.CategoryValue).name;
|
||||
this._model.azureRegion = (this._azureRegionsDropdown.value as azdata.CategoryValue).name;
|
||||
this._azureRegionsDropdown.loading = false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user