[MNT-22754] fix context menus for records (#2706)

* fix context menus for records

* fix unit tests

* fix unit tests
This commit is contained in:
Denys Vuika 2022-10-11 22:21:30 +01:00 committed by GitHub
parent fdee939243
commit df4a80f641
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 51 additions and 3 deletions

View File

@ -345,7 +345,11 @@ describe('app.evaluators', () => {
check: () => (checked = true) check: () => (checked = true)
}, },
selection: { selection: {
file: {}, file: {
entry: {
isFile: true
}
},
isEmpty: false, isEmpty: false,
nodes: [ nodes: [
{ {

View File

@ -26,6 +26,7 @@
import { AppConfigService } from '@alfresco/adf-core'; import { AppConfigService } from '@alfresco/adf-core';
import { RuleContext } from '@alfresco/adf-extensions'; import { RuleContext } from '@alfresco/adf-extensions';
import * as navigation from './navigation.rules'; import * as navigation from './navigation.rules';
import { isNodeRecord } from './record.rules';
import * as repository from './repository.rules'; import * as repository from './repository.rules';
import { isAdmin } from './user.rules'; import { isAdmin } from './user.rules';
@ -358,6 +359,7 @@ export function canUploadVersion(context: RuleContext): boolean {
return [ return [
hasFileSelected(context), hasFileSelected(context),
navigation.isNotTrashcan(context), navigation.isNotTrashcan(context),
!isNodeRecord(context),
isWriteLocked(context) ? isUserWriteLockOwner(context) : canUpdateSelectedNode(context) isWriteLocked(context) ? isUserWriteLockOwner(context) : canUpdateSelectedNode(context)
].every(Boolean); ].every(Boolean);
} }
@ -444,7 +446,9 @@ export const canManagePermissions = (context: RuleContext): boolean =>
* @param context Rule execution context * @param context Rule execution context
*/ */
export const canToggleEditOffline = (context: RuleContext): boolean => 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. * @deprecated Uses workarounds for for recent files and search api issues.

View File

@ -27,3 +27,4 @@ export * from './app.rules';
export * from './navigation.rules'; export * from './navigation.rules';
export * from './repository.rules'; export * from './repository.rules';
export * from './user.rules'; export * from './user.rules';
export * from './record.rules';

View 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'))
);
}

View File

@ -86,6 +86,7 @@ describe('evaluators', () => {
selection: { selection: {
file: { file: {
entry: { entry: {
isFile: true,
name: 'document.docx', name: 'document.docx',
isLocked: false, isLocked: false,
properties: {}, properties: {},
@ -105,6 +106,7 @@ describe('evaluators', () => {
selection: { selection: {
file: { file: {
entry: { entry: {
isFile: true,
name: 'document.docx', name: 'document.docx',
isLocked: false, isLocked: false,
properties: {}, properties: {},

View File

@ -24,6 +24,7 @@
*/ */
import { RuleContext } from '@alfresco/adf-extensions'; import { RuleContext } from '@alfresco/adf-extensions';
import { isNodeRecord } from '@alfresco/aca-shared/rules';
import { getFileExtension, supportedExtensions } from './utils'; import { getFileExtension, supportedExtensions } from './utils';
export function canOpenWithOffice(context: RuleContext): boolean { export function canOpenWithOffice(context: RuleContext): boolean {
@ -76,7 +77,7 @@ export function canOpenWithOffice(context: RuleContext): boolean {
} }
// check if record // check if record
if (file.entry.aspectNames && (file.entry.aspectNames.includes('rma:declaredRecord') || file.entry.aspectNames.includes('rma:record'))) { if (isNodeRecord(context)) {
return false; return false;
} }