[MNT-22574] Conditional AI Search (#2339)

* [MNT-22574] Support rules for search forms

* * fix lints

* Patch version increment

Co-authored-by: dhrn <dharan.g@muraai.com>
This commit is contained in:
Popovics András
2021-11-04 15:09:18 +01:00
committed by GitHub
parent f89833461c
commit 46a179c75a
11 changed files with 55 additions and 11 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "@alfresco/aca-shared",
"version": "2.6.0",
"version": "2.6.1",
"dependencies": {
"tslib": "^2.0.0"
},

View File

@@ -888,6 +888,11 @@ describe('AppExtensionService', () => {
describe('search', () => {
beforeEach(() => {
extensions.setEvaluators({
visible: () => true,
notVisible: () => false
});
applyConfig({
$id: 'test',
$name: 'test',
@@ -916,14 +921,25 @@ describe('AppExtensionService', () => {
{
id: 'app.search-1',
order: 200,
name: 'default',
name: 'search extension 1',
rules: {
visible: 'visible'
},
default: false
},
{
id: 'app.search-2',
order: 200,
name: 'default',
name: 'search extension 2',
disabled: true
},
{
id: 'app.search-3',
order: 300,
name: 'search extension 3',
rules: {
visible: 'notVisible'
}
}
]
}
@@ -939,6 +955,10 @@ describe('AppExtensionService', () => {
it('should not load the disabled search extension', () => {
expect(service.search.find(({ id }) => id === 'app.search-2')).toBe(undefined, 'disabled configuration shown in the result');
});
it('should not load the not visible search extension', () => {
expect(service.search.find(({ id }) => id === 'app.search-3')).toBe(undefined, 'not visible configuration shown in the result');
});
});
describe('rule disable', () => {

View File

@@ -295,7 +295,10 @@ export class AppExtensionService implements RuleContext {
return null;
}
const search = mergeArrays([], elements).filter((entry) => !entry.disabled);
const search = mergeArrays([], elements)
.filter((entry) => !entry.disabled)
.filter((entry) => this.filterVisible(entry))
.sort(sortByOrder);
try {
this.appConfig.config['search'] = search;