diff --git a/API.md b/API.md index 619c1c6787..f2d732b9c1 100644 --- a/API.md +++ b/API.md @@ -146,7 +146,7 @@ registry. eg. ```javascript openmct.types.addType('my-type', { - label: "My Type", + name: "My Type", description: "This is a type that I added!", creatable: true }); @@ -157,7 +157,7 @@ The `addType` function accepts two arguments: for an object. * An object type specification. An object type definition supports the following attributes - * `label`: a `string` naming this object type + * `name`: a `string` naming this object type * `description`: a `string` specifying a longer-form description of this type * `initialize`: a `function` which initializes the model for new domain objects of this type. This can be used for setting default values on an object when diff --git a/example/generator/plugin.js b/example/generator/plugin.js index 07172f2641..60f4955aee 100644 --- a/example/generator/plugin.js +++ b/example/generator/plugin.js @@ -75,7 +75,7 @@ define([ }) }); openmct.types.addType("generator", { - label: "Sine Wave Generator", + name: "Sine Wave Generator", description: "For development use. Generates example streaming telemetry data using a simple sine wave algorithm.", cssClass: "icon-telemetry", creatable: true, diff --git a/src/api/types/Type.js b/src/api/types/Type.js index e837535407..6649644e71 100644 --- a/src/api/types/Type.js +++ b/src/api/types/Type.js @@ -53,7 +53,7 @@ define(function () { */ Type.prototype.toLegacyDefinition = function () { var def = {}; - def.name = this.definition.label; + def.name = this.definition.name; def.cssClass = this.definition.cssClass; def.description = this.definition.description; def.properties = this.definition.form; diff --git a/src/api/types/TypeRegistry.js b/src/api/types/TypeRegistry.js index 0e38c26be2..a307b2a5e0 100644 --- a/src/api/types/TypeRegistry.js +++ b/src/api/types/TypeRegistry.js @@ -19,6 +19,7 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ +/*global console*/ define(['./Type'], function (Type) { /** @@ -52,9 +53,30 @@ define(['./Type'], function (Type) { * @memberof module:openmct.TypeRegistry# */ TypeRegistry.prototype.addType = function (typeKey, typeDef) { + this.standardizeType(typeDef); this.types[typeKey] = new Type(typeDef); }; + /** + * Takes a typeDef, standardizes it, and logs warnings about unsupported + * usage. + * @private + */ + TypeRegistry.prototype.standardizeType = function (typeDef) { + if (typeDef.label) { + console.warn( + 'DEPRECIATION WARNING typeDef: ' + typeDef.label + '. ' + + '`label` is depreciated in type definitions. Please use ' + + '`name` instead. This will cause errors in a future version ' + + 'of Open MCT. For more information, see ' + + 'https://github.com/nasa/openmct/issues/1568'); + if (!typeDef.name) { + typeDef.name = typeDef.label; + } + delete typeDef.label; + } + }; + /** * List keys for all registered types. * @method listKeys