diff --git a/demo-shell/src/app/components/file-view/file-view.component.html b/demo-shell/src/app/components/file-view/file-view.component.html index ab4b953f9f..3488d76c8f 100644 --- a/demo-shell/src/app/components/file-view/file-view.component.html +++ b/demo-shell/src/app/components/file-view/file-view.component.html @@ -4,7 +4,7 @@ - + diff --git a/demo-shell/src/app/components/file-view/file-view.component.ts b/demo-shell/src/app/components/file-view/file-view.component.ts index 298fc9c121..86ad27b4c2 100644 --- a/demo-shell/src/app/components/file-view/file-view.component.ts +++ b/demo-shell/src/app/components/file-view/file-view.component.ts @@ -52,7 +52,7 @@ export class FileViewComponent implements OnInit { showLeftSidebar = null; showRightSidebar = false; customToolbar = false; - isCommentEnabled = true; + isCommentDisabled = false; constructor(private router: Router, private route: ActivatedRoute, @@ -68,7 +68,7 @@ export class FileViewComponent implements OnInit { this.nodeApiService.getNode(id).subscribe( (node) => { if (node && node.isFile) { - this.isCommentEnabled = !this.contentServices.hasPermissions(node, PermissionsEnum.NOT_CONSUMER); + this.isCommentDisabled = this.contentServices.hasPermissions(node, PermissionsEnum.CONSUMER); this.nodeId = id; return; } diff --git a/lib/core/models/permissions.enum.ts b/lib/core/models/permissions.enum.ts index 22117f6846..6144997727 100644 --- a/lib/core/models/permissions.enum.ts +++ b/lib/core/models/permissions.enum.ts @@ -21,8 +21,12 @@ export class PermissionsEnum extends String { static CONSUMER: string = 'Consumer'; static COLLABORATOR: string = 'Collaborator'; static MANAGER: string = 'Manager'; + static EDITOR: string = 'Editor'; + static COORDINATOR: string = 'Coordinator'; static NOT_CONTRIBUTOR: string = '!Contributor'; static NOT_CONSUMER: string = '!Consumer'; static NOT_COLLABORATOR: string = '!Collaborator'; static NOT_MANAGER: string = '!Manager'; + static NOT_EDITOR: string = '!Editor'; + static NOT_COORDINATOR: string = '!Coordinator'; } diff --git a/lib/core/services/content.service.spec.ts b/lib/core/services/content.service.spec.ts index 2ba2608656..a029426b08 100644 --- a/lib/core/services/content.service.spec.ts +++ b/lib/core/services/content.service.spec.ts @@ -167,6 +167,16 @@ describe('ContentService', () => { let permissionNode = new Node({ permissions: { locallySet: [{ name: 'collaborator' }, { name: 'consumer' }] } }); expect(contentService.hasPermissions(permissionNode, null)).toBeFalsy(); }); + + it('should havePermission return true if the permissions is empty and the permission to check is Consumer', () => { + let permissionNode = new Node({ permissions: [] }); + expect(contentService.hasPermissions(permissionNode, 'Consumer')).toBeTruthy(); + }); + + it('should havePermission return false if the permissions is empty and the permission to check is not Consumer', () => { + let permissionNode = new Node({ permissions: [] }); + expect(contentService.hasPermissions(permissionNode, '!Consumer')).toBeFalsy(); + }); }); describe('Download blob', () => { diff --git a/lib/core/services/content.service.ts b/lib/core/services/content.service.ts index c63b6361f3..24cafd099b 100644 --- a/lib/core/services/content.service.ts +++ b/lib/core/services/content.service.ts @@ -189,7 +189,12 @@ export class ContentService { } } else { - if (permission && permission.startsWith('!')) { + + if (permission === PermissionsEnum.CONSUMER) { + hasPermissions = true; + } else if (permission === PermissionsEnum.NOT_CONSUMER) { + hasPermissions = false + } else if (permission && permission.startsWith('!')) { hasPermissions = true; } }