1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Remove unused _info/_type subflow env var magic values

This commit is contained in:
Nick O'Leary 2020-05-22 20:54:06 +01:00
parent 7969dd431f
commit 1c94064c57
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9

View File

@ -47,38 +47,6 @@ function evaluateInputValue(value, type, node) {
return redUtil.evaluateNodeProperty(value, type, node, null, null);
}
/**
* Compose information object for env var
*/
function composeInfo(info, val) {
var result = {
name: info.name,
type: info.type,
value: val,
};
if (info.ui) {
var ui = info.ui;
result.ui = {
hasUI: ui.hasUI,
icon: ui.icon,
labels: ui.labels,
type: ui.type
};
var retUI = result.ui;
if (ui.type === "input") {
retUI.inputTypes = ui.inputTypes;
}
if (ui.type === "select") {
retUI.menu = ui.menu;
}
if (ui.type === "spinner") {
retUI.spinner = ui.spinner;
}
}
return result;
}
/**
* This class represents a subflow - which is handled as a special type of Flow
*/
@ -349,15 +317,8 @@ class Subflow extends Flow {
getSetting(name) {
if (!/^\$parent\./.test(name)) {
var env = this.env;
var is_info = name.endsWith("_info");
var is_type = name.endsWith("_type");
var ename = (is_info || is_type) ? name.substring(0, name.length -5) : name; // 5 = length of "_info"/"_type"
if (env && env.hasOwnProperty(ename)) {
var val = env[ename];
if (is_type) {
return val ? val.type : undefined;
}
if (env && env.hasOwnProperty(name)) {
var val = env[name];
// If this is an env type property we need to be careful not
// to get into lookup loops.
// 1. if the value to lookup is the same as this one, go straight to parent
@ -371,11 +332,7 @@ class Subflow extends Flow {
value = value.replace(new RegExp("\\${"+name+"}","g"),"${$parent."+name+"}");
}
try {
var ret = evaluateInputValue(value, type, this.node);
if (is_info) {
return composeInfo(val, ret);
}
return ret;
return evaluateInputValue(value, type, this.node);
}
catch (e) {
this.error(e);