mirror of
https://github.com/node-red/node-red
synced 2024-11-21 23:48:30 +00:00
Merge pull request #4889 from GogoVega/fix-4888
Fix wrong unlock state when event is triggered after deployment
This commit is contained in:
commit
35f35705a5
@ -589,7 +589,9 @@ RED.deploy = (function() {
|
|||||||
RED.notify('<p>' + RED._("deploy.successfulDeploy") + '</p>', "success");
|
RED.notify('<p>' + RED._("deploy.successfulDeploy") + '</p>', "success");
|
||||||
}
|
}
|
||||||
const flowsToLock = new Set()
|
const flowsToLock = new Set()
|
||||||
|
// Node's properties cannot be modified if its workspace is locked.
|
||||||
function ensureUnlocked(id) {
|
function ensureUnlocked(id) {
|
||||||
|
// TODO: `RED.nodes.subflow` is useless
|
||||||
const flow = id && (RED.nodes.workspace(id) || RED.nodes.subflow(id) || null);
|
const flow = id && (RED.nodes.workspace(id) || RED.nodes.subflow(id) || null);
|
||||||
const isLocked = flow ? flow.locked : false;
|
const isLocked = flow ? flow.locked : false;
|
||||||
if (flow && isLocked) {
|
if (flow && isLocked) {
|
||||||
@ -642,6 +644,7 @@ RED.deploy = (function() {
|
|||||||
delete confNode.credentials;
|
delete confNode.credentials;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
// Subflow cannot be locked
|
||||||
RED.nodes.eachSubflow(function (subflow) {
|
RED.nodes.eachSubflow(function (subflow) {
|
||||||
if (subflow.changed) {
|
if (subflow.changed) {
|
||||||
subflow.changed = false;
|
subflow.changed = false;
|
||||||
@ -650,12 +653,18 @@ RED.deploy = (function() {
|
|||||||
});
|
});
|
||||||
RED.nodes.eachWorkspace(function (ws) {
|
RED.nodes.eachWorkspace(function (ws) {
|
||||||
if (ws.changed || ws.added) {
|
if (ws.changed || ws.added) {
|
||||||
ensureUnlocked(ws.z)
|
// Ensure the Workspace is unlocked to modify its properties.
|
||||||
|
ensureUnlocked(ws.id);
|
||||||
ws.changed = false;
|
ws.changed = false;
|
||||||
delete ws.added
|
delete ws.added
|
||||||
|
if (flowsToLock.has(ws)) {
|
||||||
|
ws.locked = true;
|
||||||
|
flowsToLock.delete(ws);
|
||||||
|
}
|
||||||
RED.events.emit("flows:change", ws)
|
RED.events.emit("flows:change", ws)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
// Ensures all workspaces to be locked have been locked.
|
||||||
flowsToLock.forEach(flow => {
|
flowsToLock.forEach(flow => {
|
||||||
flow.locked = true
|
flow.locked = true
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user