Merge pull request #3210 from node-red/fix-old-inject-migration

Fix issue with old inject nodes that migrated topic to 'string' type
This commit is contained in:
Nick O'Leary 2021-10-22 09:16:54 +01:00 committed by GitHub
commit 6a49b5c106
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 3 deletions

View File

@ -846,7 +846,10 @@
}, },
value: function(value) { value: function(value) {
var that = this; var that = this;
var opt = this.typeMap[this.propertyType]; // If the default type has been set to an invalid type, then on first
// creation, the current propertyType will not exist. Default to an
// empty object on the assumption the corrent type will be set shortly
var opt = this.typeMap[this.propertyType] || {};
if (!arguments.length) { if (!arguments.length) {
var v = this.input.val(); var v = this.input.val();
if (opt.export) { if (opt.export) {

View File

@ -539,7 +539,7 @@
var propertyValue = $('<input/>',{class:"node-input-prop-property-value",type:"text"}) var propertyValue = $('<input/>',{class:"node-input-prop-property-value",type:"text"})
.css("width","calc(70% - 30px)") .css("width","calc(70% - 30px)")
.appendTo(row) .appendTo(row)
.typedInput({default:prop.vt,types:['flow','global','str','num','bool','json','bin','date','jsonata','env','msg']}); .typedInput({default:prop.vt || 'str',types:['flow','global','str','num','bool','json','bin','date','jsonata','env','msg']});
propertyName.typedInput('value',prop.p); propertyName.typedInput('value',prop.p);
propertyValue.typedInput('value',prop.v); propertyValue.typedInput('value',prop.v);
@ -562,7 +562,7 @@
var topic = { var topic = {
p:'topic', p:'topic',
v: node.topic ? node.topic : '', v: node.topic ? node.topic : '',
vt:'string' vt:'str'
} }
node.props = [payload,topic]; node.props = [payload,topic];
} }
@ -578,6 +578,11 @@
newProp.v = node.topic ? node.topic : ''; newProp.v = node.topic ? node.topic : '';
} }
} }
if (newProp.vt === "string") {
// Fix bug in pre 2.1 where an old Inject node might have
// a migrated rule with type 'string' not 'str'
newProp.vt = "str";
}
eList.editableList('addItem',newProp); eList.editableList('addItem',newProp);
} }