From 98b18dbf7cd184dae34cd4c6de501d2283c5a0ec Mon Sep 17 00:00:00 2001 From: Maciej Cichanowicz Date: Fri, 3 Jan 2025 10:12:54 +0100 Subject: [PATCH] Adjust FE --- .../fragment-input-definition/item/types.ts | 3 ++- .../settings/variants/fields/InputModeSelect.tsx | 12 ++++++------ designer/client/src/reducers/scenarioState.ts | 4 +++- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/designer/client/src/components/graph/node-modal/fragment-input-definition/item/types.ts b/designer/client/src/components/graph/node-modal/fragment-input-definition/item/types.ts index 5efda562190..305c8507143 100644 --- a/designer/client/src/components/graph/node-modal/fragment-input-definition/item/types.ts +++ b/designer/client/src/components/graph/node-modal/fragment-input-definition/item/types.ts @@ -1,3 +1,4 @@ +import { isNil } from "lodash"; import { Expression, ReturnedType } from "../../../../../types"; import { resolveRefClazzName } from "./utils"; @@ -78,7 +79,7 @@ export function isAnyValueWithSuggestionsParameter(item: PermittedTypeParameterV } export function isAnyValueParameter(item: PermittedTypeParameterVariant): item is AnyValueParameterVariant { - return item.valueEditor === null; + return isNil(item.valueEditor); } const permittedTypesMapping = { diff --git a/designer/client/src/components/graph/node-modal/fragment-input-definition/settings/variants/fields/InputModeSelect.tsx b/designer/client/src/components/graph/node-modal/fragment-input-definition/settings/variants/fields/InputModeSelect.tsx index e568f6898dc..c5a232b35ae 100644 --- a/designer/client/src/components/graph/node-modal/fragment-input-definition/settings/variants/fields/InputModeSelect.tsx +++ b/designer/client/src/components/graph/node-modal/fragment-input-definition/settings/variants/fields/InputModeSelect.tsx @@ -1,4 +1,5 @@ import React from "react"; +import { isNil } from "lodash"; import { Option } from "../../../FieldsSelect"; import { TypeSelect } from "../../../TypeSelect"; import { useTranslation } from "react-i18next"; @@ -23,12 +24,11 @@ export default function InputModeSelect(props: Props) { const { t } = useTranslation(); const { temporaryUserDefinedList } = useSettings(); - const value = - item.valueEditor === null - ? InputMode.AnyValue - : item.valueEditor.allowOtherValue - ? InputMode.AnyValueWithSuggestions - : InputMode.FixedList; + const value = isNil(item.valueEditor) + ? InputMode.AnyValue + : item.valueEditor.allowOtherValue + ? InputMode.AnyValueWithSuggestions + : InputMode.FixedList; return ( <> diff --git a/designer/client/src/reducers/scenarioState.ts b/designer/client/src/reducers/scenarioState.ts index 7bbbae26dd6..202fafb64f6 100644 --- a/designer/client/src/reducers/scenarioState.ts +++ b/designer/client/src/reducers/scenarioState.ts @@ -4,7 +4,9 @@ import { ProcessStateType } from "../components/Process/types"; export const reducer: Reducer = (state = null, action: Action): ProcessStateType => { switch (action.type) { case "DISPLAY_PROCESS": - return action.scenario.state; + // Since scenario endpoint doesn't return null attributes the state will be undefined for fragments. + // Redux does not allow to return undefined values so in that case we return null explicitly. + return action.scenario.state ?? null; case "PROCESS_STATE_LOADED": return action.processState; default: