From f0e4117509fc0faef4b791de17f7490d2e5088c0 Mon Sep 17 00:00:00 2001 From: Connor KD9LSV Date: Tue, 24 Dec 2024 00:36:38 -0600 Subject: [PATCH 1/5] Add Conversion to ui-toast node. --- README.md | 2 +- transformers/index.js | 3 ++- transformers/map.json | 3 ++- transformers/nodes/ui-notification.js | 37 +++++++++++++++++++++++++++ 4 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 transformers/nodes/ui-notification.js diff --git a/README.md b/README.md index 34e74a7..7c4bc3a 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ Please note that this script does not cover everything, see below for a list of - `ui_slider` - converted to Dashboard 2.0's `ui-slider` - `ui_text_input` - converted to Dashboard 2.0's `ui-text-input` - `.tooltip` is not supported +- `ui_toast` - converted to Dashboars 2.0's `ui-notification` ### Config Nodes @@ -38,7 +39,6 @@ Please note that this script does not cover everything, see below for a list of - `ui_gauge` - [link](https://github.com/FlowFuse/node-red-dashboard-2-migration/issues/26) - `ui_chart` - [link](https://github.com/FlowFuse/node-red-dashboard-2-migration/issues/27) - `ui_audio` - [link](https://github.com/FlowFuse/node-red-dashboard-2-migration/issues/28) -- `ui_toast` - [link](https://github.com/FlowFuse/node-red-dashboard-2-migration/issues/29) - `ui_control` - [link](https://github.com/FlowFuse/node-red-dashboard-2-migration/issues/30) - `ui_template` - [link](https://github.com/FlowFuse/node-red-dashboard-2-migration/issues/31) diff --git a/transformers/index.js b/transformers/index.js index 7a54aae..cff6b05 100644 --- a/transformers/index.js +++ b/transformers/index.js @@ -7,5 +7,6 @@ module.exports = { uiSlider: require('./nodes/ui-slider'), uiSwitch: require('./nodes/ui-switch'), uiText: require('./nodes/ui-text'), - uiTextInput: require('./nodes/ui-text-input') + uiTextInput: require('./nodes/ui-text-input'), + uiNotification: require('./nodes/ui-notification') } diff --git a/transformers/map.json b/transformers/map.json index 53eb2cb..d000ecc 100644 --- a/transformers/map.json +++ b/transformers/map.json @@ -7,5 +7,6 @@ "ui_slider": "uiSlider", "ui_switch": "uiSwitch", "ui_text": "uiText", - "ui_text_input": "uiTextInput" + "ui_text_input": "uiTextInput", + "ui_notification": "uiNotification" } diff --git a/transformers/nodes/ui-notification.js b/transformers/nodes/ui-notification.js new file mode 100644 index 0000000..7c47071 --- /dev/null +++ b/transformers/nodes/ui-notification.js @@ -0,0 +1,37 @@ +module.exports = function (node, baseId, themeId) { + node.type = 'ui-notification' + + // update properties + if (node.position=="dialog"|| node.position == "prompt"){ + node.position="center center" + node.allowConfirm=true + node.allowDismiss=true + node.confirmText=node.ok + node.dismissText=node.cancel + }else{ + node.allowConfirm=false + node.allowDismiss=false + node.confirmText=node.ok + node.dismissText=node.cancel + } + if (node.highlight!=""){ + node.colorDefault=false + node.color=node.highlight; + }else{ + node.colorDefault=true; + node.color=null + } + + // new properties + + node.ui=baseId; + node.showCountdown=false + + // remove properties + // NONE + delete node.highlight + delete node.topic + delete node.sendall + + return node +} From 796185a79fb736ff3641aa886db240fdddda1e62 Mon Sep 17 00:00:00 2001 From: Connor KD9LSV Date: Tue, 24 Dec 2024 14:39:31 -0600 Subject: [PATCH 2/5] Lint Cleaning --- transformers/nodes/ui-notification.js | 42 +++++++++++++-------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/transformers/nodes/ui-notification.js b/transformers/nodes/ui-notification.js index 7c47071..4085960 100644 --- a/transformers/nodes/ui-notification.js +++ b/transformers/nodes/ui-notification.js @@ -2,30 +2,30 @@ module.exports = function (node, baseId, themeId) { node.type = 'ui-notification' // update properties - if (node.position=="dialog"|| node.position == "prompt"){ - node.position="center center" - node.allowConfirm=true - node.allowDismiss=true - node.confirmText=node.ok - node.dismissText=node.cancel - }else{ - node.allowConfirm=false - node.allowDismiss=false - node.confirmText=node.ok - node.dismissText=node.cancel + if (node.position === 'dialog' || node.position === 'prompt') { + node.position = 'center center' + node.allowConfirm = true + node.allowDismiss = true + node.confirmText = node.ok + node.dismissText = node.cancel + } else { + node.allowConfirm = false + node.allowDismiss = false + node.confirmText = node.ok + node.dismissText = node.cancel } - if (node.highlight!=""){ - node.colorDefault=false - node.color=node.highlight; - }else{ - node.colorDefault=true; - node.color=null + if (node.highlight !== '') { + node.colorDefault = false + node.color = node.highlight + } else { + node.colorDefault = true + node.color = null } - + // new properties - - node.ui=baseId; - node.showCountdown=false + + node.ui = baseId + node.showCountdown = false // remove properties // NONE From 961f3f1cae9e284d41ab46731920f613da93f189 Mon Sep 17 00:00:00 2001 From: Connor KD9LSV Date: Tue, 24 Dec 2024 15:13:12 -0600 Subject: [PATCH 3/5] need to match 1.0 notiifcation name. --- transformers/map.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/transformers/map.json b/transformers/map.json index d000ecc..c255072 100644 --- a/transformers/map.json +++ b/transformers/map.json @@ -8,5 +8,5 @@ "ui_switch": "uiSwitch", "ui_text": "uiText", "ui_text_input": "uiTextInput", - "ui_notification": "uiNotification" + "ui_toast": "uiNotification" } From 8bc0f7da7430f81a4dcec43b5fe2b1ea359417b8 Mon Sep 17 00:00:00 2001 From: Connor Dickey Date: Fri, 10 Jan 2025 09:51:08 -0600 Subject: [PATCH 4/5] Add Testing Parameters. --- tests/flows/basic-layout-after.json | 24 ++++++++++++++++++++++++ tests/flows/basic-layout-before.json | 19 +++++++++++++++++++ tests/index.js | 14 ++++++++++++++ 3 files changed, 57 insertions(+) diff --git a/tests/flows/basic-layout-after.json b/tests/flows/basic-layout-after.json index 6b64e84..0f2a68a 100644 --- a/tests/flows/basic-layout-after.json +++ b/tests/flows/basic-layout-after.json @@ -230,6 +230,30 @@ [] ] }, + { + "id": "c147bc430094baf8", + "type": "ui-notification", + "z": "94d6d107f1742efb", + "ui": "0996ab6125fd4a4b", + "position": "center center", + "colorDefault": true, + "color": null, + "displayTime": "3", + "showCountdown": false, + "outputs": 1, + "allowDismiss": true, + "dismissText": "", + "allowConfirm": true, + "confirmText": "OK", + "raw": false, + "className": "", + "name": "", + "x": 350, + "y": 400, + "wires": [ + [] + ] + }, { "id": "856a31bba370e7fc", "type": "ui-group", diff --git a/tests/flows/basic-layout-before.json b/tests/flows/basic-layout-before.json index 5efea68..9386f6b 100644 --- a/tests/flows/basic-layout-before.json +++ b/tests/flows/basic-layout-before.json @@ -223,6 +223,25 @@ [] ] }, + { + "id": "73ce8707dab7de0a", + "type": "ui_toast", + "z": "94d6d107f1742efb", + "position": "prompt", + "displayTime": "3", + "highlight": "", + "sendall": true, + "outputs": 1, + "ok": "OK", + "cancel": "Cancel", + "raw": false, + "className": "", + "topic": "", + "name": "", + "x": 350, + "y": 400, + "wires": [] + }, { "id": "856a31bba370e7fc", "type": "ui_group", diff --git a/tests/index.js b/tests/index.js index 5f6a8e1..cc612a6 100644 --- a/tests/index.js +++ b/tests/index.js @@ -205,6 +205,20 @@ describe('Dashboard Migration Script', function () { }) }) + describe('UI Notification', function () { + const input = utils.getByType(migratedFlow, 'ui-notification')[0] + const input1 = utils.getByType(basicLayoutAfter, 'ui-notification')[0] + + const excludeFromChecks = ['id', 'group'] + Object.keys(input).forEach((prop) => { + if (!excludeFromChecks.includes(prop)) { + it('should set ' + prop + ' correctly ', function () { + input[prop].should.eql(input1[prop]) + }) + } + }) + }) + describe('Unsupported UI Nodes:', function () { it('should should be disabled in the NR Editor', function () { const template0 = utils.getByType(migratedFlow, 'ui_template')[0] From 0e919f9dd2bbf9170f6e7f20c09042f762f26d0e Mon Sep 17 00:00:00 2001 From: Connor Dickey Date: Tue, 4 Feb 2025 09:42:04 -0600 Subject: [PATCH 5/5] Fix Typo of Dashboard Co-authored-by: Joe Pavitt <99246719+joepavitt@users.noreply.github.com> --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7c4bc3a..b7f049b 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Please note that this script does not cover everything, see below for a list of - `ui_slider` - converted to Dashboard 2.0's `ui-slider` - `ui_text_input` - converted to Dashboard 2.0's `ui-text-input` - `.tooltip` is not supported -- `ui_toast` - converted to Dashboars 2.0's `ui-notification` +- `ui_toast` - converted to Dashboard 2.0's `ui-notification` ### Config Nodes