From 89dbcb66389e59ae3a96c8f999b10f62c3121345 Mon Sep 17 00:00:00 2001 From: Candice Ye Date: Tue, 19 Jul 2022 10:29:19 -0700 Subject: [PATCH] Fixed default value for radio options builder if using resourceType displayName (#20070) Co-authored-by: Candice Ye --- extensions/resource-deployment/src/interfaces.ts | 2 +- .../src/ui/radioGroupLoadingComponentBuilder.ts | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/extensions/resource-deployment/src/interfaces.ts b/extensions/resource-deployment/src/interfaces.ts index dbf0342604..94d3ac7cfd 100644 --- a/extensions/resource-deployment/src/interfaces.ts +++ b/extensions/resource-deployment/src/interfaces.ts @@ -285,7 +285,7 @@ export interface IOptionsSource { export interface OptionsInfo { values?: string[] | azdata.CategoryValue[], source?: IOptionsSource, - defaultValue: string, + defaultValue: string | ResourceTypeOptionValue, optionsType?: OptionsType } diff --git a/extensions/resource-deployment/src/ui/radioGroupLoadingComponentBuilder.ts b/extensions/resource-deployment/src/ui/radioGroupLoadingComponentBuilder.ts index c115dbdfed..766ebf5d4f 100644 --- a/extensions/resource-deployment/src/ui/radioGroupLoadingComponentBuilder.ts +++ b/extensions/resource-deployment/src/ui/radioGroupLoadingComponentBuilder.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import * as azdata from 'azdata'; import * as vscode from 'vscode'; -import { OptionsInfo, FieldInfo, instanceOfDynamicEnablementInfo } from '../interfaces'; +import { OptionsInfo, FieldInfo, instanceOfDynamicEnablementInfo, ResourceTypeOptionValue } from '../interfaces'; import { getErrorMessage } from '../common/utils'; export class RadioGroupLoadingComponentBuilder implements azdata.ComponentBuilder { @@ -45,7 +45,14 @@ export class RadioGroupLoadingComponentBuilder implements azdata.ComponentBuilde } let options: (string[] | azdata.CategoryValue[]) = optionsInfo.values!; - let defaultValue: string = optionsInfo.defaultValue!; + let defaultValue: string | ResourceTypeOptionValue = optionsInfo.defaultValue!; + if (optionsInfo.defaultValue) { + if ((optionsInfo.defaultValue).displayName) { + defaultValue = (optionsInfo.defaultValue).displayName; + } else { + defaultValue = optionsInfo.defaultValue; + } + } options.forEach((op: string | azdata.CategoryValue) => { const option: azdata.CategoryValue = (typeof op === 'string') ? { name: op, displayName: op }