Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gskrobisz committed Dec 20, 2024
1 parent 62b2354 commit 2413cc2
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 68 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { useDispatch, useSelector } from "react-redux";
import { getProcessName, getScenarioGraph } from "../../../reducers/selectors/graph";
import { useEffect } from "react";
import { fetchActivityParameters } from "../../../actions/nk";
export function useActivityCapabilities() {
const dispatch = useDispatch();

const scenarioName = useSelector(getProcessName);
const scenarioGraph = useSelector(getScenarioGraph);

useEffect(() => {
dispatch(fetchActivityParameters(scenarioName, scenarioGraph));
}, [dispatch, scenarioName, scenarioGraph]);
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default function RunOffScheduleButton(props: ToolbarButtonProps) {
const available = !disabled && isPossible && capabilities.deploy;

const { open } = useWindows();
const action = (p, c) => HttpService.runOffSchedule(p, c).finally(() => dispatch(loadProcessState(processName, processVersionId)));
const action = (p, c, d) => HttpService.runOffSchedule(p, c).finally(() => dispatch(loadProcessState(processName, processVersionId)));
const message = t("panels.actions.run-of-out-schedule.dialog", "Perform single execution", { name: processName });

const defaultTooltip = t("panels.actions.run-off-schedule.tooltip", "run now");
Expand All @@ -52,7 +52,7 @@ export default function RunOffScheduleButton(props: ToolbarButtonProps) {
title: message,
kind: WindowKind.deployProcess,
width: ACTION_DIALOG_WIDTH,
meta: { action },
meta: { action, activityName: "RUN_OFF_SCHEDULE" }, // fixme: activityName, do we need this?
})
}
type={type}
Expand Down
2 changes: 1 addition & 1 deletion designer/client/src/http/HttpService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { EventTrackingSelectorType, EventTrackingType } from "../containers/even
import { BackendNotification } from "../containers/Notifications";
import { ProcessCounts } from "../reducers/graph";
import { AuthenticationSettings } from "../reducers/settings";
import { Expression, NodeType, ProcessAdditionalFields, ProcessDefinitionData, ScenarioGraph, VariableTypes } from "../types";
import { Expression, NodeId, NodeType, ProcessAdditionalFields, ProcessDefinitionData, ScenarioGraph, VariableTypes } from "../types";
import { Instant, WithId } from "../types/common";
import { fixAggregateParameters, fixBranchParametersTemplate } from "./parametersUtils";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,12 @@ class DevProcessConfigCreator extends ProcessConfigCreator {
)(TypeInformation.of(classOf[SampleProduct]))
)
),
"kafka-transaction" -> all(SourceFactory.noParamUnboundedStreamFactory[String](new NoEndingSource)),
"boundedSource" -> all(BoundedSource),
"boundedSourceWithOffset" -> all(BoundedSourceWithOffset),
"boundedSourceWithOtherParam" -> all(DummyBoundedSourceToDelete),
"oneSource" -> categories(SourceFactory.noParamUnboundedStreamFactory[String](new OneSource)),
"communicationSource" -> categories(DynamicParametersSource),
"csv-source" -> categories(SourceFactory.noParamUnboundedStreamFactory[CsvRecord](new CsvSource)),
"kafka-transaction" -> all(SourceFactory.noParamUnboundedStreamFactory[String](new NoEndingSource)),
"boundedSource" -> all(BoundedSource),
"boundedSourceWithOffset" -> all(BoundedSourceWithOffset),
"oneSource" -> categories(SourceFactory.noParamUnboundedStreamFactory[String](new OneSource)),
"communicationSource" -> categories(DynamicParametersSource),
"csv-source" -> categories(SourceFactory.noParamUnboundedStreamFactory[CsvRecord](new CsvSource)),
"csv-source-lite" -> categories(SourceFactory.noParamUnboundedStreamFactory[CsvRecord](new LiteCsvSource(_))),
"genericSourceWithCustomVariables" -> categories(GenericSourceWithCustomVariablesSample),
"sql-source" -> categories(SqlSource),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@ package pl.touk.nussknacker.engine.management.sample.source
import org.apache.flink.streaming.api.datastream.DataStreamSource
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment
import pl.touk.nussknacker.engine.api.component.{ParameterConfig, UnboundedStreamComponent}
import pl.touk.nussknacker.engine.api.definition.{
BoolParameterEditor,
FixedExpressionValue,
FixedValuesParameterEditor,
RawParameterEditor
}
import pl.touk.nussknacker.engine.api.definition.{FixedExpressionValue, FixedValuesParameterEditor, RawParameterEditor}
import pl.touk.nussknacker.engine.api.deployment.ScenarioActionName
import pl.touk.nussknacker.engine.api.editor.FixedValuesEditorMode
import pl.touk.nussknacker.engine.api.process.{SourceFactory, WithActivityParameters}
Expand All @@ -18,6 +13,7 @@ import pl.touk.nussknacker.engine.flink.api.process.FlinkCustomNodeContext
import pl.touk.nussknacker.engine.flink.util.source.CollectionSource

