mirror of
https://github.com/nasa/openmct.git
synced 2025-06-04 08:30:48 +00:00
[Persistability] Various checks in actions (Edit Properties, ImportFromJSON) (#4587)
Co-authored-by: Joshi <simplyrender@gmail.com>
This commit is contained in:
parent
8e3947e48d
commit
e634e09e32
@ -37,9 +37,11 @@ export default class EditPropertiesAction extends PropertiesAction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
appliesTo(objectPath) {
|
appliesTo(objectPath) {
|
||||||
const definition = this._getTypeDefinition(objectPath[0].type);
|
const object = objectPath[0];
|
||||||
|
const definition = this._getTypeDefinition(object.type);
|
||||||
|
const persistable = this.openmct.objects.isPersistable(object.identifier);
|
||||||
|
|
||||||
return definition && definition.creatable;
|
return persistable && definition && definition.creatable;
|
||||||
}
|
}
|
||||||
|
|
||||||
invoke(objectPath) {
|
invoke(objectPath) {
|
||||||
|
@ -43,7 +43,13 @@ export default class ImportAsJSONAction {
|
|||||||
*/
|
*/
|
||||||
appliesTo(objectPath) {
|
appliesTo(objectPath) {
|
||||||
const domainObject = objectPath[0];
|
const domainObject = objectPath[0];
|
||||||
if (domainObject && domainObject.locked) {
|
const locked = domainObject && domainObject.locked;
|
||||||
|
const persistable = this.openmct.objects.isPersistable(domainObject.identifier);
|
||||||
|
const TypeDefinition = this.openmct.types.get(domainObject.type);
|
||||||
|
const definition = TypeDefinition.definition;
|
||||||
|
const creatable = definition && definition.creatable;
|
||||||
|
|
||||||
|
if (locked || !persistable || !creatable) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,6 +97,7 @@ describe("The import JSON action", function () {
|
|||||||
domainObject
|
domainObject
|
||||||
];
|
];
|
||||||
|
|
||||||
|
spyOn(openmct.types, 'get').and.returnValue({});
|
||||||
spyOn(openmct.composition, 'get').and.returnValue(false);
|
spyOn(openmct.composition, 'get').and.returnValue(false);
|
||||||
|
|
||||||
expect(importFromJSONAction.appliesTo(objectPath)).toBe(false);
|
expect(importFromJSONAction.appliesTo(objectPath)).toBe(false);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user