mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-24 17:31:52 +00:00
[ACS-6278] - stop showing 'edit aspects' and 'manage rules' when node is a smart folder (#3512)
* [ACS-6278] - stop showing 'edit aspects' and 'manage rules' when node is a smart folder
This commit is contained in:
@@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
import * as app from './app.rules';
|
import * as app from './app.rules';
|
||||||
import { TestRuleContext } from './test-rule-context';
|
import { TestRuleContext } from './test-rule-context';
|
||||||
import { NodeEntry } from '@alfresco/js-api';
|
import { NodeEntry, RepositoryInfo } from '@alfresco/js-api';
|
||||||
import { getFileExtension } from './app.rules';
|
import { getFileExtension } from './app.rules';
|
||||||
|
|
||||||
describe('app.evaluators', () => {
|
describe('app.evaluators', () => {
|
||||||
@@ -793,4 +793,94 @@ describe('app.evaluators', () => {
|
|||||||
expect(app.canOpenWithOffice(context)).toBeTruthy();
|
expect(app.canOpenWithOffice(context)).toBeTruthy();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('canEditAspects', () => {
|
||||||
|
let context: TestRuleContext;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
context = createTestContext();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return false for multiselection', () => {
|
||||||
|
context.selection.count = 2;
|
||||||
|
|
||||||
|
expect(app.canEditAspects(context)).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return false if user cannot update the selected node', () => {
|
||||||
|
context.permissions.check = spyOn(context.permissions, 'check').and.returnValue(false);
|
||||||
|
|
||||||
|
expect(app.canEditAspects(context)).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return false if the selected node is write locked', () => {
|
||||||
|
context.selection.file = { entry: { properties: { 'cm:lockType': 'WRITE_LOCK' } } } as NodeEntry;
|
||||||
|
|
||||||
|
expect(app.canEditAspects(context)).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return false if the context is trashcan', () => {
|
||||||
|
context.navigation = { url: '/trashcan' };
|
||||||
|
|
||||||
|
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);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('canManagePermissions', () => {
|
||||||
|
let context: TestRuleContext;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
context = createTestContext();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return false if user cannot update the selected node', () => {
|
||||||
|
context.permissions.check = spyOn(context.permissions, 'check').and.returnValue(false);
|
||||||
|
|
||||||
|
expect(app.canManagePermissions(context)).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return false if the context is trashcan', () => {
|
||||||
|
context.navigation = { url: '/trashcan' };
|
||||||
|
|
||||||
|
expect(app.canManagePermissions(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.canManagePermissions(context)).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return true if user can update the selected node and it is not a trashcan nor smart folder', () => {
|
||||||
|
expect(app.canManagePermissions(context)).toBe(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function createTestContext(): TestRuleContext {
|
||||||
|
const context = new TestRuleContext();
|
||||||
|
context.repository = {
|
||||||
|
version: {
|
||||||
|
major: 10
|
||||||
|
},
|
||||||
|
edition: '',
|
||||||
|
status: undefined
|
||||||
|
} as unknown as RepositoryInfo;
|
||||||
|
|
||||||
|
context.permissions = {
|
||||||
|
check() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
context.selection.isEmpty = false;
|
||||||
|
return context;
|
||||||
|
}
|
||||||
|
@@ -495,7 +495,8 @@ export const canEditAspects = (context: RuleContext): boolean =>
|
|||||||
canUpdateSelectedNode(context),
|
canUpdateSelectedNode(context),
|
||||||
!isWriteLocked(context),
|
!isWriteLocked(context),
|
||||||
navigation.isNotTrashcan(context),
|
navigation.isNotTrashcan(context),
|
||||||
repository.isMajorVersionAvailable(context, '7')
|
repository.isMajorVersionAvailable(context, '7'),
|
||||||
|
!isSmartFolder(context)
|
||||||
].every(Boolean);
|
].every(Boolean);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -505,7 +506,7 @@ export const canEditAspects = (context: RuleContext): boolean =>
|
|||||||
* @param context Rule execution context
|
* @param context Rule execution context
|
||||||
*/
|
*/
|
||||||
export const canManagePermissions = (context: RuleContext): boolean =>
|
export const canManagePermissions = (context: RuleContext): boolean =>
|
||||||
[canUpdateSelectedNode(context), navigation.isNotTrashcan(context)].every(Boolean);
|
[canUpdateSelectedNode(context), navigation.isNotTrashcan(context), !isSmartFolder(context)].every(Boolean);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if user can toggle **Edit Offline** mode for selected node.
|
* Checks if user can toggle **Edit Offline** mode for selected node.
|
||||||
@@ -624,3 +625,15 @@ export function canOpenWithOffice(context: AcaRuleContext): boolean {
|
|||||||
|
|
||||||
return context.permissions.check(file, ['update']);
|
return context.permissions.check(file, ['update']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isSmartFolder(context: RuleContext): boolean {
|
||||||
|
if (!context.selection?.isEmpty) {
|
||||||
|
const node = context.selection.first;
|
||||||
|
if (!node?.entry.isFolder) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const nodeAspects = node.entry?.aspectNames ?? [];
|
||||||
|
return nodeAspects.includes('smf:customConfigSmartFolder') || nodeAspects.includes('smf:systemConfigSmartFolder');
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user