From ded29aee4d414be98114e19da50fca3a1445a527 Mon Sep 17 00:00:00 2001 From: Cilibiu Bogdan Date: Tue, 27 Mar 2018 11:49:49 +0300 Subject: [PATCH] edit node permission (#261) --- .../favorites/favorites.component.html | 5 +++ src/app/components/files/files.component.html | 5 +++ src/app/components/page.component.spec.ts | 36 +++++++++++++++++++ src/app/components/page.component.ts | 8 +++++ .../recent-files/recent-files.component.html | 5 +++ .../shared-files/shared-files.component.html | 5 +++ 6 files changed, 64 insertions(+) diff --git a/src/app/components/favorites/favorites.component.html b/src/app/components/favorites/favorites.component.html index 3a9f28062..a01390b04 100644 --- a/src/app/components/favorites/favorites.component.html +++ b/src/app/components/favorites/favorites.component.html @@ -181,7 +181,12 @@ +
+ +
+ diff --git a/src/app/components/files/files.component.html b/src/app/components/files/files.component.html index 2e960c20d..8a5c2f5fb 100644 --- a/src/app/components/files/files.component.html +++ b/src/app/components/files/files.component.html @@ -188,7 +188,12 @@ +
+ +
+ diff --git a/src/app/components/page.component.spec.ts b/src/app/components/page.component.spec.ts index 481ba39eb..aa8f82ed8 100644 --- a/src/app/components/page.component.spec.ts +++ b/src/app/components/page.component.spec.ts @@ -346,4 +346,40 @@ describe('PageComponent', () => { expect(component.canMoveShared(selection)).toBe(false); }); }); + + describe('canUpdate()', () => { + it('should return true if node can be edited', () => { + const selection = [ { entry: { + allowableOperations: ['update'] + } } ]; + + expect(component.canUpdate(selection)).toBe(true); + }); + + it(`should return false if node cannot be edited`, () => { + const selection = [ { entry: { + allowableOperations: ['other-permission'] + } } ]; + + expect(component.canUpdate(selection)).toBe(false); + }); + }); + + describe('canUpdateShared()', () => { + it('should return true if shared node can be edited', () => { + const selection = [ { entry: { + allowableOperationsOnTarget: ['update'] + } } ]; + + expect(component.canUpdateShared(selection)).toBe(true); + }); + + it(`should return false if shared node cannot be edited`, () => { + const selection = [ { entry: { + allowableOperationsOnTarget: ['other-permission'] + } } ]; + + expect(component.canUpdateShared(selection)).toBe(false); + }); + }); }); diff --git a/src/app/components/page.component.ts b/src/app/components/page.component.ts index ef23a06ab..9dbf299db 100644 --- a/src/app/components/page.component.ts +++ b/src/app/components/page.component.ts @@ -124,6 +124,14 @@ export abstract class PageComponent { return selection.every(node => node.entry && this.nodeSharedHasPermission(node.entry, 'delete')); } + canUpdate(selection: Array = []): boolean { + return selection.every(node => node.entry && this.nodeHasPermission(node.entry, 'update')); + } + + canUpdateShared(selection: Array = []): boolean { + return selection.every(node => node.entry && this.nodeSharedHasPermission(node.entry, 'update')); + } + canPreviewFile(selection: Array): boolean { return this.isFileSelected(selection); } diff --git a/src/app/components/recent-files/recent-files.component.html b/src/app/components/recent-files/recent-files.component.html index 4ce11ae36..16311f41b 100644 --- a/src/app/components/recent-files/recent-files.component.html +++ b/src/app/components/recent-files/recent-files.component.html @@ -170,7 +170,12 @@ +
+ +
+ diff --git a/src/app/components/shared-files/shared-files.component.html b/src/app/components/shared-files/shared-files.component.html index 9a28a5948..69238f8b9 100644 --- a/src/app/components/shared-files/shared-files.component.html +++ b/src/app/components/shared-files/shared-files.component.html @@ -187,7 +187,12 @@ +
+ +
+