Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/staging' into fix-s…
Browse files Browse the repository at this point in the history
…cala-map-in-spel-validator
  • Loading branch information
wrzontek committed Jul 9, 2024
2 parents decb483 + cb05157 commit c2daaa3
Show file tree
Hide file tree
Showing 60 changed files with 984 additions and 595 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ package pl.touk.nussknacker.engine.benchmarks.suggester
import pl.touk.nussknacker.engine.api.dict.embedded.EmbeddedDictDefinition
import pl.touk.nussknacker.engine.api.process.ClassExtractionSettings
import pl.touk.nussknacker.engine.dict.{SimpleDictQueryService, SimpleDictRegistry}
import pl.touk.nussknacker.ui.suggester.{CaretPosition2d, ExpressionSuggester}
import pl.touk.nussknacker.ui.suggester.ExpressionSuggester
import pl.touk.nussknacker.engine.testing.ModelDefinitionBuilder
import pl.touk.nussknacker.engine.api.dict.UiDictServices
import pl.touk.nussknacker.engine.api.typed.typing.{Typed, TypingResult}
import pl.touk.nussknacker.engine.definition.clazz.{ClassDefinitionExtractor, ClassDefinitionSet}
import pl.touk.nussknacker.engine.graph.expression.Expression
import pl.touk.nussknacker.engine.graph.expression.Expression.Language
import pl.touk.nussknacker.engine.util.CaretPosition2d

import java.time.{Duration, LocalDateTime}
import scala.concurrent.duration.{Duration => ScalaDuration}
Expand Down
12 changes: 5 additions & 7 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -733,9 +733,11 @@ lazy val flinkTests = (project in flink("tests"))
name := "nussknacker-flink-tests",
libraryDependencies ++= {
Seq(
"org.apache.flink" % "flink-connector-base" % flinkV % Provided,
"org.apache.flink" % "flink-streaming-java" % flinkV % Provided,
"org.apache.flink" % "flink-statebackend-rocksdb" % flinkV % Provided
"org.apache.flink" % "flink-connector-base" % flinkV % Test,
"org.apache.flink" % "flink-streaming-java" % flinkV % Test,
"org.apache.flink" % "flink-statebackend-rocksdb" % flinkV % Test,
"org.apache.flink" % "flink-connector-kafka" % flinkConnectorKafkaV % Test,
"org.apache.flink" % "flink-json" % flinkV % Test
)
}
)
Expand Down Expand Up @@ -1803,7 +1805,6 @@ lazy val flinkKafkaComponents = (project in flink("components/kafka"))
componentsUtils % Provided
)

