From 635bdf15cb590ecfef83677f1fa744815f58b3b5 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Sat, 1 May 2021 21:55:50 +0100 Subject: [PATCH] Fix use of paletteLabel in help tab Fixes #2973 --- .../editor-client/src/js/ui/tab-help.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) 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 a911e4c05..2bc932b8c 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 @@ -233,7 +233,15 @@ RED.sidebar.help = (function() { var div = $('
',{class:"red-ui-info-outline-item"}); RED.utils.createNodeIcon(n).appendTo(div); var contentDiv = $('
',{class:"red-ui-search-result-description"}).appendTo(div); - $('
',{class:"red-ui-search-result-node-label red-ui-info-outline-item-label"}).text(n.name||n._def.paletteLabel||n.type).appendTo(contentDiv); + var label = n.name; + if (!label && n._def.paletteLabel) { + try { + label = (typeof n._def.paletteLabel === "function" ? n._def.paletteLabel.call(n._def) : n._def.paletteLabel)||""; + } catch (err) { + } + } + label = label || n.type; + $('
',{class:"red-ui-search-result-node-label red-ui-info-outline-item-label"}).text(label).appendTo(contentDiv); return div; } @@ -250,6 +258,13 @@ RED.sidebar.help = (function() { helpText = RED.nodes.getNodeHelp(nodeType)||(''+RED._("sidebar.info.none")+''); var _def = RED.nodes.registry.getNodeType(nodeType); title = (_def && _def.paletteLabel)?_def.paletteLabel:nodeType; + if (typeof title === "function") { + try { + title = _def.paletteLabel.call(_def); + } catch(err) { + title = nodeType; + } + } } setInfoText(title, helpText, helpSection);