diff --git a/src/Explorer/Controls/FeaturePanel/__snapshots__/FeaturePanelComponent.test.tsx.snap b/src/Explorer/Controls/FeaturePanel/__snapshots__/FeaturePanelComponent.test.tsx.snap index 96481387c..b96478515 100644 --- a/src/Explorer/Controls/FeaturePanel/__snapshots__/FeaturePanelComponent.test.tsx.snap +++ b/src/Explorer/Controls/FeaturePanel/__snapshots__/FeaturePanelComponent.test.tsx.snap @@ -157,8 +157,8 @@ exports[`Feature panel renders all flags 1`] = ` /> Promise; type stringPromise = () => Promise; -type dropdownItemPromise = () => Promise; +type choiceItemPromise = () => Promise; type infoPromise = () => Promise; /* eslint-disable-next-line @typescript-eslint/no-explicit-any */ -export type DropdownItem = { label: string; key: string }; +export type ChoiceItem = { label: string; key: string }; -export type InputType = number | string | boolean | DropdownItem; +export type InputType = number | string | boolean | ChoiceItem; export interface BaseInput { label: (() => Promise) | string; @@ -66,8 +66,8 @@ export interface StringInput extends BaseInput { defaultValue?: string; } -export interface DropdownInput extends BaseInput { - choices: (() => Promise) | DropdownItem[]; +export interface ChoiceInput extends BaseInput { + choices: (() => Promise) | ChoiceItem[]; defaultKey?: string; } @@ -79,7 +79,7 @@ export interface Info { }; } -export type AnyInput = NumberInput | BooleanInput | StringInput | DropdownInput; +export type AnyInput = NumberInput | BooleanInput | StringInput | ChoiceInput; export interface Node { id: string; @@ -214,9 +214,9 @@ export class SmartUiComponent extends React.Component + <> Error: {this.state.errors.get(dataFieldName)} )} - + ); } else if (input.uiType === UiType.Slider) { return ( @@ -406,7 +406,7 @@ export class SmartUiComponent extends React.Component this.onInputChange(input, item.key.toString())} placeholder={placeholder as string} - options={(choices as DropdownItem[]).map(c => ({ + options={(choices as ChoiceItem[]).map(c => ({ key: c.key, text: c.label }))} @@ -449,7 +449,7 @@ export class SmartUiComponent extends React.Component Promise) | string; } -export interface DropdownInputOptions extends InputOptionsBase { - choices: (() => Promise) | DropdownItem[]; +export interface ChoiceInputOptions extends InputOptionsBase { + choices: (() => Promise) | ChoiceItem[]; } -type InputOptions = NumberInputOptions | StringInputOptions | BooleanInputOptions | DropdownInputOptions; +type InputOptions = NumberInputOptions | StringInputOptions | BooleanInputOptions | ChoiceInputOptions; function isNumberInputOptions(inputOptions: InputOptions): inputOptions is NumberInputOptions { return !!(inputOptions as NumberInputOptions).min; @@ -41,8 +41,8 @@ function isBooleanInputOptions(inputOptions: InputOptions): inputOptions is Bool return !!(inputOptions as BooleanInputOptions).trueLabel; } -function isDropdownInputOptions(inputOptions: InputOptions): inputOptions is DropdownInputOptions { - return !!(inputOptions as DropdownInputOptions).choices; +function isChoiceInputOptions(inputOptions: InputOptions): inputOptions is ChoiceInputOptions { + return !!(inputOptions as ChoiceInputOptions).choices; } const addToMap = (...decorators: Decorator[]): PropertyDecorator => { @@ -92,11 +92,11 @@ export const Values = (inputOptions: InputOptions): PropertyDecorator => { { name: "trueLabel", value: booleanInputOptions.trueLabel }, { name: "falseLabel", value: booleanInputOptions.falseLabel } ); - } else if (isDropdownInputOptions(inputOptions)) { - const dropdownInputOptions = inputOptions as DropdownInputOptions; + } else if (isChoiceInputOptions(inputOptions)) { + const choiceInputOptions = inputOptions as ChoiceInputOptions; return addToMap( - { name: "label", value: dropdownInputOptions.label }, - { name: "choices", value: dropdownInputOptions.choices } + { name: "label", value: choiceInputOptions.label }, + { name: "choices", value: choiceInputOptions.choices } ); } else { const stringInputOptions = inputOptions as StringInputOptions; diff --git a/src/SelfServe/SelfServeUtils.test.tsx b/src/SelfServe/SelfServeUtils.test.tsx index dee67df87..685374cf8 100644 --- a/src/SelfServe/SelfServeUtils.test.tsx +++ b/src/SelfServe/SelfServeUtils.test.tsx @@ -252,7 +252,7 @@ describe("SelfServeUtils", () => { type: "object", label: "Invalid Regions", placeholder: "placeholder text", - errorMessage: "label and choices are required for Dropdown input 'invalidRegions'." + errorMessage: "label and choices are required for Choice input 'invalidRegions'." }, children: [] as Node[] } diff --git a/src/SelfServe/SelfServeUtils.tsx b/src/SelfServe/SelfServeUtils.tsx index 246d6e3c7..6dcb5ded6 100644 --- a/src/SelfServe/SelfServeUtils.tsx +++ b/src/SelfServe/SelfServeUtils.tsx @@ -1,6 +1,6 @@ import "reflect-metadata"; import { - DropdownItem, + ChoiceItem, Node, Info, InputTypeValue, @@ -9,7 +9,7 @@ import { NumberInput, StringInput, BooleanInput, - DropdownInput, + ChoiceInput, InputType } from "../Explorer/Controls/SmartUi/SmartUiComponent"; @@ -58,7 +58,7 @@ export interface CommonInputTypes { step?: (() => Promise) | number; trueLabel?: (() => Promise) | string; falseLabel?: (() => Promise) | string; - choices?: (() => Promise) | DropdownItem[]; + choices?: (() => Promise) | ChoiceItem[]; uiType?: string; errorMessage?: string; onChange?: (currentState: Map, newValue: InputType) => Map; @@ -187,8 +187,8 @@ const getInput = (value: CommonInputTypes): AnyInput => { return value as BooleanInput; default: if (!value.label || !value.choices) { - value.errorMessage = `label and choices are required for Dropdown input '${value.id}'.`; + value.errorMessage = `label and choices are required for Choice input '${value.id}'.`; } - return value as DropdownInput; + return value as ChoiceInput; } };