diff --git a/extensions/mssql/src/objectManagement/interfaces.ts b/extensions/mssql/src/objectManagement/interfaces.ts index 719dea0d31..d9b40ea05b 100644 --- a/extensions/mssql/src/objectManagement/interfaces.ts +++ b/extensions/mssql/src/objectManagement/interfaces.ts @@ -495,8 +495,14 @@ export interface Server extends ObjectManagement.SqlObject { serverCollation: string; serviceTier: string; storageSpaceUsageInMB: number; - minServerMemory: number; - maxServerMemory: number; + minServerMemory: NumericServerProperty; + maxServerMemory: NumericServerProperty; +} + +export interface NumericServerProperty { + maximumValue: number; + minimumValue: number; + value: number; } export interface ServerViewInfo extends ObjectManagement.ObjectViewInfo { diff --git a/extensions/mssql/src/objectManagement/localizedConstants.ts b/extensions/mssql/src/objectManagement/localizedConstants.ts index 299fb91d39..cc778bba37 100644 --- a/extensions/mssql/src/objectManagement/localizedConstants.ts +++ b/extensions/mssql/src/objectManagement/localizedConstants.ts @@ -261,6 +261,7 @@ export const StorageSpaceUsageInMBText = localize('objectManagement.storageSpace export const VersionText = localize('objectManagement.versionText', "Version"); export const minServerMemoryText = localize('objectManagement.minServerMemoryText', "Minimum Server Memory (MB)"); export const maxServerMemoryText = localize('objectManagement.maxServerMemoryText', "Maximum Server Memory (MB)"); +export const serverMemoryMaxLowerThanMinInputError: string = localize('objectManagement.serverMemoryMaxLowerThanMinInputError', "Maximum server memory cannot be lower than minimum server memory") //Database properties Dialog export const LastDatabaseBackupText = localize('objectManagement.lastDatabaseBackup', "Last Database Backup"); diff --git a/extensions/mssql/src/objectManagement/ui/serverPropertiesDialog.ts b/extensions/mssql/src/objectManagement/ui/serverPropertiesDialog.ts index c82e383d23..efd3791c7e 100644 --- a/extensions/mssql/src/objectManagement/ui/serverPropertiesDialog.ts +++ b/extensions/mssql/src/objectManagement/ui/serverPropertiesDialog.ts @@ -4,6 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import * as azdata from 'azdata'; import { ObjectManagementDialogBase, ObjectManagementDialogOptions } from './objectManagementDialogBase'; +import { DefaultInputWidth } from '../../ui/dialogBase'; import { IObjectManagementService } from 'mssql'; import * as localizedConstants from '../localizedConstants'; import { ViewServerPropertiesDocUrl } from '../constants'; @@ -163,13 +164,13 @@ export class ServerPropertiesDialog extends ObjectManagementDialogBase { - this.objectInfo.minServerMemory = +newValue; - }, this.objectInfo.minServerMemory.toString(), isEnabled, 'number'); + this.objectInfo.minServerMemory.value = +newValue; + }, this.objectInfo.minServerMemory.value.toString(), isEnabled, 'number', DefaultInputWidth, this.objectInfo.minServerMemory.minimumValue, this.objectInfo.minServerMemory.maximumValue); const minMemoryContainer = this.createLabelInputContainer(localizedConstants.minServerMemoryText, this.minServerMemoryInput); this.maxServerMemoryInput = this.createInputBox(localizedConstants.maxServerMemoryText, async (newValue) => { - this.objectInfo.maxServerMemory = +newValue; - }, this.objectInfo.maxServerMemory.toString(), isEnabled, 'number'); + this.objectInfo.maxServerMemory.value = +newValue; + }, this.objectInfo.maxServerMemory.value.toString(), isEnabled, 'number', DefaultInputWidth, this.objectInfo.maxServerMemory.minimumValue, this.objectInfo.maxServerMemory.maximumValue); const maxMemoryContainer = this.createLabelInputContainer(localizedConstants.maxServerMemoryText, this.maxServerMemoryInput); this.memorySection = this.createGroup('', [ @@ -179,4 +180,12 @@ export class ServerPropertiesDialog extends ObjectManagementDialogBase { + const errors = await super.validateInput(); + if (this.objectInfo.maxServerMemory.value < this.objectInfo.minServerMemory.value) { + errors.push(localizedConstants.serverMemoryMaxLowerThanMinInputError); + } + return errors; + } } diff --git a/extensions/mssql/src/ui/dialogBase.ts b/extensions/mssql/src/ui/dialogBase.ts index 4dd54ce60e..d556a39655 100644 --- a/extensions/mssql/src/ui/dialogBase.ts +++ b/extensions/mssql/src/ui/dialogBase.ts @@ -147,8 +147,8 @@ export abstract class DialogBase { return this.createInputBox(ariaLabel, textChangeHandler, value, enabled, 'password', width); } - protected createInputBox(ariaLabel: string, textChangeHandler: (newValue: string) => Promise, value: string = '', enabled: boolean = true, type: azdata.InputBoxInputType = 'text', width: number = DefaultInputWidth): azdata.InputBoxComponent { - const inputbox = this.modelView.modelBuilder.inputBox().withProps({ inputType: type, enabled: enabled, ariaLabel: ariaLabel, value: value, width: width }).component(); + protected createInputBox(ariaLabel: string, textChangeHandler: (newValue: string) => Promise, value: string = '', enabled: boolean = true, type: azdata.InputBoxInputType = 'text', width: number = DefaultInputWidth, min?: number, max?: number): azdata.InputBoxComponent { + const inputbox = this.modelView.modelBuilder.inputBox().withProps({ inputType: type, enabled: enabled, ariaLabel: ariaLabel, value: value, width: width, min: min, max: max }).component(); this.disposables.push(inputbox.onTextChanged(async () => { await textChangeHandler(inputbox.value!); this.onFormFieldChange();