Skip to content

Commit

Permalink
Merge branch 'refs/heads/release/1.18' into fix-errors-related-to-nk-…
Browse files Browse the repository at this point in the history
…windows
  • Loading branch information
Dzuming committed Dec 5, 2024
2 parents 8855596 + b580599 commit 9dcac35
Show file tree
Hide file tree
Showing 18 changed files with 159 additions and 101 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,19 @@ export default forwardRef(function AceWithSettings(
const editor = editorRef.current?.editor;
const selection = editor?.session.selection;

// before setting cursor position ensure all position calculations are actual
const prepare = () => editor?.renderer.updateFull(true);

const scrollToView = throttle(
() => {
document.activeElement.scrollIntoView({ block: "nearest", inline: "nearest" });
// before setting cursor position ensure all position calculations are actual
editor?.renderer.updateFull(true);
const activeElement = editor.container.querySelector(".ace_cursor") || document.activeElement;
activeElement.scrollIntoView({ block: "nearest", inline: "nearest" });
},
150,
{ leading: false },
);

editor?.addEventListener("mousedown", prepare);
editor?.addEventListener("mouseup", scrollToView);
selection?.on("changeCursor", scrollToView);
return () => {
editor?.removeEventListener("mousedown", prepare);
editor?.removeEventListener("mouseup", scrollToView);
selection?.off("changeCursor", scrollToView);
};
}, []);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ export const ActivitiesPanelRow = memo(({ index, style, setRowHeight, handleShow
() => activities.findIndex((activeItem) => activeItem.uiType === "item" && activeItem.type === "SCENARIO_DEPLOYED"),
[activities],
);
const isRunning = firstDeployedIndex === index && scenarioState.status.name === "RUNNING";
const scenarioStatusesToActiveDeploy = ["RUNNING", "SCHEDULED"];
const isDeploymentActive = firstDeployedIndex === index && scenarioStatusesToActiveDeploy.includes(scenarioState.status.name);
const isFirstDateItem = activities.findIndex((activeItem) => activeItem.uiType === "date") === index;

useEffect(() => {
Expand All @@ -41,7 +42,7 @@ export const ActivitiesPanelRow = memo(({ index, style, setRowHeight, handleShow
case "item": {
return (
<ActivityItemProvider>
<ActivityItem activity={activity} ref={rowRef} isRunning={isRunning} searchQuery={searchQuery} />
<ActivityItem activity={activity} ref={rowRef} isDeploymentActive={isDeploymentActive} searchQuery={searchQuery} />
</ActivityItemProvider>
);
}
Expand Down Expand Up @@ -69,7 +70,7 @@ export const ActivitiesPanelRow = memo(({ index, style, setRowHeight, handleShow
return null;
}
}
}, [activity, handleHideRows, handleShowRows, isRunning, isFirstDateItem, searchQuery, t]);
}, [activity, handleHideRows, handleShowRows, isDeploymentActive, isFirstDateItem, searchQuery, t]);

return (
<div style={style} data-testid={`activity-row-${index}`}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const StyledActivityBody = styled("div")(({ theme }) => ({

export const ActivityItem = forwardRef(
(
{ activity, isRunning, searchQuery }: { activity: ItemActivity; isRunning: boolean; searchQuery: string },
{ activity, isDeploymentActive, searchQuery }: { activity: ItemActivity; isDeploymentActive: boolean; searchQuery: string },
ref: ForwardedRef<HTMLDivElement>,
) => {
const { t } = useTranslation();
Expand All @@ -55,7 +55,7 @@ export const ActivityItem = forwardRef(
>
<StyledActivityContent isActiveFound={activity.isActiveFound} isFound={activity.isFound}>
<ActivityItemHeader
isRunning={isRunning}
isDeploymentActive={isDeploymentActive}
searchQuery={searchQuery}
activity={activity}
isActiveFound={activity.isActiveFound}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ const StyledHeaderActionRoot = styled("div")(({ theme }) => ({
gap: theme.spacing(0.5),
}));

const StyledActivityItemHeader = styled("div")<{ isHighlighted: boolean; isRunning: boolean; isActiveFound: boolean }>(
({ theme, isHighlighted, isRunning, isActiveFound }) => ({
const StyledActivityItemHeader = styled("div")<{ isHighlighted: boolean; isDeploymentActive: boolean; isActiveFound: boolean }>(
({ theme, isHighlighted, isDeploymentActive, isActiveFound }) => ({
display: "flex",
alignItems: "center",
padding: theme.spacing(0.5, 0.5, 0.5, 0.75),
borderRadius: theme.spacing(0.5),
...getHeaderColors(theme, isHighlighted, isRunning, isActiveFound),
...getHeaderColors(theme, isHighlighted, isDeploymentActive, isActiveFound),
}),
);

Expand Down Expand Up @@ -167,7 +167,7 @@ const HeaderActivity = ({

interface Props {
activity: ItemActivity;
isRunning: boolean;
isDeploymentActive: boolean;
isActiveFound: boolean;
isFound: boolean;
searchQuery: string;
Expand Down Expand Up @@ -230,7 +230,7 @@ const WithOpenVersion = ({
);
};

const ActivityItemHeader = ({ activity, isRunning, isFound, isActiveFound, searchQuery }: Props) => {
const ActivityItemHeader = ({ activity, isDeploymentActive, isFound, isActiveFound, searchQuery }: Props) => {
const scenario = useSelector(getScenario);
const { processVersionId } = scenario || {};

Expand Down Expand Up @@ -279,7 +279,7 @@ const ActivityItemHeader = ({ activity, isRunning, isFound, isActiveFound, searc
]);

return (
<StyledActivityItemHeader isHighlighted={isHighlighted} isRunning={isRunning} isActiveFound={isActiveFound}>
<StyledActivityItemHeader isHighlighted={isHighlighted} isDeploymentActive={isDeploymentActive} isActiveFound={isActiveFound}>
<StyledHeaderIcon src={activity.activities.icon} id={activity.uiGeneratedId} />
{getHeaderTitle}
<StyledHeaderActionRoot>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ const runningHeaderBackground = (theme: Theme) => blend(theme.palette.background
const activeFoundItemBackground = (theme: Theme) => blend(theme.palette.background.paper, theme.palette.primary.main, 0.2);
const foundItemBackground = (theme: Theme) => blend(theme.palette.background.paper, theme.palette.primary.main, 0.08);

export const getHeaderColors = (theme: Theme, isHighlighted: boolean, isRunning: boolean, isActiveFound: boolean) => {
if (isRunning && isActiveFound) {
export const getHeaderColors = (theme: Theme, isHighlighted: boolean, isDeploymentActive: boolean, isActiveFound: boolean) => {
if (isDeploymentActive && isActiveFound) {
return {
backgroundColor: runningActiveFoundHeaderBackground(theme),
border: activeBorder(theme),
Expand All @@ -27,7 +27,7 @@ export const getHeaderColors = (theme: Theme, isHighlighted: boolean, isRunning:
};
}

if (isRunning) {
if (isDeploymentActive) {
return {
backgroundColor: runningHeaderBackground(theme),
border: defaultBorder(theme),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ package object definition {
branchParam: Boolean,
hintText: Option[String],
label: String,
// This attribute is used only by external project
requiredParam: Boolean,
// This attribute is in use only by the external project and was introduced in the 1.18 version
// The option is for decoder backward compatibility to decode responses from older versions
// The option can be removed in future releases
requiredParam: Option[Boolean],
)

@JsonCodec(encodeOnly = true) final case class UIComponentDefinition(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ object DefinitionsService {
branchParam = parameter.branchParam,
hintText = parameter.hintText,
label = parameter.label,
requiredParam = !parameter.isOptional,
requiredParam = Some(!parameter.isOptional),
)
}

Expand Down
5 changes: 3 additions & 2 deletions docs-internal/api/nu-designer-openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7002,7 +7002,6 @@ components:
- additionalVariables
- branchParam
- label
- requiredParam
properties:
name:
type: string
Expand Down Expand Up @@ -7036,7 +7035,9 @@ components:
label:
type: string
requiredParam:
type: boolean
type:
- boolean
- 'null'
UIValueParameterDto:
title: UIValueParameterDto
type: object
Expand Down
5 changes: 5 additions & 0 deletions docs/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@

* [#7207](https://github.com/TouK/nussknacker/pull/7207) Fixed minor clipboard, keyboard and focus related bugs
* [#7237](https://github.com/TouK/nussknacker/pull/7237) Fix: ToJsonEncoder keeps order fields during encoding map
* [#7240](https://github.com/TouK/nussknacker/pull/7240) Fixed race condition problem during SpEL expression evaluation
* [#7269](https://github.com/TouK/nussknacker/pull/7269) Fixed focus scrolling in expression editor
* [#7270](https://github.com/TouK/nussknacker/pull/7270) Savepoint deserialization fixup - some taken savepoints (e.g. for scenarios with async enrichers) were not deserializable which led to errors during redeployments on Flink
* [#7279](https://github.com/TouK/nussknacker/pull/7279) Fixed Flink TaskManager and Designer containers restarts in installation example
* [#7283](https://github.com/TouK/nussknacker/pull/7283) fix deployment status indicator for periodic scenarios type

### 1.18.0 (22 November 2024)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package pl.touk.nussknacker.engine.process.typeinformation

import org.apache.flink.api.common.typeinfo.{TypeInformation, Types}
import org.apache.flink.api.common.typeutils.{CompositeTypeSerializerUtil, TypeSerializer, TypeSerializerSnapshot}
import org.apache.flink.api.java.typeutils.{ListTypeInfo, MapTypeInfo, MultisetTypeInfo, RowTypeInfo}
import org.apache.flink.types.Row
import pl.touk.nussknacker.engine.api.context.ValidationContext
Expand Down Expand Up @@ -99,20 +98,10 @@ class TypingResultAwareTypeInformationDetection extends TypeInformationDetection
}

private def createScalaMapTypeInformation(typingResult: TypedObjectTypingResult) =
TypedScalaMapTypeInformation(typingResult.fields.mapValuesNow(forType), constructIntermediateCompatibilityResult)
TypedScalaMapTypeInformation(typingResult.fields.mapValuesNow(forType))

private def createJavaMapTypeInformation(typingResult: TypedObjectTypingResult) =
TypedJavaMapTypeInformation(typingResult.fields.mapValuesNow(forType), constructIntermediateCompatibilityResult)

protected def constructIntermediateCompatibilityResult(
newNestedSerializers: Array[TypeSerializer[_]],
oldNestedSerializerSnapshots: Array[TypeSerializerSnapshot[_]]
): CompositeTypeSerializerUtil.IntermediateCompatibilityResult[Nothing] = {
CompositeTypeSerializerUtil.constructIntermediateCompatibilityResult(
newNestedSerializers.map(_.snapshotConfiguration()),
oldNestedSerializerSnapshots
)
}
TypedJavaMapTypeInformation(typingResult.fields.mapValuesNow(forType))

def forValueWithContext[T](
validationContext: ValidationContext,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,36 @@ package pl.touk.nussknacker.engine.process.typeinformation.internal.typedobject
import java.{util => jutil}
import org.apache.flink.api.common.typeinfo.TypeInformation
import org.apache.flink.api.common.typeutils.{TypeSerializer, TypeSerializerSnapshot}
import pl.touk.nussknacker.engine.process.typeinformation.internal.typedobject.TypedObjectBasedTypeInformation.BuildIntermediateSchemaCompatibilityResult

case class TypedJavaMapTypeInformation(
informations: Map[String, TypeInformation[_]],
buildIntermediateSchemaCompatibilityResultFunction: BuildIntermediateSchemaCompatibilityResult
informations: Map[String, TypeInformation[_]]
) extends TypedObjectBasedTypeInformation[jutil.Map[String, AnyRef]](informations) {

override def createSerializer(
serializers: Array[(String, TypeSerializer[_])]
): TypeSerializer[jutil.Map[String, AnyRef]] =
TypedJavaMapSerializer(serializers, buildIntermediateSchemaCompatibilityResultFunction)
TypedJavaMapSerializer(serializers)

}

@SerialVersionUID(1L)
case class TypedJavaMapSerializer(
override val serializers: Array[(String, TypeSerializer[_])],
override val buildIntermediateSchemaCompatibilityResultFunction: BuildIntermediateSchemaCompatibilityResult
override val serializers: Array[(String, TypeSerializer[_])]
) extends TypedObjectBasedTypeSerializer[jutil.Map[String, AnyRef]](serializers)
with BaseJavaMapBasedSerializer[AnyRef, jutil.Map[String, AnyRef]] {

override def duplicate(serializers: Array[(String, TypeSerializer[_])]): TypeSerializer[jutil.Map[String, AnyRef]] =
TypedJavaMapSerializer(serializers, buildIntermediateSchemaCompatibilityResultFunction)
TypedJavaMapSerializer(serializers)

override def createInstance(): jutil.Map[String, AnyRef] = new jutil.HashMap()

override def snapshotConfiguration(
snapshots: Array[(String, TypeSerializerSnapshot[_])]
): TypeSerializerSnapshot[jutil.Map[String, AnyRef]] = new TypedJavaMapSerializerSnapshot(snapshots) {
override val buildIntermediateSchemaCompatibilityResult: BuildIntermediateSchemaCompatibilityResult =
buildIntermediateSchemaCompatibilityResultFunction
}
): TypeSerializerSnapshot[jutil.Map[String, AnyRef]] = new TypedJavaMapSerializerSnapshot(snapshots)

}

abstract class TypedJavaMapSerializerSnapshot extends TypedObjectBasedSerializerSnapshot[jutil.Map[String, AnyRef]] {
final class TypedJavaMapSerializerSnapshot extends TypedObjectBasedSerializerSnapshot[jutil.Map[String, AnyRef]] {

def this(serializers: Array[(String, TypeSerializerSnapshot[_])]) = {
this()
Expand All @@ -48,6 +42,6 @@ abstract class TypedJavaMapSerializerSnapshot extends TypedObjectBasedSerializer
override protected def restoreSerializer(
restored: Array[(String, TypeSerializer[_])]
): TypeSerializer[jutil.Map[String, AnyRef]] =
TypedJavaMapSerializer(restored, buildIntermediateSchemaCompatibilityResult)
TypedJavaMapSerializer(restored)

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import com.github.ghik.silencer.silent
import com.typesafe.scalalogging.LazyLogging
import org.apache.flink.api.common.ExecutionConfig
import org.apache.flink.api.common.typeinfo.TypeInformation
import org.apache.flink.api.common.typeutils.CompositeTypeSerializerUtil.IntermediateCompatibilityResult
import org.apache.flink.api.common.typeutils.{
CompositeTypeSerializerUtil,
TypeSerializer,
TypeSerializerSchemaCompatibility,
TypeSerializerSnapshot
}
import org.apache.flink.core.memory.{DataInputView, DataOutputView}
import pl.touk.nussknacker.engine.process.typeinformation.internal.typedobject.TypedObjectBasedTypeInformation.BuildIntermediateSchemaCompatibilityResult

import scala.reflect.ClassTag

Expand Down Expand Up @@ -57,15 +57,6 @@ abstract class TypedObjectBasedTypeInformation[T: ClassTag](informations: Array[
def createSerializer(serializers: Array[(String, TypeSerializer[_])]): TypeSerializer[T]
}

object TypedObjectBasedTypeInformation {

type BuildIntermediateSchemaCompatibilityResult = (
Array[TypeSerializer[_]],
Array[TypeSerializerSnapshot[_]]
) => CompositeTypeSerializerUtil.IntermediateCompatibilityResult[Nothing]

}

//We use Array instead of List here, as we need access by index, which is faster for array
abstract class TypedObjectBasedTypeSerializer[T](val serializers: Array[(String, TypeSerializer[_])])
extends TypeSerializer[T]
Expand Down Expand Up @@ -132,17 +123,13 @@ abstract class TypedObjectBasedTypeSerializer[T](val serializers: Array[(String,

def duplicate(serializers: Array[(String, TypeSerializer[_])]): TypeSerializer[T]

def buildIntermediateSchemaCompatibilityResultFunction: BuildIntermediateSchemaCompatibilityResult
}

abstract class TypedObjectBasedSerializerSnapshot[T] extends TypeSerializerSnapshot[T] with LazyLogging {

protected var serializersSnapshots: Array[(String, TypeSerializerSnapshot[_])] = _
private val constructIntermediateCompatibilityResultMethodName = "constructIntermediateCompatibilityResult"

def this(serializers: Array[(String, TypeSerializerSnapshot[_])]) = {
this()
this.serializersSnapshots = serializers
}
protected var serializersSnapshots: Array[(String, TypeSerializerSnapshot[_])] = _

override def getCurrentVersion: Int = 1

Expand Down Expand Up @@ -182,10 +169,10 @@ abstract class TypedObjectBasedSerializerSnapshot[T] extends TypeSerializerSnaps
val newKeys = newSerializers.map(_._1)
val commons = currentKeys.intersect(newKeys)

val newSerializersToUse = newSerializers.filter(k => commons.contains(k._1))
val snapshotsToUse = serializersSnapshots.filter(k => commons.contains(k._1))
val newSerializersToUse: Array[(String, TypeSerializer[_])] = newSerializers.filter(k => commons.contains(k._1))
val snapshotsToUse = serializersSnapshots.filter(k => commons.contains(k._1))

val fieldsCompatibility = buildIntermediateSchemaCompatibilityResult(
val fieldsCompatibility = constructIntermediateCompatibilityResultProxied(
newSerializersToUse.map(_._2),
snapshotsToUse.map(_._2)
)
Expand Down Expand Up @@ -237,7 +224,33 @@ abstract class TypedObjectBasedSerializerSnapshot[T] extends TypeSerializerSnaps
}
}

val buildIntermediateSchemaCompatibilityResult: BuildIntermediateSchemaCompatibilityResult
private def constructIntermediateCompatibilityResultProxied(
newNestedSerializers: Array[TypeSerializer[_]],
nestedSerializerSnapshots: Array[TypeSerializerSnapshot[_]]
): IntermediateCompatibilityResult[_] = {
// signature of CompositeTypeSerializerUtil.constructIntermediateCompatibilityResult has been changed between flink 1.18/1.19
// Because of contract of serialization/deserialization of TypeSerializerSnapshot in can't be easily provided by TypeInformationDetection SPI mechanism
try {
val newMethod = classOf[CompositeTypeSerializerUtil].getMethod(
constructIntermediateCompatibilityResultMethodName,
classOf[Array[TypeSerializerSnapshot[_]]],
classOf[Array[TypeSerializerSnapshot[_]]]
)
newMethod
.invoke(null, newNestedSerializers.map(_.snapshotConfiguration()), nestedSerializerSnapshots)
.asInstanceOf[IntermediateCompatibilityResult[_]]
} catch {
case _: NoSuchMethodException =>
val oldMethod = classOf[CompositeTypeSerializerUtil].getMethod(
constructIntermediateCompatibilityResultMethodName,
classOf[Array[TypeSerializer[_]]],
classOf[Array[TypeSerializerSnapshot[_]]]
)
oldMethod
.invoke(null, newNestedSerializers, nestedSerializerSnapshots)
.asInstanceOf[IntermediateCompatibilityResult[_]]
}
}

override def restoreSerializer(): TypeSerializer[T] = restoreSerializer(serializersSnapshots.map {
case (k, snapshot) => (k, snapshot.restoreSerializer())
Expand Down
Loading

0 comments on commit 9dcac35

Please sign in to comment.