diff --git a/designer/client/src/components/Process/ProcessStateUtils.ts b/designer/client/src/components/Process/ProcessStateUtils.ts index ebd116ebd3e..520b380fed2 100644 --- a/designer/client/src/components/Process/ProcessStateUtils.ts +++ b/designer/client/src/components/Process/ProcessStateUtils.ts @@ -19,7 +19,7 @@ class ProcessStateUtils { public canArchive = (state: ProcessStateType): boolean => state?.allowedActions.includes(PredefinedActionName.Archive); public canSeePerformSingleExecution = (state: ProcessStateType): boolean => - state?.applicableActions.includes(PredefinedActionName.PerformSingleExecution); + state?.visibleActions.includes(PredefinedActionName.PerformSingleExecution); public canPerformSingleExecution = (state: ProcessStateType): boolean => state?.allowedActions.includes(PredefinedActionName.PerformSingleExecution); diff --git a/designer/client/src/components/Process/types.ts b/designer/client/src/components/Process/types.ts index 11824909602..f5cbd62763a 100644 --- a/designer/client/src/components/Process/types.ts +++ b/designer/client/src/components/Process/types.ts @@ -70,7 +70,7 @@ export type ProcessName = Scenario["name"]; export type ProcessStateType = { status: StatusType; externalDeploymentId?: string; - applicableActions: Array; + visibleActions: Array; allowedActions: Array; actionTooltips: Record; icon: string; diff --git a/designer/client/src/components/toolbars/scenarioActions/buttons/PerformSingleExecutionButton.tsx b/designer/client/src/components/toolbars/scenarioActions/buttons/PerformSingleExecutionButton.tsx index 17453e6c4dd..a7ff57d88e2 100644 --- a/designer/client/src/components/toolbars/scenarioActions/buttons/PerformSingleExecutionButton.tsx +++ b/designer/client/src/components/toolbars/scenarioActions/buttons/PerformSingleExecutionButton.tsx @@ -31,7 +31,8 @@ export default function PerformSingleExecutionButton(props: ToolbarButtonProps) const action = (p, c) => HttpService.performSingleExecution(p, c).finally(() => dispatch(loadProcessState(processName))); const message = t("panels.actions.perform-single-execution.dialog", "Perform single execution", { name: processName }); - const tooltip = ProcessStateUtils.getActionCustomTooltip(scenarioState, PredefinedActionName.PerformSingleExecution) ?? "run now"; + const defaultTooltip = t("panels.actions.perform-single-execution.tooltip", "run now"); + const tooltip = ProcessStateUtils.getActionCustomTooltip(scenarioState, PredefinedActionName.PerformSingleExecution) ?? defaultTooltip; if (isVisible) { return ( diff --git a/designer/client/src/reducers/graph/utils.fixtures.ts b/designer/client/src/reducers/graph/utils.fixtures.ts index b3db78ae260..6363380669e 100644 --- a/designer/client/src/reducers/graph/utils.fixtures.ts +++ b/designer/client/src/reducers/graph/utils.fixtures.ts @@ -167,7 +167,7 @@ export const state: GraphState = { name: "NOT_DEPLOYED", }, version: null, - applicableActions: ["DEPLOY", "ARCHIVE", "RENAME"], + visibleActions: ["DEPLOY", "ARCHIVE", "RENAME"], allowedActions: ["DEPLOY", "ARCHIVE", "RENAME"], actionTooltips: {}, icon: "/assets/states/not-deployed.svg", diff --git a/designer/deployment-manager-api/src/main/scala/pl/touk/nussknacker/engine/api/deployment/OverridingProcessStateDefinitionManager.scala b/designer/deployment-manager-api/src/main/scala/pl/touk/nussknacker/engine/api/deployment/OverridingProcessStateDefinitionManager.scala index 15a4d4240af..c07966c9d30 100644 --- a/designer/deployment-manager-api/src/main/scala/pl/touk/nussknacker/engine/api/deployment/OverridingProcessStateDefinitionManager.scala +++ b/designer/deployment-manager-api/src/main/scala/pl/touk/nussknacker/engine/api/deployment/OverridingProcessStateDefinitionManager.scala @@ -26,12 +26,12 @@ class OverridingProcessStateDefinitionManager( statusTooltipsPF: PartialFunction[StateStatus, String] = PartialFunction.empty, statusDescriptionsPF: PartialFunction[StateStatus, String] = PartialFunction.empty, customStateDefinitions: Map[StatusName, StateDefinitionDetails] = Map.empty, - customApplicableActions: Option[List[ScenarioActionName]] = None, + customVisibleActions: Option[List[ScenarioActionName]] = None, customActionTooltips: Option[ProcessStatus => Map[ScenarioActionName, String]] = None, ) extends ProcessStateDefinitionManager { - override def applicableActions: List[ScenarioActionName] = - customApplicableActions.getOrElse(delegate.applicableActions) + override def visibleActions: List[ScenarioActionName] = + customVisibleActions.getOrElse(delegate.visibleActions) override def statusActions(processStatus: ProcessStatus): List[ScenarioActionName] = statusActionsPF.applyOrElse(processStatus, delegate.statusActions) diff --git a/designer/deployment-manager-api/src/main/scala/pl/touk/nussknacker/engine/api/deployment/ProcessStateDefinitionManager.scala b/designer/deployment-manager-api/src/main/scala/pl/touk/nussknacker/engine/api/deployment/ProcessStateDefinitionManager.scala index 6d4a63f0e9b..eb52a868320 100644 --- a/designer/deployment-manager-api/src/main/scala/pl/touk/nussknacker/engine/api/deployment/ProcessStateDefinitionManager.scala +++ b/designer/deployment-manager-api/src/main/scala/pl/touk/nussknacker/engine/api/deployment/ProcessStateDefinitionManager.scala @@ -1,6 +1,6 @@ package pl.touk.nussknacker.engine.api.deployment -import pl.touk.nussknacker.engine.api.deployment.ProcessStateDefinitionManager.{ProcessStatus, defaultApplicableActions} +import pl.touk.nussknacker.engine.api.deployment.ProcessStateDefinitionManager.{ProcessStatus, defaultVisibleActions} import pl.touk.nussknacker.engine.api.deployment.StateStatus.StatusName import pl.touk.nussknacker.engine.api.process.VersionId @@ -41,7 +41,7 @@ trait ProcessStateDefinitionManager { /** * Actions that are applicable to scenario in general. They may be available only in particular states, as defined by `def statusActions` */ - def applicableActions: List[ScenarioActionName] = defaultApplicableActions + def visibleActions: List[ScenarioActionName] = defaultVisibleActions /** * Custom tooltips for actions @@ -66,7 +66,7 @@ trait ProcessStateDefinitionManager { statusDetails.externalDeploymentId, statusDetails.status, statusDetails.version, - applicableActions, + visibleActions, statusActions(status), actionTooltips(status), statusIcon(statusDetails.status), @@ -98,7 +98,7 @@ object ProcessStateDefinitionManager { /** * Actions, that are applicable in standard use-cases for most deployment managers. */ - val defaultApplicableActions: List[ScenarioActionName] = List( + val defaultVisibleActions: List[ScenarioActionName] = List( ScenarioActionName.Cancel, ScenarioActionName.Deploy, ScenarioActionName.Pause, diff --git a/docs/MigrationGuide.md b/docs/MigrationGuide.md index 0f3b3825391..8b9b3ac2e2c 100644 --- a/docs/MigrationGuide.md +++ b/docs/MigrationGuide.md @@ -17,7 +17,7 @@ To see the biggest differences please consult the [changelog](Changelog.md). * `pl.touk.nussknacker.engine.api.deployment.ProcessStateDefinitionManager`: * added new arguments to `def processState` method (`latestVersionId: VersionId`, `deployedVersionId: Option[VersionId]`) * added new methods with default implementations: - * `def applicableActions: List[ScenarioActionName]` - allows to specify, which actions are applicable to scenario (and consequently should be visible in Designer), by default all previously available actions + * `def visibleActions: List[ScenarioActionName]` - allows to specify, which actions are applicable to scenario (and consequently should be visible in Designer), by default all previously available actions * `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 diff --git a/engine/flink/management/periodic/src/main/scala/pl/touk/nussknacker/engine/management/periodic/PeriodicProcessStateDefinitionManager.scala b/engine/flink/management/periodic/src/main/scala/pl/touk/nussknacker/engine/management/periodic/PeriodicProcessStateDefinitionManager.scala index 23959f36da4..fdc63d939f8 100644 --- a/engine/flink/management/periodic/src/main/scala/pl/touk/nussknacker/engine/management/periodic/PeriodicProcessStateDefinitionManager.scala +++ b/engine/flink/management/periodic/src/main/scala/pl/touk/nussknacker/engine/management/periodic/PeriodicProcessStateDefinitionManager.scala @@ -1,6 +1,6 @@ package pl.touk.nussknacker.engine.management.periodic -import pl.touk.nussknacker.engine.api.deployment.ProcessStateDefinitionManager.defaultApplicableActions +import pl.touk.nussknacker.engine.api.deployment.ProcessStateDefinitionManager.defaultVisibleActions import pl.touk.nussknacker.engine.api.deployment.{ OverridingProcessStateDefinitionManager, ProcessStateDefinitionManager, @@ -15,7 +15,7 @@ class PeriodicProcessStateDefinitionManager(delegate: ProcessStateDefinitionMana statusTooltipsPF = PeriodicStateStatus.statusTooltipsPF, statusDescriptionsPF = PeriodicStateStatus.statusDescriptionsPF, customStateDefinitions = PeriodicStateStatus.customStateDefinitions, - customApplicableActions = Some(defaultApplicableActions ::: ScenarioActionName.PerformSingleExecution :: Nil), + customVisibleActions = Some(defaultVisibleActions ::: ScenarioActionName.PerformSingleExecution :: Nil), customActionTooltips = Some(PeriodicStateStatus.customActionTooltips), delegate = delegate ) { diff --git a/engine/flink/management/periodic/src/test/scala/pl/touk/nussknacker/engine/management/periodic/PeriodicProcessStateDefinitionManagerTest.scala b/engine/flink/management/periodic/src/test/scala/pl/touk/nussknacker/engine/management/periodic/PeriodicProcessStateDefinitionManagerTest.scala index 5d02d9df763..29aa855cba6 100644 --- a/engine/flink/management/periodic/src/test/scala/pl/touk/nussknacker/engine/management/periodic/PeriodicProcessStateDefinitionManagerTest.scala +++ b/engine/flink/management/periodic/src/test/scala/pl/touk/nussknacker/engine/management/periodic/PeriodicProcessStateDefinitionManagerTest.scala @@ -3,7 +3,7 @@ package pl.touk.nussknacker.engine.management.periodic import org.scalatest.funsuite.AnyFunSuite import org.scalatest.matchers.should.Matchers import pl.touk.nussknacker.engine.api.deployment.ProcessStateDefinitionManager.ProcessStatus -import pl.touk.nussknacker.engine.api.deployment.{ScenarioActionName, ScenarioActionTooltip} +import pl.touk.nussknacker.engine.api.deployment.ScenarioActionName import pl.touk.nussknacker.engine.api.deployment.simple.SimpleStateStatus import pl.touk.nussknacker.engine.api.process.VersionId import pl.touk.nussknacker.engine.management.periodic.PeriodicProcessService.{DeploymentStatus, PeriodicProcessStatus} @@ -87,7 +87,7 @@ class PeriodicProcessStateDefinitionManagerTest extends AnyFunSuite with Matcher deployedVersionId = Some(VersionId(4)) ) ) shouldEqual Map( - ScenarioActionName.PerformSingleExecution -> ScenarioActionTooltip.NotAllowedForDeployedVersion + ScenarioActionName.PerformSingleExecution -> "There is new version 5 available (version 4 is deployed)" ) } @@ -99,7 +99,7 @@ class PeriodicProcessStateDefinitionManagerTest extends AnyFunSuite with Matcher deployedVersionId = Some(VersionId(4)) ) ) shouldEqual Map( - ScenarioActionName.PerformSingleExecution -> ScenarioActionTooltip.NotAllowedInCurrentState + ScenarioActionName.PerformSingleExecution -> "Disabled for CANCELED status." ) } diff --git a/extensions-api/src/main/scala/pl/touk/nussknacker/engine/api/deployment/ProcessState.scala b/extensions-api/src/main/scala/pl/touk/nussknacker/engine/api/deployment/ProcessState.scala index b793f6e8ee1..ddb425e15dc 100644 --- a/extensions-api/src/main/scala/pl/touk/nussknacker/engine/api/deployment/ProcessState.scala +++ b/extensions-api/src/main/scala/pl/touk/nussknacker/engine/api/deployment/ProcessState.scala @@ -4,6 +4,7 @@ import io.circe._ import io.circe.generic.JsonCodec import pl.touk.nussknacker.engine.api.ProcessVersion import pl.touk.nussknacker.engine.api.deployment.StateStatus.StatusName +import pl.touk.nussknacker.engine.api.process.VersionId import pl.touk.nussknacker.engine.deployment.{DeploymentId, ExternalDeploymentId} import java.net.URI @@ -26,7 +27,7 @@ import java.net.URI externalDeploymentId: Option[ExternalDeploymentId], status: StateStatus, version: Option[ProcessVersion], - applicableActions: List[ScenarioActionName], + visibleActions: List[ScenarioActionName], allowedActions: List[ScenarioActionName], actionTooltips: Map[ScenarioActionName, String], icon: URI,