From e8536f2714d41e3356f41848371e617ef53f1152 Mon Sep 17 00:00:00 2001 From: Tatiana Lopaeva Date: Fri, 18 Nov 2022 17:42:28 +0300 Subject: [PATCH] Web: Added additional conditions added. --- .../client/src/store/AccessRightsStore.js | 47 +++++-------------- packages/client/src/store/FilesStore.js | 16 ++----- 2 files changed, 17 insertions(+), 46 deletions(-) diff --git a/packages/client/src/store/AccessRightsStore.js b/packages/client/src/store/AccessRightsStore.js index 7cf6ded51c..6504628503 100644 --- a/packages/client/src/store/AccessRightsStore.js +++ b/packages/client/src/store/AccessRightsStore.js @@ -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; }; diff --git a/packages/client/src/store/FilesStore.js b/packages/client/src/store/FilesStore.js index 60d038ae14..0a3400acfb 100644 --- a/packages/client/src/store/FilesStore.js +++ b/packages/client/src/store/FilesStore.js @@ -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"]); }