diff --git a/packages/node_modules/@node-red/editor-client/locales/en-US/editor.json b/packages/node_modules/@node-red/editor-client/locales/en-US/editor.json index c3ab1f8e0..7894f1ed2 100755 --- a/packages/node_modules/@node-red/editor-client/locales/en-US/editor.json +++ b/packages/node_modules/@node-red/editor-client/locales/en-US/editor.json @@ -342,6 +342,7 @@ "module": "Module", "license": "License", "licenseOther": "Other", + "type": "Node Type", "version": "Version", "versionPlaceholder": "x.y.z", "keys": "Keywords", diff --git a/packages/node_modules/@node-red/editor-client/src/js/nodes.js b/packages/node_modules/@node-red/editor-client/src/js/nodes.js index 7b5bbe471..3e513de08 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/nodes.js +++ b/packages/node_modules/@node-red/editor-client/src/js/nodes.js @@ -1921,6 +1921,18 @@ RED.nodes = (function() { RED.events.emit("groups:remove",group); } + function getNodeHelp(type) { + var helpContent = ""; + var helpElement = $("script[data-help-name='"+type+"']"); + if (helpElement) { + helpContent = helpElement.html(); + var helpType = helpElement.attr("type"); + if (helpType === "text/markdown") { + helpContent = RED.utils.renderMarkdown(helpContent); + } + } + return helpContent; + } return { init: function() { @@ -2000,6 +2012,7 @@ RED.nodes = (function() { registerType: registry.registerNodeType, getType: registry.getNodeType, + getNodeHelp: getNodeHelp, convertNode: convertNode, add: addNode, diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/palette.js b/packages/node_modules/@node-red/editor-client/src/js/ui/palette.js index ecee89d70..bd0b55cba 100755 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/palette.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/palette.js @@ -147,7 +147,7 @@ RED.palette = (function() { var popOverContent; try { var l = "

"+RED.text.bidi.enforceTextDirectionWithUCC(label)+"

"; - popOverContent = $('
').append($(l+(info?info:$("script[data-help-name='"+type+"']").html()||"

"+RED._("palette.noInfo")+"

").trim()) + popOverContent = $('
').append($(l+(info?info:RED.nodes.getNodeHelp(type)||"

"+RED._("palette.noInfo")+"

").trim()) .filter(function(n) { return (this.nodeType == 1 && this.nodeName == "P") || (this.nodeType == 3 && this.textContent.trim().length > 0) }).slice(0,2)); @@ -264,27 +264,6 @@ RED.palette = (function() { d.data('popover',popover); - // $(d).popover({ - // title:d.type, - // placement:"right", - // trigger: "hover", - // delay: { show: 750, hide: 50 }, - // html: true, - // container:'body' - // }); - // d.on("click", function() { - // RED.view.focus(); - // var helpText; - // if (nt.indexOf("subflow:") === 0) { - // helpText = RED.utils.renderMarkdown(RED.nodes.subflow(nt.substring(8)).info||"")||(''+RED._("sidebar.info.none")+''); - // } else { - // helpText = $("script[data-help-name='"+d.attr("data-palette-type")+"']").html()||(''+RED._("sidebar.info.none")+''); - // } - // // Don't look too closely. RED.sidebar.info.set will set the 'Description' - // // section of the sidebar. Pass in the title of the Help section so it looks - // // right. - // RED.sidebar.type.show(helpText,RED._("sidebar.info.nodeHelp")); - // }); var chart = $("#red-ui-workspace-chart"); var chartSVG = $("#red-ui-workspace-chart>svg").get(0); var activeSpliceLink; diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/subflow.js b/packages/node_modules/@node-red/editor-client/src/js/ui/subflow.js index c8c649fac..b4cf4be08 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/subflow.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/subflow.js @@ -52,6 +52,10 @@ RED.subflow = (function() { ''+ ''+ ''+ + '
'+ + ''+ + ''+ + '
'+ '
'+ ''+ ''+ @@ -61,7 +65,7 @@ RED.subflow = (function() { ''+ '
'+ '
'+ - ''+ + ''+ ''+ '
'+ '
'+ @@ -1767,7 +1771,7 @@ RED.subflow = (function() { } } } - } else if (/^sf-/.test(node.type)) { + } else if (node._def.subflowModule) { var keys = Object.keys(node._def.defaults); keys.forEach(function(name) { if (name !== 'name') { @@ -1954,6 +1958,7 @@ RED.subflow = (function() { var moduleProps = node.meta || {}; [ 'module', + 'type', 'version', 'author', 'desc', @@ -1962,6 +1967,8 @@ RED.subflow = (function() { ].forEach(function(property) { $("#subflow-input-module-"+property).val(moduleProps[property]||"") }) + $("#subflow-input-module-type").attr("placeholder",node.id); + setupInputValidation($("#subflow-input-module-module"), function(newValue) { newValue = newValue.trim(); var isValid = newValue.length < 215; @@ -2008,6 +2015,7 @@ RED.subflow = (function() { var moduleProps = {}; [ 'module', + 'type', 'version', 'author', 'desc', diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/tab-help.js b/packages/node_modules/@node-red/editor-client/src/js/ui/tab-help.js index c1344e755..cc86de358 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/tab-help.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/tab-help.js @@ -247,7 +247,7 @@ RED.sidebar.help = (function() { helpText = (RED.utils.renderMarkdown(subflowNode.info||"")||(''+RED._("sidebar.info.none")+'')); title = subflowNode.name || nodeType; } else { - helpText = $("script[data-help-name='"+nodeType+"']").html()||(''+RED._("sidebar.info.none")+''); + helpText = RED.nodes.getNodeHelp(nodeType)||(''+RED._("sidebar.info.none")+''); title = nodeType; } setInfoText(title, helpText, helpSection); diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/tab-info.js b/packages/node_modules/@node-red/editor-client/src/js/ui/tab-info.js index 678356181..a8e5583cb 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/tab-info.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/tab-info.js @@ -390,19 +390,6 @@ RED.sidebar.info = (function() { } } - // var helpText = ""; - // if (node.type === "tab" || node.type === "subflow") { - // } else { - // if (subflowNode && node.type !== "subflow") { - // // Selected a subflow instance node. - // // - The subflow template info goes into help - // helpText = (RED.utils.renderMarkdown(subflowNode.info||"")||(''+RED._("sidebar.info.none")+'')); - // } else { - // helpText = $("script[data-help-name='"+node.type+"']").html()||(''+RED._("sidebar.info.none")+''); - // } - // setInfoText(helpText, helpSection.content); - // } - var infoText = ""; if (node._def && node._def.info) { @@ -415,23 +402,6 @@ RED.sidebar.info = (function() { } var infoSectionContainer = $("
").css("padding","0 6px 6px").appendTo(propertiesPanelContent) - // var editInfo = $('').appendTo(infoSectionContainer).on("click", function(evt) { - // //.text(RED._("sidebar.info.editDescription")) - // evt.preventDefault(); - // evt.stopPropagation(); - // if (node.type === 'tab') { - // - // } else if (node.type === 'subflow') { - // - // } else if (node.type === 'group') { - // - // } else if (node._def.category !== 'config') { - // RED.editor.edit(node,"editor-tab-description"); - // } else { - // - // } - // }) - setInfoText(infoText, infoSectionContainer); $(".red-ui-sidebar-info-stack").scrollTop(0); diff --git a/packages/node_modules/@node-red/registry/lib/subflow.js b/packages/node_modules/@node-red/registry/lib/subflow.js index a398d3607..97516691e 100644 --- a/packages/node_modules/@node-red/registry/lib/subflow.js +++ b/packages/node_modules/@node-red/registry/lib/subflow.js @@ -1,5 +1,8 @@ function getSubflowType(subflow) { - return "sf-"+subflow.id + if (subflow.meta && subflow.meta.type) { + return subflow.meta.type + } + return "sf:"+subflow.id } function generateSubflowConfig(subflow) { @@ -49,8 +52,14 @@ function generateSubflowConfig(subflow) { const defaultString = JSON.stringify(defaults); const credentialsString = JSON.stringify(credentials); + let nodeHelp = ""; + if (subflow.info) { + nodeHelp = `` + } + return ` +${nodeHelp} ` } diff --git a/test/resources/subflow/package/subflow.json b/test/resources/subflow/package/subflow.json index 3a9bcfa54..e5c6b25ab 100644 --- a/test/resources/subflow/package/subflow.json +++ b/test/resources/subflow/package/subflow.json @@ -1,4 +1,268 @@ -{"id":"caf258cc.4e2c48","type":"subflow","name":"Test Subflow","info":"","category":"common","in":[{"x":120,"y":100,"wires":[{"id":"2f1d674f.a02d28"}]}],"out":[{"x":560,"y":100,"wires":[{"id":"1497236e.07f12d","port":0}]},{"x":360,"y":200,"wires":[{"id":"f4334f5f.4905c","port":0}]}],"env":[{"name":"FOO","type":"cred","ui":{"icon":"font-awesome/fa-thermometer-0"}},{"name":"BAR","type":"str","value":"1","ui":{"icon":"font-awesome/fa-thermometer-2","type":"select","opts":{"opts":[{"l":{"en-US":"option 1"},"v":"1"},{"l":{"en-US":"option 2"},"v":"2"},{"l":{"en-US":"option 3"},"v":"3"}]}}},{"name":"onewithaverylongname","type":"str","value":""},{"name":"BARRY","type":"bool","value":"true","ui":{"icon":"font-awesome/fa-thermometer-4","type":"checkbox"}},{"name":"WILMA","type":"num","value":"10","ui":{"icon":"font-awesome/fbomb","type":"spinner"}},{"name":"awg","type":"num","value":"","ui":{"icon":"font-awesome/fa-address-book-o","type":"spinner"}},{"name":"awf","type":"str","value":"","ui":{"type":"select","opts":{"opts":[{"l":{"en-US":"one"},"v":"1"},{"l":{"en-US":"two"},"v":"2"},{"l":{"en-US":"three"},"v":"3"}]}}},{"name":"aawf","type":"bool","value":"true","ui":{"type":"checkbox"}},{"name":"awgawgawg","type":"str","value":"","ui":{"type":"none"}},{"name":"seagseg","type":"str","value":"","ui":{"type":"hide"}}],"meta":{},"color":"#A6BBCF","icon":"font-awesome/fa-space-shuttle","status":{"x":500,"y":300,"wires":[{"id":"8252d1cc.54f94","port":0}]}, -"flow": - [{"id":"2f1d674f.a02d28","type":"function","z":"caf258cc.4e2c48","name":"","func":"node.error(\"subflow error \"+msg.payload,msg);\nmsg.payload = {\n FOO: env.get(\"FOO\"),\n BAR: env.get(\"BAR\"),\n WILMA: env.get(\"WILMA\"),\n BARRY: env.get(\"BARRY\")\n}\nnode.warn(\"warning\");\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":240,"y":100,"wires":[["1497236e.07f12d"]]},{"id":"f4334f5f.4905c","type":"catch","z":"caf258cc.4e2c48","name":"","scope":null,"uncaught":false,"x":220,"y":200,"wires":[["8252d1cc.54f94"]]},{"id":"8252d1cc.54f94","type":"change","z":"caf258cc.4e2c48","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"error.message","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":350,"y":300,"wires":[[]]},{"id":"1497236e.07f12d","type":"random","z":"caf258cc.4e2c48","name":"","low":"1","high":"10","inte":"true","property":"random","x":420,"y":100,"wires":[[]]},{"id":"876fc49e.f15268","type":"subflow:caf258cc.4e2c48","z":"d607ce33.4fa5a","name":"","x":200,"y":760,"wires":[[],[]]}] +{ + "id": "caf258cc.4e2c48", + "type": "subflow", + "name": "Test Subflow", + "info":"This is my exportable module subflow\n\nI hope this shows as help!", + "category": "common", + "in": [ + { + "x": 120, + "y": 100, + "wires": [ + { + "id": "2f1d674f.a02d28" + } + ] + } + ], + "out": [ + { + "x": 560, + "y": 100, + "wires": [ + { + "id": "1497236e.07f12d", + "port": 0 + } + ] + }, + { + "x": 360, + "y": 200, + "wires": [ + { + "id": "f4334f5f.4905c", + "port": 0 + } + ] + } + ], + "env": [ + { + "name": "FOO", + "type": "cred", + "ui": { + "icon": "font-awesome/fa-thermometer-0" + } + }, + { + "name": "BAR", + "type": "str", + "value": "1", + "ui": { + "icon": "font-awesome/fa-thermometer-2", + "type": "select", + "opts": { + "opts": [ + { + "l": { + "en-US": "option 1" + }, + "v": "1" + }, + { + "l": { + "en-US": "option 2" + }, + "v": "2" + }, + { + "l": { + "en-US": "option 3" + }, + "v": "3" + } + ] + } + } + }, + { + "name": "onewithaverylongname", + "type": "str", + "value": "" + }, + { + "name": "BARRY", + "type": "bool", + "value": "true", + "ui": { + "icon": "font-awesome/fa-thermometer-4", + "type": "checkbox" + } + }, + { + "name": "WILMA", + "type": "num", + "value": "10", + "ui": { + "icon": "font-awesome/fbomb", + "type": "spinner" + } + }, + { + "name": "awg", + "type": "num", + "value": "", + "ui": { + "icon": "font-awesome/fa-address-book-o", + "type": "spinner" + } + }, + { + "name": "awf", + "type": "str", + "value": "", + "ui": { + "type": "select", + "opts": { + "opts": [ + { + "l": { + "en-US": "one" + }, + "v": "1" + }, + { + "l": { + "en-US": "two" + }, + "v": "2" + }, + { + "l": { + "en-US": "three" + }, + "v": "3" + } + ] + } + } + }, + { + "name": "aawf", + "type": "bool", + "value": "true", + "ui": { + "type": "checkbox" + } + }, + { + "name": "awgawgawg", + "type": "str", + "value": "", + "ui": { + "type": "none" + } + }, + { + "name": "seagseg", + "type": "str", + "value": "", + "ui": { + "type": "hide" + } + } + ], + "meta": { + "type": "fly-a-plane" + }, + "color": "#A6BBCF", + "icon": "font-awesome/fa-space-shuttle", + "status": { + "x": 500, + "y": 300, + "wires": [ + { + "id": "8252d1cc.54f94", + "port": 0 + } + ] + }, + "flow": [ + { + "id": "2f1d674f.a02d28", + "type": "function", + "z": "caf258cc.4e2c48", + "name": "", + "func": "node.error(\"subflow error \"+msg.payload,msg);\nmsg.payload = {\n FOO: env.get(\"FOO\"),\n BAR: env.get(\"BAR\"),\n WILMA: env.get(\"WILMA\"),\n BARRY: env.get(\"BARRY\")\n}\nnode.warn(\"warning\");\n\nreturn msg;", + "outputs": 1, + "noerr": 0, + "initialize": "", + "finalize": "", + "x": 240, + "y": 100, + "wires": [ + [ + "1497236e.07f12d" + ] + ] + }, + { + "id": "f4334f5f.4905c", + "type": "catch", + "z": "caf258cc.4e2c48", + "name": "", + "scope": null, + "uncaught": false, + "x": 220, + "y": 200, + "wires": [ + [ + "8252d1cc.54f94" + ] + ] + }, + { + "id": "8252d1cc.54f94", + "type": "change", + "z": "caf258cc.4e2c48", + "name": "", + "rules": [ + { + "t": "set", + "p": "payload", + "pt": "msg", + "to": "error.message", + "tot": "msg" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 350, + "y": 300, + "wires": [ + [] + ] + }, + { + "id": "1497236e.07f12d", + "type": "random", + "z": "caf258cc.4e2c48", + "name": "", + "low": "1", + "high": "10", + "inte": "true", + "property": "random", + "x": 420, + "y": 100, + "wires": [ + [] + ] + }, + { + "id": "876fc49e.f15268", + "type": "subflow:caf258cc.4e2c48", + "z": "d607ce33.4fa5a", + "name": "", + "x": 200, + "y": 760, + "wires": [ + [], + [] + ] + } + ] } \ No newline at end of file diff --git a/test/resources/subflow/test-subflow-mod-1.0.1.tgz b/test/resources/subflow/test-subflow-mod-1.0.1.tgz index 235dad158..daa53b77a 100644 Binary files a/test/resources/subflow/test-subflow-mod-1.0.1.tgz and b/test/resources/subflow/test-subflow-mod-1.0.1.tgz differ