mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
update according to PR comments
This commit is contained in:
@@ -691,6 +691,21 @@ RED.nodes = (function() {
|
||||
node[d] = n[d];
|
||||
}
|
||||
}
|
||||
var credentialSet = {};
|
||||
if (n.credentials) {
|
||||
for (var tabCred in n.credentials) {
|
||||
if (n.credentials.hasOwnProperty(tabCred)) {
|
||||
if (!n.credentials._ ||
|
||||
n.credentials["has_"+tabCred] != n.credentials._["has_"+tabCred] ||
|
||||
(n.credentials["has_"+tabCred] && n.credentials[tabCred])) {
|
||||
credentialSet[tabCred] = n.credentials[tabCred];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Object.keys(credentialSet).length > 0) {
|
||||
node.credentials = credentialSet;
|
||||
}
|
||||
}
|
||||
return node;
|
||||
}
|
||||
/**
|
||||
@@ -740,8 +755,10 @@ RED.nodes = (function() {
|
||||
}
|
||||
if (exportCreds) {
|
||||
var credentialSet = {};
|
||||
if (/^subflow:/.test(node.type) && n.credentials) {
|
||||
// A subflow instance node can have arbitrary creds
|
||||
if ((/^subflow:/.test(node.type) ||
|
||||
(node.type === "group")) &&
|
||||
n.credentials) {
|
||||
// A subflow instance/group node can have arbitrary creds
|
||||
for (var sfCred in n.credentials) {
|
||||
if (n.credentials.hasOwnProperty(sfCred)) {
|
||||
if (!n.credentials._ ||
|
||||
|
@@ -507,7 +507,7 @@ RED.editor = (function() {
|
||||
done();
|
||||
}
|
||||
}
|
||||
if (definition.credentials || /^subflow:/.test(definition.type)) {
|
||||
if (definition.credentials || /^subflow:/.test(definition.type) || (node.type === "group")) {
|
||||
if (node.credentials) {
|
||||
populateCredentialsInputs(node, definition.credentials, node.credentials, prefix);
|
||||
completePrepare();
|
||||
@@ -1467,7 +1467,7 @@ var buildingEditDialog = false;
|
||||
changes.env = editing_node.env;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (changed) {
|
||||
var wasChanged = editing_node.changed;
|
||||
|
@@ -120,6 +120,36 @@ RED.workspaces = (function() {
|
||||
dialogForm.i18n();
|
||||
}
|
||||
|
||||
function getNodeCredentials(type, id, done) {
|
||||
var timeoutNotification;
|
||||
var intialTimeout = setTimeout(function() {
|
||||
timeoutNotification = RED.notify($('<p data-i18n="[prepend]editor.loadCredentials"> <img src="red/images/spin.svg"/></p>').i18n(),{fixed: true})
|
||||
},800);
|
||||
|
||||
$.ajax({
|
||||
url: "credentials/tab/" + id,
|
||||
dataType: 'json',
|
||||
success: function(data) {
|
||||
if (timeoutNotification) {
|
||||
timeoutNotification.close();
|
||||
timeoutNotification = null;
|
||||
}
|
||||
clearTimeout(intialTimeout);
|
||||
done(data);
|
||||
},
|
||||
error: function(jqXHR,status,error) {
|
||||
if (timeoutNotification) {
|
||||
timeoutNotification.close();
|
||||
timeoutNotification = null;
|
||||
}
|
||||
clearTimeout(intialTimeout);
|
||||
RED.notify(RED._("editor.errors.credentialLoadFailed"),"error")
|
||||
done(null);
|
||||
},
|
||||
timeout: 30000,
|
||||
});
|
||||
}
|
||||
|
||||
function showEditWorkspaceDialog(id) {
|
||||
var workspace = RED.nodes.workspace(id);
|
||||
if (!workspace) {
|
||||
@@ -180,7 +210,6 @@ RED.workspaces = (function() {
|
||||
|
||||
var old_env = workspace.env;
|
||||
var new_env = RED.subflow.exportSubflowInstanceEnv(workspace);
|
||||
console.log("; NE", new_env);
|
||||
if (new_env && (new_env.length > 0)) {
|
||||
new_env.forEach(function(prop) {
|
||||
if (prop.type === "cred") {
|
||||
@@ -285,20 +314,37 @@ RED.workspaces = (function() {
|
||||
}).appendTo(editorContent).hide(),
|
||||
iconClass: "fa fa-list",
|
||||
};
|
||||
RED.subflow.buildPropertiesForm(workspace);
|
||||
editorTabs.addTab(tabPropertiesTab);
|
||||
|
||||
if (!workspace.hasOwnProperty("disabled")) {
|
||||
workspace.disabled = false;
|
||||
function cb() {
|
||||
RED.subflow.buildPropertiesForm(workspace);
|
||||
editorTabs.addTab(tabPropertiesTab);
|
||||
|
||||
if (!workspace.hasOwnProperty("disabled")) {
|
||||
workspace.disabled = false;
|
||||
}
|
||||
|
||||
$('<input id="node-input-disabled" type="checkbox">').prop("checked",workspace.disabled).appendTo(trayFooterLeft).toggleButton({
|
||||
enabledIcon: "fa-circle-thin",
|
||||
disabledIcon: "fa-ban",
|
||||
invertState: true
|
||||
})
|
||||
finishedBuilding = true;
|
||||
RED.tray.resize();
|
||||
}
|
||||
|
||||
if (workspace.credentials) {
|
||||
cb();
|
||||
}
|
||||
else {
|
||||
getNodeCredentials("tab", workspace.id, function(data) {
|
||||
if (data) {
|
||||
workspace.credentials = data;
|
||||
workspace.credentials._ = $.extend(true,{},data);
|
||||
}
|
||||
cb();
|
||||
});
|
||||
}
|
||||
|
||||
$('<input id="node-input-disabled" type="checkbox">').prop("checked",workspace.disabled).appendTo(trayFooterLeft).toggleButton({
|
||||
enabledIcon: "fa-circle-thin",
|
||||
disabledIcon: "fa-ban",
|
||||
invertState: true
|
||||
})
|
||||
finishedBuilding = true;
|
||||
RED.tray.resize();
|
||||
},
|
||||
close: function() {
|
||||
if (RED.view.state() != RED.state.IMPORT_DRAGGING) {
|
||||
|
Reference in New Issue
Block a user