Skip to content

Commit

Permalink
Merge pull request #453 from FlowFuse/ui-base-bc
Browse files Browse the repository at this point in the history
UI Base: Account for upgrade path meaning no defaults set for new properties
  • Loading branch information
joepavitt authored Dec 22, 2023
2 parents f3998be + fb9b115 commit 3d30838
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions nodes/config/ui_base.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,19 @@ module.exports = function (RED) {
function init (node, config) {
node.uiShared = uiShared // ensure we have a uiShared object on the node (for testing mainly)

if (!config.acceptsClientConfig) {
// for those upgrading, we need this for backwards compatibility
config.acceptsClientConfig = ['ui-control', 'ui-notification']
}

if (!('includeClientData' in config)) {
// for those upgrading, we need this for backwards compatibility
config.includeClientData = true
}

// expose these properties at runtime
node.acceptsClientConfig = config.acceptsClientConfig || [] // which node types can be scoped to a specific client
node.includeClientData = config.includeClientData || false // whether to include client data in msg payloads
node.acceptsClientConfig = config.acceptsClientConfig // which node types can be scoped to a specific client
node.includeClientData = config.includeClientData // whether to include client data in msg payloads

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

0 comments on commit 3d30838

Please sign in to comment.