mirror of
https://github.com/nasa/openmct.git
synced 2025-04-15 06:56:43 +00:00
Forbid condition sets on bar graphs and add a test (#4434)
* forbid condition sets on bar graph
This commit is contained in:
parent
e1e2cf9be8
commit
09b49f31ab
src/plugins/charts
@ -26,7 +26,7 @@ export default function BarGraphCompositionPolicy(openmct) {
|
||||
function hasRange(metadata) {
|
||||
const rangeValues = metadata.valuesForHints(['range']);
|
||||
|
||||
return rangeValues.length > 0;
|
||||
return rangeValues && rangeValues.length > 0;
|
||||
}
|
||||
|
||||
function hasBarGraphTelemetry(domainObject) {
|
||||
@ -41,8 +41,12 @@ export default function BarGraphCompositionPolicy(openmct) {
|
||||
|
||||
return {
|
||||
allow: function (parent, child) {
|
||||
if (child.type === 'conditionSet') {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((parent.type === BAR_GRAPH_KEY)
|
||||
&& (hasBarGraphTelemetry(child) === false)
|
||||
&& (!hasBarGraphTelemetry(child))
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
@ -283,7 +283,6 @@ describe("the plugin", function () {
|
||||
});
|
||||
|
||||
describe("The bar graph composition policy", () => {
|
||||
|
||||
it("allows composition for telemetry that contain at least one range", () => {
|
||||
const parent = {
|
||||
"composition": [],
|
||||
@ -365,6 +364,50 @@ describe("the plugin", function () {
|
||||
}).toThrow();
|
||||
expect(parent.composition.length).toBe(0);
|
||||
});
|
||||
it("disallows composition for condition sets", () => {
|
||||
const parent = {
|
||||
"composition": [],
|
||||
"configuration": {},
|
||||
"name": "Some Bar Graph",
|
||||
"type": "telemetry.plot.bar-graph",
|
||||
"location": "mine",
|
||||
"modified": 1631005183584,
|
||||
"persisted": 1631005183502,
|
||||
"identifier": {
|
||||
"namespace": "",
|
||||
"key": "b78e7e23-f2b8-4776-b1f0-3ff778f5c8a9"
|
||||
}
|
||||
};
|
||||
const testTelemetryObject = {
|
||||
identifier: {
|
||||
namespace: "",
|
||||
key: "test-object"
|
||||
},
|
||||
type: "conditionSet",
|
||||
name: "Test Object",
|
||||
telemetry: {
|
||||
values: [{
|
||||
key: "some-key",
|
||||
name: "Some attribute",
|
||||
format: "enum",
|
||||
hints: {
|
||||
domain: 1
|
||||
}
|
||||
}, {
|
||||
key: "some-other-key",
|
||||
name: "Another attribute",
|
||||
hints: {
|
||||
range: 1
|
||||
}
|
||||
}]
|
||||
}
|
||||
};
|
||||
const composition = openmct.composition.get(parent);
|
||||
expect(() => {
|
||||
composition.add(testTelemetryObject);
|
||||
}).toThrow();
|
||||
expect(parent.composition.length).toBe(0);
|
||||
});
|
||||
});
|
||||
describe('the inspector view', () => {
|
||||
let mockComposition;
|
||||
|
Loading…
x
Reference in New Issue
Block a user