From 32540dd0e6ef97a1e0de19afb31e0ef05460eded Mon Sep 17 00:00:00 2001 From: GogoVega <92022724+GogoVega@users.noreply.github.com> Date: Mon, 23 Sep 2024 16:16:53 +0200 Subject: [PATCH 1/2] Fix wrong unlock state when event is triggered --- .../@node-red/editor-client/src/js/ui/deploy.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/deploy.js b/packages/node_modules/@node-red/editor-client/src/js/ui/deploy.js index 25a67907c..e429c1586 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/deploy.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/deploy.js @@ -589,6 +589,7 @@ RED.deploy = (function() { RED.notify('

' + RED._("deploy.successfulDeploy") + '

', "success"); } const flowsToLock = new Set() + // Node's properties cannot be modified if its workspace is locked. function ensureUnlocked(id) { const flow = id && (RED.nodes.workspace(id) || RED.nodes.subflow(id) || null); const isLocked = flow ? flow.locked : false; @@ -645,6 +646,9 @@ RED.deploy = (function() { RED.nodes.eachSubflow(function (subflow) { if (subflow.changed) { subflow.changed = false; + if (flowsToLock.has(subflow)) { + subflow.locked = true; + } RED.events.emit("subflows:change", subflow); } }); @@ -653,9 +657,13 @@ RED.deploy = (function() { ensureUnlocked(ws.z) ws.changed = false; delete ws.added + if (flowsToLock.has(ws)) { + ws.locked = true; + } RED.events.emit("flows:change", ws) } }); + // Ensures all workspaces/subflows to be locked have been locked. flowsToLock.forEach(flow => { flow.locked = true }) From 49a3eded59e59b6dc1207fcd872233aa0cb2e701 Mon Sep 17 00:00:00 2001 From: GogoVega <92022724+GogoVega@users.noreply.github.com> Date: Tue, 8 Oct 2024 18:10:28 +0200 Subject: [PATCH 2/2] Apply code review + add comments Co-authored-by: Nick O'Leary --- .../@node-red/editor-client/src/js/ui/deploy.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/deploy.js b/packages/node_modules/@node-red/editor-client/src/js/ui/deploy.js index e429c1586..ed503bcfe 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/deploy.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/deploy.js @@ -591,6 +591,7 @@ RED.deploy = (function() { const flowsToLock = new Set() // Node's properties cannot be modified if its workspace is locked. function ensureUnlocked(id) { + // TODO: `RED.nodes.subflow` is useless const flow = id && (RED.nodes.workspace(id) || RED.nodes.subflow(id) || null); const isLocked = flow ? flow.locked : false; if (flow && isLocked) { @@ -643,27 +644,27 @@ RED.deploy = (function() { delete confNode.credentials; } }); + // Subflow cannot be locked RED.nodes.eachSubflow(function (subflow) { if (subflow.changed) { subflow.changed = false; - if (flowsToLock.has(subflow)) { - subflow.locked = true; - } RED.events.emit("subflows:change", subflow); } }); RED.nodes.eachWorkspace(function (ws) { if (ws.changed || ws.added) { - ensureUnlocked(ws.z) + // Ensure the Workspace is unlocked to modify its properties. + ensureUnlocked(ws.id); ws.changed = false; delete ws.added if (flowsToLock.has(ws)) { ws.locked = true; + flowsToLock.delete(ws); } RED.events.emit("flows:change", ws) } }); - // Ensures all workspaces/subflows to be locked have been locked. + // Ensures all workspaces to be locked have been locked. flowsToLock.forEach(flow => { flow.locked = true })