From 68b94737ed648d39e183144e3a68a70b63b88602 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Thu, 16 May 2019 14:42:21 +0100 Subject: [PATCH] Add tooltip on node error icon for validation errs --- .../editor-client/locales/en-US/editor.json | 3 +- .../editor-client/src/js/ui/editor.js | 21 ++++--- .../@node-red/editor-client/src/js/ui/view.js | 62 ++++++++++--------- .../editor-client/src/sass/flow.scss | 1 + 4 files changed, 49 insertions(+), 38 deletions(-) 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 a48af013d..0b979f5d5 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 @@ -321,7 +321,8 @@ "show": "Show", "hide": "Hide", "errors": { - "scopeChange": "Changing the scope will make it unavailable to nodes in other flows that use it" + "scopeChange": "Changing the scope will make it unavailable to nodes in other flows that use it", + "invalidProperties": "Invalid properties:" } }, "keyboard": { diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/editor.js b/packages/node_modules/@node-red/editor-client/src/js/ui/editor.js index fa11149c0..d580bd5e5 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/editor.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/editor.js @@ -45,6 +45,7 @@ RED.editor = (function() { node.valid = true; var subflow; var isValid; + var validationErrors; var hasChanged; if (node.type.indexOf("subflow:")===0) { subflow = RED.nodes.subflow(node.type.substring(8)); @@ -54,13 +55,17 @@ RED.editor = (function() { isValid = validateNode(subflow); hasChanged = subflow.changed; } - node.valid = isValid && validateNodeProperties(node, node._def.defaults, node); + validationErrors = validateNodeProperties(node, node._def.defaults, node); + node.valid = isValid && validationErrors.length === 0; node.changed = node.changed || hasChanged; + node.validationErrors = validationErrors; } else if (node._def) { - node.valid = validateNodeProperties(node, node._def.defaults, node); + validationErrors = validateNodeProperties(node, node._def.defaults, node); if (node._def._creds) { - node.valid = node.valid && validateNodeProperties(node, node._def.credentials, node._def._creds); + validationErrors = validationErrors.concat(validateNodeProperties(node, node._def.credentials, node._def._creds)) } + node.valid = (validationErrors.length === 0); + node.validationErrors = validationErrors; } else if (node.type == "subflow") { var subflowNodes = RED.nodes.filterNodes({z:node.id}); for (var i=0;i 0) { + clearTimeout(portLabelHoverTimeout); + portLabelHoverTimeout = setTimeout(function() { + var pos = getElementPosition(nodeErrorButton.node()); + portLabelHoverTimeout = null; + portLabelHover = showTooltip( + (pos[0]), + (pos[1]), + RED._("editor.errors.invalidProperties")+"\n - "+d.validationErrors.join("\n - "), + "top" + ); + },500); + } + }).on("mouseleave", function() { + clearTimeout(portLabelHoverTimeout); + if (portLabelHover) { + portLabelHover.remove(); + portLabelHover = null; + } + }); }); node.each(function(d,i) { diff --git a/packages/node_modules/@node-red/editor-client/src/sass/flow.scss b/packages/node_modules/@node-red/editor-client/src/sass/flow.scss index 4c152a356..367a7e10a 100644 --- a/packages/node_modules/@node-red/editor-client/src/sass/flow.scss +++ b/packages/node_modules/@node-red/editor-client/src/sass/flow.scss @@ -256,5 +256,6 @@ g.red-ui-flow-link-unknown path.red-ui-flow-link-line { font-size: 12px; pointer-events: none; -webkit-touch-callout: none; + white-space: pre; @include disable-selection; }