import scala.jdk.CollectionConverters._
import scala.util.Try

object BoundedSource extends SourceFactory with UnboundedStreamComponent {

Expand All @@ -29,41 +25,15 @@ object BoundedSource extends SourceFactory with UnboundedStreamComponent {

object BoundedSourceWithOffset extends SourceFactory with UnboundedStreamComponent {

val OFFSET_PARAMETER_NAME = "offset"

@MethodToInvoke
def source(@ParamName("elements") elements: java.util.List[Any]) =
new CollectionSource[Any](elements.asScala.toList, None, Unknown) with WithActivityParameters {

override def activityParametersDefinition: Map[String, Map[String, ParameterConfig]] = {
val fixedValuesEditor = Some(
FixedValuesParameterEditor(
List(
FixedExpressionValue("Continue", "Continue", Some("Resumes reading data where it previously stopped.")),
FixedExpressionValue("Reset", "Reset", Some("Starts reading new events only.")),
FixedExpressionValue("Restart", "Restart", Some("Rewinds reading from the earliest event.")),
),
FixedValuesEditorMode.RADIO
)
)
Map(
ScenarioActionName.Deploy.value -> Map(
"offset" -> ParameterConfig(
defaultValue = None,
editor = Some(RawParameterEditor),
validators = None,
label = Some("Offset"),
hintText = Some(
"Set offset to setup source to emit elements from specified start point in input collection. Empty field resets collection to the beginning."
)
),
// TODO: remove offsetResetStrategy
"offsetResetStrategy" -> ParameterConfig(
defaultValue = Some("Restart"),
editor = fixedValuesEditor,
validators = None,
label = Some("Starting point strategy"),
hintText = Some("Example of parameter with fixed values")
),
)
ScenarioActionName.Deploy.value -> deployActivityParameters
)
}

Expand All @@ -72,37 +42,65 @@ object BoundedSourceWithOffset extends SourceFactory with UnboundedStreamCompone
env: StreamExecutionEnvironment,
flinkNodeContext: FlinkCustomNodeContext
): DataStreamSource[T] = {
val offsetOpt = flinkNodeContext.nodeDeploymentData.flatMap(_.get("offset"))
val offsetOpt =
flinkNodeContext.nodeDeploymentData
.flatMap(_.get(OFFSET_PARAMETER_NAME))
.flatMap(s => Try(s.toInt).toOption)
val elementsWithOffset = offsetOpt match {
case Some(offset) => list.drop(offset.toInt)
case Some(offset) => list.drop(offset)
case _ => list
}
super.createSourceStream(elementsWithOffset, env, flinkNodeContext)
}

}

}

object DummyBoundedSourceToDelete extends SourceFactory with UnboundedStreamComponent {

@MethodToInvoke
def source(@ParamName("elements") elements: java.util.List[Any]) =
new CollectionSource[Any](elements.asScala.toList, None, Unknown) with WithActivityParameters {

override def activityParametersDefinition: Map[String, Map[String, ParameterConfig]] =
Map(
ScenarioActionName.Deploy.value -> Map(
"otherParameter" -> ParameterConfig(
defaultValue = None,
editor = Some(BoolParameterEditor),
validators = None,
label = Some("Other parameter"),
hintText = Some("this is hint")
)
)
private def deployActivityParameters: Map[String, ParameterConfig] = {
Map(
OFFSET_PARAMETER_NAME -> ParameterConfig(
defaultValue = None,
editor = Some(RawParameterEditor),
validators = None,
label = Some("Offset"),
hintText = Some(
"Set offset to setup source to emit elements from specified start point in input collection. Empty field resets collection to the beginning."
)

}
),
"exampleFixedRadio" -> ParameterConfig(
defaultValue = Some("Restart"),
editor = Some(
FixedValuesParameterEditor(
List(
FixedExpressionValue(
"Continue",
"Continue",
Some("Resumes reading data where it previously stopped.")
),
FixedExpressionValue("Reset", "Reset", Some("Starts reading new events only.")),
FixedExpressionValue("Restart", "Restart", Some("Rewinds reading from the earliest event.")),
),
FixedValuesEditorMode.RADIO
)
),
validators = None,
label = Some("Example fixed radio"),
hintText = Some("Hint text for example fixed radio")
),
"exampleFixedList" -> ParameterConfig(
defaultValue = None,
editor = Some(
FixedValuesParameterEditor(
List(
FixedExpressionValue("Item 1", "First item", Some("Hint text for item 1")),
FixedExpressionValue("Item 2", "Second item", Some("Hint text for item 2")),
),
)
),
validators = None,
label = Some("Example fixed list"),
hintText = Some("Hint text for example fixed list")
),
)
}

}

0 comments on commit 2413cc2

Please sign in to comment.