APPS-1568 : ACA should be extended to support visibility rules for Document List columns. (#2560)

* APPS-1568 Extended rules visibility functionality for Document List columns

* APPS-1568 Unit test case added

* APPS-1568
This commit is contained in:
Shubham Bansal
2022-06-30 04:50:07 +00:00
committed by GitHub
parent 0a9acce401
commit 3a7938b895
2 changed files with 67 additions and 2 deletions

View File

@@ -126,6 +126,13 @@ describe('AppExtensionService', () => {
});
describe('documentList', () => {
beforeEach(() => {
extensions.setEvaluators({
notVisible: () => false,
visible: () => true
});
});
it('should support column orders', () => {
applyConfig({
$id: 'test',
@@ -149,6 +156,16 @@ describe('AppExtensionService', () => {
title: 'APP.DOCUMENT_LIST.COLUMNS.NAME',
type: 'text',
order: 20
},
{
id: 'app.files.securityMarks',
key: 'securityMarks',
title: 'GOVERNANCE.SECURITY_MARKS.COLUMNS.NAME',
type: 'text',
order: 55,
rules: {
visible: 'visible'
}
}
],
libraries: [
@@ -172,14 +189,61 @@ describe('AppExtensionService', () => {
const { files, libraries } = service.documentListPresets;
expect(files.length).toBe(2);
expect(files.length).toBe(3);
expect(files[0].id).toBe('app.files.thumbnail');
expect(files[1].id).toBe('app.files.name');
expect(files[2].id).toBe('app.files.securityMarks');
expect(libraries.length).toBe(2);
expect(libraries[0].id).toBe('app.libraries.name');
expect(libraries[1].id).toBe('app.libraries.thumbnail');
});
it('should ignore column if visibility in rules is false', () => {
applyConfig({
$id: 'test',
$name: 'test',
$version: '1.0.0',
$license: 'MIT',
$vendor: 'Good company',
$runtime: '1.5.0',
features: {
documentList: {
files: [
{
id: 'app.files.thumbnail',
key: '$thumbnail',
type: 'image',
order: 10
},
{
id: 'app.files.name',
key: 'name',
title: 'APP.DOCUMENT_LIST.COLUMNS.NAME',
type: 'text',
order: 20
},
{
id: 'app.files.securityMarks',
key: 'securityMarks',
title: 'GOVERNANCE.SECURITY_MARKS.COLUMNS.NAME',
type: 'text',
order: 55,
rules: {
visible: 'notVisible'
}
}
]
}
}
});
const { files } = service.documentListPresets;
expect(files.length).toBe(2);
expect(files[0].id).toBe('app.files.thumbnail');
expect(files[1].id).toBe('app.files.name');
});
});
describe('actions', () => {

View File

@@ -211,6 +211,7 @@ export class AppExtensionService implements RuleContext {
protected getDocumentListPreset(config: ExtensionConfig, key: string): DocumentListPresetRef[] {
return this.loader
.getElements<DocumentListPresetRef>(config, `features.documentList.${key}`)
.filter((group) => this.filterVisible(group))
.filter((entry) => !entry.disabled)
.sort(sortByOrder);
}
@@ -476,7 +477,7 @@ export class AppExtensionService implements RuleContext {
};
}
filterVisible(action: ContentActionRef | SettingsGroupRef | SidebarTabRef): boolean {
filterVisible(action: ContentActionRef | SettingsGroupRef | SidebarTabRef | DocumentListPresetRef): boolean {
if (action && action.rules && action.rules.visible) {
return this.extensions.evaluateRule(action.rules.visible, this);
}