Don't allow Move and Duplicate actions on non creatable objects (#3518)

* Prevent copy and move actions for non creatable objects

* Remove unneeded code

* Remove prototype typo

* Allow duplicating an object only if it is creatable

Co-authored-by: Deep Tailor <deep.j.tailor@nasa.gov>
This commit is contained in:
Shefali Joshi 2020-11-25 14:23:12 -08:00 committed by GitHub
parent acea18fa70
commit 176226ddef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -143,13 +143,16 @@ export default class DuplicateAction {
let parent = objectPath[1];
let parentType = parent && this.openmct.types.get(parent.type);
let child = objectPath[0];
let childType = child && this.openmct.types.get(child.type);
let locked = child.locked ? child.locked : parent && parent.locked;
if (locked) {
return false;
}
return parentType
return childType
&& childType.definition.creatable
&& parentType
&& parentType.definition.creatable
&& Array.isArray(parent.composition);
}

View File

@ -154,6 +154,7 @@ export default class MoveAction {
let parent = objectPath[1];
let parentType = parent && this.openmct.types.get(parent.type);
let child = objectPath[0];
let childType = child && this.openmct.types.get(child.type);
if (child.locked || (parent && parent.locked)) {
return false;
@ -161,6 +162,8 @@ export default class MoveAction {
return parentType
&& parentType.definition.creatable
&& childType
&& childType.definition.creatable
&& Array.isArray(parent.composition);
}
}