mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-12 17:04:57 +00:00
[ADF-2358] Always enabling copy action (#3044)
This commit is contained in:
parent
232404aef3
commit
6afdbcad7c
@ -251,7 +251,7 @@
|
|||||||
<content-action
|
<content-action
|
||||||
icon="content_copy"
|
icon="content_copy"
|
||||||
title="{{'DOCUMENT_LIST.ACTIONS.FOLDER.COPY' | translate}}"
|
title="{{'DOCUMENT_LIST.ACTIONS.FOLDER.COPY' | translate}}"
|
||||||
permission="update"
|
permission="copy"
|
||||||
[disableWithNoPermission]="true"
|
[disableWithNoPermission]="true"
|
||||||
(error)="onContentActionError($event)"
|
(error)="onContentActionError($event)"
|
||||||
(success)="onContentActionSuccess($event)"
|
(success)="onContentActionSuccess($event)"
|
||||||
|
@ -344,6 +344,27 @@ describe('DocumentList', () => {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
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', () => {
|
it('should disable the action if there is no permission for the folder and disableWithNoPermission true', () => {
|
||||||
let documentMenu = new ContentActionModel({
|
let documentMenu = new ContentActionModel({
|
||||||
disableWithNoPermission: true,
|
disableWithNoPermission: true,
|
||||||
|
@ -24,7 +24,8 @@ import {
|
|||||||
DisplayMode,
|
DisplayMode,
|
||||||
ObjectDataColumn,
|
ObjectDataColumn,
|
||||||
PaginatedComponent,
|
PaginatedComponent,
|
||||||
PaginationQueryParams
|
PaginationQueryParams,
|
||||||
|
PermissionsEnum
|
||||||
} from '@alfresco/adf-core';
|
} from '@alfresco/adf-core';
|
||||||
import { AlfrescoApiService, AppConfigService, DataColumnListComponent, UserPreferencesService } from '@alfresco/adf-core';
|
import { AlfrescoApiService, AppConfigService, DataColumnListComponent, UserPreferencesService } from '@alfresco/adf-core';
|
||||||
import {
|
import {
|
||||||
@ -420,7 +421,7 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
|||||||
}
|
}
|
||||||
|
|
||||||
checkPermission(node: any, action: ContentActionModel): ContentActionModel {
|
checkPermission(node: any, action: ContentActionModel): ContentActionModel {
|
||||||
if (action.permission) {
|
if (action.permission && action.permission !== PermissionsEnum.COPY) {
|
||||||
if (this.hasPermissions(node)) {
|
if (this.hasPermissions(node)) {
|
||||||
let permissions = node.entry.allowableOperations;
|
let permissions = node.entry.allowableOperations;
|
||||||
let findPermission = permissions.find(permission => permission === action.permission);
|
let findPermission = permissions.find(permission => permission === action.permission);
|
||||||
|
@ -19,6 +19,7 @@ export class PermissionsEnum extends String {
|
|||||||
static DELETE: string = 'delete';
|
static DELETE: string = 'delete';
|
||||||
static UPDATE: string = 'update';
|
static UPDATE: string = 'update';
|
||||||
static CREATE: string = 'create';
|
static CREATE: string = 'create';
|
||||||
|
static COPY: string = 'copy';
|
||||||
static UPDATEPERMISSIONS: string = 'updatePermissions';
|
static UPDATEPERMISSIONS: string = 'updatePermissions';
|
||||||
static NOT_DELETE: string = '!delete';
|
static NOT_DELETE: string = '!delete';
|
||||||
static NOT_UPDATE: string = '!update';
|
static NOT_UPDATE: string = '!update';
|
||||||
|
@ -151,6 +151,11 @@ describe('ContentService', () => {
|
|||||||
expect(contentService.hasPermission(permissionNode, null)).toBeFalsy();
|
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', () => {
|
describe('Download blob', () => {
|
||||||
|
|
||||||
it('Should use native msSaveOrOpenBlob if the browser is IE', (done) => {
|
it('Should use native msSaveOrOpenBlob if the browser is IE', (done) => {
|
||||||
|
@ -213,6 +213,10 @@ export class ContentService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (permission === PermissionsEnum.COPY) {
|
||||||
|
hasPermission = true;
|
||||||
|
}
|
||||||
|
|
||||||
return hasPermission;
|
return hasPermission;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user