@flowfuse/nr-assistant 0.3.1-2c05106-202506300804.0 → 0.3.1-8f3f1da-202507071743.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -25,7 +25,7 @@ This plugin is designed to assist users of the FlowFuse platform by providing to
25
25
  ![flowfuse-assistant-json-generator](https://github.com/user-attachments/assets/9d4bf3ef-7ea8-4e72-9e04-73712d5323e3)
26
26
 
27
27
  ### Flows Explainer
28
- ![flowfuse-assistant-flow-explainer](https://github.com/user-attachments/assets/20f5490f-469f-4f95-b63c-cdf216139bd0)
28
+ ![flowfuse-assistant-flow-explainer](https://github.com/user-attachments/assets/6b631048-392b-4028-be8c-bc50f1398a17)
29
29
 
30
30
  ### FlowFuse Dashboard UI Template Assistant
31
31
  ![flowfuse-assistant-ui-template](https://github.com/user-attachments/assets/c6810553-40c0-429e-aa6b-039317b1dc30)
package/index.html CHANGED
@@ -972,11 +972,65 @@
972
972
  }
973
973
 
974
974
  try {
975
- const text = reply.data || 'No reply from server'
976
- showMessage(plugin._('explain-flows.dialog-result.title'), RED.utils.renderMarkdown(text), 'html', {})
975
+ const text = reply.data
976
+ let dlg = null
977
+ const options = {
978
+ buttons: [{
979
+ text: plugin._('explain-flows.dialog-result.close-button'),
980
+ icon: 'ui-icon-close',
981
+ class: 'primary',
982
+ click: function () {
983
+ $(dlg).dialog('close')
984
+ }
985
+ }]
986
+ }
987
+ if (text && text.length > 0) {
988
+ // if copy to clipboard is supported, add a button to copy the text
989
+ const isHttpsOrLocalhost = location.protocol === 'https:' || location.hostname === 'localhost' || location.hostname === '127.0.0.1'
990
+ if (isHttpsOrLocalhost && navigator.clipboard && navigator.clipboard.writeText) {
991
+ options.buttons.unshift(
992
+ {
993
+ text: plugin._('explain-flows.dialog-result.copy-button'),
994
+ icon: 'ui-icon-copy',
995
+ click: function () {
996
+ navigator.clipboard.writeText(text).then(() => {
997
+ showNotification('Copied to clipboard', { type: 'success' })
998
+ }).catch((err) => {
999
+ console.warn('Failed to copy to clipboard', err)
1000
+ showNotification(plugin._('errors.copy-failed'), { type: 'error' })
1001
+ })
1002
+ }
1003
+ }
1004
+ )
1005
+ }
1006
+ const isLocked = typeof RED.workspaces.isLocked === 'function' && RED.workspaces.isLocked()
1007
+ if (!isLocked) {
1008
+ options.buttons.unshift(
1009
+ {
1010
+ text: plugin._('explain-flows.dialog-result.comment-node-button'),
1011
+ icon: 'ui-icon-comment',
1012
+ // class: 'primary',
1013
+ click: function () {
1014
+ const commentNode = {
1015
+ type: 'comment',
1016
+ name: plugin._('explain-flows.dialog-result.comment-node-name'),
1017
+ info: text
1018
+ }
1019
+ importFlow(commentNode, false, 'Drop the generated comment node onto the workspace')
1020
+ $(dlg).dialog('close')
1021
+ }
1022
+ }
1023
+ )
1024
+ }
1025
+ }
1026
+ if (!text || text.length === 0) {
1027
+ showNotification('Sorry, no explanation could be generated.', { type: 'warning' })
1028
+ return
1029
+ }
1030
+ dlg = showMessage(plugin._('explain-flows.dialog-result.title'), RED.utils.renderMarkdown(text), 'html', options)
977
1031
  } catch (error) {
978
1032
  console.warn('Error rendering reply', error)
979
- showNotification('Sorry, something went wrong, please try again', { type: 'error' })
1033
+ showNotification(plugin._('errors.something-went-wrong'), { type: 'error' })
980
1034
  }
981
1035
  },
982
1036
  error: (jqXHR, textStatus, errorThrown) => {
@@ -1122,7 +1176,7 @@
1122
1176
  return notification
1123
1177
  }
1124
1178
 
1125
- function importFlow (flow, addFlow) {
1179
+ function importFlow (flow, addFlow, notificationMessage = 'Drop the generated node onto the workspace') {
1126
1180
  if (RED.workspaces.isLocked && RED.workspaces.isLocked()) {
1127
1181
  addFlow = true // force import to create a new tab
1128
1182
  }
@@ -1142,7 +1196,9 @@
1142
1196
  }
1143
1197
  }
1144
1198
  const importOptions = { generateIds: true, addFlow }
1145
- RED.notify('Place your generated flow onto the workspace', 'compact')
1199
+ if (notificationMessage) {
1200
+ RED.notify(notificationMessage, 'compact')
1201
+ }
1146
1202
  RED.view.importNodes(newNodes, importOptions)
1147
1203
  } catch (error) {
1148
1204
  // console.log(error)
@@ -24,7 +24,11 @@
24
24
  "description": "Explain the selected nodes"
25
25
  },
26
26
  "dialog-result": {
27
- "title": "FlowFuse Assistant: Explain Flows"
27
+ "title": "FlowFuse Assistant: Explain Flows",
28
+ "copy-button": "Copy",
29
+ "close-button": "Close",
30
+ "comment-node-button": "Comment Node",
31
+ "comment-node-name": "FlowFuse Assistant Explanation"
28
32
  },
29
33
  "errors": {
30
34
  "no-nodes-selected": "No nodes selected. Please select one or more nodes to explain.",
@@ -35,6 +39,8 @@
35
39
  "busy": "Busy processing your request. Please wait..."
36
40
  },
37
41
  "errors":{
38
- "assistant-not-enabled": "The FlowFuse Assistant is not enabled"
42
+ "assistant-not-enabled": "The FlowFuse Assistant is not enabled",
43
+ "copy-failed": "Failed to copy to clipboard",
44
+ "something-went-wrong": "Something went wrong. Please try again later."
39
45
  }
40
46
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowfuse/nr-assistant",
3
- "version": "0.3.1-2c05106-202506300804.0",
3
+ "version": "0.3.1-8f3f1da-202507071743.0",
4
4
  "description": "FlowFuse Node-RED assistant plugin",
5
5
  "main": "index.js",
6
6
  "scripts": {