From 398a91456d7bb031f08bd113e496cd64c27a4b86 Mon Sep 17 00:00:00 2001 From: Cory Rivera Date: Tue, 13 Jun 2023 13:43:55 -0700 Subject: [PATCH] Add Configure SLO section to Create Database dialog for Azure servers (#23359) --- extensions/mssql/config.json | 2 +- .../mssql/src/objectManagement/interfaces.ts | 16 +++++ .../objectManagement/localizedConstants.ts | 6 +- .../src/objectManagement/ui/databaseDialog.ts | 66 ++++++++++++++++++- 4 files changed, 85 insertions(+), 5 deletions(-) diff --git a/extensions/mssql/config.json b/extensions/mssql/config.json index 853e4db085..844be7944b 100644 --- a/extensions/mssql/config.json +++ b/extensions/mssql/config.json @@ -1,6 +1,6 @@ { "downloadUrl": "https://github.com/Microsoft/sqltoolsservice/releases/download/{#version#}/microsoft.sqltools.servicelayer-{#fileName#}", - "version": "4.8.0.20", + "version": "4.8.0.22", "downloadFileNames": { "Windows_86": "win-x86-net7.0.zip", "Windows_64": "win-x64-net7.0.zip", diff --git a/extensions/mssql/src/objectManagement/interfaces.ts b/extensions/mssql/src/objectManagement/interfaces.ts index c449ade64f..db511e37f2 100644 --- a/extensions/mssql/src/objectManagement/interfaces.ts +++ b/extensions/mssql/src/objectManagement/interfaces.ts @@ -430,6 +430,11 @@ export interface Database extends ObjectManagement.SqlObject { recoveryModel?: string; compatibilityLevel?: string; containmentType?: string; + + azureBackupRedundancyLevel?: string; + azureServiceLevelObjective?: string; + azureEdition?: string; + azureMaxSize?: string; } export interface DatabaseViewInfo extends ObjectManagement.ObjectViewInfo { @@ -438,4 +443,15 @@ export interface DatabaseViewInfo extends ObjectManagement.ObjectViewInfo { - let generalSection = this.initializeGeneralSection(); - let optionsSection = this.initializeOptionsSection(); - this.formContainer.addItems([generalSection, optionsSection]); + let components = []; + components.push(this.initializeGeneralSection()); + components.push(this.initializeOptionsSection()); + if (this.viewInfo.isAzureDB) { + components.push(this.initializeConfigureSLOSection()); + } + this.formContainer.addItems(components); } private initializeGeneralSection(): azdata.GroupContainer { @@ -82,4 +86,60 @@ export class DatabaseDialog extends ObjectManagementDialogBase 0) { + let defaultEdition = this.viewInfo.azureEditions[0]; + this.objectInfo.azureEdition = defaultEdition; + + // Service Level Objective options + let sloDetails = this.viewInfo.azureServiceLevelObjectives?.find(details => details.editionDisplayName === defaultEdition); + let serviceLevels = sloDetails?.details ?? []; + this.objectInfo.azureServiceLevelObjective = serviceLevels[0]; + let serviceLevelDropbox = this.createDropdown(localizedConstants.CurrentSLOText, async () => { + this.objectInfo.azureServiceLevelObjective = serviceLevelDropbox.value as string; + }, serviceLevels, serviceLevels[0]); + + // Maximum Database Size options + let sizeDetails = this.viewInfo.azureMaxSizes?.find(details => details.editionDisplayName === defaultEdition); + let maxSizes = sizeDetails?.details ?? []; + this.objectInfo.azureMaxSize = maxSizes[0]; + let sizeDropbox = this.createDropdown(localizedConstants.MaxSizeText, async () => { + this.objectInfo.azureMaxSize = sizeDropbox.value as string; + }, maxSizes, maxSizes[0]); + + // Azure Database Edition options + let editionDropbox = this.createDropdown(localizedConstants.EditionText, async () => { + let edition = editionDropbox.value as string; + this.objectInfo.azureEdition = edition; + + // Update dropboxes for SLO and Size, since they're edition specific + sloDetails = this.viewInfo.azureServiceLevelObjectives?.find(details => details.editionDisplayName === edition); + serviceLevels = sloDetails?.details ?? []; + serviceLevelDropbox.loading = true; + await serviceLevelDropbox.updateProperties({ value: serviceLevels[0], values: serviceLevels }); + serviceLevelDropbox.loading = false; + + sizeDetails = this.viewInfo.azureMaxSizes?.find(details => details.editionDisplayName === edition); + maxSizes = sizeDetails?.details ?? []; + sizeDropbox.loading = true; + await sizeDropbox.updateProperties({ value: maxSizes[0], values: maxSizes }); + sizeDropbox.loading = false; + }, this.viewInfo.azureEditions, defaultEdition); + + containers.push(this.createLabelInputContainer(localizedConstants.EditionText, editionDropbox)); + containers.push(this.createLabelInputContainer(localizedConstants.CurrentSLOText, serviceLevelDropbox)); + containers.push(this.createLabelInputContainer(localizedConstants.MaxSizeText, sizeDropbox)); + } + + if (this.viewInfo.azureBackupRedundancyLevels?.length > 0) { + let backupDropbox = this.createDropdown(localizedConstants.BackupRedundancyText, async () => { + this.objectInfo.azureBackupRedundancyLevel = backupDropbox.value as string; + }, this.viewInfo.azureBackupRedundancyLevels, this.viewInfo.azureBackupRedundancyLevels[0]); + containers.push(this.createLabelInputContainer(localizedConstants.BackupRedundancyText, backupDropbox)); + } + + return this.createGroup(localizedConstants.ConfigureSLOSectionHeader, containers, true, true); + } }