mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-05-12 17:04:46 +00:00
[ACA-4618] Decouple ACA and Governance (#2757)
* [ACA-4618] Remove governance dependecies from ACA * [ACA-4618] Move canOpenWithOffice evaluator to ACA shared * [ACA-4618] Add missing unit test changes * [ACA-4618] Prettier fixes
This commit is contained in:
parent
ae57a094b1
commit
8081bc81d6
@ -551,4 +551,229 @@ describe('app.evaluators', () => {
|
||||
expect(app.isContentServiceEnabled()).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('canOpenWithOffice', () => {
|
||||
it('should return [false] if using SSO', () => {
|
||||
const context: any = {
|
||||
auth: {
|
||||
isOauth: () => true
|
||||
}
|
||||
};
|
||||
|
||||
expect(app.canOpenWithOffice(context)).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should return [false] if no selection present', () => {
|
||||
const context: any = {
|
||||
selection: null
|
||||
};
|
||||
|
||||
expect(app.canOpenWithOffice(context)).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should return [false] if no file selected', () => {
|
||||
const context: any = {
|
||||
selection: {
|
||||
file: null
|
||||
}
|
||||
};
|
||||
|
||||
expect(app.canOpenWithOffice(context)).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should return [false] if selected file has no entry', () => {
|
||||
const context: any = {
|
||||
selection: {
|
||||
file: {
|
||||
entry: null
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
expect(app.canOpenWithOffice(context)).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should return [false] if selected file has no properties', () => {
|
||||
const context: any = {
|
||||
selection: {
|
||||
file: {
|
||||
entry: {
|
||||
properties: null
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
expect(app.canOpenWithOffice(context)).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should return [false] if selected file is locked', () => {
|
||||
const context: any = {
|
||||
selection: {
|
||||
file: {
|
||||
entry: {
|
||||
isLocked: true,
|
||||
properties: {}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
expect(app.canOpenWithOffice(context)).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should return [false] if selected file has no extension', () => {
|
||||
const context: any = {
|
||||
selection: {
|
||||
file: {
|
||||
entry: {
|
||||
name: 'readme',
|
||||
isLocked: false,
|
||||
properties: {}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
expect(app.canOpenWithOffice(context)).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should return [false] if extension is not supported', () => {
|
||||
const context: any = {
|
||||
selection: {
|
||||
file: {
|
||||
entry: {
|
||||
name: 'run.exe',
|
||||
isLocked: false,
|
||||
properties: {}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
expect(app.canOpenWithOffice(context)).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should return [false] if selected file has write lock', () => {
|
||||
const context: any = {
|
||||
selection: {
|
||||
file: {
|
||||
entry: {
|
||||
name: 'document.docx',
|
||||
isLocked: false,
|
||||
properties: {
|
||||
'cm:lockType': 'WRITE_LOCK'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
expect(app.canOpenWithOffice(context)).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should return [false] if selected file has read-only lock', () => {
|
||||
const context: any = {
|
||||
selection: {
|
||||
file: {
|
||||
entry: {
|
||||
name: 'document.docx',
|
||||
isLocked: false,
|
||||
properties: {
|
||||
'cm:lockType': 'READ_ONLY_LOCK'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
expect(app.canOpenWithOffice(context)).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should return [false] if current user is not lock owner', () => {
|
||||
const context: any = {
|
||||
profile: {
|
||||
id: 'user1'
|
||||
},
|
||||
selection: {
|
||||
file: {
|
||||
entry: {
|
||||
name: 'document.docx',
|
||||
isLocked: false,
|
||||
properties: {
|
||||
'cm:lockType': 'READ_ONLY_LOCK',
|
||||
'cm:lockOwner': {
|
||||
id: 'user2'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
expect(app.canOpenWithOffice(context)).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should return [false] if current user is lock owner', () => {
|
||||
const context: any = {
|
||||
profile: {
|
||||
id: 'user1'
|
||||
},
|
||||
selection: {
|
||||
file: {
|
||||
entry: {
|
||||
name: 'document.docx',
|
||||
isLocked: false,
|
||||
properties: {
|
||||
'cm:lockType': 'READ_ONLY_LOCK',
|
||||
'cm:lockOwner': {
|
||||
id: 'user1'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
expect(app.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(app.canOpenWithOffice(context)).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should return [true] if all checks succeed', () => {
|
||||
const context: any = {
|
||||
selection: {
|
||||
file: {
|
||||
entry: {
|
||||
name: 'document.docx',
|
||||
isLocked: false,
|
||||
properties: {}
|
||||
}
|
||||
}
|
||||
},
|
||||
permissions: {
|
||||
check: () => true
|
||||
}
|
||||
};
|
||||
|
||||
expect(app.canOpenWithOffice(context)).toBeTruthy();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -25,8 +25,8 @@
|
||||
|
||||
import { AppConfigService } from '@alfresco/adf-core';
|
||||
import { RuleContext } from '@alfresco/adf-extensions';
|
||||
import { getFileExtension, supportedExtensions } from '@alfresco/adf-office-services-ext';
|
||||
import * as navigation from './navigation.rules';
|
||||
import { isNodeRecord } from './record.rules';
|
||||
import * as repository from './repository.rules';
|
||||
import { isAdmin } from './user.rules';
|
||||
|
||||
@ -359,7 +359,6 @@ export function canUploadVersion(context: RuleContext): boolean {
|
||||
return [
|
||||
hasFileSelected(context),
|
||||
navigation.isNotTrashcan(context),
|
||||
!isNodeRecord(context),
|
||||
isWriteLocked(context) ? isUserWriteLockOwner(context) : canUpdateSelectedNode(context)
|
||||
].every(Boolean);
|
||||
}
|
||||
@ -446,9 +445,7 @@ export const canManagePermissions = (context: RuleContext): boolean =>
|
||||
* @param context Rule execution context
|
||||
*/
|
||||
export const canToggleEditOffline = (context: RuleContext): boolean =>
|
||||
[hasFileSelected(context), navigation.isNotTrashcan(context), canLockFile(context) || canUnlockFile(context), !isNodeRecord(context)].every(
|
||||
Boolean
|
||||
);
|
||||
[hasFileSelected(context), navigation.isNotTrashcan(context), canLockFile(context) || canUnlockFile(context)].every(Boolean);
|
||||
|
||||
/**
|
||||
* @deprecated Uses workarounds for for recent files and search api issues.
|
||||
@ -490,3 +487,58 @@ export const canInfoPreview = (context: RuleContext): boolean =>
|
||||
navigation.isSearchResults(context) && !isMultiselection(context) && !hasFolderSelected(context) && !navigation.isPreview(context);
|
||||
|
||||
export const showInfoSelectionButton = (context: RuleContext): boolean => navigation.isSearchResults(context) && !navigation.isPreview(context);
|
||||
|
||||
/**
|
||||
* Checks if the file can be opened with MS Office
|
||||
* JSON ref: `aos.canOpenWithOffice`
|
||||
*
|
||||
* @param context Rule execution context
|
||||
*/
|
||||
export function canOpenWithOffice(context: RuleContext): boolean {
|
||||
if (context.navigation && context.navigation.url && context.navigation.url.startsWith('/trashcan')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!context || !context.selection) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const { file } = context.selection;
|
||||
|
||||
if (!file || !file.entry) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const extension = getFileExtension(file.entry.name);
|
||||
if (!extension || !supportedExtensions[extension]) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!file.entry.properties) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (file.entry.isLocked) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (file.entry.properties['cm:lockType'] === 'WRITE_LOCK' || file.entry.properties['cm:lockType'] === 'READ_ONLY_LOCK') {
|
||||
return false;
|
||||
}
|
||||
|
||||
const lockOwner = file.entry.properties['cm:lockOwner'];
|
||||
if (lockOwner && lockOwner.id !== context.profile.id) {
|
||||
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'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return context.permissions.check(file, ['update']);
|
||||
}
|
||||
|
@ -27,4 +27,3 @@ export * from './app.rules';
|
||||
export * from './navigation.rules';
|
||||
export * from './repository.rules';
|
||||
export * from './user.rules';
|
||||
export * from './record.rules';
|
||||
|
@ -1,36 +0,0 @@
|
||||
/*!
|
||||
* @license
|
||||
* Alfresco Example Content Application
|
||||
*
|
||||
* Copyright (C) 2005 - 2020 Alfresco Software Limited
|
||||
*
|
||||
* This file is part of the Alfresco Example Content Application.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
*
|
||||
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { RuleContext } from '@alfresco/adf-extensions';
|
||||
|
||||
export function isNodeRecord(context: RuleContext): boolean {
|
||||
const { file } = context.selection;
|
||||
return (
|
||||
file &&
|
||||
file.entry.isFile &&
|
||||
file.entry.aspectNames &&
|
||||
(file.entry.aspectNames.includes('rma:declaredRecord') || file.entry.aspectNames.includes('rma:record'))
|
||||
);
|
||||
}
|
@ -29,7 +29,7 @@ import { EffectsModule } from '@ngrx/effects';
|
||||
import { AosEffects } from './effects/aos.effects';
|
||||
import { TranslationService } from '@alfresco/adf-core';
|
||||
import { AlfrescoOfficeExtensionService } from '@alfresco/aca-shared';
|
||||
import { canOpenWithOffice } from './evaluators';
|
||||
import { canOpenWithOffice } from '@alfresco/aca-shared/rules';
|
||||
|
||||
@NgModule({
|
||||
imports: [EffectsModule.forFeature([AosEffects])],
|
||||
|
@ -1,307 +0,0 @@
|
||||
/*!
|
||||
* @license
|
||||
* Alfresco Example Content Application
|
||||
*
|
||||
* Copyright (C) 2005 - 2020 Alfresco Software Limited
|
||||
*
|
||||
* This file is part of the Alfresco Example Content Application.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
*
|
||||
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { canOpenWithOffice } from './evaluators';
|
||||
|
||||
describe('evaluators', () => {
|
||||
describe('canOpenWithOffice', () => {
|
||||
it('should return [false] if using SSO', () => {
|
||||
const context: any = {
|
||||
auth: {
|
||||
isOauth: () => true
|
||||
}
|
||||
};
|
||||
|
||||
expect(canOpenWithOffice(context)).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should return [false] if no selection present', () => {
|
||||
const context: any = {
|
||||
selection: null
|
||||
};
|
||||
|
||||
expect(canOpenWithOffice(context)).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should return [false] if no file selected', () => {
|
||||
const context: any = {
|
||||
selection: {
|
||||
file: null
|
||||
}
|
||||
};
|
||||
|
||||
expect(canOpenWithOffice(context)).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should return [false] if selected file has no entry', () => {
|
||||
const context: any = {
|
||||
selection: {
|
||||
file: {
|
||||
entry: null
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
expect(canOpenWithOffice(context)).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should return [false] if selected file has no properties', () => {
|
||||
const context: any = {
|
||||
selection: {
|
||||
file: {
|
||||
entry: {
|
||||
properties: null
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
expect(canOpenWithOffice(context)).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should return [false] if selected file is a record with containing aspect rma:declaredRecord', () => {
|
||||
const context: any = {
|
||||
selection: {
|
||||
file: {
|
||||
entry: {
|
||||
isFile: true,
|
||||
name: 'document.docx',
|
||||
isLocked: false,
|
||||
properties: {},
|
||||
aspectNames: ['rma:declaredRecord']
|
||||
}
|
||||
}
|
||||
},
|
||||
permissions: {
|
||||
check: () => true
|
||||
}
|
||||
};
|
||||
expect(canOpenWithOffice(context)).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should return [false] if selected file is a record with containing aspect rma:record', () => {
|
||||
const context: any = {
|
||||
selection: {
|
||||
file: {
|
||||
entry: {
|
||||
isFile: true,
|
||||
name: 'document.docx',
|
||||
isLocked: false,
|
||||
properties: {},
|
||||
aspectNames: ['rma:record']
|
||||
}
|
||||
}
|
||||
},
|
||||
permissions: {
|
||||
check: () => true
|
||||
}
|
||||
};
|
||||
expect(canOpenWithOffice(context)).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should return [false] if selected file is a record 1', () => {
|
||||
const context: any = {
|
||||
selection: {
|
||||
file: {
|
||||
entry: {
|
||||
aspectName: ['rma:declaredRecord']
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
expect(canOpenWithOffice(context)).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should return [false] if selected file is locked', () => {
|
||||
const context: any = {
|
||||
selection: {
|
||||
file: {
|
||||
entry: {
|
||||
isLocked: true,
|
||||
properties: {}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
expect(canOpenWithOffice(context)).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should return [false] if selected file has no extension', () => {
|
||||
const context: any = {
|
||||
selection: {
|
||||
file: {
|
||||
entry: {
|
||||
name: 'readme',
|
||||
isLocked: false,
|
||||
properties: {}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
expect(canOpenWithOffice(context)).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should return [false] if extension is not supported', () => {
|
||||
const context: any = {
|
||||
selection: {
|
||||
file: {
|
||||
entry: {
|
||||
name: 'run.exe',
|
||||
isLocked: false,
|
||||
properties: {}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
expect(canOpenWithOffice(context)).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should return [false] if selected file has write lock', () => {
|
||||
const context: any = {
|
||||
selection: {
|
||||
file: {
|
||||
entry: {
|
||||
name: 'document.docx',
|
||||
isLocked: false,
|
||||
properties: {
|
||||
'cm:lockType': 'WRITE_LOCK'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
expect(canOpenWithOffice(context)).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should return [false] if selected file has read-only lock', () => {
|
||||
const context: any = {
|
||||
selection: {
|
||||
file: {
|
||||
entry: {
|
||||
name: 'document.docx',
|
||||
isLocked: false,
|
||||
properties: {
|
||||
'cm:lockType': 'READ_ONLY_LOCK'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
expect(canOpenWithOffice(context)).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should return [false] if current user is not lock owner', () => {
|
||||
const context: any = {
|
||||
profile: {
|
||||
id: 'user1'
|
||||
},
|
||||
selection: {
|
||||
file: {
|
||||
entry: {
|
||||
name: 'document.docx',
|
||||
isLocked: false,
|
||||
properties: {
|
||||
'cm:lockType': 'READ_ONLY_LOCK',
|
||||
'cm:lockOwner': {
|
||||
id: 'user2'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
expect(canOpenWithOffice(context)).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should return [false] if current user is lock owner', () => {
|
||||
const context: any = {
|
||||
profile: {
|
||||
id: 'user1'
|
||||
},
|
||||
selection: {
|
||||
file: {
|
||||
entry: {
|
||||
name: 'document.docx',
|
||||
isLocked: false,
|
||||
properties: {
|
||||
'cm:lockType': 'READ_ONLY_LOCK',
|
||||
'cm:lockOwner': {
|
||||
id: 'user1'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
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: {
|
||||
file: {
|
||||
entry: {
|
||||
name: 'document.docx',
|
||||
isLocked: false,
|
||||
properties: {}
|
||||
}
|
||||
}
|
||||
},
|
||||
permissions: {
|
||||
check: () => true
|
||||
}
|
||||
};
|
||||
|
||||
expect(canOpenWithOffice(context)).toBeTruthy();
|
||||
});
|
||||
});
|
||||
});
|
@ -1,94 +0,0 @@
|
||||
/*!
|
||||
* @license
|
||||
* Alfresco Example Content Application
|
||||
*
|
||||
* Copyright (C) 2005 - 2020 Alfresco Software Limited
|
||||
*
|
||||
* This file is part of the Alfresco Example Content Application.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
*
|
||||
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { RuleContext } from '@alfresco/adf-extensions';
|
||||
import { isNodeRecord } from '@alfresco/aca-shared/rules';
|
||||
import { getFileExtension, supportedExtensions } from './utils';
|
||||
|
||||
export function canOpenWithOffice(context: RuleContext): boolean {
|
||||
if (context.navigation && context.navigation.url && context.navigation.url.startsWith('/trashcan')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!context || !context.selection) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const { file } = context.selection;
|
||||
|
||||
if (!file || !file.entry) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const extension = getFileExtension(file.entry.name);
|
||||
if (!extension || !supportedExtensions[extension]) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!file.entry.properties) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (file.entry.isLocked) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
if (file.entry && file.entry.aspectNames) {
|
||||
const checkedOut = file.entry.aspectNames.find(
|
||||
(aspect: string) => aspect === 'cm:checkedOut'
|
||||
);
|
||||
|
||||
if (checkedOut) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
if (file.entry.properties['cm:lockType'] === 'WRITE_LOCK' || file.entry.properties['cm:lockType'] === 'READ_ONLY_LOCK') {
|
||||
return false;
|
||||
}
|
||||
|
||||
const lockOwner = file.entry.properties['cm:lockOwner'];
|
||||
if (lockOwner && lockOwner.id !== context.profile.id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// check if record
|
||||
if (isNodeRecord(context)) {
|
||||
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'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return context.permissions.check(file, ['update']);
|
||||
}
|
@ -26,5 +26,6 @@
|
||||
export * from './lib/aos-extension.service';
|
||||
export * from './lib/actions/aos.actions';
|
||||
export * from './lib/effects/aos.effects';
|
||||
export * from './lib/utils';
|
||||
|
||||
export * from './lib/aos-extension.module';
|
||||
|
Loading…
x
Reference in New Issue
Block a user