mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-05-12 17:04:46 +00:00
[MNT-22754] fix context menus for records (#2706)
* fix context menus for records * fix unit tests * fix unit tests
This commit is contained in:
parent
fdee939243
commit
df4a80f641
@ -345,7 +345,11 @@ describe('app.evaluators', () => {
|
||||
check: () => (checked = true)
|
||||
},
|
||||
selection: {
|
||||
file: {},
|
||||
file: {
|
||||
entry: {
|
||||
isFile: true
|
||||
}
|
||||
},
|
||||
isEmpty: false,
|
||||
nodes: [
|
||||
{
|
||||
|
@ -26,6 +26,7 @@
|
||||
import { AppConfigService } from '@alfresco/adf-core';
|
||||
import { RuleContext } from '@alfresco/adf-extensions';
|
||||
import * as navigation from './navigation.rules';
|
||||
import { isNodeRecord } from './record.rules';
|
||||
import * as repository from './repository.rules';
|
||||
import { isAdmin } from './user.rules';
|
||||
|
||||
@ -358,6 +359,7 @@ export function canUploadVersion(context: RuleContext): boolean {
|
||||
return [
|
||||
hasFileSelected(context),
|
||||
navigation.isNotTrashcan(context),
|
||||
!isNodeRecord(context),
|
||||
isWriteLocked(context) ? isUserWriteLockOwner(context) : canUpdateSelectedNode(context)
|
||||
].every(Boolean);
|
||||
}
|
||||
@ -444,7 +446,9 @@ 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)].every(Boolean);
|
||||
[hasFileSelected(context), navigation.isNotTrashcan(context), canLockFile(context) || canUnlockFile(context), !isNodeRecord(context)].every(
|
||||
Boolean
|
||||
);
|
||||
|
||||
/**
|
||||
* @deprecated Uses workarounds for for recent files and search api issues.
|
||||
|
@ -27,3 +27,4 @@ export * from './app.rules';
|
||||
export * from './navigation.rules';
|
||||
export * from './repository.rules';
|
||||
export * from './user.rules';
|
||||
export * from './record.rules';
|
||||
|
36
projects/aca-shared/rules/src/record.rules.ts
Normal file
36
projects/aca-shared/rules/src/record.rules.ts
Normal file
@ -0,0 +1,36 @@
|
||||
/*!
|
||||
* @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'))
|
||||
);
|
||||
}
|
@ -86,6 +86,7 @@ describe('evaluators', () => {
|
||||
selection: {
|
||||
file: {
|
||||
entry: {
|
||||
isFile: true,
|
||||
name: 'document.docx',
|
||||
isLocked: false,
|
||||
properties: {},
|
||||
@ -105,6 +106,7 @@ describe('evaluators', () => {
|
||||
selection: {
|
||||
file: {
|
||||
entry: {
|
||||
isFile: true,
|
||||
name: 'document.docx',
|
||||
isLocked: false,
|
||||
properties: {},
|
||||
|
@ -24,6 +24,7 @@
|
||||
*/
|
||||
|
||||
import { RuleContext } from '@alfresco/adf-extensions';
|
||||
import { isNodeRecord } from '@alfresco/aca-shared/rules';
|
||||
import { getFileExtension, supportedExtensions } from './utils';
|
||||
|
||||
export function canOpenWithOffice(context: RuleContext): boolean {
|
||||
@ -76,7 +77,7 @@ export function canOpenWithOffice(context: RuleContext): boolean {
|
||||
}
|
||||
|
||||
// check if record
|
||||
if (file.entry.aspectNames && (file.entry.aspectNames.includes('rma:declaredRecord') || file.entry.aspectNames.includes('rma:record'))) {
|
||||
if (isNodeRecord(context)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user