diff --git a/src/api/annotation/AnnotationAPI.js b/src/api/annotation/AnnotationAPI.js index f6da19d2b9..3ca5889b1b 100644 --- a/src/api/annotation/AnnotationAPI.js +++ b/src/api/annotation/AnnotationAPI.js @@ -95,7 +95,6 @@ export default class AnnotationAPI extends EventEmitter { this.availableTags = {}; this.namespaceToSaveAnnotations = ''; this.#targetComparatorMap = new Map(); - this.annotatableTypes = []; this.ANNOTATION_TYPES = ANNOTATION_TYPES; this.ANNOTATION_TYPE = ANNOTATION_TYPE; @@ -116,17 +115,6 @@ export default class AnnotationAPI extends EventEmitter { domainObject.annotationType = domainObject.annotationType || 'plotspatial'; } }); - - this.openmct.on('start', () => { - const types = this.openmct.types.getTypes(); - const typeKeys = Object.keys(types); - - typeKeys.forEach((key) => { - if (types[key].definition.annotatable) { - this.annotatableTypes.push(key); - } - }); - }); } /** * Creates an annotation on a given domain object (e.g., a plot) and a set of targets (e.g., telemetry objects) @@ -594,14 +582,4 @@ export default class AnnotationAPI extends EventEmitter { _.isEqual(targets, otherTargets) ); } - - /** - * Checks if the given type is annotatable - * @param {string} type The type to check - * @returns {boolean} Returns true if the type is annotatable - */ - isAnnotatableType(type) { - console.log('type', type, this.annotatableTypes); - return this.annotatableTypes.some((annotatableType) => annotatableType === type); - } } diff --git a/src/api/telemetry/TelemetryAPI.js b/src/api/telemetry/TelemetryAPI.js index 9d83152b24..e5be70590f 100644 --- a/src/api/telemetry/TelemetryAPI.js +++ b/src/api/telemetry/TelemetryAPI.js @@ -284,27 +284,6 @@ export default class TelemetryAPI { return value; } - hasNumericTelemetry(domainObject) { - if (!Object.prototype.hasOwnProperty.call(domainObject, 'telemetry')) { - return false; - } - - let metadata = this.openmct.telemetry.getMetadata(domainObject); - - return metadata.values().length > 0 && this.#hasDomainAndNumericRange(metadata); - } - - #hasDomainAndNumericRange(metadata) { - const rangeValues = metadata.valuesForHints(['range']); - const domains = metadata.valuesForHints(['domain']); - - return ( - domains.length > 0 && - rangeValues.length > 0 && - !rangeValues.every((value) => value.format === 'string') - ); - } - /** * Generates a numeric hash value for an options object. The hash is consistent * for equivalent option objects regardless of property order. diff --git a/src/api/types/TypeRegistry.js b/src/api/types/TypeRegistry.js index 4ed36a2f1a..9506992edb 100644 --- a/src/api/types/TypeRegistry.js +++ b/src/api/types/TypeRegistry.js @@ -89,17 +89,6 @@ export default class TypeRegistry { get(typeKey) { return this.types[typeKey] || UNKNOWN_TYPE; } - /** - * List all registered types. - * @returns {Type[]} all registered types - */ - getTypes() { - return this.types; - } - /** - * Import legacy types. - * @param {TypeDefinition[]} types the types to import - */ importLegacyTypes(types) { types .filter((t) => this.get(t.key) === UNKNOWN_TYPE) diff --git a/src/plugins/gauge/GaugeCompositionPolicy.js b/src/plugins/gauge/GaugeCompositionPolicy.js index 070cdc1dea..d334c4f62c 100644 --- a/src/plugins/gauge/GaugeCompositionPolicy.js +++ b/src/plugins/gauge/GaugeCompositionPolicy.js @@ -21,10 +21,28 @@ *****************************************************************************/ export default function GaugeCompositionPolicy(openmct) { + function hasNumericTelemetry(domainObject) { + const hasTelemetry = openmct.telemetry.isTelemetryObject(domainObject); + if (!hasTelemetry) { + return false; + } + + const metadata = openmct.telemetry.getMetadata(domainObject); + + return metadata.values().length > 0 && hasDomainAndRange(metadata); + } + + function hasDomainAndRange(metadata) { + return ( + metadata.valuesForHints(['range']).length > 0 && + metadata.valuesForHints(['domain']).length > 0 + ); + } + return { allow: function (parent, child) { if (parent.type === 'gauge') { - return openmct.telemetry.hasNumericTelemetry(child); + return hasNumericTelemetry(child); } return true; diff --git a/src/plugins/inspectorViews/annotations/AnnotationsViewProvider.js b/src/plugins/inspectorViews/annotations/AnnotationsViewProvider.js index 970f3ee79a..bfc477d7c7 100644 --- a/src/plugins/inspectorViews/annotations/AnnotationsViewProvider.js +++ b/src/plugins/inspectorViews/annotations/AnnotationsViewProvider.js @@ -63,14 +63,6 @@ export default function AnnotationsViewProvider(openmct) { ); _destroy = destroy; }, - showTab: function () { - const isAnnotatableType = openmct.annotation.isAnnotatableType(domainObject.type); - const metadata = openmct.telemetry.getMetadata(domainObject); - const hasImagery = metadata?.valuesForHints(['image']).length > 0; - const hasNumericTelemetry = openmct.telemetry.hasNumericTelemetry(domainObject); - - return isAnnotatableType || hasImagery || hasNumericTelemetry; - }, priority: function () { return openmct.priority.DEFAULT; }, diff --git a/src/plugins/inspectorViews/styles/StylesInspectorViewProvider.js b/src/plugins/inspectorViews/styles/StylesInspectorViewProvider.js index 8abc1acdc1..52d79afdd4 100644 --- a/src/plugins/inspectorViews/styles/StylesInspectorViewProvider.js +++ b/src/plugins/inspectorViews/styles/StylesInspectorViewProvider.js @@ -91,15 +91,6 @@ export default function StylesInspectorViewProvider(openmct) { ); _destroy = destroy; }, - showTab: function () { - const objectSelection = selection?.[0]; - const objectContext = objectSelection?.[0]?.context; - const layoutItem = objectContext?.layoutItem; - const domainObject = objectContext?.item; - const hasStyles = domainObject?.configuration?.objectStyles; - - return layoutItem || hasStyles; - }, priority: function () { return openmct.priority.DEFAULT; }, diff --git a/src/plugins/notebook/NotebookType.js b/src/plugins/notebook/NotebookType.js index ef299fb69c..375c22af8a 100644 --- a/src/plugins/notebook/NotebookType.js +++ b/src/plugins/notebook/NotebookType.js @@ -28,7 +28,6 @@ export default class NotebookType { this.description = description; this.cssClass = icon; this.creatable = true; - this.annotatable = true; this.form = [ { key: 'defaultSort', diff --git a/src/plugins/plot/PlotViewProvider.js b/src/plugins/plot/PlotViewProvider.js index 425e495aa9..7645a1881e 100644 --- a/src/plugins/plot/PlotViewProvider.js +++ b/src/plugins/plot/PlotViewProvider.js @@ -25,6 +25,27 @@ import mount from 'utils/mount'; import Plot from './PlotView.vue'; export default function PlotViewProvider(openmct) { + function hasNumericTelemetry(domainObject) { + if (!Object.prototype.hasOwnProperty.call(domainObject, 'telemetry')) { + return false; + } + + let metadata = openmct.telemetry.getMetadata(domainObject); + + return metadata.values().length > 0 && hasDomainAndNumericRange(metadata); + } + + function hasDomainAndNumericRange(metadata) { + const rangeValues = metadata.valuesForHints(['range']); + const domains = metadata.valuesForHints(['domain']); + + return ( + domains.length > 0 && + rangeValues.length > 0 && + !rangeValues.every((value) => value.format === 'string') + ); + } + function isCompactView(objectPath) { let isChildOfTimeStrip = objectPath.find((object) => object.type === 'time-strip'); @@ -36,7 +57,7 @@ export default function PlotViewProvider(openmct) { name: 'Plot', cssClass: 'icon-telemetry', canView(domainObject, objectPath) { - return openmct.telemetry.hasNumericTelemetry(domainObject); + return hasNumericTelemetry(domainObject); }, view: function (domainObject, objectPath) { diff --git a/src/plugins/plot/overlayPlot/OverlayPlotCompositionPolicy.js b/src/plugins/plot/overlayPlot/OverlayPlotCompositionPolicy.js index 6178caebee..ca5185e8b0 100644 --- a/src/plugins/plot/overlayPlot/OverlayPlotCompositionPolicy.js +++ b/src/plugins/plot/overlayPlot/OverlayPlotCompositionPolicy.js @@ -1,10 +1,25 @@ export default function OverlayPlotCompositionPolicy(openmct) { + function hasNumericTelemetry(domainObject) { + const hasTelemetry = openmct.telemetry.isTelemetryObject(domainObject); + if (!hasTelemetry) { + return false; + } + + let metadata = openmct.telemetry.getMetadata(domainObject); + + return metadata.values().length > 0 && hasDomainAndRange(metadata); + } + + function hasDomainAndRange(metadata) { + return ( + metadata.valuesForHints(['range']).length > 0 && + metadata.valuesForHints(['domain']).length > 0 + ); + } + return { allow: function (parent, child) { - if ( - parent.type === 'telemetry.plot.overlay' && - !openmct.telemetry.hasNumericTelemetry(child) - ) { + if (parent.type === 'telemetry.plot.overlay' && hasNumericTelemetry(child) === false) { return false; } diff --git a/src/plugins/timeline/TimelineCompositionPolicy.js b/src/plugins/timeline/TimelineCompositionPolicy.js index c03b21467c..150f46217a 100644 --- a/src/plugins/timeline/TimelineCompositionPolicy.js +++ b/src/plugins/timeline/TimelineCompositionPolicy.js @@ -23,6 +23,22 @@ const ALLOWED_TYPES = ['telemetry.plot.overlay', 'telemetry.plot.stacked', 'plan', 'gantt-chart']; const DISALLOWED_TYPES = ['telemetry.plot.bar-graph', 'telemetry.plot.scatter-plot']; export default function TimelineCompositionPolicy(openmct) { + function hasNumericTelemetry(domainObject, metadata) { + const hasTelemetry = openmct.telemetry.isTelemetryObject(domainObject); + if (!hasTelemetry || !metadata) { + return false; + } + + return metadata.values().length > 0 && hasDomainAndRange(metadata); + } + + function hasDomainAndRange(metadata) { + return ( + metadata.valuesForHints(['range']).length > 0 && + metadata.valuesForHints(['domain']).length > 0 + ); + } + function hasImageTelemetry(domainObject, metadata) { if (!metadata) { return false; @@ -38,7 +54,7 @@ export default function TimelineCompositionPolicy(openmct) { if ( !DISALLOWED_TYPES.includes(child.type) && - (openmct.telemetry.hasNumericTelemetry(child) || + (hasNumericTelemetry(child, metadata) || hasImageTelemetry(child, metadata) || ALLOWED_TYPES.includes(child.type)) ) {