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

Fix use of paletteLabel in help tab

Fixes #2973
This commit is contained in:
Nick O'Leary 2021-05-01 21:55:50 +01:00
parent b0e4fb7602
commit 635bdf15cb
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9

View File

@ -233,7 +233,15 @@ RED.sidebar.help = (function() {
var div = $('<div>',{class:"red-ui-info-outline-item"});
RED.utils.createNodeIcon(n).appendTo(div);
var contentDiv = $('<div>',{class:"red-ui-search-result-description"}).appendTo(div);
$('<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;
$('<div>',{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)||('<span class="red-ui-help-info-none">'+RED._("sidebar.info.none")+'</span>');
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);