Skip to content

Commit

Permalink
[ACS-6278] - disable manage rules for smart folders (#3518)
Browse files Browse the repository at this point in the history
  • Loading branch information
dominikiwanekhyland authored Nov 14, 2023
1 parent c9e0f7a commit 57ac20a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
*/

import { AcaRuleContext } from '@alfresco/aca-shared/rules';
import { isFolderRulesEnabled, canManageFolderRules } from './folder-rules.rules';
import { canManageFolderRules, isFolderRulesEnabled } from './folder-rules.rules';
import { NodeEntry } from '@alfresco/js-api';

describe('Folder Rules Visibility Rules', () => {
describe('isFolderRulesEnabled', () => {
Expand Down Expand Up @@ -81,5 +82,12 @@ describe('Folder Rules Visibility Rules', () => {
const result = canManageFolderRules(context);
expect(result).toEqual(false);
});

it('should not allow creating a rule if the selected node is a smart folder', () => {
context.selection.first = { entry: { aspectNames: ['smf:customConfigSmartFolder'], isFolder: true } } as NodeEntry;
const result = canManageFolderRules(context);

expect(result).toBe(false);
});
});
});
4 changes: 2 additions & 2 deletions projects/aca-content/folder-rules/src/folder-rules.rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
*/

import { AcaRuleContext, hasFolderSelected, canEditFolder, isNotFavorites } from '@alfresco/aca-shared/rules';
import { AcaRuleContext, canEditFolder, hasFolderSelected, isNotFavorites, isSmartFolder } from '@alfresco/aca-shared/rules';

export const isFolderRulesEnabled = (context: AcaRuleContext) => context.appConfig.get<boolean>('plugins.folderRules', false);
export const isFolderRulesAllowed = (context: AcaRuleContext) =>
isFolderRulesEnabled(context) && canEditFolder(context) && hasFolderSelected(context) && isNotFavorites(context);
isFolderRulesEnabled(context) && canEditFolder(context) && hasFolderSelected(context) && isNotFavorites(context) && !isSmartFolder(context);

export const canManageFolderRules = (context: AcaRuleContext): boolean => isFolderRulesAllowed(context);
8 changes: 1 addition & 7 deletions projects/aca-shared/rules/src/app.rules.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
*/

import * as app from './app.rules';
import { getFileExtension } from './app.rules';
import { TestRuleContext } from './test-rule-context';
import { NodeEntry, RepositoryInfo } from '@alfresco/js-api';
import { getFileExtension } from './app.rules';

describe('app.evaluators', () => {
describe('getFileExtension', () => {
Expand Down Expand Up @@ -825,12 +825,6 @@ describe('app.evaluators', () => {
expect(app.canEditAspects(context)).toBe(false);
});

it('should return false if the selected node is a smart folder', () => {
context.selection.first = { entry: { aspectNames: ['smf:customConfigSmartFolder'], isFolder: true } } as NodeEntry;

expect(app.canEditAspects(context)).toBe(false);
});

it('should return true if all conditions are met', () => {
expect(app.canEditAspects(context)).toBe(true);
});
Expand Down
5 changes: 2 additions & 3 deletions projects/aca-shared/rules/src/app.rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -495,8 +495,7 @@ export const canEditAspects = (context: RuleContext): boolean =>
canUpdateSelectedNode(context),
!isWriteLocked(context),
navigation.isNotTrashcan(context),
repository.isMajorVersionAvailable(context, '7'),
!isSmartFolder(context)
repository.isMajorVersionAvailable(context, '7')
].every(Boolean);

/**
Expand Down Expand Up @@ -626,7 +625,7 @@ export function canOpenWithOffice(context: AcaRuleContext): boolean {
return context.permissions.check(file, ['update']);
}

function isSmartFolder(context: RuleContext): boolean {
export function isSmartFolder(context: RuleContext): boolean {
if (!context.selection?.isEmpty) {
const node = context.selection.first;
if (!node?.entry.isFolder) {
Expand Down

0 comments on commit 57ac20a

Please sign in to comment.