From 00ff09a97f1cbadd0b4a4c1676b6fcc4d79c0d37 Mon Sep 17 00:00:00 2001 From: frikky Date: Tue, 2 Jun 2020 17:15:21 +0200 Subject: [PATCH] #39: Added check to all functions of useEffect --- frontend/src/AngularWorkflow.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/frontend/src/AngularWorkflow.js b/frontend/src/AngularWorkflow.js index 86fb1b6c..4a135227 100644 --- a/frontend/src/AngularWorkflow.js +++ b/frontend/src/AngularWorkflow.js @@ -172,7 +172,11 @@ const AngularWorkflow = (props) => { const [workflowExecutions, setWorkflowExecutions] = React.useState([]); const unloadText = 'Are you sure you want to leave?' - useBeforeunload(() => unloadText) + useBeforeunload(() => { + if (!lastSaved) { + return unloadText + } + }) const [elements, setElements] = useState([]) const { start, stop } = useInterval({ @@ -828,6 +832,7 @@ const AngularWorkflow = (props) => { const onEdgeSelect = (event) => { setRightSideBarOpen(true) + setLastSaved(false) const triggercheck = workflow.triggers.find(trigger => trigger.id === event.target.data()["source"]) if (triggercheck === undefined) { @@ -843,6 +848,7 @@ const AngularWorkflow = (props) => { const onNodeSelect = (event) => { const data = event.target.data() + setLastSaved(false) //console.log(data) if (data.type === "ACTION") { @@ -949,7 +955,7 @@ const AngularWorkflow = (props) => { } const onNodeAdded = (event) => { - //setLastSaved(false) + setLastSaved(false) const node = event.target if (node.isNode() && cy.nodes().size() === 1) { @@ -960,6 +966,7 @@ const AngularWorkflow = (props) => { } const onEdgeRemoved = (event) => { + setLastSaved(false) const edge = event.target workflow.branches = workflow.branches.filter(a => a.id !== edge.data().id) @@ -980,6 +987,7 @@ const AngularWorkflow = (props) => { const onNodeRemoved = (event) => { const node = event.target const data = node.data() + setLastSaved(false) //var currentnode = cy.getElementById(data.id) //if (currentnode.length === 0) { @@ -4340,7 +4348,6 @@ const AngularWorkflow = (props) => { return null } - setLastSaved(false) if (Object.getOwnPropertyNames(selectedAction).length > 0 && Object.getOwnPropertyNames(selectedApp).length > 0) { //console.time('ACTIONSTART'); return( @@ -4850,7 +4857,7 @@ const AngularWorkflow = (props) => { return (
{loadedCheck}