-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace "run now" CustomAction with standard action PerformSingleExecution #7165
base: staging
Are you sure you want to change the base?
Changes from all commits
6374e6e
d3c0e7d
daa96bd
9d20653
aeaec47
10f2268
6c9fa55
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
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 HttpService from "../../../../http/HttpService"; | ||
import { getProcessName, isPerformSingleExecutionPossible, isPerformSingleExecutionVisible } from "../../../../reducers/selectors/graph"; | ||
import { getCapabilities } from "../../../../reducers/selectors/other"; | ||
import { useWindows, WindowKind } from "../../../../windowManager"; | ||
import { ToggleProcessActionModalData } from "../../../modals/DeployProcessDialog"; | ||
import { ToolbarButton } from "../../../toolbarComponents/toolbarButtons"; | ||
import { ToolbarButtonProps } from "../../types"; | ||
import { ACTION_DIALOG_WIDTH } from "../../../../stylesheets/variables"; | ||
import ProcessStateUtils from "../../../Process/ProcessStateUtils"; | ||
import { RootState } from "../../../../reducers"; | ||
import { getProcessState } from "../../../../reducers/selectors/scenarioState"; | ||
import { ActionTooltip, PredefinedActionName } from "../../../Process/types"; | ||
|
||
export default function PerformSingleExecutionButton(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 processName = useSelector(getProcessName); | ||
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))); | ||
const message = t("panels.actions.perform-single-execution.dialog", "Perform single execution", { name: processName }); | ||
|
||
const actionTooltip = ProcessStateUtils.getActionCustomTooltip(scenarioState, PredefinedActionName.PerformSingleExecution); | ||
|
||
const tooltip = | ||
actionTooltip === ActionTooltip.NotAllowedForDeployedVersion | ||
? t( | ||
"panels.actions.perform-single-execution.tooltip.not-allowed-for-deployed-version", | ||
"There is new version {{ latestVersion }} available.{{ deployedVersionDescription }}", | ||
{ | ||
latestVersion: scenarioState.latestVersionId, | ||
deployedVersionDescription: scenarioState?.deployedVersionId | ||
? ` (version ${scenarioState.deployedVersionId} is deployed)` | ||
: ``, | ||
}, | ||
) | ||
: actionTooltip === ActionTooltip.NotAllowedInCurrentState | ||
? t("panels.actions.perform-single-execution.tooltip.not-allowed-in-current-state", "Disabled for {{ status }} status.", { | ||
status: scenarioState.status.name, | ||
}) | ||
: "run now"; | ||
|
||
if (isVisible) { | ||
return ( | ||
<ToolbarButton | ||
name={t("panels.actions.perform-single-execution.button", "run now")} | ||
title={tooltip} | ||
disabled={!available} | ||
icon={<Icon />} | ||
onClick={() => | ||
open<ToggleProcessActionModalData>({ | ||
title: message, | ||
kind: WindowKind.deployProcess, | ||
width: ACTION_DIALOG_WIDTH, | ||
meta: { action }, | ||
}) | ||
} | ||
type={type} | ||
/> | ||
); | ||
} else return <></>; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,13 +5,7 @@ import pl.touk.nussknacker.engine.api.ProcessVersion | |
import pl.touk.nussknacker.engine.api.process.ProcessName | ||
import pl.touk.nussknacker.engine.api.test.ScenarioTestData | ||
import pl.touk.nussknacker.engine.canonicalgraph.CanonicalProcess | ||
import pl.touk.nussknacker.engine.deployment.{ | ||
CustomActionResult, | ||
DeploymentData, | ||
DeploymentId, | ||
ExternalDeploymentId, | ||
User | ||
} | ||
import pl.touk.nussknacker.engine.deployment._ | ||
import pl.touk.nussknacker.engine.testmode.TestProcess.TestResults | ||
|
||
// DM Prefix is from Deployment Manager, to distinguish from commands passed into the domain service layer (DeploymentService) | ||
|
@@ -86,3 +80,9 @@ case class DMCancelScenarioCommand(scenarioName: ProcessName, user: User) extend | |
|
||
case class DMStopScenarioCommand(scenarioName: ProcessName, savepointDir: Option[String], user: User) | ||
extends DMScenarioCommand[SavepointResult] | ||
|
||
case class DMPerformSingleExecutionCommand( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added in this PR description the general plan for periodics, especially the change that is already in progress. I'm not sure ATM about the future of CustomAction's. We aren't using them internally anymore - "run now" was our only usage. They are left in the codebased and APIs right now, so Nu users can still use them. I guess we need to decide, whether to leave CustomAction's as they are, or remove them. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should remove custom actions. It was done only for this one thing. It complicates deployments mechanism and slow down development. Let's add a removal step to the plan |
||
processVersion: ProcessVersion, | ||
canonicalProcess: CanonicalProcess, | ||
user: User, | ||
) extends DMScenarioCommand[SingleExecutionResult] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I see, there is no option to disable a custom action based on FE types. Do we need this
disabled
flag?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is part of common
ToolbarButtonProps
, used for all buttons. AFAIK this value must be provided. I guess at the moment it is the only button, that is never disabled on FE side, so constantfalse
provided hereAfter Arek's comments I added internationalization of tooltip messages, I think it needs FE review too.