Skip to content

Commit 3d30838

Browse files
authored
Merge pull request #453 from FlowFuse/ui-base-bc
UI Base: Account for upgrade path meaning no defaults set for new properties
2 parents f3998be + fb9b115 commit 3d30838

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

nodes/config/ui_base.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,19 @@ module.exports = function (RED) {
4545
function init (node, config) {
4646
node.uiShared = uiShared // ensure we have a uiShared object on the node (for testing mainly)
4747

48+
if (!config.acceptsClientConfig) {
49+
// for those upgrading, we need this for backwards compatibility
50+
config.acceptsClientConfig = ['ui-control', 'ui-notification']
51+
}
52+
53+
if (!('includeClientData' in config)) {
54+
// for those upgrading, we need this for backwards compatibility
55+
config.includeClientData = true
56+
}
57+
4858
// expose these properties at runtime
49-
node.acceptsClientConfig = config.acceptsClientConfig || [] // which node types can be scoped to a specific client
50-
node.includeClientData = config.includeClientData || false // whether to include client data in msg payloads
59+
node.acceptsClientConfig = config.acceptsClientConfig // which node types can be scoped to a specific client
60+
node.includeClientData = config.includeClientData // whether to include client data in msg payloads
5161

5262
// eventually check if we have routes used, so we can support multiple base UIs
5363
if (!uiShared.app) {
@@ -275,7 +285,7 @@ module.exports = function (RED) {
275285
*/
276286
function emit (event, msg, wNode) {
277287
Object.values(uiShared.connections).forEach(conn => {
278-
const nodeAllowsConstraints = n.acceptsClientConfig.includes(wNode.type)
288+
const nodeAllowsConstraints = n.acceptsClientConfig?.includes(wNode.type)
279289
if ((nodeAllowsConstraints && isValidConnection(conn, msg)) || !nodeAllowsConstraints) {
280290
conn.emit(event, msg)
281291
}

0 commit comments

Comments
 (0)