mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
DocumentList - Check permissions on delete folder/file (#1808)
* Add check permission on delete folder/file * Provide a way to disable the action when if there is no permission * Improve the code using the external permission inside the folder/document action service * Add basic documentation. - How disable the button when the permission is missing - How to show a notification message when the permission is missing * Resize the image * Change the value to true for demo purpose * Update folder-actions.service.ts * Update document-actions.service.ts
This commit is contained in:
committed by
Mario Romano
parent
ab3d18e5c1
commit
f6102dfc07
@@ -41,9 +41,18 @@ export class ContentActionComponent implements OnInit, OnChanges {
|
||||
@Input()
|
||||
target: string;
|
||||
|
||||
@Input()
|
||||
permission: string;
|
||||
|
||||
@Input()
|
||||
disableWithNoPermission: boolean;
|
||||
|
||||
@Output()
|
||||
execute = new EventEmitter();
|
||||
|
||||
@Output()
|
||||
permissionEvent = new EventEmitter();
|
||||
|
||||
model: ContentActionModel;
|
||||
|
||||
constructor(
|
||||
@@ -57,6 +66,8 @@ export class ContentActionComponent implements OnInit, OnChanges {
|
||||
this.model = new ContentActionModel({
|
||||
title: this.title,
|
||||
icon: this.icon,
|
||||
permission: this.permission,
|
||||
disableWithNoPermission: this.disableWithNoPermission,
|
||||
target: this.target
|
||||
});
|
||||
|
||||
@@ -98,6 +109,9 @@ export class ContentActionComponent implements OnInit, OnChanges {
|
||||
|
||||
if (ltarget === 'folder') {
|
||||
if (this.folderActions) {
|
||||
this.folderActions.permissionEvent.subscribe((permision) => {
|
||||
this.permissionEvent.emit(permision);
|
||||
});
|
||||
return this.folderActions.getHandler(name);
|
||||
}
|
||||
return null;
|
||||
|
@@ -86,7 +86,22 @@ describe('DocumentList', () => {
|
||||
spyOn(action, 'handler').and.stub();
|
||||
|
||||
documentList.executeContentAction(node, action);
|
||||
expect(action.handler).toHaveBeenCalledWith(node, documentList);
|
||||
expect(action.handler).toHaveBeenCalledWith(node, documentList, undefined);
|
||||
|
||||
});
|
||||
|
||||
it('should execute action with node and permission', () => {
|
||||
let node = new FileNode();
|
||||
let action = new ContentActionModel();
|
||||
action.handler = function () {
|
||||
console.log('mock handler');
|
||||
};
|
||||
action.permission = 'fake-permission';
|
||||
|
||||
spyOn(action, 'handler').and.stub();
|
||||
|
||||
documentList.executeContentAction(node, action);
|
||||
expect(action.handler).toHaveBeenCalledWith(node, documentList, 'fake-permission');
|
||||
|
||||
});
|
||||
|
||||
|
@@ -306,7 +306,7 @@ export class DocumentListComponent implements OnInit, OnChanges, AfterContentIni
|
||||
*/
|
||||
executeContentAction(node: MinimalNodeEntity, action: ContentActionModel) {
|
||||
if (node && node.entry && action) {
|
||||
action.handler(node, this);
|
||||
action.handler(node, this, action.permission);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user