diff --git a/README.md b/README.md index 21d2f63..019e168 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_control` - converted to Dashboard 2.0's `ui-control` - `ui_numeric` - converted to Dashboard 2.0's `ui-numeric-input` ### Config Nodes @@ -39,7 +40,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/tests/flows/basic-layout-after.json b/tests/flows/basic-layout-after.json index cc1e8a5..8ac80d0 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": "940a12ce19bf2212", "type": "ui-number-input", diff --git a/tests/flows/basic-layout-before.json b/tests/flows/basic-layout-before.json index 1c7797f..87f3706 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": "b52c292d531874a6", "type": "ui_numeric", diff --git a/tests/index.js b/tests/index.js index 028d30b..5884f8a 100644 --- a/tests/index.js +++ b/tests/index.js @@ -205,6 +205,20 @@ 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('UI Number Input', function () { const input = utils.getByType(migratedFlow, 'ui-number-input')[0] const input1 = utils.getByType(basicLayoutAfter, 'ui-number-input')[0] diff --git a/transformers/index.js b/transformers/index.js index 8f39fef..cec4af0 100644 --- a/transformers/index.js +++ b/transformers/index.js @@ -8,5 +8,6 @@ module.exports = { uiSwitch: require('./nodes/ui-switch'), uiText: require('./nodes/ui-text'), uiTextInput: require('./nodes/ui-text-input'), + uiControl: require('./nodes/ui-control'), uiNumeric: require('./nodes/ui-numeric') } diff --git a/transformers/map.json b/transformers/map.json index 9a1a789..625222e 100644 --- a/transformers/map.json +++ b/transformers/map.json @@ -8,5 +8,6 @@ "ui_switch": "uiSwitch", "ui_text": "uiText", "ui_text_input": "uiTextInput", + "ui_ui_control": "uiControl", "ui_numeric": "uiNumeric" } diff --git a/transformers/nodes/ui-control.js b/transformers/nodes/ui-control.js new file mode 100644 index 0000000..953acf0 --- /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 +}