mirror of
https://github.com/nasa/openmct.git
synced 2025-03-19 18:45:31 +00:00
moving to canView, since that is where the logic should be
This commit is contained in:
parent
3cba87d55b
commit
cc99f19318
@ -30,19 +30,25 @@ export default function AnnotationsViewProvider(openmct) {
|
||||
name: 'Annotations',
|
||||
canView: function (selection) {
|
||||
const availableTags = openmct.annotation.getAvailableTags();
|
||||
const selectionContext = selection?.[0]?.[0]?.context;
|
||||
const domainObject = selectionContext?.item;
|
||||
const isLayoutItem = selectionContext?.layoutItem;
|
||||
|
||||
if (availableTags.length < 1) {
|
||||
if (availableTags.length < 1 || isLayoutItem || !domainObject) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return selection.length;
|
||||
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;
|
||||
},
|
||||
view: function (selection) {
|
||||
let _destroy = null;
|
||||
|
||||
const selectionContext = selection?.[0]?.[0]?.context;
|
||||
const domainObject = selectionContext?.item;
|
||||
const isLayoutItem = selectionContext?.layoutItem;
|
||||
const domainObject = selection?.[0]?.[0]?.context?.item;
|
||||
|
||||
return {
|
||||
show: function (element) {
|
||||
@ -65,18 +71,6 @@ export default function AnnotationsViewProvider(openmct) {
|
||||
);
|
||||
_destroy = destroy;
|
||||
},
|
||||
showTab: function () {
|
||||
if (isLayoutItem) {
|
||||
return false;
|
||||
}
|
||||
|
||||
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;
|
||||
},
|
||||
|
@ -35,8 +35,8 @@ function isLayoutObject(selection, objectType) {
|
||||
);
|
||||
}
|
||||
|
||||
function isCreatableObject(object, type) {
|
||||
return NON_STYLABLE_TYPES.indexOf(object.type) < 0 && type.definition.creatable;
|
||||
function isCreatableObject(object, typeObject) {
|
||||
return NON_STYLABLE_TYPES.indexOf(object.type) < 0 && typeObject.definition.creatable;
|
||||
}
|
||||
|
||||
export default function StylesInspectorViewProvider(openmct) {
|
||||
@ -47,23 +47,28 @@ export default function StylesInspectorViewProvider(openmct) {
|
||||
canView: function (selection) {
|
||||
const objectSelection = selection?.[0];
|
||||
const objectContext = objectSelection?.[0]?.context;
|
||||
const layoutItem = objectContext?.layoutItem;
|
||||
const domainObject = objectContext?.item;
|
||||
const isFlexibleLayoutContainer =
|
||||
domainObject?.type === 'flexible-layout' && objectContext.type === 'container';
|
||||
const hasStyles = domainObject?.configuration?.objectStyles;
|
||||
const isFlexibleLayoutContainer = ['flexible-layout', 'fixed-layout'].includes(
|
||||
domainObject?.type
|
||||
);
|
||||
const isLayoutItem = objectContext?.layoutItem;
|
||||
|
||||
if (layoutItem) {
|
||||
if (isLayoutItem) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!domainObject || isFlexibleLayoutContainer) {
|
||||
if (!domainObject || isFlexibleLayoutContainer || !hasStyles) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const type = openmct.types.get(domainObject.type);
|
||||
const typeObject = openmct.types.get(domainObject.type);
|
||||
|
||||
return (
|
||||
isLayoutObject(objectSelection, domainObject.type) || isCreatableObject(domainObject, type)
|
||||
hasStyles ||
|
||||
isLayoutItem ||
|
||||
isLayoutObject(objectSelection, domainObject.type) ||
|
||||
isCreatableObject(domainObject, typeObject)
|
||||
);
|
||||
},
|
||||
view: function (selection) {
|
||||
@ -91,15 +96,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;
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user