Web: Added additional conditions added.

This commit is contained in:
Tatiana Lopaeva 2022-11-18 17:42:28 +03:00
parent 8ae61fdfff
commit e8536f2714
2 changed files with 17 additions and 46 deletions

View File

@ -174,37 +174,6 @@ class AccessRightsStore {
return getFileRoleActions(access).deleteAlien;
};
generalMoveProhibitionConditions = (rootFolderType, fileEditing) =>
rootFolderType === FolderType.Archive ||
rootFolderType === FolderType.TRASH ||
rootFolderType === FolderType.Favorites ||
rootFolderType === FolderType.Recent ||
rootFolderType === FolderType.Privacy ||
fileEditing;
canMoveItsItems = (item) => {
const { rootFolderType, access, editing: fileEditing } = item;
if (this.generalMoveProhibitionConditions(rootFolderType, fileEditing))
return false;
return getFileRoleActions(access).moveSelf;
};
canMoveAlienItems = (item) => {
const {
rootFolderType,
access,
editing: fileEditing,
} = item;
if (this.generalMoveProhibitionConditions(rootFolderType, fileEditing))
return false;
return getFileRoleActions(access).moveAlien;
};
canMakeForm = (item) => {
const { rootFolderType, access } = item;
@ -260,12 +229,20 @@ class AccessRightsStore {
return create;
}
canMoveItems = (room) => {
const { rootFolderType } = room;
canMoveItems = (item) => {
const { rootFolderType, access, editing: fileEditing } = item;
if (rootFolderType === FolderType.Archive) return false;
if (
rootFolderType === FolderType.Archive ||
rootFolderType === FolderType.TRASH ||
rootFolderType === FolderType.Favorites ||
rootFolderType === FolderType.Recent ||
rootFolderType === FolderType.Privacy ||
fileEditing
)
return false;
const { moveSelf, moveAlien } = getFileRoleActions(room.access);
const { moveSelf, moveAlien } = getFileRoleActions(access);
return moveSelf || moveAlien;
};

View File

@ -1056,16 +1056,10 @@ class FilesStore {
...{ editing: isEditing },
});
const canMoveItsItems = this.accessRightsStore.canMoveItsItems({
const canMove = this.accessRightsStore.canMoveItems({
...item,
...{ editing: isEditing },
});
const canMoveAlienItems = this.accessRightsStore.canMoveItsItems({
...item,
...{ editing: isEditing },
});
const canMoveAbility = canMoveItsItems || canMoveAlienItems;
const canDeleteAbility = canDeleteItsItems || canDeleteAlienItems;
const canCopy = this.accessRightsStore.canCopy(item);
@ -1163,7 +1157,7 @@ class FilesStore {
fileOptions = this.removeOptions(fileOptions, ["delete"]);
}
if (!canMoveAbility) {
if (!canMove) {
fileOptions = this.removeOptions(fileOptions, ["move-to"]);
}
@ -1174,7 +1168,7 @@ class FilesStore {
if (!canCreateCopy) {
fileOptions = this.removeOptions(fileOptions, ["copy"]);
}
if (!canMoveAbility && !canCopy && !canCreateCopy) {
if (!canMove && !canCopy && !canCreateCopy) {
fileOptions = this.removeOptions(fileOptions, ["move"]);
}
@ -1435,7 +1429,7 @@ class FilesStore {
if (!canDeleteAbility) {
fileOptions = this.removeOptions(fileOptions, ["delete"]);
}
if (!canMoveAbility) {
if (!canMove) {
folderOptions = this.removeOptions(folderOptions, ["move-to"]);
}
@ -1447,7 +1441,7 @@ class FilesStore {
fileOptions = this.removeOptions(fileOptions, ["copy"]);
}
if (!canMoveAbility && !canCopy && !canCreateCopy) {
if (!canMove && !canCopy && !canCreateCopy) {
folderOptions = this.removeOptions(folderOptions, ["move"]);
}