Skip to content

Commit 7e9a85f

Browse files
author
Łukasz Bigorajski
committed
FE adjustments
1 parent c0629cc commit 7e9a85f

File tree

12 files changed

+61
-69
lines changed

12 files changed

+61
-69
lines changed

designer/client/src/components/graph/node-modal/editors/expression/Editor.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { BoolEditor } from "./BoolEditor";
22
import { SpelEditor } from "./SpelEditor";
33
import { SqlEditor } from "./SqlEditor";
4-
import { StringEditor } from "./StringEditor";
4+
import { StaticStringEditor } from "./StaticStringEditor";
55
import { FixedValuesEditor } from "./FixedValuesEditor";
66
import { EditorType, ExpressionLang, ExpressionObj } from "./types";
77
import React, { ForwardRefExoticComponent, LegacyRef, ReactNode } from "react";
@@ -62,7 +62,7 @@ export const editors: Record<EditorType, SimpleEditor | ExtendedEditor> = {
6262
[EditorType.JSON_PARAMETER_EDITOR]: JsonEditor,
6363
[EditorType.PERIOD_EDITOR]: PeriodEditor,
6464
[EditorType.SPEL_PARAMETER_EDITOR]: SpelEditor,
65-
[EditorType.STRING_PARAMETER_EDITOR]: StringEditor,
65+
[EditorType.STATIC_STRING_PARAMETER_EDITOR]: StaticStringEditor,
6666
[EditorType.TEXTAREA_PARAMETER_EDITOR]: TextareaEditor,
6767
[EditorType.TIME]: TimeEditor,
6868
[EditorType.SQL_PARAMETER_EDITOR]: SqlEditor,

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

+10-2
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ import ReactAce from "react-ace/lib/ace";
66
import { ExtendedEditor } from "./Editor";
77
import { Formatter } from "./Formatter";
88
import { SpelEditor, SpelEditorProps } from "./SpelEditor";
9-
import { isSwitchableTo } from "./StringEditor";
10-
import { EditorMode } from "./types";
9+
import { EditorMode, ExpressionLang, ExpressionObj } from "./types";
1110
import { Ace } from "ace-builds";
1211
import { editorsParameters } from "./editorsParameters";
12+
import { isQuoted } from "./SpelQuotesUtils";
1313

1414
interface SyntaxMode extends Ace.SyntaxMode {
1515
$highlightRules: {
@@ -114,6 +114,14 @@ export const SqlEditor: ExtendedEditor<Props> = (props: Props) => {
114114
);
115115
};
116116

117+
const splitConcats = (value: string) => {
118+
return value.split(/\s*\+\s*/gm);
119+
};
120+
121+
export const isSwitchableTo = ({ expression, language }: ExpressionObj): boolean => {
122+
return language === ExpressionLang.SpEL && splitConcats(expression.trim()).some(isQuoted);
123+
};
124+
117125
SqlEditor.isSwitchableTo = isSwitchableTo;
118126
SqlEditor.notSwitchableToHint = () =>
119127
i18next.t(
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import React from "react";
2+
import Input from "../field/Input";
3+
import { OnValueChange, SimpleEditor } from "./Editor";
4+
import { Formatter, FormatterType, typeFormatters } from "./Formatter";
5+
import { ExpressionObj } from "./types";
6+
import { FieldError } from "../Validators";
7+
import { editorsParameters } from "./editorsParameters";
8+
9+
type Props = {
10+
expressionObj: ExpressionObj;
11+
onValueChange: OnValueChange;
12+
className: string;
13+
formatter: Formatter;
14+
fieldErrors: FieldError[];
15+
showValidation: boolean;
16+
};
17+
18+
export const StaticStringEditor: SimpleEditor<Props> = (props: Props) => {
19+
const { expressionObj, onValueChange, formatter, ...passProps } = props;
20+
const stringFormatter = formatter == null ? typeFormatters[FormatterType.String] : formatter;
21+
22+
return (
23+
<Input
24+
{...passProps}
25+
onChange={(event) =>
26+
onValueChange({
27+
expression: stringFormatter.encode(event.target.value),
28+
language: editorsParameters.StaticStringParameterEditor.language,
29+
})
30+
}
31+
value={stringFormatter.decode(expressionObj.expression) as string}
32+
/>
33+
);
34+
};

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

-50
This file was deleted.

designer/client/src/components/graph/node-modal/editors/expression/editorsParameters.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export const editorsParameters: Record<EditorType, { displayName: string; langua
2121
[EditorType.JSON_PARAMETER_EDITOR]: { displayName: "Json", language: ExpressionLang.JSON },
2222
[EditorType.PERIOD_EDITOR]: { displayName: "Period", language: ExpressionLang.SpEL },
2323
[EditorType.SPEL_PARAMETER_EDITOR]: { displayName: "Expression", language: ExpressionLang.SpEL },
24-
[EditorType.STRING_PARAMETER_EDITOR]: { displayName: "Text", language: ExpressionLang.String },
24+
[EditorType.STATIC_STRING_PARAMETER_EDITOR]: { displayName: "Text", language: ExpressionLang.String },
2525
[EditorType.TEXTAREA_PARAMETER_EDITOR]: { displayName: "Text", language: ExpressionLang.SpEL },
2626
[EditorType.TIME]: { displayName: "Time", language: ExpressionLang.SpEL },
2727
[EditorType.SQL_PARAMETER_EDITOR]: { displayName: "SQL", language: ExpressionLang.SQL },

designer/client/src/components/graph/node-modal/editors/expression/types.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export enum EditorMode {
2323
export enum EditorType {
2424
SPEL_PARAMETER_EDITOR = "SpelParameterEditor",
2525
BOOL_PARAMETER_EDITOR = "BoolParameterEditor",
26-
STRING_PARAMETER_EDITOR = "StringParameterEditor",
26+
STATIC_STRING_PARAMETER_EDITOR = "StaticStringParameterEditor",
2727
FIXED_VALUES_PARAMETER_EDITOR = "FixedValuesParameterEditor",
2828
FIXED_VALUES_WITH_ICON_PARAMETER_EDITOR = "FixedValuesWithIconParameterEditor",
2929
FIXED_VALUES_WITH_RADIO_PARAMETER_EDITOR = "FixedValuesWithRadioParameterEditor",

designer/client/test/Editors/StringEditor-test.tsx renamed to designer/client/test/Editors/StaticStringEditor-test.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import * as React from "react";
22

33
import { render, screen } from "@testing-library/react";
4-
import { StringEditor } from "../../src/components/graph/node-modal/editors/expression/StringEditor";
4+
import { StaticStringEditor } from "../../src/components/graph/node-modal/editors/expression/StaticStringEditor";
55
import { mockFieldErrors, mockFormatter, mockValueChange } from "./helpers";
66
import { NuThemeProvider } from "../../src/containers/theme/nuThemeProvider";
77
import { nodeInputWithError } from "../../src/components/graph/node-modal/NodeDetailsContent/NodeTableStyled";
88

9-
describe(StringEditor.name, () => {
9+
describe(StaticStringEditor.name, () => {
1010
it("should display validation error when the field is required", () => {
1111
render(
1212
<NuThemeProvider>
13-
<StringEditor
13+
<StaticStringEditor
1414
className={""}
1515
onValueChange={mockValueChange}
1616
expressionObj={{ language: "spel", expression: "" }}

docs-internal/api/nu-designer-openapi.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -5682,9 +5682,6 @@ components:
56825682
format: date-time
56835683
createdBy:
56845684
type: string
5685-
StaticStringParameterEditor:
5686-
title: StaticStringParameterEditor
5687-
type: object
56885685
CronParameterEditor:
56895686
title: CronParameterEditor
56905687
type: object
@@ -7281,7 +7278,6 @@ components:
72817278
title: StaticParameterEditor
72827279
oneOf:
72837280
- $ref: '#/components/schemas/BoolParameterEditor'
7284-
- $ref: '#/components/schemas/StaticStringParameterEditor'
72857281
- $ref: '#/components/schemas/CronParameterEditor'
72867282
- $ref: '#/components/schemas/DateParameterEditor'
72877283
- $ref: '#/components/schemas/DateTimeParameterEditor'
@@ -7292,8 +7288,12 @@ components:
72927288
- $ref: '#/components/schemas/FixedValuesWithRadioParameterEditor'
72937289
- $ref: '#/components/schemas/JsonParameterEditor'
72947290
- $ref: '#/components/schemas/PeriodParameterEditor'
7291+
- $ref: '#/components/schemas/StaticStringParameterEditor'
72957292
- $ref: '#/components/schemas/TextareaParameterEditor'
72967293
- $ref: '#/components/schemas/TimeParameterEditor'
7294+
StaticStringParameterEditor:
7295+
title: StaticStringParameterEditor
7296+
type: object
72977297
StatisticDto:
72987298
title: StatisticDto
72997299
type: object

engine/flink/management/dev-model/src/main/scala/pl/touk/nussknacker/engine/management/sample/DevProcessConfigCreator.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ class DevProcessConfigCreator extends ProcessConfigCreator {
147147
ComponentConfig.zero.copy(
148148
params = Some(
149149
Map(
150-
ParameterName("bar") -> ParameterConfig(Some("'barValueFromProviderCode'"), None, None, None, None)
150+
ParameterName("bar") -> ParameterConfig(Some("barValueFromProviderCode"), None, None, None, None)
151151
)
152152
)
153153
)

engine/flink/management/dev-model/src/main/scala/pl/touk/nussknacker/engine/management/sample/LoggingService.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import cats.implicits.catsSyntaxOptionId
44
import org.slf4j.LoggerFactory
55
import org.slf4j.event.Level
66
import pl.touk.nussknacker.engine.api._
7-
import pl.touk.nussknacker.engine.api.component.{ParameterConfig, StaticParameterConfig}
7+
import pl.touk.nussknacker.engine.api.component.StaticParameterConfig
88
import pl.touk.nussknacker.engine.api.definition.BoolParameterEditor
99
import pl.touk.nussknacker.engine.api.deployment.{ScenarioActionName, WithActionParametersSupport}
1010
import pl.touk.nussknacker.engine.api.editor.{Editor, EditorType}

engine/flink/management/dev-model/src/main/scala/pl/touk/nussknacker/engine/management/sample/service/DynamicMultipleParamsService.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ object DynamicMultipleParamsService extends EagerService with SingleInputDynamic
5454
NextParameters(
5555
List(
5656
Parameter(ParameterName("baz"), Typed[String])
57-
.copy(defaultValue = Some(Expression.spel(s"'$fooValue' + '-' + ${barValue.renderedTemplate}")))
57+
.copy(defaultValue = Some(Expression.spel(s"'$fooValue' + '-' + '${barValue.renderedTemplate}''")))
5858
)
5959
)
6060
case TransformationStep(

utils/schemed-kafka-components-utils/src/test/scala/pl/touk/nussknacker/engine/schemedkafka/sink/flink/AvroSinkValueParameterTest.scala

+3-3
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,15 @@ class AvroSchemaBasedParameterTest extends AnyFunSuite with Matchers {
6464
) shouldBe List(
6565
Parameter(name = ParameterName("a"), typ = typing.Typed[String]).copy(
6666
isLazyParameter = true,
67-
editors = List(SpelParameterEditor, SpelTemplateParameterEditor),
68-
defaultValue = Some(Expression.spel("''"))
67+
editors = List(SpelTemplateParameterEditor, SpelParameterEditor),
68+
defaultValue = Some(Expression.spelTemplate(""))
6969
),
7070
Parameter(name = ParameterName("b.c"), typ = typing.Typed[Long])
7171
.copy(isLazyParameter = true, defaultValue = Some(Expression.spel("0"))),
7272
Parameter(name = ParameterName("c"), typ = typing.Typed[String]).copy(
7373
isLazyParameter = true,
7474
defaultValue = Some(Expression.spel("'c-field-default'")),
75-
editors = List(SpelParameterEditor, SpelTemplateParameterEditor),
75+
editors = List(SpelTemplateParameterEditor, SpelParameterEditor),
7676
),
7777
Parameter(name = ParameterName("d"), typ = typing.Typed[Long])
7878
.copy(isLazyParameter = true, defaultValue = Some(Expression.spel("42L"))),

0 commit comments

Comments
 (0)