mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Use subflow.info for help text and meta.type for node type
This commit is contained in:
parent
160ca6add4
commit
d5cc5b2574
@ -342,6 +342,7 @@
|
||||
"module": "Module",
|
||||
"license": "License",
|
||||
"licenseOther": "Other",
|
||||
"type": "Node Type",
|
||||
"version": "Version",
|
||||
"versionPlaceholder": "x.y.z",
|
||||
"keys": "Keywords",
|
||||
|
@ -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,
|
||||
|
@ -147,7 +147,7 @@ RED.palette = (function() {
|
||||
var popOverContent;
|
||||
try {
|
||||
var l = "<p><b>"+RED.text.bidi.enforceTextDirectionWithUCC(label)+"</b></p>";
|
||||
popOverContent = $('<div></div>').append($(l+(info?info:$("script[data-help-name='"+type+"']").html()||"<p>"+RED._("palette.noInfo")+"</p>").trim())
|
||||
popOverContent = $('<div></div>').append($(l+(info?info:RED.nodes.getNodeHelp(type)||"<p>"+RED._("palette.noInfo")+"</p>").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||"")||('<span class="red-ui-help-info-none">'+RED._("sidebar.info.none")+'</span>');
|
||||
// } else {
|
||||
// helpText = $("script[data-help-name='"+d.attr("data-palette-type")+"']").html()||('<span class="red-ui-help-info-none">'+RED._("sidebar.info.none")+'</span>');
|
||||
// }
|
||||
// // 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;
|
||||
|
@ -52,6 +52,10 @@ RED.subflow = (function() {
|
||||
'<label for="subflow-input-module-module" data-i18n="[append]editor:subflow.module"><i class="fa fa-cube"></i> </label>'+
|
||||
'<input style="width: calc(100% - 110px)" type="text" id="subflow-input-module-module" data-i18n="[placeholder]common.label.name">'+
|
||||
'</div>'+
|
||||
'<div class="form-row">'+
|
||||
'<label for="subflow-input-module-type" data-i18n="[append]editor:subflow.type"> </label>'+
|
||||
'<input style="width: calc(100% - 110px)" type="text" id="subflow-input-module-type">'+
|
||||
'</div>'+
|
||||
'<div class="form-row">'+
|
||||
'<label for="subflow-input-module-version" data-i18n="[append]editor:subflow.version"></label>'+
|
||||
'<input style="width: calc(100% - 110px)" type="text" id="subflow-input-module-version" data-i18n="[placeholder]editor:subflow.versionPlaceholder">'+
|
||||
@ -61,7 +65,7 @@ RED.subflow = (function() {
|
||||
'<input style="width: calc(100% - 110px)" type="text" id="subflow-input-module-desc">'+
|
||||
'</div>'+
|
||||
'<div class="form-row">'+
|
||||
'<label for="subflow-input-module-version" data-i18n="[append]editor:subflow.license"></label>'+
|
||||
'<label for="subflow-input-module-license" data-i18n="[append]editor:subflow.license"></label>'+
|
||||
'<input style="width: calc(100% - 110px)" type="text" id="subflow-input-module-license">'+
|
||||
'</div>'+
|
||||
'<div class="form-row">'+
|
||||
@ -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',
|
||||
|
@ -247,7 +247,7 @@ RED.sidebar.help = (function() {
|
||||
helpText = (RED.utils.renderMarkdown(subflowNode.info||"")||('<span class="red-ui-help-info-none">'+RED._("sidebar.info.none")+'</span>'));
|
||||
title = subflowNode.name || nodeType;
|
||||
} else {
|
||||
helpText = $("script[data-help-name='"+nodeType+"']").html()||('<span class="red-ui-help-info-none">'+RED._("sidebar.info.none")+'</span>');
|
||||
helpText = RED.nodes.getNodeHelp(nodeType)||('<span class="red-ui-help-info-none">'+RED._("sidebar.info.none")+'</span>');
|
||||
title = nodeType;
|
||||
}
|
||||
setInfoText(title, helpText, helpSection);
|
||||
|
@ -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||"")||('<span class="red-ui-help-info-none">'+RED._("sidebar.info.none")+'</span>'));
|
||||
// } else {
|
||||
// helpText = $("script[data-help-name='"+node.type+"']").html()||('<span class="red-ui-help-info-none">'+RED._("sidebar.info.none")+'</span>');
|
||||
// }
|
||||
// setInfoText(helpText, helpSection.content);
|
||||
// }
|
||||
|
||||
var infoText = "";
|
||||
|
||||
if (node._def && node._def.info) {
|
||||
@ -415,23 +402,6 @@ RED.sidebar.info = (function() {
|
||||
}
|
||||
var infoSectionContainer = $("<div>").css("padding","0 6px 6px").appendTo(propertiesPanelContent)
|
||||
|
||||
// var editInfo = $('<button class="red-ui-button red-ui-button-small" style="float: right"><i class="fa fa-file-text-o"></button>').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);
|
||||
|
@ -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 = `<script type="text/markdown" data-help-name="${subflowType}">${subflow.info}</script>`
|
||||
}
|
||||
|
||||
return `<script type="text/javascript">
|
||||
RED.nodes.registerType("${subflowType}",{
|
||||
subflowModule: true,
|
||||
category: "${category}",
|
||||
color: "${color}",
|
||||
defaults: ${defaultString},
|
||||
@ -100,6 +109,7 @@ function generateSubflowConfig(subflow) {
|
||||
</div>
|
||||
<div id="subflow-input-ui"></div>
|
||||
</script>
|
||||
${nodeHelp}
|
||||
`
|
||||
}
|
||||
|
||||
|
@ -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": [
|
||||
[],
|
||||
[]
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user