mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-3228] Added lock check for context actions (#4163)
* [ADF-3228] Added lock check in content service * [ADF-3228] added unit test for lock check * [ADF-3228] fixed wrong line on rebase * [ADF-3228] fixed e2e related to new lock behaviour * [ADF-3228] externalised lock service and added more unit tests * [ADF-3228] added lock service to disable context actions * [ADF-3228] fixed e2e rebased to the latest
This commit is contained in:
@@ -443,6 +443,99 @@ describe('DocumentList', () => {
|
||||
expect(actions[0].disabled).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should disable the action if a readonly lock is applied to the file', () => {
|
||||
let documentMenu = new ContentActionModel({
|
||||
permission: 'delete',
|
||||
target: 'document',
|
||||
title: 'FileAction'
|
||||
});
|
||||
|
||||
documentList.actions = [
|
||||
documentMenu
|
||||
];
|
||||
|
||||
let nodeFile = {
|
||||
entry: {
|
||||
isFile: true,
|
||||
name: 'xyz',
|
||||
isLocked: true,
|
||||
allowableOperations: ['create', 'update', 'delete'],
|
||||
properties: { 'cm:lockType': 'READ_ONLY_LOCK', 'cm:lockLifetime': 'PERSISTENT' }
|
||||
}
|
||||
};
|
||||
|
||||
let actions = documentList.getNodeActions(nodeFile);
|
||||
expect(actions.length).toBe(1);
|
||||
expect(actions[0].title).toEqual('FileAction');
|
||||
expect(actions[0].disabled).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should not disable the action for the lock owner if write lock is applied', () => {
|
||||
let documentMenu = new ContentActionModel({
|
||||
permission: 'delete',
|
||||
target: 'document',
|
||||
title: 'FileAction'
|
||||
});
|
||||
|
||||
spyOn(apiService.getInstance(), 'getEcmUsername').and.returnValue('lockOwner');
|
||||
|
||||
documentList.actions = [
|
||||
documentMenu
|
||||
];
|
||||
|
||||
let nodeFile = {
|
||||
entry: {
|
||||
isFile: true,
|
||||
name: 'xyz',
|
||||
isLocked: true,
|
||||
allowableOperations: ['create', 'update', 'delete'],
|
||||
properties: {
|
||||
'cm:lockType': 'WRITE_LOCK',
|
||||
'cm:lockLifetime': 'PERSISTENT',
|
||||
'cm:lockOwner': { id: 'lockOwner', displayName: 'lockOwner' }
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
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 write lock is applied and user is not the lock owner', () => {
|
||||
let documentMenu = new ContentActionModel({
|
||||
permission: 'delete',
|
||||
target: 'document',
|
||||
title: 'FileAction'
|
||||
});
|
||||
|
||||
spyOn(apiService.getInstance(), 'getEcmUsername').and.returnValue('jerryTheKillerCow');
|
||||
|
||||
documentList.actions = [
|
||||
documentMenu
|
||||
];
|
||||
|
||||
let nodeFile = {
|
||||
entry: {
|
||||
isFile: true,
|
||||
name: 'xyz',
|
||||
isLocked: true,
|
||||
allowableOperations: ['create', 'update', 'delete'],
|
||||
properties: {
|
||||
'cm:lockType': 'WRITE_LOCK',
|
||||
'cm:lockLifetime': 'PERSISTENT',
|
||||
'cm:lockOwner': { id: 'lockOwner', displayName: 'lockOwner' }
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
let actions = documentList.getNodeActions(nodeFile);
|
||||
expect(actions.length).toBe(1);
|
||||
expect(actions[0].title).toEqual('FileAction');
|
||||
expect(actions[0].disabled).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should not disable the action if there is the right permission for the folder', () => {
|
||||
const documentMenu = new ContentActionModel({
|
||||
disableWithNoPermission: true,
|
||||
|
Reference in New Issue
Block a user