import { RuleContext } from '@alfresco/adf-extensions' ; import { getFileExtension , supportedExtensions } from './utils' ; export function canOpenWithOffice ( context ) { 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 ; } if ( file . entry . aspectNames && ( file . entry . aspectNames . includes ( 'rma:declaredRecord' ) || file . entry . aspectNames . includes ( 'rma:record' ) ) ) { return false ; } 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' ] ) ; }