Skip to content

Commit

Permalink
[MNT-22754] fix context menus for records (#2706)
Browse files Browse the repository at this point in the history
* fix context menus for records

* fix unit tests

* fix unit tests
  • Loading branch information
DenysVuika committed Oct 11, 2022
1 parent fdee939 commit df4a80f
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 3 deletions.
6 changes: 5 additions & 1 deletion projects/aca-shared/rules/src/app.rules.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,11 @@ describe('app.evaluators', () => {
check: () => (checked = true)
},
selection: {
file: {},
file: {
entry: {
isFile: true
}
},
isEmpty: false,
nodes: [
{
Expand Down
6 changes: 5 additions & 1 deletion projects/aca-shared/rules/src/app.rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions projects/aca-shared/rules/src/public-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 36 additions & 0 deletions projects/aca-shared/rules/src/record.rules.ts
Original file line number Diff line number Diff line change
@@ -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'))
);
}
2 changes: 2 additions & 0 deletions projects/adf-office-services-ext/src/lib/evaluators.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ describe('evaluators', () => {
selection: {
file: {
entry: {
isFile: true,
name: 'document.docx',
isLocked: false,
properties: {},
Expand All @@ -105,6 +106,7 @@ describe('evaluators', () => {
selection: {
file: {
entry: {
isFile: true,
name: 'document.docx',
isLocked: false,
properties: {},
Expand Down
3 changes: 2 additions & 1 deletion projects/adf-office-services-ext/src/lib/evaluators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit df4a80f

Please sign in to comment.