Added branch flip feature
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import React, { useState, useEffect, useLayoutEffect } from "react";
|
import React, { useState, useEffect, useLayoutEffect, useMemo } from "react";
|
||||||
import { toast } from 'react-toastify';
|
import { toast } from 'react-toastify';
|
||||||
import { makeStyles, createStyles } from "@mui/styles";
|
import { makeStyles, createStyles } from "@mui/styles";
|
||||||
import theme from '../theme.jsx';
|
import theme from '../theme.jsx';
|
||||||
@@ -207,16 +207,16 @@ const ParsedAction = (props) => {
|
|||||||
}
|
}
|
||||||
}, [expansionModalOpen])
|
}, [expansionModalOpen])
|
||||||
|
|
||||||
useEffect(() => {
|
// useEffect(() => {
|
||||||
setParamValues(selectedAction.parameters.map((param) => {
|
// setParamValues(selectedAction.parameters?.map((param) => {
|
||||||
return {
|
// return {
|
||||||
name: param.name,
|
// name: param.name,
|
||||||
value: param.value,
|
// value: param.value,
|
||||||
}
|
// }
|
||||||
}))
|
// }))
|
||||||
},[
|
// },[
|
||||||
selectedAction, selectedApp,setNewSelectedAction, workflow,
|
// selectedAction, selectedApp,setNewSelectedAction, workflow,
|
||||||
])
|
// ])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (selectedAction.parameters === null || selectedAction.parameters === undefined) {
|
if (selectedAction.parameters === null || selectedAction.parameters === undefined) {
|
||||||
@@ -565,6 +565,79 @@ const ParsedAction = (props) => {
|
|||||||
setActionlist(newActionList);
|
setActionlist(newActionList);
|
||||||
}, [workflow.execution_variables, workflow.workflow_variables, workflowExecutions, workflow, selectedAction, listCache, getParents]);
|
}, [workflow.execution_variables, workflow.workflow_variables, workflowExecutions, workflow, selectedAction, listCache, getParents]);
|
||||||
|
|
||||||
|
|
||||||
|
const memoizedParam = useMemo(() => {
|
||||||
|
let appActions = [];
|
||||||
|
if (getParents) {
|
||||||
|
const parents = getParents(selectedAction);
|
||||||
|
if (parents.length > 1) {
|
||||||
|
const labels = [];
|
||||||
|
for (let parentNode of parents) {
|
||||||
|
if (parentNode.label !== "Execution Argument" && !labels.includes(parentNode.label)) {
|
||||||
|
labels.push(parentNode.label);
|
||||||
|
let exampleData = parentNode.example ?? "";
|
||||||
|
if (!exampleData && workflowExecutions.length > 0) {
|
||||||
|
for (let exec of workflowExecutions) {
|
||||||
|
const foundResult = exec.results?.find(result => result.action.id === parentNode.id);
|
||||||
|
if (foundResult) {
|
||||||
|
const valid = validateJson(foundResult.result);
|
||||||
|
if (valid.valid && valid.result.success !== false) {
|
||||||
|
exampleData = valid.result;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
appActions.push({
|
||||||
|
type: "action",
|
||||||
|
id: parentNode.id,
|
||||||
|
name: parentNode.label,
|
||||||
|
autocomplete: parentNode.label.split(" ").join("_"),
|
||||||
|
example: exampleData,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let newParameters = selectedAction.parameters?.map((param) => {
|
||||||
|
let paramvalue = param.value;
|
||||||
|
if(paramvalue.includes("$")){
|
||||||
|
let actions = workflow.actions?.map((action) => {
|
||||||
|
return "$"+action.label.toLowerCase();
|
||||||
|
})
|
||||||
|
if(actionlist.length > 0){
|
||||||
|
let appParentActions = appActions?.map(action => "$" + action.name.toLowerCase());
|
||||||
|
let notPresentAction = actions?.filter((action) => !appParentActions?.includes(action))
|
||||||
|
console.log("ACTIONS: ", actions)
|
||||||
|
console.log("APP ACTIONS: ", appParentActions)
|
||||||
|
console.log("NOT PRESENT: ", notPresentAction)
|
||||||
|
notPresentAction?.forEach((action) => {
|
||||||
|
console.log("Not included Action: ", action)
|
||||||
|
if(paramvalue.includes(action)){
|
||||||
|
paramvalue = paramvalue.replace(action, "")
|
||||||
|
paramvalue = paramvalue.replace(/^\s*[\r\n]/gm, "");
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.log("After removing param value: ", paramvalue)
|
||||||
|
return {...param, value: paramvalue}
|
||||||
|
});
|
||||||
|
selectedAction.parameters = newParameters;
|
||||||
|
setSelectedAction(selectedAction);
|
||||||
|
return newParameters;
|
||||||
|
},[actionlist,selectedAction,workflow.actions,workflow,selectedApp,setNewSelectedAction])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setParamValues(memoizedParam.map((param) => {
|
||||||
|
return {
|
||||||
|
name: param.name,
|
||||||
|
value: param.value,
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
},[memoizedParam])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
selectedNameChange(appActionName)
|
selectedNameChange(appActionName)
|
||||||
|
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ import {
|
|||||||
ArrowForward as ArrowForwardIcon,
|
ArrowForward as ArrowForwardIcon,
|
||||||
|
|
||||||
} from "@mui/icons-material";
|
} from "@mui/icons-material";
|
||||||
|
import SwapHorizIcon from '@mui/icons-material/SwapHoriz';
|
||||||
//import * as cytoscape from "cytoscape";
|
//import * as cytoscape from "cytoscape";
|
||||||
import cytoscape from "cytoscape";
|
import cytoscape from "cytoscape";
|
||||||
|
|
||||||
@@ -11672,10 +11672,10 @@ const releaseToConnectLabel = "Release to Connect"
|
|||||||
</Typography>
|
</Typography>
|
||||||
: null}
|
: null}
|
||||||
|
|
||||||
<div style={{position: "absolute", bottom: 10, width: "90%", margin: "auto", }}>
|
<div style={{position: "absolute", bottom: 15, width: "90%", margin: "auto", }}>
|
||||||
{/*
|
|
||||||
<Button
|
<Button
|
||||||
style={{ margin: "auto", marginTop: "10px" }}
|
style={{ margin: "auto", marginTop: "15px" }}
|
||||||
color="secondary"
|
color="secondary"
|
||||||
fullWidth
|
fullWidth
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
@@ -11689,33 +11689,37 @@ const releaseToConnectLabel = "Release to Connect"
|
|||||||
|
|
||||||
var branchdata = JSON.parse(JSON.stringify(foundBranch.data()))
|
var branchdata = JSON.parse(JSON.stringify(foundBranch.data()))
|
||||||
console.log("BEFORE: ", branchdata)
|
console.log("BEFORE: ", branchdata)
|
||||||
|
console.log("Start node", workflow.start)
|
||||||
const newid = uuidv4()
|
const startNode = workflow.start
|
||||||
branchdata.source = target
|
if(source === startNode){
|
||||||
branchdata.target = source
|
toast("Can't point to Start Node")
|
||||||
branchdata.id = newid
|
}else{
|
||||||
branchdata._id = newid
|
const newid = uuidv4()
|
||||||
|
branchdata.source = target
|
||||||
foundBranch.remove()
|
branchdata.target = source
|
||||||
|
branchdata.id = newid
|
||||||
setTimeout(() => {
|
branchdata._id = newid
|
||||||
toast("Edge being added!")
|
|
||||||
cy.add({
|
foundBranch.remove()
|
||||||
group: "edges",
|
|
||||||
source: target,
|
cy.add({
|
||||||
target: source,
|
group: "edges",
|
||||||
data: branchdata,
|
source: target,
|
||||||
})
|
target: source,
|
||||||
}, 2500)
|
data: branchdata,
|
||||||
|
})
|
||||||
|
selectedEdge.id = newid
|
||||||
|
setSelectedEdge(selectedEdge)
|
||||||
|
toast("Branch direction changed!")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
fullWidth
|
fullWidth
|
||||||
>
|
>
|
||||||
<DeleteIcon style={{marginRight: 10, }}/>
|
<SwapHorizIcon style={{marginRight: 10 }}/>
|
||||||
Change Direction
|
Flip Branch
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
{/*<Button
|
||||||
style={{ margin: "auto", }}
|
style={{ margin: "auto", }}
|
||||||
color="secondary"
|
color="secondary"
|
||||||
fullWidth
|
fullWidth
|
||||||
@@ -11741,7 +11745,7 @@ const releaseToConnectLabel = "Release to Connect"
|
|||||||
</Button>
|
</Button>
|
||||||
*/}
|
*/}
|
||||||
<Button
|
<Button
|
||||||
style={{ margin: "auto", marginTop: 50, }}
|
style={{ margin: "auto", marginTop: 20, }}
|
||||||
color="secondary"
|
color="secondary"
|
||||||
fullWidth
|
fullWidth
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
@@ -11751,7 +11755,6 @@ const releaseToConnectLabel = "Release to Connect"
|
|||||||
if (foundBranch !== undefined && foundBranch !== null) {
|
if (foundBranch !== undefined && foundBranch !== null) {
|
||||||
foundBranch.remove()
|
foundBranch.remove()
|
||||||
}
|
}
|
||||||
|
|
||||||
setConditionsModalOpen(false)
|
setConditionsModalOpen(false)
|
||||||
setSelectedEdge({})
|
setSelectedEdge({})
|
||||||
}}
|
}}
|
||||||
|
|||||||
Reference in New Issue
Block a user