[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', '');
@@ -22,15 +22,8 @@
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
*/
import {
DocumentListComponent,
DocumentListService,
SearchAiInputState,
SearchAiService,
ShareDataRow,
UploadService
} from '@alfresco/adf-content-services';
import { ShowHeaderMode, UserPreferencesService } from '@alfresco/adf-core';
import { DocumentListComponent, DocumentListService, ShareDataRow, UploadService } from '@alfresco/adf-content-services';
import { ShowHeaderMode } from '@alfresco/adf-core';
import { ContentActionRef, DocumentListPresetRef, SelectionState } from '@alfresco/adf-extensions';
import { DestroyRef, Directive, HostListener, inject, OnChanges, OnDestroy, OnInit, SimpleChanges, ViewChild } from '@angular/core';
import { Store } from '@ngrx/store';
@@ -52,7 +45,6 @@ import { AutoDownloadService } from '../../services/auto-download.service';
import { BreakpointObserver, Breakpoints } from '@angular/cdk/layout';
import { Router } from '@angular/router';
import { AppSettingsService } from '../../services/app-settings.service';
import { NavigationHistoryService } from '../../services/navigation-history.service';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
/* eslint-disable @angular-eslint/directive-class-suffix */
@@ -86,24 +78,13 @@ export abstract class PageComponent implements OnInit, OnDestroy, OnChanges {
protected breakpointObserver = inject(BreakpointObserver);
protected uploadService = inject(UploadService);
protected router = inject(Router);
protected userPreferencesService = inject(UserPreferencesService);
protected searchAiService = inject(SearchAiService);
protected readonly destroyRef = inject(DestroyRef);
private readonly autoDownloadService = inject(AutoDownloadService, { optional: true });
private readonly navigationHistoryService = inject(NavigationHistoryService);
protected subscriptions: Subscription[] = [];
private _searchAiInputState: SearchAiInputState = {
active: false
};
get searchAiInputState(): SearchAiInputState {
return this._searchAiInputState;
}
ngOnInit() {
this.extensions
.getCreateActions()
@@ -156,12 +137,6 @@ export abstract class PageComponent implements OnInit, OnDestroy, OnChanges {
.subscribe((result) => {
this.isSmallScreen = result.matches;
});
this.searchAiService.toggleSearchAiInput$
.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe((searchAiInputState) => (this._searchAiInputState = searchAiInputState));
this.setKnowledgeRetrievalState();
}
ngOnChanges(changes: SimpleChanges) {
@@ -245,19 +220,6 @@ export abstract class PageComponent implements OnInit, OnDestroy, OnChanges {
return obj.id;
}
private setKnowledgeRetrievalState() {
const nodes = this.userPreferencesService.get('knowledgeRetrievalNodes');
if (nodes && this.navigationHistoryService.shouldReturnLastSelection('/knowledge-retrieval')) {
this.selectedNodesState = JSON.parse(nodes);
}
if (!this.selectedNodesState && !this.router.url.startsWith('/knowledge-retrieval')) {
this.searchAiService.updateSearchAiInputState({
active: false
});
}
}
private isOutletPreviewUrl(): boolean {
return location.href.includes('viewer:view');
}
@@ -30,13 +30,11 @@ import { NodeEntry } from '@alfresco/js-api';
import { DocumentBasePageService } from './document-base-page.service';
import { Store } from '@ngrx/store';
import { Component } from '@angular/core';
import { DiscoveryApiService, DocumentListService, SearchAiInputState, SearchAiService } from '@alfresco/adf-content-services';
import { DiscoveryApiService, DocumentListService } from '@alfresco/adf-content-services';
import { MockStore, provideMockStore } from '@ngrx/store/testing';
import { provideCoreAuth, UserPreferencesService } from '@alfresco/adf-core';
import { of, Subscription } from 'rxjs';
import { provideCoreAuth } from '@alfresco/adf-core';
import { Subscription } from 'rxjs';
import { MatDialogModule } from '@angular/material/dialog';
import { NavigationHistoryService } from '../../services/navigation-history.service';
import { Router } from '@angular/router';
@Component({
selector: 'aca-test',
@@ -57,49 +55,23 @@ class TestComponent extends PageComponent {
}
describe('PageComponent', () => {
const mockNodes = JSON.stringify({ node: 'mockNode' });
let component: TestComponent;
let store: Store<AppState>;
let fixture: ComponentFixture<TestComponent>;
let documentListService: DocumentListService;
let userPreferencesService: jasmine.SpyObj<UserPreferencesService>;
let navigationHistoryService: { shouldReturnLastSelection: jasmine.Spy };
let searchAiService: SearchAiService;
let router: { url: string };
beforeEach(() => {
userPreferencesService = jasmine.createSpyObj('UserPreferencesService', ['get', 'set']);
navigationHistoryService = jasmine.createSpyObj('NavigationHistoryService', ['shouldReturnLastSelection']);
router = { url: '/some-url' };
searchAiService = jasmine.createSpyObj('SearchAiService', ['updateSearchAiInputState', 'toggleSearchAiInput$']);
searchAiService.toggleSearchAiInput$ = of({ active: false });
TestBed.configureTestingModule({
imports: [LibTestingModule, MatDialogModule],
declarations: [TestComponent],
providers: [
provideCoreAuth(),
{ provide: DocumentBasePageService, useClass: DocumentBasePageServiceMock },
{ provide: DiscoveryApiService, useValue: discoveryApiServiceMockValue },
{
provide: UserPreferencesService,
useValue: userPreferencesService
},
{
provide: NavigationHistoryService,
useValue: navigationHistoryService
},
{
provide: Router,
useValue: router
},
{ provide: SearchAiService, useValue: searchAiService }
{ provide: DiscoveryApiService, useValue: discoveryApiServiceMockValue }
]
});
store = TestBed.inject(Store);
searchAiService = TestBed.inject(SearchAiService);
documentListService = TestBed.inject(DocumentListService);
fixture = TestBed.createComponent(TestComponent);
component = fixture.componentInstance;
@@ -203,81 +175,6 @@ describe('PageComponent', () => {
expect(store.dispatch).toHaveBeenCalledWith(jasmine.objectContaining({ ...new ViewNodeAction(id) }));
});
});
describe('setKnowledgeRetrievalState()', () => {
it('should set selectedNodesState when nodes exist and last selection is valid', () => {
userPreferencesService.get.and.returnValue(mockNodes);
navigationHistoryService.shouldReturnLastSelection.and.returnValue(true);
component.ngOnInit();
expect(component.selectedNodesState).toEqual(JSON.parse(mockNodes));
});
it('should not set selectedNodesState when nodes do not exist', () => {
userPreferencesService.get.and.returnValue(null);
navigationHistoryService.shouldReturnLastSelection.and.returnValue(true);
component.ngOnInit();
expect(component.selectedNodesState).toBeUndefined();
});
it('should not set selectedNodesState when shouldReturnLastSelection returns false', () => {
userPreferencesService.get.and.returnValue(mockNodes);
navigationHistoryService.shouldReturnLastSelection.and.returnValue(false);
component.ngOnInit();
expect(component.selectedNodesState).toBeUndefined();
});
it('should update searchAiInputState when selectedNodesState is undefined and url does not start with /knowledge-retrieval', () => {
userPreferencesService.get.and.returnValue(mockNodes);
navigationHistoryService.shouldReturnLastSelection.and.returnValue(false);
router.url = '/some-other-url';
component.ngOnInit();
expect(searchAiService.updateSearchAiInputState).toHaveBeenCalledWith({ active: false });
});
it('should not update searchAiInputState when url starts with /knowledge-retrieval', () => {
userPreferencesService.get.and.returnValue(undefined);
navigationHistoryService.shouldReturnLastSelection.and.returnValue(true);
router.url = '/knowledge-retrieval';
component.ngOnInit();
expect(searchAiService.updateSearchAiInputState).not.toHaveBeenCalled();
});
it('should not update searchAiInputState when selectedNodesState in not null', () => {
userPreferencesService.get.and.returnValue(mockNodes);
navigationHistoryService.shouldReturnLastSelection.and.returnValue(true);
router.url = '/other';
component.ngOnInit();
expect(searchAiService.updateSearchAiInputState).not.toHaveBeenCalled();
});
});
describe('SearchAiService toggleSearchAiInput$ event handler', () => {
it('should set searchAiInputState', () => {
const initialSearchAiInputState = component.searchAiInputState;
const searchAiInputState: SearchAiInputState = {
active: true
};
searchAiService.toggleSearchAiInput$ = of(searchAiInputState);
component.ngOnInit();
expect(component.searchAiInputState).toBe(searchAiInputState);
expect(initialSearchAiInputState).toEqual({
active: false
});
});
});
});
describe('Info Drawer state', () => {
@@ -167,4 +167,11 @@ export class AppSettingsService {
get authDownloadThreshold(): number {
return this.appConfig.get<number>('viewer.fileAutoDownloadSizeThresholdInMB', 15);
}
/**
* Get the Knowledge Discovery URL from the app settings.
*/
get knowledgeDiscoveryUrl(): string {
return this.appConfig.get<string>('knowledgeDiscoveryUrl', '');
}
}
@@ -1,45 +0,0 @@
/*!
* Copyright © 2005-2025 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
*/
import { Action } from '@ngrx/store';
import { AiSearchByTermPayload } from '../models/ai-search-by-term-payload';
export enum SearchAiActionTypes {
SearchByTermAi = 'SEARCH_BY_TERM_AI',
ToggleAiSearchInput = 'TOGGLE_AI_SEARCH_INPUT'
}
export class SearchByTermAiAction implements Action {
readonly type = SearchAiActionTypes.SearchByTermAi;
constructor(public payload: AiSearchByTermPayload) {}
}
export class ToggleAISearchInput implements Action {
readonly type = SearchAiActionTypes.ToggleAiSearchInput;
constructor(
public agentId: string,
public searchTerm?: string
) {}
}
@@ -1,28 +0,0 @@
/*!
* Copyright © 2005-2025 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
*/
export interface AiSearchByTermPayload {
searchTerm: string;
agentId: string;
}
@@ -36,11 +36,9 @@ export * from './actions/viewer.actions';
export * from './actions/metadata-aspect.actions';
export * from './actions/template.actions';
export * from './actions/contextmenu.actions';
export * from './actions/search-ai.actions';
export * from './effects/router.effects';
export * from './models/ai-search-by-term-payload';
export * from './models/delete-status.model';
export * from './models/deleted-node-info.model';
export * from './models/node-info.model';
@@ -25,7 +25,6 @@
import { AppStore } from '../states/app.state';
import { createSelector } from '@ngrx/store';
const HXI_CONNECTOR = 'alfresco-hxinsight-connector-prediction-applier-extension';
export const selectApp = (state: AppStore) => state.app;
/** @deprecated use `UserProfileService` instead */
@@ -39,7 +38,6 @@ export const infoDrawerPreview = createSelector(selectApp, (state) => state.info
export const getRepositoryStatus = createSelector(selectApp, (state) => state.repository);
export const getCurrentACSVersion = createSelector(getRepositoryStatus, (repository) => repository.version?.display?.split(' ')[0]);
export const isQuickShareEnabled = createSelector(getRepositoryStatus, (info) => info.status.isQuickShareEnabled);
export const isHXIConnectorEnabled = createSelector(getRepositoryStatus, (info) => !!info?.modules?.find((module) => module.id === HXI_CONNECTOR));
export const isAdmin = createSelector(selectApp, (state) => state.user.isAdmin);
export const getFileUploadingDialog = createSelector(selectApp, (state) => state.fileUploadingDialog);
export const showLoaderSelector = createSelector(selectApp, (state) => state.showLoader);