mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-09-17 14:21:14 +00:00
[ACS-8484] Add feature flag to knowledge retrieval (#4003)
This commit is contained in:
committed by
Aleksander Sklorz
parent
a577285cd9
commit
c45e4501d1
@@ -14,7 +14,8 @@
|
|||||||
"contentService": true,
|
"contentService": true,
|
||||||
"folderRules": true,
|
"folderRules": true,
|
||||||
"tagsEnabled": true,
|
"tagsEnabled": true,
|
||||||
"categoriesEnabled": true
|
"categoriesEnabled": true,
|
||||||
|
"knowledgeRetrievalEnabled": true
|
||||||
},
|
},
|
||||||
"oauth2": {
|
"oauth2": {
|
||||||
"host": "{protocol}//{hostname}{:port}/auth/realms/alfresco",
|
"host": "{protocol}//{hostname}{:port}/auth/realms/alfresco",
|
||||||
|
@@ -27,7 +27,7 @@ import { LibrariesComponent } from './components/libraries/libraries.component';
|
|||||||
import { FavoriteLibrariesComponent } from './components/favorite-libraries/favorite-libraries.component';
|
import { FavoriteLibrariesComponent } from './components/favorite-libraries/favorite-libraries.component';
|
||||||
import { SearchResultsComponent } from './components/search/search-results/search-results.component';
|
import { SearchResultsComponent } from './components/search/search-results/search-results.component';
|
||||||
import { SearchLibrariesResultsComponent } from './components/search/search-libraries-results/search-libraries-results.component';
|
import { SearchLibrariesResultsComponent } from './components/search/search-libraries-results/search-libraries-results.component';
|
||||||
import { AppSharedRuleGuard, GenericErrorComponent, ExtensionRoute, ExtensionsDataLoaderGuard } from '@alfresco/aca-shared';
|
import { AppSharedRuleGuard, GenericErrorComponent, ExtensionRoute, ExtensionsDataLoaderGuard, PluginEnabledGuard } from '@alfresco/aca-shared';
|
||||||
import { AuthGuard } from '@alfresco/adf-core';
|
import { AuthGuard } from '@alfresco/adf-core';
|
||||||
import { FavoritesComponent } from './components/favorites/favorites.component';
|
import { FavoritesComponent } from './components/favorites/favorites.component';
|
||||||
import { RecentFilesComponent } from './components/recent-files/recent-files.component';
|
import { RecentFilesComponent } from './components/recent-files/recent-files.component';
|
||||||
@@ -510,7 +510,11 @@ export const CONTENT_LAYOUT_ROUTES: Route = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'knowledge-retrieval',
|
path: 'knowledge-retrieval',
|
||||||
component: SearchAiResultsComponent
|
component: SearchAiResultsComponent,
|
||||||
|
canActivate: [PluginEnabledGuard],
|
||||||
|
data: {
|
||||||
|
plugin: 'plugins.knowledgeRetrievalEnabled'
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '**',
|
path: '**',
|
||||||
|
@@ -53,18 +53,14 @@ describe('SearchAiInputContainerComponent', () => {
|
|||||||
provide: AgentService,
|
provide: AgentService,
|
||||||
useValue: {
|
useValue: {
|
||||||
getAgents: () =>
|
getAgents: () =>
|
||||||
of({
|
of([
|
||||||
list: {
|
{
|
||||||
entries: [
|
id: '1',
|
||||||
{
|
name: 'HR Agent',
|
||||||
entry: {
|
description: 'HR Agent',
|
||||||
id: '1',
|
avatar: 'avatar1'
|
||||||
name: 'HR Agent'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
})
|
])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@@ -23,9 +23,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import * as app from './app.rules';
|
import * as app from './app.rules';
|
||||||
import { getFileExtension } from './app.rules';
|
|
||||||
import { TestRuleContext } from './test-rule-context';
|
import { TestRuleContext } from './test-rule-context';
|
||||||
import { NodeEntry, RepositoryInfo, StatusInfo } from '@alfresco/js-api';
|
import { NodeEntry, RepositoryInfo, StatusInfo } from '@alfresco/js-api';
|
||||||
|
import { getFileExtension } from './app.rules';
|
||||||
|
|
||||||
describe('app.evaluators', () => {
|
describe('app.evaluators', () => {
|
||||||
let context: TestRuleContext;
|
let context: TestRuleContext;
|
||||||
@@ -540,6 +540,47 @@ describe('app.evaluators', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('isKnowledgeRetrievalEnabled', () => {
|
||||||
|
it('should call context.appConfig.get with correct parameters', () => {
|
||||||
|
context.appConfig = { get: jasmine.createSpy() } as any;
|
||||||
|
|
||||||
|
app.canDisplayKnowledgeRetrievalButton(context);
|
||||||
|
expect(context.appConfig.get).toHaveBeenCalledWith('plugins.knowledgeRetrievalEnabled', true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return false if get from appConfig returns false', () => {
|
||||||
|
expect(
|
||||||
|
app.canDisplayKnowledgeRetrievalButton({
|
||||||
|
appConfig: {
|
||||||
|
get: () => false
|
||||||
|
}
|
||||||
|
} as any)
|
||||||
|
).toBeFalse();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return true if get from appConfig returns true and navigation is correct', () => {
|
||||||
|
expect(
|
||||||
|
app.canDisplayKnowledgeRetrievalButton({
|
||||||
|
navigation: { url: '/personal-files' },
|
||||||
|
appConfig: {
|
||||||
|
get: () => true
|
||||||
|
}
|
||||||
|
} as any)
|
||||||
|
).toBeTrue();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return false if get from appConfig returns true, but navigation is not correct', () => {
|
||||||
|
expect(
|
||||||
|
app.canDisplayKnowledgeRetrievalButton({
|
||||||
|
navigation: { url: '/my-special-files' },
|
||||||
|
appConfig: {
|
||||||
|
get: () => true
|
||||||
|
}
|
||||||
|
} as any)
|
||||||
|
).toBeFalse();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('isContentServiceEnabled', () => {
|
describe('isContentServiceEnabled', () => {
|
||||||
it('should call context.appConfig.get with correct parameters', () => {
|
it('should call context.appConfig.get with correct parameters', () => {
|
||||||
context.appConfig = { get: jasmine.createSpy() } as any;
|
context.appConfig = { get: jasmine.createSpy() } as any;
|
||||||
|
@@ -631,8 +631,9 @@ export const areTagsEnabled = (context: AcaRuleContext): boolean => context.appC
|
|||||||
export const areCategoriesEnabled = (context: AcaRuleContext): boolean => context.appConfig.get('plugins.categoriesEnabled', true);
|
export const areCategoriesEnabled = (context: AcaRuleContext): boolean => context.appConfig.get('plugins.categoriesEnabled', true);
|
||||||
|
|
||||||
export const canDisplayKnowledgeRetrievalButton = (context: AcaRuleContext): boolean =>
|
export const canDisplayKnowledgeRetrievalButton = (context: AcaRuleContext): boolean =>
|
||||||
navigation.isPersonalFiles(context) ||
|
context.appConfig.get('plugins.knowledgeRetrievalEnabled', true) &&
|
||||||
navigation.isSharedFiles(context) ||
|
(navigation.isPersonalFiles(context) ||
|
||||||
navigation.isRecentFiles(context) ||
|
navigation.isSharedFiles(context) ||
|
||||||
navigation.isFavorites(context) ||
|
navigation.isRecentFiles(context) ||
|
||||||
((navigation.isSearchResults(context) || navigation.isLibraryContent(context)) && navigation.isNotLibraries(context));
|
navigation.isFavorites(context) ||
|
||||||
|
((navigation.isSearchResults(context) || navigation.isLibraryContent(context)) && navigation.isNotLibraries(context)));
|
||||||
|
Reference in New Issue
Block a user