From 6afdbcad7c41a1a9259110e95fae933adad4e312 Mon Sep 17 00:00:00 2001 From: Vito Date: Wed, 7 Mar 2018 14:11:36 +0000 Subject: [PATCH] [ADF-2358] Always enabling copy action (#3044) --- .../app/components/files/files.component.html | 2 +- .../document-list.component.spec.ts | 21 +++++++++++++++++++ .../components/document-list.component.ts | 5 +++-- lib/core/models/permissions.enum.ts | 1 + lib/core/services/content.service.spec.ts | 5 +++++ lib/core/services/content.service.ts | 4 ++++ 6 files changed, 35 insertions(+), 3 deletions(-) diff --git a/demo-shell/src/app/components/files/files.component.html b/demo-shell/src/app/components/files/files.component.html index 2cc49fea9a..ff581fd2c5 100644 --- a/demo-shell/src/app/components/files/files.component.html +++ b/demo-shell/src/app/components/files/files.component.html @@ -251,7 +251,7 @@ { }); + it('should not disable the action if there is copy permission', () => { + let documentMenu = new ContentActionModel({ + disableWithNoPermission: true, + permission: 'copy', + target: 'document', + title: 'FileAction' + }); + + documentList.actions = [ + documentMenu + ]; + + let nodeFile = { entry: { isFile: true, name: 'xyz', allowableOperations: ['create', 'update'] } }; + + let actions = documentList.getNodeActions(nodeFile); + expect(actions.length).toBe(1); + expect(actions[0].title).toEqual('FileAction'); + expect(actions[0].disabled).toBeFalsy(); + + }); + it('should disable the action if there is no permission for the folder and disableWithNoPermission true', () => { let documentMenu = new ContentActionModel({ disableWithNoPermission: true, diff --git a/lib/content-services/document-list/components/document-list.component.ts b/lib/content-services/document-list/components/document-list.component.ts index 29bea2d3d9..bf50a7530a 100644 --- a/lib/content-services/document-list/components/document-list.component.ts +++ b/lib/content-services/document-list/components/document-list.component.ts @@ -24,7 +24,8 @@ import { DisplayMode, ObjectDataColumn, PaginatedComponent, - PaginationQueryParams + PaginationQueryParams, + PermissionsEnum } from '@alfresco/adf-core'; import { AlfrescoApiService, AppConfigService, DataColumnListComponent, UserPreferencesService } from '@alfresco/adf-core'; import { @@ -420,7 +421,7 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte } checkPermission(node: any, action: ContentActionModel): ContentActionModel { - if (action.permission) { + if (action.permission && action.permission !== PermissionsEnum.COPY) { if (this.hasPermissions(node)) { let permissions = node.entry.allowableOperations; let findPermission = permissions.find(permission => permission === action.permission); diff --git a/lib/core/models/permissions.enum.ts b/lib/core/models/permissions.enum.ts index d2e2cc7429..42035ed551 100644 --- a/lib/core/models/permissions.enum.ts +++ b/lib/core/models/permissions.enum.ts @@ -19,6 +19,7 @@ export class PermissionsEnum extends String { static DELETE: string = 'delete'; static UPDATE: string = 'update'; static CREATE: string = 'create'; + static COPY: string = 'copy'; static UPDATEPERMISSIONS: string = 'updatePermissions'; static NOT_DELETE: string = '!delete'; static NOT_UPDATE: string = '!update'; diff --git a/lib/core/services/content.service.spec.ts b/lib/core/services/content.service.spec.ts index ddf11b57d6..1e9428723e 100644 --- a/lib/core/services/content.service.spec.ts +++ b/lib/core/services/content.service.spec.ts @@ -151,6 +151,11 @@ describe('ContentService', () => { expect(contentService.hasPermission(permissionNode, null)).toBeFalsy(); }); + it('should havePermission return true if permission parameter is copy', () => { + let permissionNode = null; + expect(contentService.hasPermission(permissionNode, 'copy')).toBeTruthy(); + }); + describe('Download blob', () => { it('Should use native msSaveOrOpenBlob if the browser is IE', (done) => { diff --git a/lib/core/services/content.service.ts b/lib/core/services/content.service.ts index b8edafc6ad..8a3de5099c 100644 --- a/lib/core/services/content.service.ts +++ b/lib/core/services/content.service.ts @@ -213,6 +213,10 @@ export class ContentService { } } + if (permission === PermissionsEnum.COPY) { + hasPermission = true; + } + return hasPermission; }