From e89341f6bd2482931c1c029aa00e758f4fafa67e Mon Sep 17 00:00:00 2001 From: Cheena Malhotra <13396919+cheenamalhotra@users.noreply.github.com> Date: Fri, 2 Dec 2022 13:48:23 -0800 Subject: [PATCH] Set both label and values to custom options select Boxes (#21354) --- .../connection/browser/connectionWidget.ts | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/sql/workbench/services/connection/browser/connectionWidget.ts b/src/sql/workbench/services/connection/browser/connectionWidget.ts index 94b4e55cd1..017d128e5c 100644 --- a/src/sql/workbench/services/connection/browser/connectionWidget.ts +++ b/src/sql/workbench/services/connection/browser/connectionWidget.ts @@ -267,14 +267,22 @@ export class ConnectionWidget extends lifecycle.Disposable { let customOptionsContainer = DialogHelper.appendRow(this._tableContainer, option.displayName, 'connection-label', 'connection-input', 'custom-connection-options', false, option.description, 100); switch (option.valueType) { case ServiceOptionType.boolean: - // Convert 'defaultValue' to string for comparison as it can be boolean here. - let optionValue = (option.defaultValue.toString() === true.toString()) ? this._trueInputValue : this._falseInputValue; - this._customOptionWidgets[i] = new SelectBox([this._trueInputValue, this._falseInputValue], optionValue, this._contextViewService, customOptionsContainer, { ariaLabel: option.displayName }); - DialogHelper.appendInputSelectBox(customOptionsContainer, this._customOptionWidgets[i] as SelectBox); - this._register(styler.attachSelectBoxStyler(this._customOptionWidgets[i] as SelectBox, this._themeService)); - break; case ServiceOptionType.category: - this._customOptionWidgets[i] = new SelectBox(option.categoryValues.map(c => c.displayName), option.defaultValue, this._contextViewService, customOptionsContainer, { ariaLabel: option.displayName }); + let selectedValue = option.defaultValue; + + let options = option.valueType === ServiceOptionType.category + ? option.categoryValues.map(v => { + return { text: v.displayName, value: v.name } as SelectOptionItemSQL; + }) + : + [ // Handle boolean options so we can map displaynames to values. + { displayName: this._trueInputValue, value: 'true' }, + { displayName: this._falseInputValue, value: 'false' } + ].map(v => { + return { text: v.displayName, value: v.value } as SelectOptionItemSQL; + }); + + this._customOptionWidgets[i] = new SelectBox(options, selectedValue, this._contextViewService, customOptionsContainer, { ariaLabel: option.displayName }); DialogHelper.appendInputSelectBox(customOptionsContainer, this._customOptionWidgets[i] as SelectBox); this._register(styler.attachSelectBoxStyler(this._customOptionWidgets[i] as SelectBox, this._themeService)); break;