Add `oneditsave` credentials changes to history

pull/4797/head
GogoVega 2024-10-25 23:33:19 +02:00
parent ed4b98b598
commit 966064328f
No known key found for this signature in database
GPG Key ID: E1E048B63AC5AC2B
1 changed files with 26 additions and 0 deletions

View File

@ -804,6 +804,17 @@ RED.editor = (function() {
}
}
const oldCreds = {};
if (editing_node._def.credentials) {
for (const prop in editing_node._def.credentials) {
if (Object.prototype.hasOwnProperty.call(editing_node._def.credentials, prop)) {
if (prop in editing_node.credentials) {
oldCreds[prop] = editing_node.credentials[prop];
}
}
}
}
try {
const rc = editing_node._def.oneditsave.call(editing_node);
if (rc === true) {
@ -835,6 +846,21 @@ RED.editor = (function() {
}
}
}
if (editing_node._def.credentials) {
for (const prop in editing_node._def.credentials) {
if (Object.prototype.hasOwnProperty.call(editing_node._def.credentials, prop)) {
if (oldCreds[prop] !== editing_node.credentials[prop]) {
if (editing_node.credentials[prop] === '__PWRD__') {
continue;
}
editState.changes.credentials = editState.changes.credentials || {};
editState.changes.credentials[prop] = oldCreds[prop];
editState.changed = true;
}
}
}
}
}
}