mirror of
				https://github.com/node-red/node-red.git
				synced 2025-03-01 10:36:34 +00:00 
			
		
		
		
	Add env type to subflow env var types
Also remove date and regex types
This commit is contained in:
		| @@ -570,7 +570,7 @@ RED.editor = (function() { | ||||
|                     }).appendTo(row) | ||||
|  | ||||
|                     valueField.typedInput({default:'str', | ||||
|                                            types:['str','num','bool','json','bin','re','date'] | ||||
|                                            types:['str','num','bool','json','bin','env'] | ||||
|                                           }); | ||||
|  | ||||
|                     valueField.typedInput('type', opt.parent?(opt.type||opt.parent.type):opt.type); | ||||
|   | ||||
| @@ -265,7 +265,7 @@ class Subflow extends Flow { | ||||
|         if (env && env.hasOwnProperty(name)) { | ||||
|             var val = env[name]; | ||||
|             try { | ||||
|                 var ret = redUtil.evaluateNodeProperty(val.value, val.type, null, null, null); | ||||
|                 var ret = redUtil.evaluateNodeProperty(val.value, val.type, this.node, null, null); | ||||
|                 return ret; | ||||
|             } | ||||
|             catch (e) { | ||||
|   | ||||
| @@ -166,7 +166,7 @@ describe('subflow', function() { | ||||
|             n1.receive({payload:"foo"}); | ||||
|         }); | ||||
|     }); | ||||
|      | ||||
|  | ||||
|     it('should access env var of subflow instance', function(done) { | ||||
|         var flow = [ | ||||
|             {id:"t0", type:"tab", label:"", disabled:false, info:""}, | ||||
| @@ -256,13 +256,11 @@ describe('subflow', function() { | ||||
|             {id:"t0", type:"tab", label:"", disabled:false, info:""}, | ||||
|             {id:"n1", x:10, y:10, z:"t0", type:"subflow:s1", | ||||
|              env: [ | ||||
|                  {name: "KS", type: "str", value: "STR"}, | ||||
|                  {name: "KN", type: "num", value: "100"}, | ||||
|                  {name: "KB", type: "bool", value: "true"}, | ||||
|                  {name: "KJ", type: "json", value: "[1,2,3]"}, | ||||
|                  {name: "Kb", type: "bin", value: "[65,65]"}, | ||||
|                  {name: "KR", type: "re", value: "[A-Z]"}, | ||||
|                  {name: "KD", type: "date", value: ""} | ||||
|                  {name: "Ke", type: "env", value: "KS"} | ||||
|              ], | ||||
|              wires:[["n2"]]}, | ||||
|             {id:"n2", x:10, y:10, z:"t0", type:"helper", wires:[]}, | ||||
| @@ -275,10 +273,13 @@ describe('subflow', function() { | ||||
|              out:[{ | ||||
|                  x:10, y:10, | ||||
|                  wires:[ {id:"s1-n1", port:0} ] | ||||
|              }] | ||||
|              }], | ||||
|              env: [ | ||||
|                  {name: "KS", type: "str", value: "STR"} | ||||
|              ] | ||||
|             }, | ||||
|             {id:"s1-n1", x:10, y:10, z:"s1", type:"function", | ||||
|              func:"msg.VS = env.get('KS'); msg.VN = env.get('KN'); msg.VB = env.get('KB'); msg.VJ = env.get('KJ'); msg.Vb = env.get('Kb'); msg.VR = env.get('KR'); msg.VD = env.get('KD'); return msg;", | ||||
|              func:"msg.VE = env.get('Ke'); msg.VS = env.get('KS'); msg.VN = env.get('KN'); msg.VB = env.get('KB'); msg.VJ = env.get('KJ'); msg.Vb = env.get('Kb'); return msg;", | ||||
|              wires:[]} | ||||
|         ]; | ||||
|         helper.load(functionNode, flow, function() { | ||||
| @@ -292,14 +293,10 @@ describe('subflow', function() { | ||||
|                     msg.should.have.property("VJ", [1,2,3]); | ||||
|                     msg.should.have.property("Vb"); | ||||
|                     should.ok(msg.Vb instanceof Buffer); | ||||
|                     msg.should.have.property("VR"); | ||||
|                     should.ok(msg.VR instanceof RegExp); | ||||
|                     msg.should.have.property("VD"); | ||||
|                     should.ok((typeof msg.VD) === "number"); | ||||
|                     msg.should.have.property("VE","STR"); | ||||
|                     done(); | ||||
|                 } | ||||
|                 catch (e) { | ||||
|                     console.log(e); | ||||
|                     done(e); | ||||
|                 } | ||||
|             }); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user