mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2026-09-09 18:02:54 +00:00
[ACA-2259] Edit in Microsoft Office - check update permissions (#1015)
* [ACA-2259] Edit in Microsoft Office - check update permissions * [ACA-2259] check update permissions - unit tests * [ACA-2259] refactor - check allowableOperationsOnTarget from service * [ACA-2259] add back check only on target for SharedFiles * [ACA-2259] SharedLinks are not folders * type-safe api for node permissions * workaround for shared files * use hasOwnProperty function
This commit is contained in:
committed by
Denys Vuika
parent
07f45e08cf
commit
88e74b1e2d
@@ -189,6 +189,25 @@ describe('evaluators', () => {
|
||||
expect(canOpenWithOffice(context)).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should return [false] if permissions check is false', () => {
|
||||
const context: any = {
|
||||
selection: {
|
||||
file: {
|
||||
entry: {
|
||||
name: 'document.docx',
|
||||
isLocked: false,
|
||||
properties: {}
|
||||
}
|
||||
}
|
||||
},
|
||||
permissions: {
|
||||
check: () => false
|
||||
}
|
||||
};
|
||||
|
||||
expect(canOpenWithOffice(context)).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should return [true] if all checks succeed', () => {
|
||||
const context: any = {
|
||||
selection: {
|
||||
@@ -199,6 +218,9 @@ describe('evaluators', () => {
|
||||
properties: {}
|
||||
}
|
||||
}
|
||||
},
|
||||
permissions: {
|
||||
check: () => true
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -26,7 +26,24 @@ export function canOpenWithOffice(
|
||||
|
||||
const { file } = context.selection;
|
||||
|
||||
if (!file || !file.entry || !file.entry.properties) {
|
||||
if (!file || !file.entry) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// workaround for Shared files
|
||||
if (
|
||||
context.navigation &&
|
||||
context.navigation.url &&
|
||||
context.navigation.url.startsWith('/shared')
|
||||
) {
|
||||
if (file.entry.hasOwnProperty('allowableOperationsOnTarget')) {
|
||||
return context.permissions.check(file, ['update'], {
|
||||
target: 'allowableOperationsOnTarget'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (!file.entry.properties) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -63,5 +80,5 @@ export function canOpenWithOffice(
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return context.permissions.check(file, ['update']);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user