From 43ac66233ef3bd17114cd635dc2ce6d01afd23c1 Mon Sep 17 00:00:00 2001 From: Henry Hsu Date: Fri, 28 May 2021 16:06:09 -0700 Subject: [PATCH] [Issue] remove FollowTimerAction, followIndicator and tests (#3855) Co-authored-by: Henry Hsu Co-authored-by: Andrew Henry --- platform/features/clock/bundle.js | 18 +--- .../clock/src/actions/FollowTimerAction.js | 56 ----------- .../clock/src/indicators/FollowIndicator.js | 51 ---------- .../test/actions/FollowTimerActionSpec.js | 89 ----------------- .../test/indicators/FollowIndicatorSpec.js | 96 ------------------- 5 files changed, 1 insertion(+), 309 deletions(-) delete mode 100644 platform/features/clock/src/actions/FollowTimerAction.js delete mode 100644 platform/features/clock/src/indicators/FollowIndicator.js delete mode 100644 platform/features/clock/test/actions/FollowTimerActionSpec.js delete mode 100644 platform/features/clock/test/indicators/FollowIndicatorSpec.js diff --git a/platform/features/clock/bundle.js b/platform/features/clock/bundle.js index 2a009d9214..cc0690dfd3 100644 --- a/platform/features/clock/bundle.js +++ b/platform/features/clock/bundle.js @@ -23,13 +23,11 @@ define([ "moment-timezone", "./src/indicators/ClockIndicator", - "./src/indicators/FollowIndicator", "./src/services/TickerService", "./src/services/TimerService", "./src/controllers/ClockController", "./src/controllers/TimerController", "./src/controllers/RefreshingController", - "./src/actions/FollowTimerAction", "./src/actions/StartTimerAction", "./src/actions/RestartTimerAction", "./src/actions/StopTimerAction", @@ -39,13 +37,11 @@ define([ ], function ( MomentTimezone, ClockIndicator, - FollowIndicator, TickerService, TimerService, ClockController, TimerController, RefreshingController, - FollowTimerAction, StartTimerAction, RestartTimerAction, StopTimerAction, @@ -144,15 +140,6 @@ define([ } ], "actions": [ - { - "key": "timer.follow", - "implementation": FollowTimerAction, - "depends": ["timerService"], - "category": "contextual", - "name": "Follow Timer", - "cssClass": "icon-clock", - "priority": "optional" - }, { "key": "timer.start", "implementation": StartTimerAction, @@ -299,10 +286,7 @@ define([ } } ], - "runs": [{ - "implementation": FollowIndicator, - "depends": ["openmct", "timerService"] - }], + "runs": [], "licenses": [ { "name": "moment-duration-format", diff --git a/platform/features/clock/src/actions/FollowTimerAction.js b/platform/features/clock/src/actions/FollowTimerAction.js deleted file mode 100644 index 175cfdf8b0..0000000000 --- a/platform/features/clock/src/actions/FollowTimerAction.js +++ /dev/null @@ -1,56 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT is licensed under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0. - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - * Open MCT includes source code licensed under additional open source - * licenses. See the Open Source Licenses file (LICENSES.md) included with - * this source code distribution or the Licensing information page available - * at runtime from the About dialog for additional information. - *****************************************************************************/ - -define( - [], - function () { - - /** - * Designates a specific timer for following. Timelines, for example, - * use the actively followed timer to display a time-of-interest line - * and interpret time conductor bounds in the Timeline's relative - * time frame. - * - * @implements {Action} - * @memberof platform/features/clock - * @constructor - * @param {ActionContext} context the context for this action - */ - function FollowTimerAction(timerService, context) { - var domainObject = - context.domainObject - && context.domainObject.useCapability('adapter'); - this.perform = - timerService.setTimer.bind(timerService, domainObject); - } - - FollowTimerAction.appliesTo = function (context) { - var model = - (context.domainObject && context.domainObject.getModel()) - || {}; - - return model.type === 'timer'; - }; - - return FollowTimerAction; - } -); diff --git a/platform/features/clock/src/indicators/FollowIndicator.js b/platform/features/clock/src/indicators/FollowIndicator.js deleted file mode 100644 index 204e62b340..0000000000 --- a/platform/features/clock/src/indicators/FollowIndicator.js +++ /dev/null @@ -1,51 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2018, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT is licensed under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0. - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - * Open MCT includes source code licensed under additional open source - * licenses. See the Open Source Licenses file (LICENSES.md) included with - * this source code distribution or the Licensing information page available - * at runtime from the About dialog for additional information. - *****************************************************************************/ - -define([], function () { - - /** - * Indicator that displays the active timer, as well as its - * current state. - * @memberof platform/features/clock - */ - return function installFollowIndicator(openmct, timerService) { - var indicator = openmct.indicators.simpleIndicator(); - var timer = timerService.getTimer(); - setIndicatorStatus(timer); - - function setIndicatorStatus(newTimer) { - if (newTimer !== undefined) { - indicator.iconClass('icon-timer'); - indicator.statusClass('s-status-on'); - indicator.text('Following timer ' + newTimer.name); - } else { - indicator.iconClass('icon-timer'); - indicator.statusClass('s-status-disabled'); - indicator.text('No timer being followed'); - } - } - - timerService.on('change', setIndicatorStatus); - - openmct.indicators.add(indicator); - }; -}); diff --git a/platform/features/clock/test/actions/FollowTimerActionSpec.js b/platform/features/clock/test/actions/FollowTimerActionSpec.js deleted file mode 100644 index bed3f46842..0000000000 --- a/platform/features/clock/test/actions/FollowTimerActionSpec.js +++ /dev/null @@ -1,89 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT is licensed under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0. - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - * Open MCT includes source code licensed under additional open source - * licenses. See the Open Source Licenses file (LICENSES.md) included with - * this source code distribution or the Licensing information page available - * at runtime from the About dialog for additional information. - *****************************************************************************/ - -define([ - "../../src/actions/FollowTimerAction" -], function (FollowTimerAction) { - var TIMER_SERVICE_METHODS = - ['setTimer', 'getTimer', 'clearTimer', 'on', 'off']; - - describe("The Follow Timer action", function () { - var testContext; - var testModel; - var testAdaptedObject; - - beforeEach(function () { - testModel = {}; - testContext = { - domainObject: jasmine.createSpyObj('domainObject', [ - 'getModel', - 'useCapability' - ]) - }; - testAdaptedObject = { foo: 'bar' }; - testContext.domainObject.getModel.and.returnValue(testModel); - testContext.domainObject.useCapability.and.callFake(function (c) { - return c === 'adapter' && testAdaptedObject; - }); - }); - - it("is applicable to timers", function () { - testModel.type = "timer"; - expect(FollowTimerAction.appliesTo(testContext)).toBe(true); - }); - - it("is inapplicable to non-timers", function () { - testModel.type = "folder"; - expect(FollowTimerAction.appliesTo(testContext)).toBe(false); - }); - - describe("when instantiated", function () { - var mockTimerService; - var action; - - beforeEach(function () { - mockTimerService = jasmine.createSpyObj( - 'timerService', - TIMER_SERVICE_METHODS - ); - action = new FollowTimerAction(mockTimerService, testContext); - }); - - it("does not interact with the timer service", function () { - TIMER_SERVICE_METHODS.forEach(function (method) { - expect(mockTimerService[method]).not.toHaveBeenCalled(); - }); - }); - - describe("and performed", function () { - beforeEach(function () { - action.perform(); - }); - - it("sets the active timer", function () { - expect(mockTimerService.setTimer) - .toHaveBeenCalledWith(testAdaptedObject); - }); - }); - }); - }); -}); diff --git a/platform/features/clock/test/indicators/FollowIndicatorSpec.js b/platform/features/clock/test/indicators/FollowIndicatorSpec.js deleted file mode 100644 index 5716daa77e..0000000000 --- a/platform/features/clock/test/indicators/FollowIndicatorSpec.js +++ /dev/null @@ -1,96 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2018, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT is licensed under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0. - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - * Open MCT includes source code licensed under additional open source - * licenses. See the Open Source Licenses file (LICENSES.md) included with - * this source code distribution or the Licensing information page available - * at runtime from the About dialog for additional information. - *****************************************************************************/ - -define([ - "../../src/indicators/FollowIndicator", - "../../src/services/TimerService", - "../../../../../src/MCT", - 'zepto' -], function ( - FollowIndicator, - TimerService, - MCT, - $ -) { - xdescribe("The timer-following indicator", function () { - var timerService; - var openmct; - - beforeEach(function () { - openmct = new MCT(); - timerService = new TimerService(openmct); - spyOn(openmct.indicators, "add"); - }); - - it("adds an indicator when installed", function () { - FollowIndicator(openmct, timerService); - expect(openmct.indicators.add).toHaveBeenCalled(); - }); - - it("indicates that no timer is being followed", function () { - FollowIndicator(openmct, timerService); - var simpleIndicator = openmct.indicators.add.calls.mostRecent().args[0]; - var element = simpleIndicator.element; - var text = $('.indicator-text', element).text().trim(); - expect(text).toEqual('No timer being followed'); - }); - - describe("when a timer is set", function () { - var testObject; - var simpleIndicator; - - beforeEach(function () { - testObject = { - identifier: { - namespace: 'namespace', - key: 'key' - }, - name: "some timer!" - }; - timerService.setTimer(testObject); - FollowIndicator(openmct, timerService); - simpleIndicator = openmct.indicators.add.calls.mostRecent().args[0]; - }); - - it("displays the timer's name", function () { - var element = simpleIndicator.element; - var text = $('.indicator-text', element).text().trim(); - expect(text).toEqual('Following timer ' + testObject.name); - }); - - it("displays the timer's name when it changes", function () { - var secondTimer = { - identifier: { - namespace: 'namespace', - key: 'key2' - }, - name: "Some other timer" - }; - var element = simpleIndicator.element; - timerService.setTimer(secondTimer); - var text = $('.indicator-text', element).text().trim(); - expect(text).toEqual('Following timer ' + secondTimer.name); - }); - - }); - }); -});