Skip to content

Commit

Permalink
Merge branch 'staging' into integer-dictionary-support-in-fragment-in…
Browse files Browse the repository at this point in the history
…puts
  • Loading branch information
mateuszkp96 committed Dec 17, 2024
2 parents 25ce59a + 5069ac1 commit d8af8ec
Show file tree
Hide file tree
Showing 54 changed files with 158 additions and 179 deletions.
6 changes: 2 additions & 4 deletions designer/client/src/components/Process/ProcessStateUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@ class ProcessStateUtils {

public canArchive = (state: ProcessStateType): boolean => state?.allowedActions.includes(PredefinedActionName.Archive);

public canSeePerformSingleExecution = (state: ProcessStateType): boolean =>
state?.visibleActions.includes(PredefinedActionName.PerformSingleExecution);
public canSeeRunOffSchedule = (state: ProcessStateType): boolean => state?.visibleActions.includes(PredefinedActionName.RunOffSchedule);

public canPerformSingleExecution = (state: ProcessStateType): boolean =>
state?.allowedActions.includes(PredefinedActionName.PerformSingleExecution);
public canRunOffSchedule = (state: ProcessStateType): boolean => state?.allowedActions.includes(PredefinedActionName.RunOffSchedule);

getStateDescription({ isArchived, isFragment }: Scenario, processState: ProcessStateType): string {
if (isArchived) {
Expand Down
2 changes: 1 addition & 1 deletion designer/client/src/components/Process/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export enum PredefinedActionName {
Archive = "ARCHIVE",
UnArchive = "UNARCHIVE",
Pause = "PAUSE",
PerformSingleExecution = "PERFORM_SINGLE_EXECUTION",
RunOffSchedule = "RUN_OFF_SCHEDULE",
}

export type ActionName = string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export enum BuiltinButtonTypes {
processSave = "process-save",
processDeploy = "process-deploy",
processCancel = "process-cancel",
processPerformSingleExecution = "process-perform-single-execution",
processRunOffSchedule = "process-run-off-schedule",
editUndo = "edit-undo",
editRedo = "edit-redo",
editCopy = "edit-copy",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import { ZoomOutButton } from "../../toolbars/view/buttons/ZoomOutButton";
import { BuiltinButtonTypes } from "./BuiltinButtonTypes";
import { CustomButtonTypes } from "./CustomButtonTypes";
import { ToolbarButton, ToolbarButtonTypes } from "./types";
import PerformSingleExecutionButton from "../../toolbars/scenarioActions/buttons/PerformSingleExecutionButton";
import RunOffScheduleButton from "../../toolbars/scenarioActions/buttons/RunOffScheduleButton";

export type PropsOfButton<T> = ToolbarButton & {
type: T;
Expand All @@ -45,7 +45,7 @@ export const TOOLBAR_BUTTONS_MAP: ToolbarButtonsMap = {
[BuiltinButtonTypes.processSave]: SaveButton,
[BuiltinButtonTypes.processDeploy]: DeployButton,
[BuiltinButtonTypes.processCancel]: CancelDeployButton,
[BuiltinButtonTypes.processPerformSingleExecution]: PerformSingleExecutionButton,
[BuiltinButtonTypes.processRunOffSchedule]: RunOffScheduleButton,
[BuiltinButtonTypes.viewZoomIn]: ZoomInButton,
[BuiltinButtonTypes.viewZoomOut]: ZoomOutButton,
[BuiltinButtonTypes.viewReset]: ResetViewButton,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function defaultToolbarsConfig(isFragment: boolean, isArchived: boolean):
{ type: BuiltinButtonTypes.processSave },
{ type: BuiltinButtonTypes.processDeploy },
{ type: BuiltinButtonTypes.processCancel },
{ type: BuiltinButtonTypes.processPerformSingleExecution },
{ type: BuiltinButtonTypes.processRunOffSchedule },
],
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import React from "react";
import { useTranslation } from "react-i18next";
import { useDispatch, useSelector } from "react-redux";
import { loadProcessState } from "../../../../actions/nk";
import Icon from "../../../../assets/img/toolbarButtons/perform-single-execution.svg";
import Icon from "../../../../assets/img/toolbarButtons/run-off-schedule.svg";
import HttpService from "../../../../http/HttpService";
import {
getProcessName,
getProcessVersionId,
isPerformSingleExecutionPossible,
isPerformSingleExecutionVisible,
isRunOffSchedulePossible,
isRunOffScheduleVisible,
} from "../../../../reducers/selectors/graph";
import { getCapabilities } from "../../../../reducers/selectors/other";
import { useWindows, WindowKind } from "../../../../windowManager";
Expand All @@ -21,30 +21,29 @@ import { RootState } from "../../../../reducers";
import { getProcessState } from "../../../../reducers/selectors/scenarioState";
import { PredefinedActionName } from "../../../Process/types";

export default function PerformSingleExecutionButton(props: ToolbarButtonProps) {
export default function RunOffScheduleButton(props: ToolbarButtonProps) {
const { t } = useTranslation();
const dispatch = useDispatch();
const { disabled, type } = props;
const scenarioState = useSelector((state: RootState) => getProcessState(state));
const isVisible = useSelector(isPerformSingleExecutionVisible);
const isPossible = useSelector(isPerformSingleExecutionPossible);
const isVisible = useSelector(isRunOffScheduleVisible);
const isPossible = useSelector(isRunOffSchedulePossible);
const processName = useSelector(getProcessName);
const processVersionId = useSelector(getProcessVersionId);
const capabilities = useSelector(getCapabilities);
const available = !disabled && isPossible && capabilities.deploy;

const { open } = useWindows();
const action = (p, c) =>
HttpService.performSingleExecution(p, c).finally(() => dispatch(loadProcessState(processName, processVersionId)));
const message = t("panels.actions.perform-single-execution.dialog", "Perform single execution", { name: processName });
const action = (p, c) => 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.perform-single-execution.tooltip", "run now");
const tooltip = ProcessStateUtils.getActionCustomTooltip(scenarioState, PredefinedActionName.PerformSingleExecution) ?? defaultTooltip;
const defaultTooltip = t("panels.actions.run-off-schedule.tooltip", "run now");
const tooltip = ProcessStateUtils.getActionCustomTooltip(scenarioState, PredefinedActionName.RunOffSchedule) ?? defaultTooltip;

if (isVisible) {
return (
<ToolbarButton
name={t("panels.actions.perform-single-execution.button", "run now")}
name={t("panels.actions.run-off-schedule.button", "run now")}
title={tooltip}
disabled={!available}
icon={<Icon />}
Expand Down
4 changes: 2 additions & 2 deletions designer/client/src/containers/event-tracking/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ export const mapToolbarButtonToStatisticsEvent = (
case BuiltinButtonTypes.processCancel: {
return EventTrackingSelector.ScenarioCancel;
}
case BuiltinButtonTypes.processPerformSingleExecution: {
return EventTrackingSelector.ScenarioPerformSingleExecution;
case BuiltinButtonTypes.processRunOffSchedule: {
return EventTrackingSelector.ScenarioRunOffSchedule;
}
case BuiltinButtonTypes.processArchiveToggle: {
return EventTrackingSelector.ScenarioArchiveToggle;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ enum ClickEventsSelector {
ScenarioSave = "SCENARIO_SAVE",
TestCounts = "TEST_COUNTS",
ScenarioCancel = "SCENARIO_CANCEL",
ScenarioPerformSingleExecution = "SCENARIO_PERFORM_SINGLE_EXECUTION",
ScenarioRunOffSchedule = "SCENARIO_RUN_OFF_SCHEDULE",
ScenarioArchiveToggle = "SCENARIO_ARCHIVE_TOGGLE",
ScenarioUnarchive = "SCENARIO_UNARCHIVE",
ScenarioCustomAction = "SCENARIO_CUSTOM_ACTION",
Expand Down
4 changes: 2 additions & 2 deletions designer/client/src/http/HttpService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,12 +360,12 @@ class HttpService {
});
}

performSingleExecution(processName: string, comment?: string) {
runOffSchedule(processName: string, comment?: string) {
const data = {
comment: comment,
};
return api
.post(`/processManagement/performSingleExecution/${encodeURIComponent(processName)}`, data)
.post(`/processManagement/runOffSchedule/${encodeURIComponent(processName)}`, data)
.then((res) => {
const msg = res.data.msg;
this.#addInfo(msg);
Expand Down
8 changes: 3 additions & 5 deletions designer/client/src/reducers/selectors/graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,10 @@ export const isDeployedVersion = createSelector(
(visibleVersion, deployedVersion) => visibleVersion === deployedVersion,
);
export const isCancelPossible = createSelector(getProcessState, (state) => ProcessStateUtils.canCancel(state));
export const isPerformSingleExecutionVisible = createSelector([getProcessState], (state) =>
ProcessStateUtils.canSeePerformSingleExecution(state),
);
export const isPerformSingleExecutionPossible = createSelector(
export const isRunOffScheduleVisible = createSelector([getProcessState], (state) => ProcessStateUtils.canSeeRunOffSchedule(state));
export const isRunOffSchedulePossible = createSelector(
[hasError, getProcessState, isFragment],
(error, state, fragment) => !fragment && !error && ProcessStateUtils.canPerformSingleExecution(state),
(error, state, fragment) => !fragment && !error && ProcessStateUtils.canRunOffSchedule(state),
);
export const isMigrationPossible = createSelector(
[isSaveDisabled, hasError, getProcessState, isFragment],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ case class DMCancelScenarioCommand(scenarioName: ProcessName, user: User) extend
case class DMStopScenarioCommand(scenarioName: ProcessName, savepointDir: Option[String], user: User)
extends DMScenarioCommand[SavepointResult]

case class DMPerformSingleExecutionCommand(
case class DMRunOffScheduleCommand(
processVersion: ProcessVersion,
canonicalProcess: CanonicalProcess,
user: User,
) extends DMScenarioCommand[SingleExecutionResult]
) extends DMScenarioCommand[RunOffScheduleResult]
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ trait StubbingCommands { self: DeploymentManager =>
case _: DMCancelDeploymentCommand => Future.successful(())
case _: DMCancelScenarioCommand => Future.successful(())
case _: DMMakeScenarioSavepointCommand => Future.successful(SavepointResult(""))
case _: DMPerformSingleExecutionCommand | _: DMCustomActionCommand | _: DMTestScenarioCommand => notImplemented
case _: DMRunOffScheduleCommand | _: DMCustomActionCommand | _: DMTestScenarioCommand => notImplemented
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ package pl.touk.nussknacker.restmodel

import io.circe.generic.JsonCodec

@JsonCodec final case class PerformSingleExecutionRequest(
@JsonCodec final case class RunOffScheduleRequest(
comment: Option[String] = None,
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ package pl.touk.nussknacker.restmodel
import io.circe.generic.JsonCodec

@JsonCodec
final case class PerformSingleExecutionResponse(isSuccess: Boolean, msg: String)
final case class RunOffScheduleResponse(isSuccess: Boolean, msg: String)
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ processToolbarConfig {
{ type: "process-deploy", disabled: { fragment: true, archived: true, type: "oneof" } }
{ type: "process-cancel", disabled: { fragment: true, archived: true, type: "oneof" } }
{ type: "custom-link", name: "metrics", icon: "/assets/buttons/metrics.svg", url: "/metrics/$processName", disabled: { fragment: true } }
{ type: "process-perform-single-execution", disabled: { fragment: true, archived: true, type: "oneof" } }
{ type: "process-run-off-schedule", disabled: { fragment: true, archived: true, type: "oneof" } }
]
}
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import pl.touk.nussknacker.engine.testmode.TestProcess._
import pl.touk.nussknacker.restmodel.{
CustomActionRequest,
CustomActionResponse,
PerformSingleExecutionRequest,
PerformSingleExecutionResponse
RunOffScheduleRequest,
RunOffScheduleResponse
}
import pl.touk.nussknacker.ui.api.ProcessesResources.ProcessUnmarshallingError
import pl.touk.nussknacker.ui.api.description.NodesApiEndpoints.Dtos.AdhocTestParametersRequest
Expand Down Expand Up @@ -275,24 +275,25 @@ class ManagementResources(
)
}
}
} ~ path("performSingleExecution" / ProcessNameSegment) { processName =>
(post & processId(processName) & entity(as[PerformSingleExecutionRequest])) { (processIdWithName, req) =>
canDeploy(processIdWithName) {
complete {
measureTime("singleExecution", metricRegistry) {
deploymentService
.processCommand(
PerformSingleExecutionCommand(
commonData = CommonCommandData(processIdWithName, req.comment.flatMap(Comment.from), user),
} ~ path(("runOffSchedule" | "performSingleExecution") / ProcessNameSegment) {
processName => // backward compatibility purpose
(post & processId(processName) & entity(as[RunOffScheduleRequest])) { (processIdWithName, req) =>
canDeploy(processIdWithName) {
complete {
measureTime("singleExecution", metricRegistry) {
deploymentService
.processCommand(
RunOffScheduleCommand(
commonData = CommonCommandData(processIdWithName, req.comment.flatMap(Comment.from), user),
)
)
)
.flatMap(actionResult =>
toHttpResponse(PerformSingleExecutionResponse(isSuccess = true, actionResult.msg))(StatusCodes.OK)
)
.flatMap(actionResult =>
toHttpResponse(RunOffScheduleResponse(isSuccess = true, actionResult.msg))(StatusCodes.OK)
)
}
}
}
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ object ToolbarButtonConfigType extends Enumeration {
CustomLink
)

val ProcessSave: Value = Value("process-save")
val ProcessCancel: Value = Value("process-cancel")
val ProcessDeploy: Value = Value("process-deploy")
val ProcessPerformSingleExecution: Value = Value("process-perform-single-execution")
val ProcessSave: Value = Value("process-save")
val ProcessCancel: Value = Value("process-cancel")
val ProcessDeploy: Value = Value("process-deploy")
val ProcessRunOffSchedule: Value = Value("process-run-off-schedule")

val EditUndo: Value = Value("edit-undo")
val EditRedo: Value = Value("edit-redo")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ class DeploymentService(

def processCommand[Result](command: ScenarioCommand[Result]): Future[Result] = {
command match {
case command: RunDeploymentCommand => runDeployment(command)
case command: CancelScenarioCommand => cancelScenario(command)
case command: PerformSingleExecutionCommand => processSingleExecution(command)
case command: CustomActionCommand => processCustomAction(command)
case command: RunDeploymentCommand => runDeployment(command)
case command: CancelScenarioCommand => cancelScenario(command)
case command: RunOffScheduleCommand => runOffSchedule(command)
case command: CustomActionCommand => processCustomAction(command)
}
}

Expand Down Expand Up @@ -313,7 +313,7 @@ class DeploymentService(
val fixedActionDefinitions = List(
CustomActionDefinition(ScenarioActionName.Deploy, Nil, Nil, None),
CustomActionDefinition(ScenarioActionName.Cancel, Nil, Nil, None),
CustomActionDefinition(ScenarioActionName.PerformSingleExecution, Nil, Nil, None)
CustomActionDefinition(ScenarioActionName.RunOffSchedule, Nil, Nil, None)
)
val actionsDefinedInCustomActions = dispatcher
.deploymentManagerUnsafe(processingType)
Expand Down Expand Up @@ -731,13 +731,13 @@ class DeploymentService(
Await.result(dbioRunner.run(actionRepository.deleteInProgressActions()), 10 seconds)
}

private def processSingleExecution(command: PerformSingleExecutionCommand): Future[SingleExecutionResult] = {
private def runOffSchedule(command: RunOffScheduleCommand): Future[RunOffScheduleResult] = {
processAction(
command = command,
actionName = ScenarioActionName.PerformSingleExecution,
actionName = ScenarioActionName.RunOffSchedule,
actionParams = Map.empty,
dmCommandCreator = ctx =>
DMPerformSingleExecutionCommand(
DMRunOffScheduleCommand(
ctx.latestScenarioDetails.toEngineProcessVersion,
ctx.latestScenarioDetails.json,
command.commonData.user.toManagerUser,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import pl.touk.nussknacker.engine.api.component.NodesDeploymentData
import pl.touk.nussknacker.engine.api.deployment.DeploymentUpdateStrategy.StateRestoringStrategy
import pl.touk.nussknacker.engine.api.deployment.ScenarioActionName
import pl.touk.nussknacker.engine.api.process.ProcessIdWithName
import pl.touk.nussknacker.engine.deployment.{CustomActionResult, ExternalDeploymentId, SingleExecutionResult}
import pl.touk.nussknacker.engine.deployment.{CustomActionResult, ExternalDeploymentId, RunOffScheduleResult}
import pl.touk.nussknacker.ui.security.api.LoggedUser

import scala.concurrent.Future
Expand Down Expand Up @@ -34,9 +34,9 @@ case class CustomActionCommand(
params: Map[String, String],
) extends ScenarioCommand[CustomActionResult]

case class PerformSingleExecutionCommand(
case class RunOffScheduleCommand(
commonData: CommonCommandData,
) extends ScenarioCommand[SingleExecutionResult]
) extends ScenarioCommand[RunOffScheduleResult]

// TODO CancelScenarioCommand will be legacy in some future because it operates on the scenario level instead of deployment level -
// we should replace it by command operating on deployment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ class DbScenarioActionRepository private (
ScenarioActivityType.ScenarioPaused
case ScenarioActionName.Rename =>
ScenarioActivityType.ScenarioNameChanged
case ScenarioActionName.PerformSingleExecution =>
case ScenarioActionName.RunOffSchedule =>
ScenarioActivityType.PerformedSingleExecution
case otherCustomName =>
ScenarioActivityType.CustomAction(otherCustomName.value)
Expand Down Expand Up @@ -518,7 +518,7 @@ class DbScenarioActionRepository private (
case ScenarioActivityType.OutgoingMigration =>
None
case ScenarioActivityType.PerformedSingleExecution =>
Some(ScenarioActionName.PerformSingleExecution)
Some(ScenarioActionName.RunOffSchedule)
case ScenarioActivityType.PerformedScheduledExecution =>
None
case ScenarioActivityType.AutomaticUpdate =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ class V1_057__MigrateActionsAndCommentsToScenarioActivities
}
"migrate custom action 'run now' with comment to scenario_activities table" in {
testMigratingActionWithComment(
scenarioActionName = ScenarioActionName.PerformSingleExecution,
scenarioActionName = ScenarioActionName.RunOffSchedule,
actionComment = Some("Run now: Deployed at the request of business"),
expectedActivity = (sid, sad, user, date, sv) =>
ScenarioActivity.PerformedSingleExecution(
Expand Down
2 changes: 2 additions & 0 deletions docs/MigrationGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ To see the biggest differences please consult the [changelog](Changelog.md).
* `def actionTooltips(processStatus: ProcessStatus): Map[ScenarioActionName, String]` - allows to define custom tooltips for actions, if not defined the default is still used
* modified method:
* `def statusActions(processStatus: ProcessStatus): List[ScenarioActionName]` - changed argument, to include information about latest and deployed versions
* [#7347](https://github.com/TouK/nussknacker/pull/7347) All calls to `org.apache.flink.api.common.functions.RichFunction.open(Configuration)`,
which is deprecated, were replaced with calls to `org.apache.flink.api.common.functions.RichFunction.open(OpenContext)`

## In version 1.18.0

Expand Down
Loading

0 comments on commit d8af8ec

Please sign in to comment.