[ARVADOS-WORKBENCH2] updated: 1.4.1-370-g95e3ef0e

Git user git at public.arvados.org
Wed Jun 17 18:41:05 UTC 2020


Summary of changes:
 src/store/resources/resources.test.ts | 38 -----------------------------------
 src/store/resources/resources.ts      | 22 ++------------------
 2 files changed, 2 insertions(+), 58 deletions(-)

       via  95e3ef0e518ae228bbb9179b816309ce6dc402cc (commit)
      from  612b040a79d1338ea3935dd2fc57dc0908d6ee20 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 95e3ef0e518ae228bbb9179b816309ce6dc402cc
Author: Daniel Kutyła <daniel.kutyla at contractors.roche.com>
Date:   Wed Jun 17 20:40:04 2020 +0200

    16437: Reverted changes handling share for all users
    
    Arvados-DCO-1.1-Signed-off-by: Daniel Kutyła <daniel.kutyla at contractors.roche.com>

diff --git a/src/store/resources/resources.test.ts b/src/store/resources/resources.test.ts
index da630eb4..d3f084af 100644
--- a/src/store/resources/resources.test.ts
+++ b/src/store/resources/resources.test.ts
@@ -6,7 +6,6 @@ import { getResourceWithEditableStatus } from "./resources";
 import { ResourceKind } from "~/models/resource";
 
 const groupFixtures = {
-    all_users_group: 'zzzzz-j7d0g-fffffffffffffff',
     user_uuid: 'zzzzz-tpzed-0123456789ab789',
     user_resource_uuid: 'zzzzz-tpzed-0123456789abcde',
     user_from_another_cluster_uuid: 'aaaaa-tpzed-0123456789ab111',
@@ -15,24 +14,11 @@ const groupFixtures = {
     not_editable_collection_resource_uuid: 'zzzzz-4zz18-0123456789ab654',
     editable_project_resource_uuid: 'zzzzz-j7d0g-0123456789ab123',
     not_editable_project_resource_uuid: 'zzzzz-j7d0g-0123456789ab321',
-    project_shared_with_all_users_uuid: 'zzzzz-j7d0g-0123456789abaaa'
 };
 
 describe('resources', () => {
     describe('getResourceWithEditableStatus', () => {
         const resourcesState = {
-            [groupFixtures.project_shared_with_all_users_uuid]: {
-                uuid: groupFixtures.project_shared_with_all_users_uuid,
-                ownerUuid: groupFixtures.user_uuid,
-                createdAt: 'string',
-                modifiedByClientUuid: 'string',
-                modifiedByUserUuid: 'string',
-                modifiedAt: 'string',
-                href: 'string',
-                kind: ResourceKind.PROJECT,
-                writableBy: [groupFixtures.all_users_group],
-                etag: 'string',
-            },
             [groupFixtures.editable_project_resource_uuid]: {
                 uuid: groupFixtures.editable_project_resource_uuid,
                 ownerUuid: groupFixtures.user_uuid,
@@ -92,30 +78,6 @@ describe('resources', () => {
             }
         };
 
-        it('should return editable equal to true for all users from the same cluster', () => {
-            // given
-            const id = groupFixtures.project_shared_with_all_users_uuid;
-            const userUuid = groupFixtures.user_uuid;
-
-            // when
-            const result = getResourceWithEditableStatus(id, userUuid)(resourcesState);
-
-            // then
-            expect(result!.isEditable).toBeTruthy();
-        });
-
-        it('should return not editable for all users from another cluster cluster', () => {
-            // given
-            const id = groupFixtures.project_shared_with_all_users_uuid;
-            const userUuid = groupFixtures.user_from_another_cluster_uuid;
-
-            // when
-            const result = getResourceWithEditableStatus(id, userUuid)(resourcesState);
-
-            // then
-            expect(result!.isEditable).toBeFalsy();
-        });
-
         it('should return editable user resource (resource UUID is equal to user UUID)', () => {
             // given
             const id = groupFixtures.user_resource_uuid;
diff --git a/src/store/resources/resources.ts b/src/store/resources/resources.ts
index 908762bb..eb3c5509 100644
--- a/src/store/resources/resources.ts
+++ b/src/store/resources/resources.ts
@@ -9,8 +9,6 @@ import { GroupResource } from "~/models/group";
 
 export type ResourcesState = { [key: string]: Resource };
 
-const allUsersGroupSuffix = 'j7d0g-fffffffffffffff';
-
 const getResourceWritableBy = (state: ResourcesState, id: string, userUuid: string): string[] => {
     if (!id) {
         return [];
@@ -35,24 +33,8 @@ export const getResourceWithEditableStatus = <T extends EditableResource & Group
     (state: ResourcesState): T | undefined => {
         const resource = JSON.parse(JSON.stringify(state[id] as T));
 
-        if (resource && userUuid) {
-            resource.isEditable = false;
-
-            const writableBy = getResourceWritableBy(state, id, userUuid);
-
-            if (writableBy.indexOf(userUuid) > -1) { // first check if user can edit the resource
-                resource.isEditable = true;
-            } else { // if user has no direct access check if resource is shared with all users
-                const sharedWithAll = writableBy.find(uuid => uuid.indexOf(allUsersGroupSuffix) === 6);
-
-                if (sharedWithAll) { // verify if clusterId match
-                    const [userClusterId] = userUuid.split('-');
-
-                    if (sharedWithAll.indexOf(userClusterId) === 0) {
-                        resource.isEditable = true;
-                    }
-                }
-            }
+        if (resource) {
+            resource.isEditable = userUuid ? getResourceWritableBy(state, id, userUuid).indexOf(userUuid) > -1 : false;
         }
 
         return resource;

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list