Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NU-1940] Add seconds to sample generator period editor and remove white arrows #7373

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,14 @@ export default function TimeRangeComponent(props: Props) {
<input
readOnly={readOnly}
value={value[component.fieldName] || ""}
onChange={(event) => onChange(component.fieldName, parseInt(event.target.value))}
onChange={(event) => onChange(component.fieldName, event.target.value)}
className={cx([
nodeInput,
"time-range-input",
showValidation && !isValid && nodeInputWithError,
isMarked && "marked",
readOnly && "read-only",
])}
type={"number"}
/>
<span className={"time-range-component-label"}>{component.label}</span>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,15 @@ export default function TimeRangeEditor(props: Props): JSX.Element {
const [value, setValue] = useState(() => decode(expression));

const onComponentChange = useCallback(
(fieldName: string, fieldValue: number) => {
setValue({
...value,
[fieldName]: isNaN(fieldValue) ? null : fieldValue,
});
(fieldName: string, fieldValue: string) => {
// treating empty string as null to allow deleting single digit
const parsedValue = fieldValue === "" ? null : parseInt(fieldValue);
if (parsedValue === null || !isNaN(parsedValue)) {
setValue({
...value,
[fieldName]: parsedValue,
});
}
},
[value],
);
Expand Down
1 change: 0 additions & 1 deletion designer/client/test/Editors/DurationEditor-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ describe(DurationEditor.name, () => {
</NuThemeProvider>,
);

expect(screen.getByRole("spinbutton")).toHaveClass(nodeInputWithError);
expect(screen.getByText("validation error")).toBeInTheDocument();
});
});
1 change: 0 additions & 1 deletion designer/client/test/Editors/PeriodEditor-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ describe(PeriodEditor.name, () => {
</NuThemeProvider>,
);

expect(screen.getByRole("spinbutton")).toHaveClass(nodeInputWithError);
expect(screen.getByText("validation error")).toBeInTheDocument();
});
});
4 changes: 3 additions & 1 deletion docs/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@
* [#7341](https://github.com/TouK/nussknacker/pull/7341) Added possibility to choose presets and define lists for Integer typed parameter inputs in fragments.
* [#7356](https://github.com/TouK/nussknacker/pull/7356) Integers converted to BigDecimals have scale 18,
this fixes issue with unexpected low scale when performing division on BigDecimals which were created in such conversion.
* [#7368](https://github.com/TouK/nussknacker/pull/7368) Component rename: `periodic` to `sample-generator`
* [#7379](https://github.com/TouK/nussknacker/pull/7379) Removed CustomAction mechanism.
* Changes to `periodic` component (renamed to `sample-generator`):
* [#7368](https://github.com/TouK/nussknacker/pull/7368) Component rename: `periodic` to `sample-generator`
* [#7373](https://github.com/TouK/nussknacker/pull/7373) Improvements to `period` editor

## 1.18

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import org.apache.flink.streaming.api.functions.source.SourceFunction
import org.apache.flink.util.Collector
import pl.touk.nussknacker.engine.api._
import pl.touk.nussknacker.engine.api.component.UnboundedStreamComponent
import pl.touk.nussknacker.engine.api.editor.{DualEditor, DualEditorMode, SimpleEditor, SimpleEditorType}
import pl.touk.nussknacker.engine.api.process.{BasicContextInitializer, Source, SourceFactory}
import pl.touk.nussknacker.engine.api.typed.typing.Unknown
import pl.touk.nussknacker.engine.api.typed.{ReturningType, typing}
Expand All @@ -24,6 +25,7 @@ import pl.touk.nussknacker.engine.flink.api.typeinformation.TypeInformationDetec
import pl.touk.nussknacker.engine.util.TimestampUtils.supportedTypeToMillis

import java.time.Duration
import java.time.temporal.ChronoUnit
import java.{util => jul}
import javax.annotation.Nullable
import javax.validation.constraints.Min
Expand All @@ -50,7 +52,15 @@ class SampleGeneratorSourceFactory(timestampAssigner: TimestampWatermarkHandler[
@silent("deprecated")
@MethodToInvoke
def create(
@ParamName("period") period: Duration,
@ParamName("period")
@DualEditor(
simpleEditor = new SimpleEditor(
`type` = SimpleEditorType.DURATION_EDITOR,
timeRangeComponents = Array(ChronoUnit.DAYS, ChronoUnit.HOURS, ChronoUnit.MINUTES, ChronoUnit.SECONDS)
),
defaultMode = DualEditorMode.SIMPLE
)
period: Duration,
// TODO: @DefaultValue(1) instead of nullable
@ParamName("count") @Nullable @Min(1) nullableCount: Integer,
@ParamName("value") value: LazyParameter[AnyRef]
Expand Down
Loading