[ACS-12037] Remove Knowledge Discovery from ACA (#5278)

* [ACS-12037] Remove Knowledge Discovery from ACA

* [ACS-12037] CR comments

* [ACS-12037] Update package-lock

* [ACS-12037] Add new rule documentation

* [ACS-12037] Fix unit tests
This commit is contained in:
Grzegorz Jaśkowski
2026-07-11 00:57:12 +02:00
committed by GitHub
parent 318a6ea43c
commit 48842513a9
73 changed files with 216 additions and 5785 deletions
@@ -27,7 +27,6 @@ import { createVersionRule, getFileExtension, isPreferencesApiAvailable, isNodeI
import { TestRuleContext } from './test-rule-context';
import { NodeEntry, RepositoryInfo, StatusInfo } from '@alfresco/js-api';
import { ProfileState, RuleContext } from '@alfresco/adf-extensions';
import { AppConfigService } from '@alfresco/adf-core';
describe('app.evaluators', () => {
let context: TestRuleContext;
@@ -544,124 +543,6 @@ describe('app.evaluators', () => {
});
});
describe('canDisplayKnowledgeRetrievalButton', () => {
const testCanDisplayKnowledgeRetrievalButton = (testTitle: string, url: string, knowledgeRetrievalEnabled: boolean, expected: boolean) => {
it(testTitle, () => {
context.appConfig = jasmine.createSpyObj<AppConfigService>({
get: knowledgeRetrievalEnabled
});
context.navigation.url = url;
expect(app.canDisplayKnowledgeRetrievalButton(context)).toBe(expected);
});
};
[
{
pageName: 'personal files',
pageUrl: '/personal-files'
},
{
pageName: 'shared files',
pageUrl: '/shared'
},
{
pageName: 'recent files',
pageUrl: '/recent-files'
},
{
pageName: 'favorites',
pageUrl: '/favorites'
},
{
pageName: 'library content',
pageUrl: '/libraries/some-id'
},
{
pageName: 'repository view',
pageUrl: '/repository'
}
].forEach((testCase) => {
testCanDisplayKnowledgeRetrievalButton(
`should return false if get from appConfig returns false and navigation is ${testCase.pageName}`,
testCase.pageUrl,
false,
false
);
testCanDisplayKnowledgeRetrievalButton(
`should return true if get from appConfig returns true and navigation is ${testCase.pageName}`,
testCase.pageUrl,
true,
true
);
});
testCanDisplayKnowledgeRetrievalButton(
'should return false if get from appConfig returns false and navigation is search results but not for libraries',
'/search',
false,
false
);
testCanDisplayKnowledgeRetrievalButton(
'should return true if get from appConfig returns true and navigation is search results but not for libraries',
'/search',
true,
true
);
testCanDisplayKnowledgeRetrievalButton(
'should return false if get from appConfig returns false and navigation is search results for libraries',
'/search/libraries',
false,
false
);
testCanDisplayKnowledgeRetrievalButton(
'should return false if get from appConfig returns true and navigation is search results for libraries',
'/search/libraries',
true,
false
);
testCanDisplayKnowledgeRetrievalButton(
'should return false if get from appConfig returns false and navigation is libraries',
'/libraries',
false,
false
);
testCanDisplayKnowledgeRetrievalButton(
'should return false if get from appConfig returns true and navigation is libraries',
'/libraries',
true,
false
);
testCanDisplayKnowledgeRetrievalButton(
'should return false if get from appConfig returns false and navigation is incorrect',
'/my-special-files',
false,
false
);
testCanDisplayKnowledgeRetrievalButton(
'should return false if get from appConfig returns true but navigation is incorrect',
'/my-special-files',
true,
false
);
it('should call get on context.appConfig with correct parameters', () => {
context.appConfig = jasmine.createSpyObj<AppConfigService>({
get: false
});
app.canDisplayKnowledgeRetrievalButton(context);
expect(context.appConfig.get).toHaveBeenCalledWith('plugins.knowledgeRetrievalEnabled', false);
});
});
describe('isContentServiceEnabled', () => {
it('should call context.appConfig.get with correct parameters', () => {
context.appConfig = { get: jasmine.createSpy() } as any;
+8 -9
View File
@@ -570,15 +570,6 @@ export const areTagsEnabled = (context: AcaRuleContext): boolean => context.appC
export const areCategoriesEnabled = (context: AcaRuleContext): boolean => context.appConfig.get('plugins.categoriesEnabled', true);
export const canDisplayKnowledgeRetrievalButton = (context: AcaRuleContext): boolean =>
context.appConfig.get('plugins.knowledgeRetrievalEnabled', false) &&
(navigation.isPersonalFiles(context) ||
navigation.isRepositoryView(context) ||
navigation.isSharedFiles(context) ||
navigation.isRecentFiles(context) ||
navigation.isFavorites(context) ||
((navigation.isSearchResults(context) || navigation.isLibraryContent(context)) && !navigation.isLibraries(context)));
export const isSSOEnabled = (context: AcaRuleContext): boolean => context.appConfig.get('authType') === 'OAUTH';
/**
@@ -604,3 +595,11 @@ export const isCheckedOut = (context: RuleContext): boolean => {
export const isNodeLink = (context: RuleContext): boolean =>
!context.selection?.isEmpty &&
context.selection.nodes.some((node) => node.entry?.nodeType === 'app:filelink' || node.entry?.nodeType === 'app:folderlink');
/**
* Checks if the Knowledge Discovery URL is configured.
* JSON ref: `app.isKnowledgeDiscoveryUrlPresent`
*
* @param context Rule execution context
*/
export const isKnowledgeDiscoveryUrlPresent = (context: AcaRuleContext): boolean => !!context.appConfig.get<string>('knowledgeDiscoveryUrl', '');