mirror of
https://github.com/nasa/openmct.git
synced 2025-06-19 07:38:15 +00:00
Move all support for the legacy API into a plugin (#4614)
* Make legacy support optional * Fix order of legacy plugin registration * Added 'supportComposition' function * Add composition policy to check that parent supports composition * Fix memory leaks in timer
This commit is contained in:
@ -31,7 +31,7 @@ export default class LADTableViewProvider {
|
||||
}
|
||||
|
||||
canView(domainObject) {
|
||||
const supportsComposition = this.openmct.composition.get(domainObject) !== undefined;
|
||||
const supportsComposition = this.openmct.composition.supportsComposition(domainObject);
|
||||
const providesTelemetry = this.openmct.telemetry.isTelemetryObject(domainObject);
|
||||
|
||||
return domainObject.type === 'LadTable'
|
||||
|
@ -130,14 +130,6 @@ describe("the plugin", function () {
|
||||
let mockComposition;
|
||||
|
||||
beforeEach(async () => {
|
||||
const getFunc = openmct.$injector.get;
|
||||
spyOn(openmct.$injector, "get")
|
||||
.withArgs("exportImageService").and.returnValue({
|
||||
exportPNG: () => {},
|
||||
exportJPG: () => {}
|
||||
})
|
||||
.and.callFake(getFunc);
|
||||
|
||||
barGraphObject = {
|
||||
identifier: {
|
||||
namespace: "",
|
||||
|
@ -87,6 +87,7 @@ describe("Clock plugin:", () => {
|
||||
|
||||
spyOn(openmct.objects, 'get').and.returnValue(Promise.resolve(clockViewObject));
|
||||
spyOn(openmct.objects, 'save').and.returnValue(Promise.resolve(true));
|
||||
spyOn(openmct.objects, 'supportsMutation').and.returnValue(true);
|
||||
|
||||
const applicableViews = openmct.objectViews.get(clockViewObject, [clockViewObject]);
|
||||
clockViewProvider = applicableViews.find(viewProvider => viewProvider.key === 'clock.view');
|
||||
|
@ -23,7 +23,6 @@ import ConditionSetViewProvider from './ConditionSetViewProvider.js';
|
||||
import ConditionSetCompositionPolicy from "./ConditionSetCompositionPolicy";
|
||||
import ConditionSetMetadataProvider from './ConditionSetMetadataProvider';
|
||||
import ConditionSetTelemetryProvider from './ConditionSetTelemetryProvider';
|
||||
import ConditionSetViewPolicy from './ConditionSetViewPolicy';
|
||||
import uuid from "uuid";
|
||||
|
||||
export default function ConditionPlugin() {
|
||||
@ -55,10 +54,6 @@ export default function ConditionPlugin() {
|
||||
domainObject.telemetry = {};
|
||||
}
|
||||
});
|
||||
openmct.legacyExtension('policies', {
|
||||
category: 'view',
|
||||
implementation: ConditionSetViewPolicy
|
||||
});
|
||||
openmct.composition.addPolicy(new ConditionSetCompositionPolicy(openmct).allow);
|
||||
openmct.telemetry.addProvider(new ConditionSetMetadataProvider(openmct));
|
||||
openmct.telemetry.addProvider(new ConditionSetTelemetryProvider(openmct));
|
||||
|
78
src/plugins/legacySupport/BundleRegistry.js
Normal file
78
src/plugins/legacySupport/BundleRegistry.js
Normal file
@ -0,0 +1,78 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2021, 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 () {
|
||||
|
||||
function BundleRegistry() {
|
||||
this.bundles = {};
|
||||
this.knownBundles = {};
|
||||
}
|
||||
|
||||
BundleRegistry.prototype.register = function (path, definition) {
|
||||
if (Object.prototype.hasOwnProperty.call(this.knownBundles, path)) {
|
||||
throw new Error('Cannot register bundle with duplicate path', path);
|
||||
}
|
||||
|
||||
this.knownBundles[path] = definition;
|
||||
};
|
||||
|
||||
BundleRegistry.prototype.enable = function (path) {
|
||||
if (!this.knownBundles[path]) {
|
||||
throw new Error('Unknown bundle ' + path);
|
||||
}
|
||||
|
||||
this.bundles[path] = this.knownBundles[path];
|
||||
};
|
||||
|
||||
BundleRegistry.prototype.disable = function (path) {
|
||||
if (!this.bundles[path]) {
|
||||
throw new Error('Tried to disable inactive bundle ' + path);
|
||||
}
|
||||
|
||||
delete this.bundles[path];
|
||||
};
|
||||
|
||||
BundleRegistry.prototype.contains = function (path) {
|
||||
return Boolean(this.bundles[path]);
|
||||
};
|
||||
|
||||
BundleRegistry.prototype.get = function (path) {
|
||||
return this.bundles[path];
|
||||
};
|
||||
|
||||
BundleRegistry.prototype.list = function () {
|
||||
return Object.keys(this.bundles);
|
||||
};
|
||||
|
||||
BundleRegistry.prototype.remove = BundleRegistry.prototype.disable;
|
||||
|
||||
BundleRegistry.prototype.delete = function (path) {
|
||||
if (!this.knownBundles[path]) {
|
||||
throw new Error('Cannot remove Unknown Bundle ' + path);
|
||||
}
|
||||
|
||||
delete this.bundles[path];
|
||||
delete this.knownBundles[path];
|
||||
};
|
||||
|
||||
return BundleRegistry;
|
||||
});
|
88
src/plugins/legacySupport/BundleRegistrySpec.js
Normal file
88
src/plugins/legacySupport/BundleRegistrySpec.js
Normal file
@ -0,0 +1,88 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2021, 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(['./BundleRegistry'], function (BundleRegistry) {
|
||||
|
||||
describe("BundleRegistry", function () {
|
||||
let testPath;
|
||||
let bundleRegistry;
|
||||
|
||||
beforeEach(function () {
|
||||
testPath = 'some/bundle';
|
||||
bundleRegistry = new BundleRegistry();
|
||||
});
|
||||
|
||||
it("initially lists no bundles", function () {
|
||||
expect(bundleRegistry.list()).toEqual([]);
|
||||
});
|
||||
|
||||
it("initially contains no bundles", function () {
|
||||
expect(bundleRegistry.contains(testPath))
|
||||
.toBe(false);
|
||||
});
|
||||
|
||||
it("initially provides no bundles", function () {
|
||||
expect(bundleRegistry.get(testPath))
|
||||
.toBeUndefined();
|
||||
});
|
||||
|
||||
describe("when a bundle has been registered", function () {
|
||||
let testBundleDef;
|
||||
|
||||
beforeEach(function () {
|
||||
testBundleDef = { someKey: "some value" };
|
||||
bundleRegistry.register(testPath, testBundleDef);
|
||||
bundleRegistry.enable(testPath);
|
||||
});
|
||||
|
||||
it("lists registered bundles", function () {
|
||||
expect(bundleRegistry.list()).toEqual([testPath]);
|
||||
});
|
||||
|
||||
it("contains registered bundles", function () {
|
||||
expect(bundleRegistry.contains(testPath))
|
||||
.toBe(true);
|
||||
});
|
||||
|
||||
it("provides registered bundles", function () {
|
||||
expect(bundleRegistry.get(testPath))
|
||||
.toBe(testBundleDef);
|
||||
});
|
||||
|
||||
describe("and then removed", function () {
|
||||
beforeEach(function () {
|
||||
bundleRegistry.remove(testPath);
|
||||
});
|
||||
|
||||
it("appears empty again", function () {
|
||||
expect(bundleRegistry.list()).toEqual([]);
|
||||
});
|
||||
|
||||
it("does not contain the removed bundle", function () {
|
||||
expect(bundleRegistry.contains(testPath))
|
||||
.toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
101
src/plugins/legacySupport/installDefaultBundles.js
Normal file
101
src/plugins/legacySupport/installDefaultBundles.js
Normal file
@ -0,0 +1,101 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2021, 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.
|
||||
*****************************************************************************/
|
||||
const DEFAULTS = [
|
||||
'src/adapter',
|
||||
'platform/framework',
|
||||
'platform/core',
|
||||
'platform/representation',
|
||||
'platform/commonUI/browse',
|
||||
'platform/commonUI/edit',
|
||||
'platform/commonUI/dialog',
|
||||
'platform/commonUI/general',
|
||||
'platform/commonUI/inspect',
|
||||
'platform/commonUI/mobile',
|
||||
'platform/commonUI/notification',
|
||||
'platform/containment',
|
||||
'platform/exporters',
|
||||
'platform/telemetry',
|
||||
'platform/identity',
|
||||
'platform/persistence/aggregator',
|
||||
'platform/policy',
|
||||
'platform/entanglement',
|
||||
'platform/status',
|
||||
'platform/commonUI/regions'
|
||||
];
|
||||
|
||||
define([
|
||||
'../../adapter/bundle',
|
||||
'../../../example/eventGenerator/bundle',
|
||||
'../../../example/export/bundle',
|
||||
'../../../example/forms/bundle',
|
||||
'../../../example/identity/bundle',
|
||||
'../../../example/mobile/bundle',
|
||||
'../../../example/msl/bundle',
|
||||
'../../../example/notifications/bundle',
|
||||
'../../../example/persistence/bundle',
|
||||
'../../../example/policy/bundle',
|
||||
'../../../example/profiling/bundle',
|
||||
'../../../example/scratchpad/bundle',
|
||||
'../../../example/styleguide/bundle',
|
||||
'../../../platform/commonUI/browse/bundle',
|
||||
'../../../platform/commonUI/dialog/bundle',
|
||||
'../../../platform/commonUI/edit/bundle',
|
||||
'../../../platform/commonUI/general/bundle',
|
||||
'../../../platform/commonUI/inspect/bundle',
|
||||
'../../../platform/commonUI/mobile/bundle',
|
||||
'../../../platform/commonUI/notification/bundle',
|
||||
'../../../platform/commonUI/regions/bundle',
|
||||
'../../../platform/containment/bundle',
|
||||
'../../../platform/core/bundle',
|
||||
'../../../platform/entanglement/bundle',
|
||||
'../../../platform/exporters/bundle',
|
||||
'../../../platform/features/static-markup/bundle',
|
||||
'../../../platform/framework/bundle',
|
||||
'../../../platform/framework/src/load/Bundle',
|
||||
'../../../platform/identity/bundle',
|
||||
'../../../platform/persistence/aggregator/bundle',
|
||||
'../../../platform/persistence/elastic/bundle',
|
||||
'../../../platform/persistence/queue/bundle',
|
||||
'../../../platform/policy/bundle',
|
||||
'../../../platform/representation/bundle',
|
||||
'../../../platform/status/bundle',
|
||||
'../../../platform/telemetry/bundle'
|
||||
], function () {
|
||||
const LEGACY_BUNDLES = Array.from(arguments);
|
||||
|
||||
return function installDefaultBundles(bundleRegistry) {
|
||||
registerLegacyBundles(LEGACY_BUNDLES);
|
||||
enableDefaultBundles();
|
||||
|
||||
function registerLegacyBundles(bundles) {
|
||||
bundles.forEach((bundle, i) => {
|
||||
bundleRegistry.register(bundle.name, bundle.definition);
|
||||
});
|
||||
}
|
||||
|
||||
function enableDefaultBundles() {
|
||||
DEFAULTS.forEach(function (bundlePath) {
|
||||
bundleRegistry.enable(bundlePath);
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
@ -20,15 +20,6 @@
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
|
||||
function ConditionSetViewPolicy() {
|
||||
}
|
||||
|
||||
ConditionSetViewPolicy.prototype.allow = function (view, domainObject) {
|
||||
if (domainObject.getModel().type === 'conditionSet') {
|
||||
return view.key === 'conditionSet.view';
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
export default ConditionSetViewPolicy;
|
||||
define(['./BundleRegistry'], function (BundleRegistry) {
|
||||
return new BundleRegistry();
|
||||
});
|
33
src/plugins/legacySupport/legacyRegistrySpec.js
Normal file
33
src/plugins/legacySupport/legacyRegistrySpec.js
Normal file
@ -0,0 +1,33 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2021, 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([
|
||||
'./legacyRegistry',
|
||||
'./BundleRegistry'
|
||||
], function (legacyRegistry, BundleRegistry) {
|
||||
|
||||
describe("legacyRegistry", function () {
|
||||
it("is a BundleRegistry", function () {
|
||||
expect(legacyRegistry instanceof BundleRegistry).toBe(true);
|
||||
});
|
||||
});
|
||||
});
|
126
src/plugins/legacySupport/plugin.js
Normal file
126
src/plugins/legacySupport/plugin.js
Normal file
@ -0,0 +1,126 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2021, 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.
|
||||
*****************************************************************************/
|
||||
import installDefaultBundles from './installDefaultBundles';
|
||||
import BundleRegistry from './BundleRegistry';
|
||||
import Main from '../../../platform/framework/src/Main';
|
||||
import objectUtils from '../../api/objects/object-utils';
|
||||
import DomainObjectImpl from '../../../platform/core/src/objects/DomainObjectImpl';
|
||||
import ContextualDomainObject from '../../../platform/core/src/capabilities/ContextualDomainObject';
|
||||
|
||||
export default function LegacySupportPlugin() {
|
||||
return function install(openmct) {
|
||||
openmct.legacyBundle = {
|
||||
extensions: {
|
||||
services: [
|
||||
{
|
||||
key: "openmct",
|
||||
implementation: function ($injector) {
|
||||
openmct.$injector = $injector;
|
||||
|
||||
return openmct;
|
||||
},
|
||||
depends: ['$injector']
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
openmct.legacyExtension = function (category, extension) {
|
||||
this.legacyBundle.extensions[category] =
|
||||
this.legacyBundle.extensions[category] || [];
|
||||
this.legacyBundle.extensions[category].push(extension);
|
||||
}.bind(openmct);
|
||||
|
||||
/**
|
||||
* Return a legacy object, for compatibility purposes only. This method
|
||||
* will be deprecated and removed in the future.
|
||||
* @private
|
||||
*/
|
||||
openmct.legacyObject = function (domainObject) {
|
||||
let capabilityService = this.$injector.get('capabilityService');
|
||||
|
||||
function instantiate(model, keyString) {
|
||||
const capabilities = capabilityService.getCapabilities(model, keyString);
|
||||
model.id = keyString;
|
||||
|
||||
return new DomainObjectImpl(keyString, model, capabilities);
|
||||
}
|
||||
|
||||
if (Array.isArray(domainObject)) {
|
||||
// an array of domain objects. [object, ...ancestors] representing
|
||||
// a single object with a given chain of ancestors. We instantiate
|
||||
// as a single contextual domain object.
|
||||
return domainObject
|
||||
.map((o) => {
|
||||
let keyString = objectUtils.makeKeyString(o.identifier);
|
||||
let oldModel = objectUtils.toOldFormat(o);
|
||||
|
||||
return instantiate(oldModel, keyString);
|
||||
})
|
||||
.reverse()
|
||||
.reduce((parent, child) => {
|
||||
return new ContextualDomainObject(child, parent);
|
||||
});
|
||||
|
||||
} else {
|
||||
let keyString = objectUtils.makeKeyString(domainObject.identifier);
|
||||
let oldModel = objectUtils.toOldFormat(domainObject);
|
||||
|
||||
return instantiate(oldModel, keyString);
|
||||
}
|
||||
}.bind(openmct);
|
||||
|
||||
openmct.legacyRegistry = new BundleRegistry();
|
||||
installDefaultBundles(openmct.legacyRegistry);
|
||||
|
||||
const patchedStart = openmct.start.bind(openmct);
|
||||
openmct.start = async () => {
|
||||
openmct.legacyRegistry.register('adapter', openmct.legacyBundle);
|
||||
openmct.legacyRegistry.enable('adapter');
|
||||
|
||||
openmct.legacyExtension('runs', {
|
||||
depends: ['navigationService'],
|
||||
implementation: function (navigationService) {
|
||||
navigationService
|
||||
.addListener(openmct.emit.bind(openmct, 'navigation'));
|
||||
}
|
||||
});
|
||||
|
||||
// TODO: remove with legacy types.
|
||||
openmct.types.listKeys().forEach(function (typeKey) {
|
||||
const type = openmct.types.get(typeKey);
|
||||
const legacyDefinition = type.toLegacyDefinition();
|
||||
legacyDefinition.key = typeKey;
|
||||
openmct.legacyExtension('types', legacyDefinition);
|
||||
});
|
||||
|
||||
const main = new Main();
|
||||
const angularInstance = await main.run(openmct);
|
||||
|
||||
openmct.$angular = angularInstance;
|
||||
openmct.$injector.get('objectService');
|
||||
|
||||
return patchedStart();
|
||||
};
|
||||
|
||||
};
|
||||
}
|
@ -30,7 +30,6 @@ import {
|
||||
describe('the plugin', () => {
|
||||
let notificationIndicatorPlugin;
|
||||
let openmct;
|
||||
let indicatorObject;
|
||||
let indicatorElement;
|
||||
let parentElement;
|
||||
let mockMessages = ['error', 'test', 'notifications'];
|
||||
@ -43,9 +42,6 @@ describe('the plugin', () => {
|
||||
|
||||
parentElement = document.createElement('div');
|
||||
|
||||
indicatorObject = openmct.indicators.indicatorObjects.find(indicator => indicator.key === 'notifications-indicator');
|
||||
indicatorElement = indicatorObject.element;
|
||||
|
||||
openmct.on('start', () => {
|
||||
mockMessages.forEach(message => {
|
||||
openmct.notifications.error(message);
|
||||
@ -53,7 +49,7 @@ describe('the plugin', () => {
|
||||
done();
|
||||
});
|
||||
|
||||
openmct.startHeadless();
|
||||
openmct.start();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
@ -68,7 +64,7 @@ describe('the plugin', () => {
|
||||
});
|
||||
|
||||
it('notifies the user of the number of notifications', () => {
|
||||
let notificationCountElement = parentElement.querySelector('.c-indicator__count');
|
||||
let notificationCountElement = document.querySelector('.c-indicator__count');
|
||||
|
||||
expect(notificationCountElement.innerText).toEqual(mockMessages.length.toString());
|
||||
});
|
||||
|
@ -533,13 +533,6 @@ describe("the plugin", function () {
|
||||
let plotViewComponentObject;
|
||||
|
||||
beforeEach(() => {
|
||||
const getFunc = openmct.$injector.get;
|
||||
spyOn(openmct.$injector, "get")
|
||||
.withArgs("exportImageService").and.returnValue({
|
||||
exportPNG: () => {},
|
||||
exportJPG: () => {}
|
||||
})
|
||||
.and.callFake(getFunc);
|
||||
|
||||
stackedPlotObject = {
|
||||
identifier: {
|
||||
|
@ -74,7 +74,9 @@ define([
|
||||
'./clock/plugin',
|
||||
'./DeviceClassifier/plugin',
|
||||
'./timer/plugin',
|
||||
'./localStorage/plugin'
|
||||
'./localStorage/plugin',
|
||||
'./legacySupport/plugin.js',
|
||||
'../adapter/indicators/legacy-indicators-plugin'
|
||||
], function (
|
||||
_,
|
||||
UTCTimeSystem,
|
||||
@ -129,7 +131,9 @@ define([
|
||||
Clock,
|
||||
DeviceClassifier,
|
||||
Timer,
|
||||
LocalStorage
|
||||
LocalStorage,
|
||||
LegacySupportPlugin,
|
||||
LegacyIndicatorsPlugin
|
||||
) {
|
||||
const bundleMap = {
|
||||
Elasticsearch: 'platform/persistence/elastic'
|
||||
@ -237,6 +241,8 @@ define([
|
||||
plugins.Timer = Timer.default;
|
||||
plugins.DeviceClassifier = DeviceClassifier.default;
|
||||
plugins.LocalStorage = LocalStorage.default;
|
||||
plugins.LegacySupport = LegacySupportPlugin.default;
|
||||
plugins.LegacyIndicators = LegacyIndicatorsPlugin;
|
||||
|
||||
return plugins;
|
||||
});
|
||||
|
@ -191,7 +191,7 @@ export default {
|
||||
});
|
||||
});
|
||||
},
|
||||
destroyed() {
|
||||
beforeDestroy() {
|
||||
this.active = false;
|
||||
if (this.unlisten) {
|
||||
this.unlisten();
|
||||
|
@ -60,6 +60,8 @@ describe("Timer plugin:", () => {
|
||||
timerDefinition = openmct.types.get('timer').definition;
|
||||
timerDefinition.initialize(timerDomainObject);
|
||||
|
||||
spyOn(openmct.objects, 'supportsMutation').and.returnValue(true);
|
||||
|
||||
openmct.on('start', resolve);
|
||||
openmct.start(appHolder);
|
||||
});
|
||||
@ -93,6 +95,8 @@ describe("Timer plugin:", () => {
|
||||
const applicableViews = openmct.objectViews.get(timerViewObject, [timerViewObject]);
|
||||
timerViewProvider = applicableViews.find(viewProvider => viewProvider.key === 'timer.view');
|
||||
|
||||
spyOn(openmct.objects, 'get').and.returnValue(Promise.resolve(timerViewObject));
|
||||
|
||||
mutableTimerObject = await openmct.objects.getMutable(timerViewObject.identifier);
|
||||
|
||||
timerObjectPath = [mutableTimerObject];
|
||||
@ -102,6 +106,10 @@ describe("Timer plugin:", () => {
|
||||
await Vue.nextTick();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
timerView.destroy();
|
||||
});
|
||||
|
||||
it("should migrate old object properties to the configuration section", () => {
|
||||
openmct.objects.applyGetInterceptors(timerViewObject.identifier, timerViewObject);
|
||||
expect(timerViewObject.configuration.timerFormat).toBe('short');
|
||||
|
Reference in New Issue
Block a user