Fix Independent Time Conductor for Plans within Time Strips (#5671)

* Update `IndependentTimeContext` only if its `objectPath` differs

* Ensure independent time conductor, fixed and realtime inputs have the right objectPath

* [e2e] Add Plan creation test

* [e2e] add Create TimeStrip test

* mark new faultManagement suite with @unstable

* Upgrade to @playwright/test v1.25.0

* Extract `createPlanFromJSON` to appActions

* [e2e] Add TimeStrip test for Plans, Independent Time Contexts

* [e2e] Move test annotation to the top

* [e2e] fix timestrip test

* Update docker image so the tests run

* update playwright on GHA as well

* [e2e] Fix menu test

* Error if no objectPath provided

Co-authored-by: Shefali <simplyrender@gmail.com>
Co-authored-by: Jesse Mazzella <jesse.d.mazzella@nasa.gov>
This commit is contained in:
Jesse Mazzella
2022-09-09 17:31:03 -07:00
committed by GitHub
parent c231c2d7cb
commit a7ea5afa59
15 changed files with 397 additions and 42 deletions

View File

@ -171,27 +171,38 @@ class TimeAPI extends GlobalTimeContext {
* @memberof module:openmct.TimeAPI#
* @method getContextForView
*/
getContextForView(objectPath = []) {
const viewKey = objectPath.length && this.openmct.objects.makeKeyString(objectPath[0].identifier);
if (viewKey) {
let viewTimeContext = this.getIndependentContext(viewKey);
if (viewTimeContext) {
this.independentContexts.delete(viewKey);
} else {
viewTimeContext = new IndependentTimeContext(this.openmct, this, objectPath);
}
// return a new IndependentContext in case the objectPath is different
this.independentContexts.set(viewKey, viewTimeContext);
return viewTimeContext;
getContextForView(objectPath) {
if (!objectPath || !Array.isArray(objectPath)) {
throw new Error('No objectPath provided');
}
// always follow the global time context
return this;
}
const viewKey = objectPath.length && this.openmct.objects.makeKeyString(objectPath[0].identifier);
if (!viewKey) {
// Return the global time context
return this;
}
let viewTimeContext = this.getIndependentContext(viewKey);
if (!viewTimeContext) {
// If the context doesn't exist yet, create it.
viewTimeContext = new IndependentTimeContext(this.openmct, this, objectPath);
this.independentContexts.set(viewKey, viewTimeContext);
} else {
// If it already exists, compare the objectPath to see if it needs to be updated.
const currentPath = this.openmct.objects.getRelativePath(viewTimeContext.objectPath);
const newPath = this.openmct.objects.getRelativePath(objectPath);
if (currentPath !== newPath) {
// If the path has changed, update the context.
this.independentContexts.delete(viewKey);
viewTimeContext = new IndependentTimeContext(this.openmct, this, objectPath);
this.independentContexts.set(viewKey, viewTimeContext);
}
}
return viewTimeContext;
}
}
export default TimeAPI;