// TODO: check if any flink-table / connector / format dependencies' scope can be limited
lazy val flinkTableApiComponents = (project in flink("components/table"))
.settings(commonSettings)
.settings(assemblyNoScala("flinkTable.jar"): _*)
Expand All @@ -1812,13 +1813,10 @@ lazy val flinkTableApiComponents = (project in flink("components/table"))
name := "nussknacker-flink-table-components",
libraryDependencies ++= {
Seq(
"org.apache.flink" % "flink-table" % flinkV,
"org.apache.flink" % "flink-table-api-java" % flinkV,
"org.apache.flink" % "flink-table-api-java-bridge" % flinkV,
"org.apache.flink" % "flink-table-planner-loader" % flinkV,
"org.apache.flink" % "flink-table-runtime" % flinkV,
"org.apache.flink" % "flink-connector-kafka" % flinkConnectorKafkaV,
"org.apache.flink" % "flink-json" % flinkV,
)
}
)
Expand Down
14 changes: 3 additions & 11 deletions designer/client/cypress/e2e/process2.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,8 @@ describe("Process view", () => {

it("should have node search toolbar", () => {
cy.get("[data-testid=search-panel]").should("be.visible");
cy.get("[data-testid=search-panel]")
.contains(/^search$/i)
.click();
cy.get("[title='toggle left panel']").click();
cy.get("[data-testid=search-panel]").should("be.not.visible");
cy.get("#nk-graph-main").click();
cy.realPress(["Meta", "F"]);
cy.get("[data-testid=search-panel] input").should("be.visible").should("be.focused");
cy.get("[data-testid=search-panel]").contains(/^search$/i);
cy.get("[data-testid=search-panel] input").click();
cy.realType("en");
cy.get("[data-testid=search-panel]").contains(/sms/i).click();
cy.getNode("enricher")
Expand All @@ -47,9 +41,7 @@ describe("Process view", () => {
cy.get("[data-testid=window]")
.contains(/^cancel$/i)
.click();
cy.get("#nk-graph-main").click();
cy.realPress(["Meta", "F"]);
cy.get("[data-testid=search-panel] input").should("be.visible").should("be.focused");
cy.get("[data-testid=search-panel] input").click().clear();
cy.realType("source");
cy.wait(750); //wait for animation
cy.getNode("enricher")
Expand Down
42 changes: 2 additions & 40 deletions designer/client/src/components/toolbars/search/SearchPanel.tsx
Original file line number Diff line number Diff line change
@@ -1,58 +1,20 @@
import { isEmpty } from "lodash";
import React, { ReactElement, useCallback, useRef, useState } from "react";
import { useTranslation } from "react-i18next";
import { useDispatch, useSelector } from "react-redux";
import { toggleToolbar } from "../../../actions/nk/toolbars";
import { useDocumentListeners } from "../../../containers/useDocumentListeners";
import { getToolbarsConfigId } from "../../../reducers/selectors/toolbars";
import { useSidePanel } from "../../sidePanels/SidePanel";
import { SearchIcon } from "../../table/SearchFilter";
import { Focusable } from "../../themed/InputWithIcon";
import { ToolbarPanelProps } from "../../toolbarComponents/DefaultToolbarPanel";
import { ToolbarWrapper } from "../../toolbarComponents/toolbarWrapper/ToolbarWrapper";
import { SearchResults } from "./SearchResults";
import { SearchInputWithIcon } from "../../themed/SearchInput";
import { EventTrackingSelector, getEventTrackingProps, EventTrackingType, useEventTracking } from "../../../containers/event-tracking";
import { EventTrackingSelector, getEventTrackingProps } from "../../../containers/event-tracking";

export function SearchPanel(props: ToolbarPanelProps): ReactElement {
const { t } = useTranslation();
const dispatch = useDispatch();
const toolbarsConfigId = useSelector(getToolbarsConfigId);
const { trackEvent } = useEventTracking();
const [filter, setFilter] = useState<string>("");
const clearFilter = useCallback(() => setFilter(""), []);

const searchRef = useRef<Focusable>();
const sidePanel = useSidePanel();

useDocumentListeners({
keydown: (e) => {
switch (e.key.toUpperCase()) {
case "ESCAPE": {
e.preventDefault();
e.stopImmediatePropagation();
clearFilter();
const target = e.composedPath().shift();
if (target instanceof HTMLElement) {
target.blur();
}
break;
}
case "F": {
if (!e.ctrlKey && !e.metaKey) return;
e.preventDefault();
e.stopPropagation();
if (!sidePanel.isOpened) {
sidePanel.onToggle();
}
dispatch(toggleToolbar(props.id, toolbarsConfigId, false));
searchRef.current.focus();
trackEvent({ selector: EventTrackingSelector.FocusSearchNodeField, event: EventTrackingType.Keyboard });
break;
}
}
},
});

return (
<ToolbarWrapper {...props} title={t("panels.search.title", "Search")} onExpand={() => searchRef.current?.focus()}>
Expand All @@ -66,7 +28,7 @@ export function SearchPanel(props: ToolbarPanelProps): ReactElement {
>
<SearchIcon isEmpty={isEmpty(filter)} />
</SearchInputWithIcon>
<SearchResults filterValues={filter.toLowerCase().split(/\s/).filter(Boolean)} />
<SearchResults filterValues={[filter.toLowerCase()].filter(Boolean)} />
</ToolbarWrapper>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ object PrettyValidationErrors {
node("Unknown, fatal validation error", s"Fatal error: $message, please check configuration")
case CannotCreateObjectError(message, nodeId) =>
node(s"Could not create $nodeId: $message", s"Could not create $nodeId: $message")

case UnresolvedFragment(id) => node("Unresolved fragment", s"fragment $id encountered, this should not happen")
case FragmentOutputNotDefined(id, _) => node(s"Output $id not defined", "Please check fragment definition")
case UnknownFragmentOutput(id, _) => node(s"Unknown fragment output $id", "Please check fragment definition")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ import pl.touk.nussknacker.engine.graph.sink.SinkRef
import pl.touk.nussknacker.engine.graph.source.SourceRef
import pl.touk.nussknacker.engine.graph.variable.Field
import pl.touk.nussknacker.engine.spel.ExpressionSuggestion
import pl.touk.nussknacker.engine.util.CaretPosition2d
import pl.touk.nussknacker.restmodel.BaseEndpointDefinitions
import pl.touk.nussknacker.restmodel.BaseEndpointDefinitions.SecuredEndpoint
import pl.touk.nussknacker.restmodel.definition.{UIParameter, UIValueParameter}
import pl.touk.nussknacker.restmodel.validation.ValidationResults.{NodeValidationError, NodeValidationErrorType}
import pl.touk.nussknacker.security.AuthCredentials
import pl.touk.nussknacker.ui.suggester.CaretPosition2d
import pl.touk.nussknacker.ui.api.TapirCodecs.ScenarioNameCodec._
import pl.touk.nussknacker.ui.api.description.NodesApiEndpoints.Dtos.NodesError.{
MalformedTypingResult,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ trait ComponentService {
implicit user: LoggedUser
): Future[XError[List[ComponentUsagesInScenario]]]

def getUsagesPerDesignerWideComponentId(
implicit loggedUser: LoggedUser,
ec: ExecutionContext
): Future[Map[DesignerWideComponentId, Long]]

}

object DefaultComponentService {
Expand Down Expand Up @@ -140,6 +145,11 @@ class DefaultComponentService(
}
}

override def getUsagesPerDesignerWideComponentId(
implicit loggedUser: LoggedUser,
ec: ExecutionContext
): Future[Map[DesignerWideComponentId, Long]] = getUserAccessibleComponentUsages

private def getUserAccessibleComponentUsages(
implicit loggedUser: LoggedUser,
ec: ExecutionContext
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,13 @@ class NussknackerAppFactory(processingTypeDataStateFactory: ProcessingTypeDataSt
db <- DbRef.create(config.resolved)
feStatisticsRepository <- QuestDbFEStatisticsRepository.create(system, clock, config.resolved)
server = new NussknackerHttpServer(
new AkkaHttpBasedRouteProvider(db, metricsRegistry, processingTypeDataStateFactory, feStatisticsRepository)(
new AkkaHttpBasedRouteProvider(
db,
metricsRegistry,
processingTypeDataStateFactory,
feStatisticsRepository,
clock
)(
system,
materializer
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,14 @@ class MigrationService(
)(implicit loggedUser: LoggedUser): Future[Either[NuDesignerError, Unit]] = if (useLegacyCreateScenarioApi) {
processService
.createProcess(
CreateScenarioCommand(processName, Some(parameters.category), None, None, isFragment, forwardedUsername)
CreateScenarioCommand(
name = processName,
category = Some(parameters.category),
processingMode = Some(parameters.processingMode),
engineSetupName = Some(parameters.engineSetupName),
isFragment = isFragment,
forwardedUserName = forwardedUsername
)
)
.map(_.toEither)
.map {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import pl.touk.nussknacker.ui.listener.{Comment => CommentValue}
import pl.touk.nussknacker.ui.process.ScenarioAttachmentService.AttachmentToAdd
import pl.touk.nussknacker.ui.process.repository.DbProcessActivityRepository.{Attachment, Comment, ProcessActivity}
import pl.touk.nussknacker.ui.security.api.{ImpersonatedUser, LoggedUser, RealLoggedUser}
import pl.touk.nussknacker.ui.statistics.{AttachmentsTotal, CommentsTotal}

import java.sql.Timestamp
import java.time.Instant
Expand All @@ -32,6 +33,8 @@ trait ProcessActivityRepository {
implicit ec: ExecutionContext
): Future[Option[AttachmentEntityData]]

def getActivityStats(implicit ec: ExecutionContext): Future[Map[String, Int]]

}

final case class DbProcessActivityRepository(protected val dbRef: DbRef, commentRepository: CommentRepository)(
Expand Down Expand Up @@ -74,6 +77,18 @@ final case class DbProcessActivityRepository(protected val dbRef: DbRef, comment
run(findProcessActivityAction)
}

override def getActivityStats(implicit ec: ExecutionContext): Future[Map[String, Int]] = {
val findScenarioProcessActivityStats = for {
attachmentsTotal <- attachmentsTable.length.result
commentsTotal <- commentsTable.length.result
} yield Map(
AttachmentsTotal -> attachmentsTotal,
CommentsTotal -> commentsTotal,
).map { case (k, v) => (k.toString, v) }

run(findScenarioProcessActivityStats)
}

override def addAttachment(
attachmentToAdd: AttachmentToAdd
)(implicit ec: ExecutionContext, loggedUser: LoggedUser): Future[Unit] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ class AkkaHttpBasedRouteProvider(
dbRef: DbRef,
metricsRegistry: MetricRegistry,
processingTypeDataStateFactory: ProcessingTypeDataStateFactory,
feStatisticsRepository: FEStatisticsRepository[Future]
feStatisticsRepository: FEStatisticsRepository[Future],
designerClock: Clock
)(implicit system: ActorSystem, materializer: Materializer)
extends RouteProvider[Route]
with Directives
Expand Down Expand Up @@ -488,6 +489,7 @@ class AkkaHttpBasedRouteProvider(
.values
.flatten
.toList,
designerClock
)

val statisticsApiHttpService = new StatisticsApiHttpService(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package pl.touk.nussknacker.ui.statistics

import java.util.UUID

class CorrelationId(val value: String) extends AnyVal

object CorrelationId {
def apply(): CorrelationId =
new CorrelationId(UUID.randomUUID().toString)
}
Loading

0 comments on commit c2daaa3

Please sign in to comment.