has permission cosnumer skip logic

This commit is contained in:
Eugenio Romano 2019-02-13 15:01:26 +00:00
parent 801d9bfff8
commit 469bb214b5
5 changed files with 23 additions and 4 deletions

View File

@ -4,7 +4,7 @@
<adf-info-drawer [title]="'APP.INFO_DRAWER.TITLE' | translate">
<adf-info-drawer-tab [label]="'APP.INFO_DRAWER.COMMENTS' | translate">
<adf-comments [nodeId]="nodeId" [readOnly]="isCommentEnabled"></adf-comments>
<adf-comments [nodeId]="nodeId" [readOnly]="isCommentDisabled"></adf-comments>
</adf-info-drawer-tab>
<adf-info-drawer-tab [label]="'APP.INFO_DRAWER.PROPERTIES' | translate">

View File

@ -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;
}

View File

@ -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';
}

View File

@ -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', () => {

View File

@ -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;
}
}