mirror of
https://github.com/nasa/openmct.git
synced 2025-06-22 09:08:43 +00:00
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:
@ -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;
|
||||
|
Reference in New Issue
Block a user