Allow tags files to define namespace to save annotations (#6274)

* allow tags files to define namespace to save annotations

* add tests

* typo in test name

* lint

* change param to objects object and remove debug
This commit is contained in:
Scott Bell
2023-02-08 15:48:03 +01:00
committed by GitHub
parent 10decda94e
commit 5a8f1d542e
5 changed files with 96 additions and 9 deletions

View File

@@ -84,6 +84,7 @@ export default class AnnotationAPI extends EventEmitter {
super();
this.openmct = openmct;
this.availableTags = {};
this.namespaceToSaveAnnotations = '';
this.ANNOTATION_TYPES = ANNOTATION_TYPES;
this.ANNOTATION_TYPE = ANNOTATION_TYPE;
@@ -139,7 +140,7 @@ export default class AnnotationAPI extends EventEmitter {
const domainObjectKeyString = this.openmct.objects.makeKeyString(domainObject.identifier);
const originalPathObjects = await this.openmct.objects.getOriginalPath(domainObjectKeyString);
const originalContextPath = this.openmct.objects.getRelativePath(originalPathObjects);
const namespace = domainObject.identifier.namespace;
const namespace = this.namespaceToSaveAnnotations;
const type = 'annotation';
const typeDefinition = this.openmct.types.get(type);
const definition = typeDefinition.definition;
@@ -198,6 +199,14 @@ export default class AnnotationAPI extends EventEmitter {
this.availableTags[tagKey] = tagsDefinition;
}
/**
* @method setNamespaceToSaveAnnotations
* @param {String} namespace the namespace to save new annotations to
*/
setNamespaceToSaveAnnotations(namespace) {
this.namespaceToSaveAnnotations = namespace;
}
/**
* @method isAnnotation
* @param {DomainObject} domainObject the domainObject in question