Aasim/fix/sqldbtypos (#13130)

* fixed some easy typos on sql db wizard.

* Fixed some instructions in the notebook

* - Added option to enable or disable firewall rules

* converted toggle firewall dropdown to checkbox
This commit is contained in:
Aasim Khan
2020-10-29 11:53:56 -07:00
committed by GitHub
parent 66da2a46c5
commit e15ad17967
10 changed files with 142 additions and 75 deletions

View File

@@ -14,12 +14,12 @@ export const WizardDoneButtonLabel = localize('deployAzureSQLDB.ScriptToNotebook
export const MissingRequiredInformationErrorMessage = localize('deployAzureSQLDB.MissingRequiredInfoError', "Please fill out the required fields marked with red asterisks.");
// Azure settings page constants
export const AzureSettingsPageTitle = localize('deployAzureSQLDB.AzureSettingsPageTitle', "Azure SQL Database - Azure Account Settings");
export const AzureSettingsSummaryPageTitle = localize('deployAzureSQLDB.AzureSettingsSummaryPageTitle', "Azure Account Settings");
export const AzureAccountDropdownLabel = localize('deployAzureSQLDB.AzureAccountDropdownLabel', "Azure Account");
export const AzureSettingsPageTitle = localize('deployAzureSQLDB.AzureSettingsPageTitle', "Azure SQL Database - Azure account settings");
export const AzureSettingsSummaryPageTitle = localize('deployAzureSQLDB.AzureSettingsSummaryPageTitle', "Azure account settings");
export const AzureAccountDropdownLabel = localize('deployAzureSQLDB.AzureAccountDropdownLabel', "Azure account");
export const AzureAccountSubscriptionDropdownLabel = localize('deployAzureSQLDB.AzureSubscriptionDropdownLabel', "Subscription");
export const AzureAccountDatabaseServersDropdownLabel = localize('deployAzureSQLDB.AzureDatabaseServersDropdownLabel', "Server");
export const AzureAccountResourceGroupDropdownLabel = localize('deployAzureSQLDB.ResourceGroup', "Resource Group");
export const AzureAccountResourceGroupDropdownLabel = localize('deployAzureSQLDB.ResourceGroup', "Resource group");
//@todo alma1 9/8/20 Region label used for upcoming server creation feature.
//export const AzureAccountRegionDropdownLabel = localize('deployAzureSQLDB.AzureRegionDropdownLabel', "Region (for Public IP Address)");
@@ -38,8 +38,10 @@ export const FirewallRuleNameLabel = localize('deployAzureSQLDB.FirewallRuleName
export const DatabaseNameLabel = localize('deployAzureSQLDB.DatabaseNameLabel', "SQL database name");
export const CollationNameLabel = localize('deployAzureSQLDB.CollationNameLabel', "Database collation");
export const CollationNameSummaryLabel = localize('deployAzureSQLDB.CollationNameSummaryLabel', "Collation for database");
export const IpAddressInfoLabel = localize('deployAzureSQLDB.IpAddressInfoLabel', "Enter IP Addresses in IPv4 format.");
export const StartIpAddressLabel = localize('deployAzureSQLDB.StartIpAddressLabel', "Min IP Address in firewall Ip Range");
export const EndIpAddressLabel = localize('deployAzureSQLDB.EndIpAddressLabel', "Max IP Address in firewall IP Range");
export const StartIpAddressShortLabel = localize('deployAzureSQLDB.StartIpAddressShortLabel', "Min IP Address");
export const EndIpAddressShortLabel = localize('deployAzureSQLDB.EndIpAddressShortLabel', "Max IP Address");
export const IpAddressInfoLabel = localize('deployAzureSQLDB.IpAddressInfoLabel', "Enter IP addresses in IPv4 format.");
export const StartIpAddressLabel = localize('deployAzureSQLDB.StartIpAddressLabel', "Min IP address in firewall IP range");
export const EndIpAddressLabel = localize('deployAzureSQLDB.EndIpAddressLabel', "Max IP address in firewall IP range");
export const StartIpAddressShortLabel = localize('deployAzureSQLDB.StartIpAddressShortLabel', "Min IP address");
export const EndIpAddressShortLabel = localize('deployAzureSQLDB.EndIpAddressShortLabel', "Max IP address");
export const FirewallRuleDescription = localize('deployAzureSQLDB.FirewallRuleDescription', "Create a firewall rule for your local client IP in order to connect to your database through Azure Data Studio after creation is completed.");
export const FirewallToggleLabel = localize('deployAzureSQLDB.FirewallToggleLabel', "Create a firewall rule");

View File

@@ -27,6 +27,7 @@ export class DeployAzureSQLDBWizardModel extends Model {
public endIpAddress!: string;
public firewallRuleName!: string;
public databaseCollation!: string;
public newFirewallRule!: boolean;
constructor() {
@@ -41,11 +42,14 @@ export class DeployAzureSQLDBWizardModel extends Model {
statements.push(`azure_sqldb_server_name = '${this.azureServerName}'`);
//statements.push(`azure_sqldb_database_edition = '${this.databaseEdition}'`); //@todo alma1 10/7/2020 used for upcoming datbase hardware creation feature.
statements.push(`azure_sqldb_database_name = '${this.databaseName}'`);
//statements.push(`azure_sqldb_location = '${this.azureRegion}'`); //@todo alma1 9/10/2020 used for upcoming server creation feature.
statements.push(`azure_sqldb_ip_start = '${this.startIpAddress}'`);
statements.push(`azure_sqldb_ip_end = '${this.endIpAddress}'`);
statements.push(`azure_sqldb_firewall_name = '${this.firewallRuleName}'`);
statements.push(`azure_sqldb_collation = '${this.databaseCollation}'`);
//statements.push(`azure_sqldb_location = '${this.azureRegion}'`); //@todo alma1 9/10/2020 used for upcoming server creation feature.
statements.push(`azure_sqldb_enable_firewall_rule = ${(this.newFirewallRule) ? 'True' : 'False'}`);
if (this.newFirewallRule) {
statements.push(`azure_sqldb_ip_start = '${this.startIpAddress}'`);
statements.push(`azure_sqldb_ip_end = '${this.endIpAddress}'`);
statements.push(`azure_sqldb_firewall_name = '${this.firewallRuleName}'`);
}
// statements.push(`azure_sqldb_family = '${this.databaseFamily}'`); //@todo alma1 10/7/2020 used for upcoming datbase hardware creation feature.
// statements.push(`azure_sqldb_vcore = '${this.vCoreNumber}'`);
// statements.push(`azure_sqldb_maxmemory = '${this.storageInGB}'`);

View File

@@ -12,6 +12,7 @@ import { azureResource } from 'azureResource';
import * as vscode from 'vscode';
import { BasePage } from './basePage';
import * as nls from 'vscode-nls';
import * as localizedConstants from '../../../localizedConstants';
const localize = nls.loadMessageBundle();
export class AzureSettingsPage extends BasePage {
@@ -166,11 +167,11 @@ export class AzureSettingsPage extends BasePage {
});
this.signInButton = view.modelBuilder.button().withProperties<azdata.ButtonProperties>({
label: 'Sign In',
label: localizedConstants.signIn,
width: '100px'
}).component();
this.refreshButton = view.modelBuilder.button().withProperties<azdata.ButtonProperties>({
label: 'Refresh',
label: localizedConstants.refresh,
width: '100px'
}).component();

View File

@@ -9,6 +9,7 @@ import { DeployAzureSQLDBWizard } from '../deployAzureSQLDBWizard';
import * as constants from '../constants';
import { BasePage } from './basePage';
import * as nls from 'vscode-nls';
import { createCheckbox, createFlexContainer, createLabel } from '../../modelViewUtils';
const localize = nls.loadMessageBundle();
export class DatabaseSettingsPage extends BasePage {
@@ -24,6 +25,10 @@ export class DatabaseSettingsPage extends BasePage {
private _collationTextbox!: azdata.InputBoxComponent;
private _collationTextRow!: azdata.FlexContainer;
private _IpInfoText!: azdata.TextComponent;
private _firewallToggleDropdown!: azdata.CheckBoxComponent;
private _firewallToggleLabel!: azdata.TextComponent;
private _form!: azdata.FormContainer;
@@ -39,6 +44,7 @@ export class DatabaseSettingsPage extends BasePage {
this.pageObject.registerContent(async (view: azdata.ModelView) => {
await Promise.all([
this.createIpAddressText(view),
this.createFirewallToggle(view),
this.createFirewallNameText(view),
this.createDatabaseNameText(view),
this.createCollationText(view)
@@ -52,6 +58,9 @@ export class DatabaseSettingsPage extends BasePage {
{
component: this._collationTextRow
},
{
component: createFlexContainer(view, [this._firewallToggleLabel, this._firewallToggleDropdown])
},
{
component: this._firewallRuleNameTextRow
},
@@ -128,6 +137,37 @@ export class DatabaseSettingsPage extends BasePage {
this._endIpAddressTextRow = this.wizard.createFormRowComponent(view, constants.EndIpAddressLabel, '', this._endIpAddressTextbox, true);
}
private createFirewallToggle(view: azdata.ModelView) {
this._firewallToggleDropdown = createCheckbox(view, {
initialValue: true,
label: '',
required: false
});
this._firewallToggleLabel = createLabel(view, {
text: constants.FirewallToggleLabel,
description: constants.FirewallRuleDescription,
required: false,
width: '250px',
cssStyles: {
'font-weight': '400',
'font-size': '13px',
}
});
this.wizard.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;
});
}
private createFirewallNameText(view: azdata.ModelView) {
this._firewallRuleNameTextbox = view.modelBuilder.inputBox().component();
@@ -173,25 +213,28 @@ export class DatabaseSettingsPage extends BasePage {
let databasename = this._databaseNameTextbox.value!;
let collationname = this._collationTextbox.value!;
if (!(ipRegex.test(startipvalue))) {
errorMessages.push(localize('deployAzureSQLDB.DBMinIpInvalidError', "Min Ip address is invalid"));
}
if (this.wizard.model.newFirewallRule) {
if (!(ipRegex.test(startipvalue))) {
errorMessages.push(localize('deployAzureSQLDB.DBMinIpInvalidError', "Min Ip address is invalid"));
}
if (!(ipRegex.test(endipvalue))) {
errorMessages.push(localize('deployAzureSQLDB.DBMaxIpInvalidError', "Max Ip address is invalid"));
}
if (!(ipRegex.test(endipvalue))) {
errorMessages.push(localize('deployAzureSQLDB.DBMaxIpInvalidError', "Max Ip address is invalid"));
}
if (/^\d+$/.test(firewallname)) {
errorMessages.push(localize('deployAzureSQLDB.DBFirewallOnlyNumericNameError', "Firewall name cannot contain only numbers."));
}
if (firewallname.length < 1 || firewallname.length > 100) {
errorMessages.push(localize('deployAzureSQLDB.DBFirewallLengthError', "Firewall name must be between 1 and 100 characters long."));
}
if (/[\\\/"\'\[\]:\|<>\+=;,\?\*@\&,]/g.test(firewallname)) {
errorMessages.push(localize('deployAzureSQLDB.DBFirewallSpecialCharError', "Firewall name cannot contain special characters \/\"\"[]:|<>+=;,?*@&, ."));
}
if (/[A-Z]/g.test(firewallname)) {
errorMessages.push(localize('deployAzureSQLDB.DBFirewallUpperCaseError', "Upper case letters are not allowed for firewall name"));
}
if (/^\d+$/.test(firewallname)) {
errorMessages.push(localize('deployAzureSQLDB.DBFirewallOnlyNumericNameError', "Firewall name cannot contain only numbers."));
}
if (firewallname.length < 1 || firewallname.length > 100) {
errorMessages.push(localize('deployAzureSQLDB.DBFirewallLengthError', "Firewall name must be between 1 and 100 characters long."));
}
if (/[\\\/"\'\[\]:\|<>\+=;,\?\*@\&,]/g.test(firewallname)) {
errorMessages.push(localize('deployAzureSQLDB.DBFirewallSpecialCharError', "Firewall name cannot contain special characters \/\"\"[]:|<>+=;,?*@&, ."));
}
if (/[A-Z]/g.test(firewallname)) {
errorMessages.push(localize('deployAzureSQLDB.DBFirewallUpperCaseError', "Upper case letters are not allowed for firealll name"));
}
if (/^\d+$/.test(databasename)) {

View File

@@ -7,6 +7,7 @@ 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';
@@ -136,6 +137,17 @@ export class AzureSQLDBSummaryPage extends WizardPageBase<DeployAzureSQLDBWizard
defaultValue: model.databaseCollation,
labelCSSStyles: { fontWeight: FontWeight.Bold }
},
{
type: FieldType.ReadonlyText,
label: constants.FirewallToggleLabel,
defaultValue: model.newFirewallRule ? localizedConstants.yes : localizedConstants.no,
labelCSSStyles: { fontWeight: FontWeight.Bold }
}
]
};
if (model.newFirewallRule) {
databaseSettingSection.fields?.push(
{
type: FieldType.ReadonlyText,
label: constants.FirewallRuleNameLabel,
@@ -153,9 +165,8 @@ export class AzureSQLDBSummaryPage extends WizardPageBase<DeployAzureSQLDBWizard
label: constants.EndIpAddressShortLabel,
defaultValue: model.endIpAddress,
labelCSSStyles: { fontWeight: FontWeight.Bold }
}
]
};
});
}
const createSectionFunc = async (sectionInfo: SectionInfo): Promise<azdata.FormComponent> => {