Unverified Commit 68089664 authored by Beka Westberg's avatar Beka Westberg Committed by GitHub

Fix deprecation being inconsistent (#2219)

parent 4a41f72d
......@@ -197,6 +197,19 @@ Blockly.ComponentBlock.addGenericOption = function(block, options) {
options.splice(options.length - 1, 0, item);
};
/**
* Marks the passed block as a badBlock() and disables it if the data associated
* with the block is not defined, or the data is marked as deprecated.
* @param {Blockly.BlockSvg} block The block to check for deprecation.
* @param {EventDescriptor|MethodDescriptor|PropertyDescriptor} data The data
* associated with the block which is possibly deprecated.
*/
Blockly.ComponentBlock.checkDeprecated = function(block, data) {
if (data && data.deprecated && block.workspace == Blockly.mainWorkspace) {
block.setDisabled(true);
}
}
/**
* Create an event block of the given type for a component with the given
* instance name. eventType is one of the "events" objects in a typeJsonString
......@@ -301,12 +314,10 @@ Blockly.Blocks.component_event = {
input.init();
}
if (eventType && eventType.deprecated === "true" && this.workspace === Blockly.mainWorkspace) {
this.badBlock();
this.setDisabled(true);
}
this.verify(); // verify the block and mark it accordingly
// Set as badBlock if it doesn't exist.
this.verify();
// Disable it if it does exist and is deprecated.
Blockly.ComponentBlock.checkDeprecated(this, eventType);
this.rendered = oldRendered;
},
......@@ -770,15 +781,10 @@ Blockly.Blocks.component_method = {
this.errors = [{name:"checkIfUndefinedBlock"}, {name:"checkIsInDefinition"},
{name:"checkComponentNotExistsError"}, {name: "checkGenericComponentSocket"}];
// mark the block bad if the method isn't defined or is marked deprecated
var method = this.getMethodTypeObject();
if ((!method || method.deprecated === true || method.deprecated === 'true') &&
this.workspace === Blockly.mainWorkspace) {
this.badBlock();
this.setDisabled(true);
}
this.verify(); // verify the block and mark it accordingly
// Set as badBlock if it doesn't exist.
this.verify();
// Disable it if it does exist and is deprecated.
Blockly.ComponentBlock.checkDeprecated(this, this.getMethodTypeObject());
this.rendered = oldRendered;
},
......@@ -1029,9 +1035,9 @@ Blockly.Blocks.component_set_get = {
this.setColour(Blockly.ComponentBlock.COLOUR_GET);
}
var tooltipDescription;
if (this.propertyName) {
tooltipDescription = componentDb.getInternationalizedPropertyDescription(this.getTypeName(), this.propertyName,
this.propertyObject.description);
if (this.propertyName && this.propertyObject) {
tooltipDescription = componentDb.getInternationalizedPropertyDescription(
this.getTypeName(), this.propertyName, this.propertyObject.description);
} else {
tooltipDescription = Blockly.Msg.UNDEFINED_BLOCK_TOOLTIP;
}
......@@ -1126,13 +1132,10 @@ Blockly.Blocks.component_set_get = {
{name:"checkComponentNotExistsError"}, {name: 'checkGenericComponentSocket'},
{name: 'checkEmptySetterSocket'}];
if (thisBlock.propertyObject && this.propertyObject.deprecated === "true" && this.workspace === Blockly.mainWorkspace) {
// [lyn, 2015/12/27] mark deprecated properties as bad
this.badBlock();
this.setDisabled(true);
}
// Set as badBlock if it doesn't exist.
this.verify();
// Disable it if it does exist and is deprecated.
Blockly.ComponentBlock.checkDeprecated(this, this.propertyObject);
for (var i = 0, input; input = this.inputList[i]; i++) {
input.init();
......
......@@ -351,7 +351,6 @@ Blockly.ComponentDatabase.prototype.populateTypes = function(componentInfos) {
info.properties[property.name] = property;
if (typeof property['deprecated'] === 'string') {
property['deprecated'] = JSON.parse(property['deprecated']);
if (property['deprecated']) continue;
}
if (property['rw'] == 'read-write') {
property.mutability = Blockly.PROPERTY_READWRITEABLE;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment