-
Notifications
You must be signed in to change notification settings - Fork 94
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
[Nu-5490] Expand Custom Action with display policy #5491
Changes from 8 commits
900384c
8511475
5a440b9
f2ea1de
50c888e
5a355fd
eabdbfa
e1b6633
1ab8474
97a1cb5
8e2918c
4f433e6
8875442
375d8b5
e1df125
5f241ef
bb77e36
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import {CustomActionDisplayPolicy} from "../types"; | ||
import {useSelector} from "react-redux"; | ||
import {getProcessName, getProcessVersionId} from "../reducers/selectors/graph"; | ||
import HttpService from "../http/HttpService"; | ||
|
||
export async function resolveCustomActionDisplayability(displayPolicy: CustomActionDisplayPolicy){ | ||
const processName = useSelector(getProcessName); | ||
const processVersionId = useSelector(getProcessVersionId); | ||
|
||
switch(displayPolicy) { | ||
case CustomActionDisplayPolicy.CurrentlyViewedProcessVersionIsDeployed: | ||
try { | ||
const response = await HttpService.fetchLastDeployedVersionId(processName); | ||
const data = response.data; | ||
return data.versionId === processVersionId; | ||
} catch (error) { | ||
console.error("Error while fetching last deployed version ID:", error); | ||
return false; | ||
} | ||
default: | ||
return false; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ case class CustomAction( | |
name: String, | ||
// We cannot use "engine.api.deployment.StateStatus" because it can be implemented as a class containing nonconstant attributes | ||
allowedStateStatusNames: List[String], | ||
displayPolicy: Option[CustomActionDisplayPolicy] = None, | ||
parameters: List[CustomActionParameter] = Nil, | ||
icon: Option[URI] = None | ||
) | ||
|
@@ -32,3 +33,8 @@ case class CustomActionParameter(name: String, editor: ParameterEditor) | |
case class CustomActionRequest(name: String, processVersion: ProcessVersion, user: User, params: Map[String, String]) | ||
|
||
case class CustomActionResult(req: CustomActionRequest, msg: String) | ||
|
||
sealed trait CustomActionDisplayPolicy | ||
|
||
// TODO: Add more | ||
case object CurrentlyViewedProcessVersionIsDeployed extends CustomActionDisplayPolicy | ||
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'm not sure if it is good approach. Those policies seem to be instance-specific, but each NU instance can be configured with different custom actions, different policies. What happens when I want to add my own custom policy? E.g I want a button that is enabled when scenario diagram contains specified node. Do I need to hardcode it here and in designer/client/src/helpers/customActionDisplayabilityResolver.ts ? 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. Answering to your very last question, the answer is yes. If such hardcoded solution cannot be taken into account, the natural improvement is to create some configuration language (implemented using yaml, json, whatever), send it thru' the backend and teach frontend to read it. And of course we should not then use selaed traits. |
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.
Can we use results of
processService.getLatestProcessWithDetails
orprocessService.getProcessWithDetails
instead of adding new endpoint? SeeScenarioWithDetails.lastDeployedAction
, there is some info on current and last deployed version.