Skip to content

Commit

Permalink
Review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mgoworko committed Dec 2, 2024
1 parent cb6085c commit cbd42a5
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
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 @@ -70,7 +70,7 @@ export type ProcessName = Scenario["name"];
export type ProcessStateType = {
status: StatusType;
externalDeploymentId?: string;
applicableActions: Array<ActionName>;
visibleActions: Array<ActionName>;
allowedActions: Array<ActionName>;
actionTooltips: Record<ActionName, string>;
icon: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
2 changes: 1 addition & 1 deletion designer/client/src/reducers/graph/utils.fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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
Expand All @@ -66,7 +66,7 @@ trait ProcessStateDefinitionManager {
statusDetails.externalDeploymentId,
statusDetails.status,
statusDetails.version,
applicableActions,
visibleActions,
statusActions(status),
actionTooltips(status),
statusIcon(statusDetails.status),
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion docs/MigrationGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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)"
)
}

Expand All @@ -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."
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down

0 comments on commit cbd42a5

Please sign in to comment.