Skip to content

Commit c5afc24

Browse files
mockExpression added variables from context to suggestions
1 parent 7f3796a commit c5afc24

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

designer/client/src/components/graph/node-modal/editors/expression/MockExpressionField.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import { get } from "lodash";
22
import type { ReactNode} from "react";
3+
import { useMemo } from "react";
34
import React, { useCallback, useState } from "react";
45
import { useTranslation } from "react-i18next";
56

7+
import type ProcessUtils from "../../../../../common/ProcessUtils";
68
import type { NodeType, NodeValidationError, UIParameter } from "../../../../../types";
79
import { useDiffMark } from "../../PathsToMark";
810
import { useTestResults } from "../../TestResultsWrapper";
@@ -20,13 +22,14 @@ type Props = {
2022
isEditMode: boolean;
2123
showValidation: boolean;
2224
showSwitch: boolean;
25+
findAvailableVariables: ReturnType<typeof ProcessUtils.findAvailableVariables>;
2326
setNodeDataAt: <T>(propToMutate: string, newValue: T, defaultValue?: T) => void;
2427
renderFieldLabel: (paramName: string) => ReactNode;
2528
errors: NodeValidationError[];
2629
};
2730

2831
function MockExpressionField(props: Props): JSX.Element {
29-
const { editedNode, isEditMode, showValidation, showSwitch, setNodeDataAt, renderFieldLabel, errors } = props;
32+
const { editedNode, isEditMode, showValidation, showSwitch, findAvailableVariables, setNodeDataAt, renderFieldLabel, errors } = props;
3033
const [mockExpression, setMockExpression] = useState(() => {
3134
return get(editedNode, MOCK_EXPRESSION_FIELD_NAME) || { expression: "", language: "spel" };
3235
});
@@ -46,6 +49,8 @@ function MockExpressionField(props: Props): JSX.Element {
4649
[setNodeDataAt],
4750
);
4851

52+
const variableTypes = useMemo(() => findAvailableVariables(editedNode.id), [findAvailableVariables, editedNode.id]);
53+
4954
const { t } = useTranslation();
5055
const testResultsState = useTestResults();
5156

@@ -59,7 +64,7 @@ function MockExpressionField(props: Props): JSX.Element {
5964
const mockExpressionParameter: UIParameter = {
6065
additionalVariables: {},
6166
branchParam: false,
62-
defaultValue: { expression: "", language: undefined },
67+
defaultValue: { expression: "", language: "spel" },
6368
editor: { type: EditorType.SPEL_PARAMETER_EDITOR },
6469
label: "",
6570
name: MOCK_EXPRESSION_FIELD_NAME,
@@ -78,9 +83,9 @@ function MockExpressionField(props: Props): JSX.Element {
7883
showValidation={showValidation}
7984
showSwitch={showSwitch}
8085
readOnly={readOnly}
81-
variableTypes={{}}
86+
variableTypes={variableTypes}
8287
onValueChange={onValueChange}
83-
fieldErrors={getValidationErrorsForField(errors, MOCK_EXPRESSION_FIELD_NAME)} // todo: check if it works
88+
fieldErrors={getValidationErrorsForField(errors, MOCK_EXPRESSION_FIELD_NAME)}
8489
/>
8590
</ExpressionTestResults>
8691
);

designer/client/src/components/graph/node-modal/enricherProcessor.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ export function EnricherProcessor({
9595
editedNode={node}
9696
showValidation={showValidation}
9797
showSwitch={showSwitch}
98+
findAvailableVariables={findAvailableVariables}
9899
setNodeDataAt={setProperty}
99100
renderFieldLabel={renderFieldLabel}
100101
errors={errors}

0 commit comments

Comments
 (0)