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

@@ -1,175 +0,0 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as azdata from 'azdata';
import * as vscode from 'vscode';
import * as constants from './constants';
import { INotebookService } from '../../services/notebookService';
import { IToolsService } from '../../services/toolsService';
import { WizardBase } from '../wizardBase';
import { WizardPageBase } from '../wizardPageBase';
import { DeployAzureSQLDBWizardModel } from './deployAzureSQLDBWizardModel';
import { AzureSQLDBWizardInfo } from '../../interfaces';
import { AzureSettingsPage } from './pages/azureSettingsPage';
import { DatabaseSettingsPage } from './pages/databaseSettingsPage';
import axios, { AxiosRequestConfig } from 'axios';
import { AzureSQLDBSummaryPage } from './pages/summaryPage';
import { EOL } from 'os';
export class DeployAzureSQLDBWizard extends WizardBase<DeployAzureSQLDBWizard, WizardPageBase<DeployAzureSQLDBWizard>, DeployAzureSQLDBWizardModel> {
constructor(private wizardInfo: AzureSQLDBWizardInfo, private _notebookService: INotebookService, private _toolsService: IToolsService) {
super(
constants.WizardTitle,
'DeployAzureSqlDBWizard',
new DeployAzureSQLDBWizardModel(),
_toolsService
);
}
private cache: Map<string, any> = new Map();
protected initialize(): void {
this.setPages(this.getPages());
this.wizardObject.generateScriptButton.hidden = true;
this.wizardObject.doneButton.label = constants.WizardDoneButtonLabel;
}
public get notebookService(): INotebookService {
return this._notebookService;
}
public get toolService(): IToolsService {
return this._toolsService;
}
protected async onOk(): Promise<void> {
await this.scriptToNotebook();
}
protected onCancel(): void {
}
private getPages(): WizardPageBase<DeployAzureSQLDBWizard>[] {
const pages: WizardPageBase<DeployAzureSQLDBWizard>[] = [];
pages.push(new AzureSettingsPage(this));
pages.push(new DatabaseSettingsPage(this));
pages.push(new AzureSQLDBSummaryPage(this));
return pages;
}
private async scriptToNotebook(): Promise<void> {
const variableValueStatements = this.model.getCodeCellContentForNotebook();
const insertionPosition = 2; // Cell number 2 is the position where the python variable setting statements need to be inserted in this.wizardInfo.notebook.
try {
await this.notebookService.openNotebookWithEdits(this.wizardInfo.notebook, variableValueStatements, insertionPosition);
} catch (error) {
vscode.window.showErrorMessage(error);
}
}
public async getRequest(url: string, useCache = false): Promise<any> {
if (useCache) {
if (this.cache.has(url)) {
return this.cache.get(url);
}
}
let token = this.model.securityToken.token;
const config: AxiosRequestConfig = {
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${token}`
},
validateStatus: () => true // Never throw
};
const response = await axios.get(url, config);
if (response.status !== 200) {
let errorMessage: string[] = [];
errorMessage.push(response.status.toString());
errorMessage.push(response.statusText);
if (response.data && response.data.error) {
errorMessage.push(`${response.data.error.code} : ${response.data.error.message}`);
}
vscode.window.showErrorMessage(errorMessage.join(EOL));
}
if (useCache) {
this.cache.set(url, response);
}
return response;
}
public createFormRowComponent(view: azdata.ModelView, title: string, description: string, component: azdata.Component, required: boolean): azdata.FlexContainer {
component.updateProperties({
required: required,
width: '480px'
});
const labelText = view.modelBuilder.text()
.withProperties<azdata.TextComponentProperties>(
{
value: title,
width: '250px',
description: description,
requiredIndicator: required,
})
.component();
labelText.updateCssStyles({
'font-weight': '400',
'font-size': '13px',
});
const flexContainer = view.modelBuilder.flexContainer()
.withLayout(
{
flexFlow: 'row',
alignItems: 'center',
})
.withItems(
[labelText, component],
{
CSSStyles: { 'margin-right': '5px' }
})
.component();
return flexContainer;
}
public changeComponentDisplay(component: azdata.Component, display: ('none' | 'block')) {
component.updateProperties({
required: display === 'block'
});
component.updateCssStyles({
display: display
});
}
public changeRowDisplay(container: azdata.FlexContainer, display: ('none' | 'block')) {
container.items.map((component) => {
component.updateProperties({
required: (display === 'block'),
});
component.updateCssStyles({
display: display,
});
});
}
public addDropdownValues(component: azdata.DropDownComponent, values: azdata.CategoryValue[], width?: number) {
component.updateProperties({
values: values,
width: '480px'
});
}
public showErrorMessage(message: string) {
this.wizardObject.message = {
text: message,
level: azdata.window.MessageLevel.Error
};
}
}

View File

@@ -5,9 +5,22 @@
import { EOL } from 'os';
import * as azdata from 'azdata';
import { Model } from '../model';
import * as vscode from 'vscode';
import * as constants from './constants';
import axios, { AxiosRequestConfig } from 'axios';
import { ResourceTypeModel } from '../resourceTypeModel';
import { INotebookService } from '../../services/notebookService';
import { IToolsService } from '../../services/toolsService';
import { AzureSQLDBDeploymentProvider } from '../../interfaces';
import { ResourceTypeWizard } from '../resourceTypeWizard';
import { ResourceTypePage } from '../resourceTypePage';
import { DatabaseSettingsPage } from './pages/databaseSettingsPage';
import { AzureSQLDBSummaryPage } from './pages/summaryPage';
import { AzureSettingsPage } from './pages/azureSettingsPage';
export class DeployAzureSQLDBWizardModel extends ResourceTypeModel {
private cache: Map<string, any> = new Map();
export class DeployAzureSQLDBWizardModel extends Model {
public azureAccount!: azdata.Account;
public securityToken!: any;
public azureSubscription!: string;
@@ -29,9 +42,142 @@ export class DeployAzureSQLDBWizardModel extends Model {
public databaseCollation!: string;
public newFirewallRule!: boolean;
public get notebookService(): INotebookService {
return this.wizard.notebookService;
}
constructor() {
super();
public get toolService(): IToolsService {
return this.wizard.toolsService;
}
constructor(public sqldbProvider: AzureSQLDBDeploymentProvider, wizard: ResourceTypeWizard) {
super(sqldbProvider, wizard);
this.wizard.wizardObject.title = constants.WizardTitle;
}
initialize(): void {
this.wizard.setPages(this.getPages());
this.wizard.wizardObject.generateScriptButton.hidden = true;
this.wizard.wizardObject.doneButton.label = constants.WizardDoneButtonLabel;
}
async onOk(): Promise<void> {
await this.scriptToNotebook();
}
onCancel(): void {
}
private getPages(): ResourceTypePage[] {
const pages: ResourceTypePage[] = [];
pages.push(new AzureSettingsPage(this));
pages.push(new DatabaseSettingsPage(this));
pages.push(new AzureSQLDBSummaryPage(this));
return pages;
}
public async getRequest(url: string, useCache = false): Promise<any> {
if (useCache) {
if (this.cache.has(url)) {
return this.cache.get(url);
}
}
let token = this.securityToken.token;
const config: AxiosRequestConfig = {
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${token}`
},
validateStatus: () => true // Never throw
};
const response = await axios.get(url, config);
if (response.status !== 200) {
let errorMessage: string[] = [];
errorMessage.push(response.status.toString());
errorMessage.push(response.statusText);
if (response.data && response.data.error) {
errorMessage.push(`${response.data.error.code} : ${response.data.error.message}`);
}
vscode.window.showErrorMessage(errorMessage.join(EOL));
}
if (useCache) {
this.cache.set(url, response);
}
return response;
}
public createFormRowComponent(view: azdata.ModelView, title: string, description: string, component: azdata.Component, required: boolean): azdata.FlexContainer {
component.updateProperties({
required: required,
width: '480px'
});
const labelText = view.modelBuilder.text()
.withProperties<azdata.TextComponentProperties>(
{
value: title,
width: '250px',
description: description,
requiredIndicator: required,
})
.component();
labelText.updateCssStyles({
'font-weight': '400',
'font-size': '13px',
});
const flexContainer = view.modelBuilder.flexContainer()
.withLayout(
{
flexFlow: 'row',
alignItems: 'center',
})
.withItems(
[labelText, component],
{
CSSStyles: { 'margin-right': '5px' }
})
.component();
return flexContainer;
}
public changeComponentDisplay(component: azdata.Component, display: ('none' | 'block')) {
component.updateProperties({
required: display === 'block'
});
component.updateCssStyles({
display: display
});
}
public changeRowDisplay(container: azdata.FlexContainer, display: ('none' | 'block')) {
container.items.map((component) => {
component.updateProperties({
required: (display === 'block'),
});
component.updateCssStyles({
display: display,
});
});
}
public addDropdownValues(component: azdata.DropDownComponent, values: azdata.CategoryValue[], width?: number) {
component.updateProperties({
values: values,
width: '480px'
});
}
private async scriptToNotebook(): Promise<void> {
const variableValueStatements = this.getCodeCellContentForNotebook();
const insertionPosition = 2; // Cell number 2 is the position where the python variable setting statements need to be inserted in this.wizardInfo.notebook.
try {
await this.notebookService.openNotebookWithEdits(this.sqldbProvider.azureSQLDBWizard.notebook, variableValueStatements, insertionPosition);
} catch (error) {
vscode.window.showErrorMessage(error);
}
}
public getCodeCellContentForNotebook(): string[] {

View File

@@ -6,12 +6,12 @@
import * as azdata from 'azdata';
import { EOL } from 'os';
import * as constants from '../constants';
import { DeployAzureSQLDBWizard } from '../deployAzureSQLDBWizard';
import { apiService } from '../../../services/apiService';
import { azureResource } from 'azureResource';
import * as vscode from 'vscode';
import { BasePage } from './basePage';
import * as nls from 'vscode-nls';
import { DeployAzureSQLDBWizardModel } from '../deployAzureSQLDBWizardModel';
import * as localizedConstants from '../../../localizedConstants';
const localize = nls.loadMessageBundle();
@@ -59,11 +59,11 @@ export class AzureSettingsPage extends BasePage {
private _accountsMap!: Map<string, azdata.Account>;
private _subscriptionsMap!: Map<string, azureResource.AzureResourceSubscription>;
constructor(wizard: DeployAzureSQLDBWizard) {
constructor(private _model: DeployAzureSQLDBWizardModel) {
super(
constants.AzureSettingsPageTitle,
'',
wizard
_model.wizard
);
this._accountsMap = new Map();
this._subscriptionsMap = new Map();
@@ -91,19 +91,19 @@ export class AzureSettingsPage extends BasePage {
.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)
},
// { //@todo alma1 9/9/2020 Used for upcoming server creation feature.
// component: this.wizard.createFormRowComponent(view, constants.AzureAccountResourceGroupDropdownLabel, '', this._resourceGroupDropdown, true)
// },
{
component: this.wizard.createFormRowComponent(view, constants.AzureAccountDatabaseServersDropdownLabel, '', this._serverGroupDropdown, true)
component: this._model.createFormRowComponent(view, constants.AzureAccountDatabaseServersDropdownLabel, '', this._serverGroupDropdown, true)
},
// { //@todo alma1 9/8/2020 Used for upcoming server creation feature.
// component: this.wizard.createFormRowComponent(view, constants.AzureAccountRegionDropdownLabel, '', this._azureRegionsDropdown, true)
@@ -162,7 +162,7 @@ export class AzureSettingsPage extends BasePage {
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();
});
@@ -193,13 +193,13 @@ export class AzureSettingsPage extends BasePage {
let accounts = await azdata.accounts.getAllAccounts();
if (accounts.length === 0) {
this.wizard.showErrorMessage(localize('deployAzureSQLDB.azureSignInError', "Sign in to an Azure account first"));
this._model.wizard.showErrorMessage(localize('deployAzureSQLDB.azureSignInError', "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 = {
@@ -211,7 +211,7 @@ export class AzureSettingsPage extends BasePage {
}),
);
this.wizard.model.azureAccount = accounts[0];
this._model.azureAccount = accounts[0];
this._azureAccountsDropdown.loading = false;
await this.populateAzureSubscriptionsDropdown();
@@ -223,11 +223,11 @@ export class AzureSettingsPage extends BasePage {
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
);
@@ -266,7 +266,7 @@ export class AzureSettingsPage extends BasePage {
}
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 = {
@@ -278,11 +278,11 @@ export class AzureSettingsPage extends BasePage {
})
);
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
);
@@ -299,9 +299,9 @@ export class AzureSettingsPage extends BasePage {
}).component();
this._serverGroupDropdown.onValueChanged(async (value) => {
if (value.selected === ((this._serverGroupDropdown.value as azdata.CategoryValue).displayName)) {
this.wizard.model.azureServerName = value.selected;
this.wizard.model.azureResouceGroup = (this._serverGroupDropdown.value as azdata.CategoryValue).name.replace(RegExp('^(.*?)/resourceGroups/'), '').replace(RegExp('/providers/.*'), '');
this.wizard.model.azureRegion = (this._serverGroupDropdown.value as azdata.CategoryValue).name.replace(RegExp('^(.*?)/location/'), '');
this._model.azureServerName = value.selected;
this._model.azureResouceGroup = (this._serverGroupDropdown.value as azdata.CategoryValue).name.replace(RegExp('^(.*?)/resourceGroups/'), '').replace(RegExp('/providers/.*'), '');
this._model.azureRegion = (this._serverGroupDropdown.value as azdata.CategoryValue).name.replace(RegExp('^(.*?)/location/'), '');
//this.populateManagedInstanceDropdown(); //@todo alma1 9/8/2020 functions below are used for upcoming database hardware creation feature.
}
});
@@ -318,8 +318,8 @@ export class AzureSettingsPage extends BasePage {
// await this.populateManagedInstanceDropdown(); //@todo alma1 9/8/2020 functions below are used for upcoming database hardware creation feature.
return;
}
let url = `https://management.azure.com/subscriptions/${this.wizard.model.azureSubscription}/providers/Microsoft.Sql/servers?api-version=2019-06-01-preview`;
let response = await this.wizard.getRequest(url);
let url = `https://management.azure.com/subscriptions/${this._model.azureSubscription}/providers/Microsoft.Sql/servers?api-version=2019-06-01-preview`;
let response = await this._model.getRequest(url);
if (response.data.value.length === 0) {
this._serverGroupDropdown.updateProperties({
values: [
@@ -335,7 +335,7 @@ export class AzureSettingsPage extends BasePage {
} else {
response.data.value.sort((a: azdata.CategoryValue, b: azdata.CategoryValue) => (a!.name > b!.name) ? 1 : -1);
}
this.wizard.addDropdownValues(
this._model.addDropdownValues(
this._serverGroupDropdown,
response.data.value.map((value: any) => {
return {
@@ -346,9 +346,9 @@ export class AzureSettingsPage extends BasePage {
})
);
if (this._serverGroupDropdown.value) {
this.wizard.model.azureServerName = (this._serverGroupDropdown.value as azdata.CategoryValue).displayName;
this.wizard.model.azureResouceGroup = (this._serverGroupDropdown.value as azdata.CategoryValue).name.replace(RegExp('^(.*?)/resourceGroups/'), '').replace(RegExp('/providers/.*'), '');
this.wizard.model.azureRegion = (this._serverGroupDropdown.value as azdata.CategoryValue).name.replace(RegExp('^(.*?)/location/'), '');
this._model.azureServerName = (this._serverGroupDropdown.value as azdata.CategoryValue).displayName;
this._model.azureResouceGroup = (this._serverGroupDropdown.value as azdata.CategoryValue).name.replace(RegExp('^(.*?)/resourceGroups/'), '').replace(RegExp('/providers/.*'), '');
this._model.azureRegion = (this._serverGroupDropdown.value as azdata.CategoryValue).name.replace(RegExp('^(.*?)/location/'), '');
}
this._serverGroupDropdown.loading = false;
// await this.populateManagedInstanceDropdown(); //@todo alma1 9/8/2020 functions below are used for upcoming database hardware creation feature.
@@ -760,7 +760,7 @@ export class AzureSettingsPage extends BasePage {
// errorMessages.push(localize('deployAzureSQLDB.SupportedFamiliesError', "No Supported Family found in current DB edition.\nSelect a different edition"));
// }
this.wizard.showErrorMessage(errorMessages.join(EOL));
this._model.wizard.showErrorMessage(errorMessages.join(EOL));
return errorMessages.join(EOL);
}
}

View File

@@ -3,9 +3,8 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { WizardPageBase } from '../../wizardPageBase';
import { DeployAzureSQLDBWizard } from '../deployAzureSQLDBWizard';
import { ResourceTypePage } from '../../resourceTypePage';
export abstract class BasePage extends WizardPageBase<DeployAzureSQLDBWizard> {
export abstract class BasePage extends ResourceTypePage {
public abstract initialize(): void;
}

View File

@@ -5,10 +5,10 @@
import * as azdata from 'azdata';
import { EOL } from 'os';
import { DeployAzureSQLDBWizard } from '../deployAzureSQLDBWizard';
import * as constants from '../constants';
import { BasePage } from './basePage';
import * as nls from 'vscode-nls';
import { DeployAzureSQLDBWizardModel } from '../deployAzureSQLDBWizardModel';
import { createCheckbox, createFlexContainer, createLabel } from '../../modelViewUtils';
const localize = nls.loadMessageBundle();
@@ -32,11 +32,11 @@ export class DatabaseSettingsPage extends BasePage {
private _form!: azdata.FormContainer;
constructor(wizard: DeployAzureSQLDBWizard) {
constructor(private _model: DeployAzureSQLDBWizardModel) {
super(
constants.DatabaseSettingsPageTitle,
'',
wizard
_model.wizard
);
}
@@ -119,10 +119,10 @@ export class DatabaseSettingsPage extends BasePage {
}).component();
this._startIpAddressTextbox.onTextChanged((value) => {
this.wizard.model.startIpAddress = value;
this._model.startIpAddress = value;
});
this._startIpAddressTextRow = this.wizard.createFormRowComponent(view, constants.StartIpAddressLabel, '', this._startIpAddressTextbox, true);
this._startIpAddressTextRow = this._model.createFormRowComponent(view, constants.StartIpAddressLabel, '', this._startIpAddressTextbox, true);
//End IP Address Section:
@@ -131,10 +131,10 @@ export class DatabaseSettingsPage extends BasePage {
}).component();
this._endIpAddressTextbox.onTextChanged((value) => {
this.wizard.model.endIpAddress = value;
this._model.endIpAddress = value;
});
this._endIpAddressTextRow = this.wizard.createFormRowComponent(view, constants.EndIpAddressLabel, '', this._endIpAddressTextbox, true);
this._endIpAddressTextRow = this._model.createFormRowComponent(view, constants.EndIpAddressLabel, '', this._endIpAddressTextbox, true);
}
private createFirewallToggle(view: azdata.ModelView) {
@@ -156,15 +156,15 @@ export class DatabaseSettingsPage extends BasePage {
}
});
this.wizard.model.newFirewallRule = true;
this._model.newFirewallRule = true;
this._firewallToggleDropdown.onChanged((value) => {
let displayValue: 'block' | 'none' = (value) ? 'block' : 'none';
this.wizard.changeRowDisplay(this._firewallRuleNameTextRow, displayValue);
this.wizard.changeRowDisplay(this._endIpAddressTextRow, displayValue);
this.wizard.changeRowDisplay(this._startIpAddressTextRow, displayValue);
this.wizard.changeComponentDisplay(this._IpInfoText, displayValue);
this.wizard.model.newFirewallRule = value;
this._model.changeRowDisplay(this._firewallRuleNameTextRow, displayValue);
this._model.changeRowDisplay(this._endIpAddressTextRow, displayValue);
this._model.changeRowDisplay(this._startIpAddressTextRow, displayValue);
this._model.changeComponentDisplay(this._IpInfoText, displayValue);
this._model.newFirewallRule = value;
});
}
@@ -172,10 +172,10 @@ export class DatabaseSettingsPage extends BasePage {
this._firewallRuleNameTextbox = view.modelBuilder.inputBox().component();
this._firewallRuleNameTextRow = this.wizard.createFormRowComponent(view, constants.FirewallRuleNameLabel, '', this._firewallRuleNameTextbox, true);
this._firewallRuleNameTextRow = this._model.createFormRowComponent(view, constants.FirewallRuleNameLabel, '', this._firewallRuleNameTextbox, true);
this._firewallRuleNameTextbox.onTextChanged((value) => {
this.wizard.model.firewallRuleName = value;
this._model.firewallRuleName = value;
});
}
@@ -183,10 +183,10 @@ export class DatabaseSettingsPage extends BasePage {
this._databaseNameTextbox = view.modelBuilder.inputBox().component();
this._databaseNameTextRow = this.wizard.createFormRowComponent(view, constants.DatabaseNameLabel, '', this._databaseNameTextbox, true);
this._databaseNameTextRow = this._model.createFormRowComponent(view, constants.DatabaseNameLabel, '', this._databaseNameTextbox, true);
this._databaseNameTextbox.onTextChanged((value) => {
this.wizard.model.databaseName = value;
this._model.databaseName = value;
});
}
@@ -197,10 +197,10 @@ export class DatabaseSettingsPage extends BasePage {
}).component();
this._collationTextbox.onTextChanged((value) => {
this.wizard.model.databaseCollation = value;
this._model.databaseCollation = value;
});
this._collationTextRow = this.wizard.createFormRowComponent(view, constants.CollationNameLabel, '', this._collationTextbox, true);
this._collationTextRow = this._model.createFormRowComponent(view, constants.CollationNameLabel, '', this._collationTextbox, true);
}
@@ -213,7 +213,7 @@ export class DatabaseSettingsPage extends BasePage {
let databasename = this._databaseNameTextbox.value!;
let collationname = this._collationTextbox.value!;
if (this.wizard.model.newFirewallRule) {
if (this._model.newFirewallRule) {
if (!(ipRegex.test(startipvalue))) {
errorMessages.push(localize('deployAzureSQLDB.DBMinIpInvalidError', "Min Ip address is invalid"));
}
@@ -260,19 +260,19 @@ export class DatabaseSettingsPage extends BasePage {
errorMessages.push(localize('deployAzureSQLDB.DBCollationSpecialCharError', "Collation name cannot contain special characters \/\"\"[]:|<>+=;,?*@&, ."));
}
this.wizard.showErrorMessage(errorMessages.join(EOL));
this._model.wizard.showErrorMessage(errorMessages.join(EOL));
return errorMessages.join(EOL);
}
protected async databaseNameExists(dbName: string): Promise<boolean> {
const url = `https://management.azure.com` +
`/subscriptions/${this.wizard.model.azureSubscription}` +
`/resourceGroups/${this.wizard.model.azureResouceGroup}` +
`/subscriptions/${this._model.azureSubscription}` +
`/resourceGroups/${this._model.azureResouceGroup}` +
`/providers/Microsoft.Sql` +
`/servers/${this.wizard.model.azureServerName}` +
`/servers/${this._model.azureServerName}` +
`/databases?api-version=2017-10-01-preview`;
let response = await this.wizard.getRequest(url, true);
let response = await this._model.getRequest(url, true);
let nameArray = response.data.value.map((v: any) => { return v.name; });
return (nameArray.includes(dbName));

View File

@@ -4,24 +4,24 @@
*--------------------------------------------------------------------------------------------*/
import * as azdata from 'azdata';
import { WizardPageBase } from '../../wizardPageBase';
import { DeployAzureSQLDBWizard } from '../deployAzureSQLDBWizard';
import * as constants from '../constants';
import * as localizedConstants from '../../../localizedConstants';
import { SectionInfo, LabelPosition, FontWeight, FieldType } from '../../../interfaces';
import { createSection } from '../../modelViewUtils';
import { BasePage } from '../../deployAzureSQLVMWizard/pages/basePage';
import { DeployAzureSQLDBWizardModel } from '../deployAzureSQLDBWizardModel';
export class AzureSQLDBSummaryPage extends WizardPageBase<DeployAzureSQLDBWizard> {
export class AzureSQLDBSummaryPage extends BasePage {
private formItems: azdata.FormComponent[] = [];
private _form!: azdata.FormBuilder;
private _view!: azdata.ModelView;
constructor(wizard: DeployAzureSQLDBWizard) {
constructor(private _model: DeployAzureSQLDBWizardModel) {
super(
'Summary',
'',
wizard
_model.wizard
);
}
@@ -42,7 +42,7 @@ export class AzureSQLDBSummaryPage extends WizardPageBase<DeployAzureSQLDBWizard
this.formItems = [];
let model = this.wizard.model;
let model = this._model;
const labelWidth = '150px';
const inputWidth = '400px';