diff --git a/platform/features/events/src/policies/MessagesViewPolicy.js b/platform/features/events/src/policies/MessagesViewPolicy.js index b31ca94374..4426872b1e 100644 --- a/platform/features/events/src/policies/MessagesViewPolicy.js +++ b/platform/features/events/src/policies/MessagesViewPolicy.js @@ -35,6 +35,16 @@ define( */ function MessagesViewPolicy() { + function hasStringTelemetry(domainObject) { + var telemetry = domainObject && + domainObject.getCapability('telemetry'), + metadata = telemetry ? telemetry.getMetadata() : {}, + ranges = metadata.ranges || []; + + return ranges.some(function (range) { + return range.format === 'string'; + }); + } return { /** * Check whether or not a given action is allowed by this @@ -47,12 +57,10 @@ define( // This policy only applies for the Messages view if (view.key === 'messages') { // The Messages view is allowed only if the domain - // object is a Event Message Generator - if (domainObject.getModel().type !== 'eventGenerator') { + // object has string telemetry + if (!hasStringTelemetry(domainObject)) { return false; } - - // TODO: This may later apply to more types beyond just eventGenerator. } // Like all policies, allow by default. diff --git a/platform/features/events/test/policies/MessagesViewPolicySpec.js b/platform/features/events/test/policies/MessagesViewPolicySpec.js index 0c26b8f249..6e3430f64e 100644 --- a/platform/features/events/test/policies/MessagesViewPolicySpec.js +++ b/platform/features/events/test/policies/MessagesViewPolicySpec.js @@ -32,6 +32,7 @@ define( describe("The messages view policy", function () { var mockDomainObject, testType, + telemetryType, policy; beforeEach(function () { @@ -42,18 +43,18 @@ define( mockDomainObject.getModel.andCallFake(function (c) { return {type: testType}; }); - + policy = new MessagesViewPolicy(); }); - it("disallows the message view for non Event Generators", function () { - testType = 'notAnEventGenerator'; + it("disallows the message view for objects without string telemetry", function () { + telemetryType = 'notString'; expect(policy.allow({ key: 'messages' }, mockDomainObject)) .toBeFalsy(); }); - it("allows the message view for Event Generators", function () { - testType = 'eventGenerator'; + it("allows the message view for objects with string telemetry", function () { + telemetryType = 'string'; expect(policy.allow({ key: 'messages' }, mockDomainObject)) .toBeTruthy(); });