Merge pull request #1434 from Monilprajapati/mergingIssue

Merging issue
This commit is contained in:
Frikky
2024-06-22 23:45:38 +02:00
committed by GitHub
+64 -48
View File
@@ -5699,16 +5699,15 @@ const releaseToConnectLabel = "Release to Connect"
// Checks for errors in edges when they're added // Checks for errors in edges when they're added
const onEdgeAdded = (event) => { const onEdgeAdded = (event) => {
setLastSaved(false); const edge = event.target.data()
const edge = event.target.data(); //console.log("EDGE ADDED!: ", edge)
//console.log("edge added: ", edge)
if (edge.source === undefined && edge.target === undefined) { if (edge.source === undefined && edge.target === undefined) {
// console.log("Edge source and target is undefined")
return return
} }
if (edge.readded === true) { if (edge.readded === true) {
console.log("Readded edge - stopping") // console.log("Readded edge - stopping")
event.target.data("readded", false) event.target.data("readded", false)
return return
@@ -5717,6 +5716,7 @@ const releaseToConnectLabel = "Release to Connect"
const sourcenode = cy.getElementById(edge.source) const sourcenode = cy.getElementById(edge.source)
const destinationnode = cy.getElementById(edge.target) const destinationnode = cy.getElementById(edge.target)
if (sourcenode === undefined || sourcenode === null || destinationnode === undefined || destinationnode === null) { if (sourcenode === undefined || sourcenode === null || destinationnode === undefined || destinationnode === null) {
// console.log("Source or destination node is undefined")
} else { } else {
//console.log("Edge added: Is it a trigger? If so, check if it already has a branch and remove it: ", sourcenode.data()) //console.log("Edge added: Is it a trigger? If so, check if it already has a branch and remove it: ", sourcenode.data())
if (sourcenode.data("type") === "TRIGGER") { if (sourcenode.data("type") === "TRIGGER") {
@@ -5729,17 +5729,17 @@ const releaseToConnectLabel = "Release to Connect"
console.log("Node: ", targetedge) console.log("Node: ", targetedge)
if (targetedge !== -1) { if (targetedge !== -1) {
event.target.remove()
//console.log("Found branch already!") //console.log("Found branch already!")
toast.error("Triggers can have exactly one target node") toast.error("Triggers can have exactly one target node")
event.target.remove()
return return
// name: "Shuffle Workflow", // name: "Shuffle Workflow",
// name: "User Input", // name: "User Input",
} else { } else {
console.log("Node doesn't already have one") // console.log("Node doesn't already have one")
} }
}, 50) }, 50)
} }
@@ -5753,6 +5753,10 @@ const releaseToConnectLabel = "Release to Connect"
} }
} }
if (edge.decorator === true) {
// console.log("Doing nothing to branch because decorator")
return
}
var targetnode = workflow.triggers.findIndex( var targetnode = workflow.triggers.findIndex(
(data) => data.id === edge.target (data) => data.id === edge.target
@@ -5770,7 +5774,7 @@ const releaseToConnectLabel = "Release to Connect"
if (eventTarget.data("isButton") === true) { if (eventTarget.data("isButton") === true) {
const parentNode = cy.getElementById(eventTarget.data("attachedTo")) const parentNode = cy.getElementById(eventTarget.data("attachedTo"))
event.target.remove() event.target.remove()
console.log("Setting it to parentnode: ", parentNode.data()) // console.log("Setting it to parentnode: ", parentNode.data())
if (parentNode !== undefined && parentNode !== null) { if (parentNode !== undefined && parentNode !== null) {
//event.target.data("target", eventTarget.data("attachedTo")) //event.target.data("target", eventTarget.data("attachedTo"))
@@ -5792,15 +5796,14 @@ const releaseToConnectLabel = "Release to Connect"
} }
} }
if ( if (eventTarget.data("isDescriptor") === true || eventTarget.data("type") === "COMMENT") {
eventTarget.data("isDescriptor") === true || // console.log("Removing because of descriptor or comment")
eventTarget.data("type") === "COMMENT" event.target.remove()
) { return
console.log("Removing because of descriptor or comment")
event.target.remove();
return;
} }
setLastSaved(false)
targetnode = -1; targetnode = -1;
// Check if: // Check if:
@@ -5808,38 +5811,51 @@ const releaseToConnectLabel = "Release to Connect"
// dest == dest && source == source // dest == dest && source == source
// backend: check all children? to stop recursion // backend: check all children? to stop recursion
var found = false; var found = false;
for (let branchkey in workflow.branches) { const branches = cy.edges().jsons()
if (
workflow.branches[branchkey].destination_id === edge.source && const startNode = cy.nodes().jsons().find((node) => node.data.isStartNode === true)
workflow.branches[branchkey].source_id === edge.target var startnodeId = workflow.start
) { if (startNode !== undefined && startNode !== null) {
toast("A branch in the opposite direction already exists"); startnodeId = startNode.data.id
event.target.remove(); }
found = true;
break; //for (let branchkey in workflow.branches) {
} else if ( for (let branchkey in branches) {
workflow.branches[branchkey].destination_id === edge.target && const branch = branches[branchkey].data
workflow.branches[branchkey].source_id === edge.source
) { //if (workflow.branches[branchkey].destination_id === edge.source && workflow.branches[branchkey].source_id === edge.target) {
//toast("That branch already exists"); if (branch.target === edge.source && branch.source === edge.target) {
event.target.remove(); toast("A branch in the opposite direction already exists")
event.target.remove()
found = true
break
//} else if (workflow.branches[branchkey].destination_id === edge.target && workflow.branches[branchkey].source_id === edge.source) {
} else if (branch.target === edge.target && branch.source === edge.source) {
if (branch.conditions === undefined) {
// Edgehandles
} else {
// console.log("Removing because the same branch already exists")
event.target.remove()
found = true
break
}
} else if (edge.target === startnodeId) {
targetnode = workflow.triggers.findIndex((data) => data.id === edge.source)
found = true;
break;
} else if (edge.target === workflow.start) {
targetnode = workflow.triggers.findIndex(
(data) => data.id === edge.source
);
if (targetnode === -1) { if (targetnode === -1) {
if (targetnode.type !== "TRIGGER") { if (targetnode.type !== "TRIGGER") {
toast("Can't make arrow to starting node"); toast("Can't make arrow to starting node")
event.target.remove(); event.target.remove()
break; break
} }
found = true; found = true;
} }
} else if (edge.source === workflow.branches[branchkey].source_id) { //} else if (edge.source === workflow.branches[branchkey].source_id) {
} else if (edge.source === branch.source) {
// FIXME: Verify multi-target for triggers // FIXME: Verify multi-target for triggers
// 1. Check if destination exists // 1. Check if destination exists
// 2. Check if source is a trigger // 2. Check if source is a trigger
@@ -5883,7 +5899,6 @@ const releaseToConnectLabel = "Release to Connect"
newdst !== null newdst !== null
) { ) {
const dstdata = RunAutocompleter(newdst.data()); const dstdata = RunAutocompleter(newdst.data());
//console.log("DST Autocompleter: ", dstdata);
} }
var newbranch = { var newbranch = {
@@ -12535,9 +12550,9 @@ const releaseToConnectLabel = "Release to Connect"
let mappingWithName = {} let mappingWithName = {}
let listWithValues = workflow.triggers[selectedTriggerIndex].parameters[5]?.value.split(";").filter(e => e).map(e => e.split("=")) let listWithValues = workflow.triggers[selectedTriggerIndex].parameters[5]?.value.split(";").filter(e => e).map(e => e.split("="))
console.log("LIST WITH VALUES: ", listWithValues) console.log("LIST WITH VALUES: ", listWithValues)
if (listWithValues === undefined || listWithValues === null || listWithValues.length === 0) { // if (listWithValues === undefined || listWithValues === null || listWithValues.length === 0) {
return "no-overrides"; // return "no-overrides";
} // }
for (let i = 0; i < listWithValues.length; i++) { for (let i = 0; i < listWithValues.length; i++) {
mappingWithName[listWithValues[i][0]] = listWithValues[i][1] mappingWithName[listWithValues[i][0]] = listWithValues[i][1]
@@ -15793,7 +15808,6 @@ const releaseToConnectLabel = "Release to Connect"
right: 0, right: 0,
left: isMobile ? 20 : leftBarSize + 20, left: isMobile ? 20 : leftBarSize + 20,
top: isMobile ? 30 : appBarSize + 20, top: isMobile ? 30 : appBarSize + 20,
pointerEvents: "none",
} }
@@ -15814,7 +15828,6 @@ const releaseToConnectLabel = "Release to Connect"
<div style={topBarStyle}> <div style={topBarStyle}>
<div style={{ <div style={{
margin: "0px 10px 0px 10px", margin: "0px 10px 0px 10px",
pointerEvents: "none",
}}> }}>
<Breadcrumbs <Breadcrumbs
aria-label="breadcrumb" aria-label="breadcrumb"
@@ -15839,7 +15852,6 @@ const releaseToConnectLabel = "Release to Connect"
</Link> </Link>
<h2 style={{ <h2 style={{
margin: 0, margin: 0,
pointerEvents: "none",
}}>{workflow.name}</h2> }}>{workflow.name}</h2>
</Breadcrumbs> </Breadcrumbs>
@@ -18460,7 +18472,7 @@ const releaseToConnectLabel = "Release to Connect"
</div> </div>
{foundnotifications > 0 ? {foundnotifications > 0 ?
<Tooltip title={"This workflow created " + foundnotifications + " notification(s)"} placement="top"> <Tooltip title={"This workflow created " + foundnotifications + " notification(s). Click to explore them."} placement="top">
<ErrorOutlineIcon <ErrorOutlineIcon
style={{color: "rgba(255,255,255,0.4)", marginTop: 10, marginRight: 10, }} style={{color: "rgba(255,255,255,0.4)", marginTop: 10, marginRight: 10, }}
onClick={(e) => { onClick={(e) => {
@@ -21473,6 +21485,10 @@ const releaseToConnectLabel = "Release to Connect"
setElements([]) setElements([])
} }
// // Remove all edges
// cy.edges().remove()
// cy.nodes().remove()
// Remove all cy nodes // Remove all cy nodes
setTimeout(() => { setTimeout(() => {
setupGraph(newrevision) setupGraph(newrevision)