From ee936fbc889e7beb65dac7de32990ff8cde9649f Mon Sep 17 00:00:00 2001 From: Connor KD9LSV Date: Tue, 24 Dec 2024 00:34:14 -0600 Subject: [PATCH 1/5] Add Ui-Control modifications. --- README.md | 3 +-- transformers/index.js | 3 ++- transformers/map.json | 3 ++- transformers/nodes/ui-control.js | 14 ++++++++++++++ 4 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 transformers/nodes/ui-control.js diff --git a/README.md b/README.md index 34e74a7..d576084 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_control` - converted to Dashboard 2.0's `ui-control` ### Config Nodes - `ui_tab` - converted to Dashboard 2.0's `ui-page` @@ -39,7 +39,6 @@ Please note that this script does not cover everything, see below for a list of - `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) ## Usage diff --git a/transformers/index.js b/transformers/index.js index 7a54aae..74d7cf7 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'), + uiControl: require('./nodes/ui-control') } diff --git a/transformers/map.json b/transformers/map.json index 53eb2cb..bce41d9 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_control": "uiControl" } diff --git a/transformers/nodes/ui-control.js b/transformers/nodes/ui-control.js new file mode 100644 index 0000000..2c28be7 --- /dev/null +++ b/transformers/nodes/ui-control.js @@ -0,0 +1,14 @@ +module.exports = function (node, baseId, themeId) { + node.type = 'ui-control' + + // update properties + // NONE + + // new properties + node.ui=baseId; + + // remove properties + // NONE + + return node +} From 0be3883363b4debd16568ed1826fa5c0f27fe5b2 Mon Sep 17 00:00:00 2001 From: Connor KD9LSV Date: Tue, 24 Dec 2024 14:41:06 -0600 Subject: [PATCH 2/5] Lint Clean --- transformers/nodes/ui-control.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/transformers/nodes/ui-control.js b/transformers/nodes/ui-control.js index 2c28be7..953acf0 100644 --- a/transformers/nodes/ui-control.js +++ b/transformers/nodes/ui-control.js @@ -5,7 +5,7 @@ module.exports = function (node, baseId, themeId) { // NONE // new properties - node.ui=baseId; + node.ui = baseId // remove properties // NONE From 5a315fc0169926d879bc467cbc2572519dd0362d Mon Sep 17 00:00:00 2001 From: Connor KD9LSV Date: Tue, 24 Dec 2024 15:14:25 -0600 Subject: [PATCH 3/5] properly map 1.0 name --- transformers/map.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/transformers/map.json b/transformers/map.json index bce41d9..a0754ce 100644 --- a/transformers/map.json +++ b/transformers/map.json @@ -8,5 +8,5 @@ "ui_switch": "uiSwitch", "ui_text": "uiText", "ui_text_input": "uiTextInput", - "ui_control": "uiControl" + "ui_ui_control": "uiControl" } From 938a4ab0c60e3c8df05a9e29317f284d3845b33c Mon Sep 17 00:00:00 2001 From: Connor Dickey Date: Fri, 10 Jan 2025 09:34:35 -0600 Subject: [PATCH 4/5] Add Test Parameters. --- tests/flows/basic-layout-after.json | 13 +++++++++++++ tests/flows/basic-layout-before.json | 12 ++++++++++++ tests/index.js | 15 +++++++++++++++ 3 files changed, 40 insertions(+) diff --git a/tests/flows/basic-layout-after.json b/tests/flows/basic-layout-after.json index 6b64e84..7e03622 100644 --- a/tests/flows/basic-layout-after.json +++ b/tests/flows/basic-layout-after.json @@ -230,6 +230,19 @@ [] ] }, + { + "id": "3cef1870d65a9462", + "type": "ui-control", + "z": "94d6d107f1742efb", + "name": "My Control", + "ui": "69c6fbb86f6e5033", + "events": "all", + "x": 320, + "y": 200, + "wires": [ + [] + ] + }, { "id": "856a31bba370e7fc", "type": "ui-group", diff --git a/tests/flows/basic-layout-before.json b/tests/flows/basic-layout-before.json index 5efea68..b9fe598 100644 --- a/tests/flows/basic-layout-before.json +++ b/tests/flows/basic-layout-before.json @@ -223,6 +223,18 @@ [] ] }, + { + "id": "12094eeb6261dd1d", + "type": "ui_ui_control", + "z": "94d6d107f1742efb", + "name": "My Control", + "events": "all", + "x": 320, + "y": 200, + "wires": [ + [] + ] + }, { "id": "856a31bba370e7fc", "type": "ui_group", diff --git a/tests/index.js b/tests/index.js index 5f6a8e1..6b4e356 100644 --- a/tests/index.js +++ b/tests/index.js @@ -205,6 +205,21 @@ describe('Dashboard Migration Script', function () { }) }) + describe('UI Control:', function () { + const button = utils.getByType(migratedFlow, 'ui-control')[0] + const button1 = utils.getByType(basicLayoutAfter, 'ui-control')[0] + + const excludeFromChecks = ['id'] + Object.keys(button).forEach((prop) => { + if (!excludeFromChecks.includes(prop)) { + it('should set ' + prop + ' correctly ', function () { + button[prop].should.eql(button1[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 7313e012968c0f57a2e030367409660f17d9d1d8 Mon Sep 17 00:00:00 2001 From: Connor Dickey Date: Fri, 10 Oct 2025 22:45:36 -0500 Subject: [PATCH 5/5] Remove Space for Linting --- tests/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/index.js b/tests/index.js index c845bf5..5884f8a 100644 --- a/tests/index.js +++ b/tests/index.js @@ -219,7 +219,6 @@ describe('Dashboard Migration Script', function () { }) }) - describe('UI Number Input', function () { const input = utils.getByType(migratedFlow, 'ui-number-input')[0] const input1 = utils.getByType(basicLayoutAfter, 'ui-number-input')[0]