mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-24 17:31:52 +00:00
[ACS-8779] Keep selections and question after going to the previous page (#4147)
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
[sorting]="['title', 'asc']"
|
||||
[sortingMode]="'client'"
|
||||
[displayCheckboxesOnHover]="true"
|
||||
[preselectNodes]="selectedNodesState?.nodes"
|
||||
(node-dblclick)="handleNodeClick($event)"
|
||||
[imageResolver]="imageResolver"
|
||||
(selectedItemsCountChanged)="onSelectedItemsCountChanged($event)"
|
||||
|
@@ -25,6 +25,7 @@
|
||||
[multiselect]="true"
|
||||
[navigate]="false"
|
||||
[sorting]="['modifiedAt', 'desc']"
|
||||
[preselectNodes]="selectedNodesState?.nodes"
|
||||
[sortingMode]="'client'"
|
||||
[imageResolver]="imageResolver"
|
||||
[displayCheckboxesOnHover]="true"
|
||||
|
@@ -36,6 +36,7 @@
|
||||
[node]="nodeResult"
|
||||
[allowDropFiles]="true"
|
||||
[displayCheckboxesOnHover]="true"
|
||||
[preselectNodes]="selectedNodesState?.nodes"
|
||||
[navigate]="false"
|
||||
[sorting]="['name', 'asc']"
|
||||
[imageResolver]="imageResolver"
|
||||
|
@@ -1,5 +1,5 @@
|
||||
<aca-search-ai-input
|
||||
(searchSubmitted)="hideSearchInput()"
|
||||
[searchTerm]="(inputState$ | async).searchTerm"
|
||||
[placeholder]="placeholder"
|
||||
[agentId]="agentId"
|
||||
[useStoredNodes]="useStoredNodes">
|
||||
@@ -12,7 +12,7 @@
|
||||
mat-icon-button
|
||||
(click)="leaveSearchInput()"
|
||||
data-automation-id="aca-search-ai-input-container-leaving-search-button"
|
||||
[title]="'KNOWLEDGE_RETRIEVAL.SEARCH.SEARCH_INPUT.HIDE_INPUT' | translate"
|
||||
[title]="(isKnowledgeRetrievalPage ? 'KNOWLEDGE_RETRIEVAL.SEARCH.SEARCH_INPUT.HIDE_ANSWER' : 'KNOWLEDGE_RETRIEVAL.SEARCH.SEARCH_INPUT.HIDE_INPUT') | translate"
|
||||
class="aca-search-ai-input-container-close">
|
||||
<mat-icon>close</mat-icon>
|
||||
</button>
|
||||
|
@@ -34,21 +34,40 @@ import { DebugElement } from '@angular/core';
|
||||
import { MatIconButton } from '@angular/material/button';
|
||||
import { MatIcon } from '@angular/material/icon';
|
||||
import { SearchAiNavigationService } from '../../../../services/search-ai-navigation.service';
|
||||
import { NavigationEnd, NavigationStart, Router, RouterEvent } from '@angular/router';
|
||||
import { NavigationEnd, Router, RouterEvent } from '@angular/router';
|
||||
import { getAppSelection } from '@alfresco/aca-shared/store';
|
||||
|
||||
describe('SearchAiInputContainerComponent', () => {
|
||||
const routingEvents$: Subject<RouterEvent> = new Subject();
|
||||
|
||||
let component: SearchAiInputContainerComponent;
|
||||
let fixture: ComponentFixture<SearchAiInputContainerComponent>;
|
||||
let routingEvents$: Subject<RouterEvent>;
|
||||
let searchAiService: SearchAiService;
|
||||
let store: MockStore;
|
||||
let mockSearchAiService: jasmine.SpyObj<SearchAiService>;
|
||||
let searchNavigationService: SearchAiNavigationService;
|
||||
let mockRouter: any;
|
||||
|
||||
beforeEach(() => {
|
||||
mockSearchAiService = jasmine.createSpyObj('SearchAiService', ['updateSearchAiInputState'], {
|
||||
toggleSearchAiInput$: of(true)
|
||||
});
|
||||
|
||||
mockRouter = {
|
||||
url: '/some-url',
|
||||
events: routingEvents$.asObservable(),
|
||||
routerState: {
|
||||
root: {}
|
||||
},
|
||||
snapshot: {}
|
||||
};
|
||||
|
||||
TestBed.configureTestingModule({
|
||||
imports: [SearchAiInputContainerComponent, ContentTestingModule],
|
||||
providers: [
|
||||
{ provide: Router, useValue: mockRouter },
|
||||
provideMockStore(),
|
||||
{ provide: SearchAiService, useValue: mockSearchAiService },
|
||||
{
|
||||
provide: AgentService,
|
||||
useValue: {
|
||||
@@ -70,6 +89,7 @@ describe('SearchAiInputContainerComponent', () => {
|
||||
component = fixture.componentInstance;
|
||||
store = TestBed.inject(MockStore);
|
||||
searchAiService = TestBed.inject(SearchAiService);
|
||||
searchNavigationService = TestBed.inject(SearchAiNavigationService);
|
||||
store.overrideSelector(getAppSelection, {
|
||||
nodes: [],
|
||||
isEmpty: true,
|
||||
@@ -77,8 +97,6 @@ describe('SearchAiInputContainerComponent', () => {
|
||||
libraries: []
|
||||
});
|
||||
component.agentId = '1';
|
||||
routingEvents$ = new Subject<RouterEvent>();
|
||||
spyOnProperty(TestBed.inject(Router), 'events').and.returnValue(routingEvents$);
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
@@ -115,13 +133,10 @@ describe('SearchAiInputContainerComponent', () => {
|
||||
expect(inputComponent.useStoredNodes).toBeTrue();
|
||||
});
|
||||
|
||||
it('should call updateSearchAiInputState on SearchAiService when triggered searchSubmitted event', () => {
|
||||
spyOn(searchAiService, 'updateSearchAiInputState');
|
||||
inputComponent.searchSubmitted.emit();
|
||||
it('should set inputState$ to toggleSearchAiInput$ from the service on ngOnInit', () => {
|
||||
component.ngOnInit();
|
||||
|
||||
expect(searchAiService.updateSearchAiInputState).toHaveBeenCalledWith({
|
||||
active: false
|
||||
});
|
||||
expect(component.inputState$).toBe(mockSearchAiService.toggleSearchAiInput$);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -140,44 +155,35 @@ describe('SearchAiInputContainerComponent', () => {
|
||||
button = fixture.debugElement.query(By.directive(MatIconButton));
|
||||
});
|
||||
|
||||
it('should have correct title', () => {
|
||||
it('should have correct title when page is not knowledge-retrieval', () => {
|
||||
mockRouter.url = '/other-page';
|
||||
|
||||
component.ngOnInit();
|
||||
|
||||
expect(button.nativeElement.title).toBe('KNOWLEDGE_RETRIEVAL.SEARCH.SEARCH_INPUT.HIDE_INPUT');
|
||||
});
|
||||
|
||||
it('should have correct title when page is knowledge-retrieval', () => {
|
||||
mockRouter.url = '/knowledge-retrieval/some-data';
|
||||
|
||||
component.ngOnInit();
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(button.nativeElement.title).toBe('KNOWLEDGE_RETRIEVAL.SEARCH.SEARCH_INPUT.HIDE_ANSWER');
|
||||
});
|
||||
|
||||
it('should contain close icon', () => {
|
||||
expect(button.query(By.directive(MatIcon)).nativeElement.textContent).toBe('close');
|
||||
});
|
||||
|
||||
it('should call updateSearchAiInputState on SearchAiService when clicked', () => {
|
||||
spyOn(searchAiService, 'updateSearchAiInputState');
|
||||
it('should call navigateToPreviousRoute on SearchAiService when clicked', () => {
|
||||
spyOn(searchNavigationService, 'navigateToPreviousRouteOrCloseInput');
|
||||
button.nativeElement.click();
|
||||
|
||||
expect(searchAiService.updateSearchAiInputState).toHaveBeenCalledWith({
|
||||
active: false
|
||||
});
|
||||
});
|
||||
|
||||
it('should call navigateToPreviousRoute on SearchAiNavigationService when clicked', () => {
|
||||
const searchNavigationService = TestBed.inject(SearchAiNavigationService);
|
||||
spyOn(searchNavigationService, 'navigateToPreviousRoute');
|
||||
button.nativeElement.click();
|
||||
|
||||
expect(searchNavigationService.navigateToPreviousRoute).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe('Navigation', () => {
|
||||
it('should call updateSearchAiInputState on SearchAiService when navigation starts', () => {
|
||||
spyOn(searchAiService, 'updateSearchAiInputState');
|
||||
routingEvents$.next(new NavigationStart(1, ''));
|
||||
|
||||
expect(searchAiService.updateSearchAiInputState).toHaveBeenCalledWith({
|
||||
active: false
|
||||
});
|
||||
expect(searchNavigationService.navigateToPreviousRouteOrCloseInput).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should not call updateSearchAiInputState on SearchAiService when there is different event than navigation starts', () => {
|
||||
spyOn(searchAiService, 'updateSearchAiInputState');
|
||||
routingEvents$.next(new NavigationEnd(1, '', ''));
|
||||
|
||||
expect(searchAiService.updateSearchAiInputState).not.toHaveBeenCalled();
|
||||
|
@@ -22,27 +22,27 @@
|
||||
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { Component, Input, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import { Component, Input, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { SearchAiInputComponent } from '../search-ai-input/search-ai-input.component';
|
||||
import { MatDividerModule } from '@angular/material/divider';
|
||||
import { SearchAiNavigationService } from '../../../../services/search-ai-navigation.service';
|
||||
import { NavigationStart, Router } from '@angular/router';
|
||||
import { filter, takeUntil } from 'rxjs/operators';
|
||||
import { SearchAiService } from '@alfresco/adf-content-services';
|
||||
import { SearchAiService, SearchAiInputState } from '@alfresco/adf-content-services';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { Subject } from 'rxjs';
|
||||
import { Observable } from 'rxjs';
|
||||
import { AsyncPipe } from '@angular/common';
|
||||
import { Router } from '@angular/router';
|
||||
|
||||
@Component({
|
||||
standalone: true,
|
||||
imports: [SearchAiInputComponent, MatIconModule, MatDividerModule, MatButtonModule, TranslateModule],
|
||||
imports: [SearchAiInputComponent, MatIconModule, MatDividerModule, MatButtonModule, TranslateModule, AsyncPipe],
|
||||
selector: 'aca-search-ai-input-container',
|
||||
templateUrl: './search-ai-input-container.component.html',
|
||||
styleUrls: ['./search-ai-input-container.component.scss'],
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
export class SearchAiInputContainerComponent implements OnInit, OnDestroy {
|
||||
export class SearchAiInputContainerComponent implements OnInit {
|
||||
@Input()
|
||||
placeholder = 'KNOWLEDGE_RETRIEVAL.SEARCH.SEARCH_INPUT.DEFAULT_PLACEHOLDER';
|
||||
@Input()
|
||||
@@ -50,32 +50,17 @@ export class SearchAiInputContainerComponent implements OnInit, OnDestroy {
|
||||
@Input()
|
||||
useStoredNodes: boolean;
|
||||
|
||||
private onDestroy$ = new Subject<void>();
|
||||
inputState$: Observable<SearchAiInputState>;
|
||||
isKnowledgeRetrievalPage = false;
|
||||
|
||||
constructor(private searchAiService: SearchAiService, private searchNavigationService: SearchAiNavigationService, private router: Router) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.router.events
|
||||
.pipe(
|
||||
filter((event) => event instanceof NavigationStart),
|
||||
takeUntil(this.onDestroy$)
|
||||
)
|
||||
.subscribe(() => this.hideSearchInput());
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.onDestroy$.next();
|
||||
this.onDestroy$.complete();
|
||||
}
|
||||
|
||||
hideSearchInput(): void {
|
||||
this.searchAiService.updateSearchAiInputState({
|
||||
active: false
|
||||
});
|
||||
this.isKnowledgeRetrievalPage = this.router.url.startsWith('/knowledge-retrieval');
|
||||
this.inputState$ = this.searchAiService.toggleSearchAiInput$;
|
||||
}
|
||||
|
||||
leaveSearchInput(): void {
|
||||
this.searchNavigationService.navigateToPreviousRoute();
|
||||
this.hideSearchInput();
|
||||
this.searchNavigationService.navigateToPreviousRouteOrCloseInput();
|
||||
}
|
||||
}
|
||||
|
@@ -28,7 +28,7 @@ import { MatSelect, MatSelectModule } from '@angular/material/select';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { MockStore, provideMockStore } from '@ngrx/store/testing';
|
||||
import { AgentService, ContentTestingModule, SearchAiService } from '@alfresco/adf-content-services';
|
||||
import { getAppSelection, SearchByTermAiAction } from '@alfresco/aca-shared/store';
|
||||
import { getAppSelection, SearchByTermAiAction, ToggleAISearchInput } from '@alfresco/aca-shared/store';
|
||||
import { of, Subject } from 'rxjs';
|
||||
import { Agent, NodeEntry } from '@alfresco/js-api';
|
||||
import { FormControlDirective } from '@angular/forms';
|
||||
@@ -70,6 +70,7 @@ describe('SearchAiInputComponent', () => {
|
||||
let store: MockStore;
|
||||
let agents$: Subject<Agent[]>;
|
||||
let dialog: MatDialog;
|
||||
let activatedRoute: ActivatedRoute;
|
||||
|
||||
const prepareBeforeTest = (): void => {
|
||||
selectionState = {
|
||||
@@ -101,6 +102,7 @@ describe('SearchAiInputComponent', () => {
|
||||
]
|
||||
});
|
||||
|
||||
activatedRoute = TestBed.inject(ActivatedRoute);
|
||||
fixture = TestBed.createComponent(SearchAiInputComponent);
|
||||
component = fixture.componentInstance;
|
||||
store = TestBed.inject(MockStore);
|
||||
@@ -133,6 +135,23 @@ describe('SearchAiInputComponent', () => {
|
||||
expect(selectElement.componentInstance.hideSingleSelectionIndicator).toBeTrue();
|
||||
});
|
||||
|
||||
it('should set queryControl value to searchTerm if searchTerm is defined', () => {
|
||||
const query = 'some new query';
|
||||
component.searchTerm = query;
|
||||
|
||||
component.ngOnInit();
|
||||
|
||||
expect(component.queryControl.value).toBe(query);
|
||||
});
|
||||
|
||||
it('should set queryControl value to query param if searchTerm is not defined', () => {
|
||||
component.searchTerm = undefined;
|
||||
|
||||
component.ngOnInit();
|
||||
|
||||
expect(component.queryControl.value).toBe('some query');
|
||||
});
|
||||
|
||||
it('should get agents on init', () => {
|
||||
agents$.next(agentList);
|
||||
component.ngOnInit();
|
||||
@@ -239,6 +258,11 @@ describe('SearchAiInputComponent', () => {
|
||||
});
|
||||
|
||||
it('should be disabled by default', () => {
|
||||
activatedRoute.snapshot.queryParams = { query: '' };
|
||||
|
||||
component.ngOnInit();
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(submitButton.nativeElement.disabled).toBeTrue();
|
||||
});
|
||||
|
||||
@@ -371,12 +395,13 @@ describe('SearchAiInputComponent', () => {
|
||||
spyOn(store, 'dispatch');
|
||||
submittingTrigger();
|
||||
|
||||
expect(store.dispatch).toHaveBeenCalledOnceWith(
|
||||
expect(store.dispatch).toHaveBeenCalledWith(
|
||||
new SearchByTermAiAction({
|
||||
searchTerm: query,
|
||||
agentId: component.agentId
|
||||
})
|
||||
);
|
||||
expect(store.dispatch).toHaveBeenCalledWith(new ToggleAISearchInput('2', 'some query'));
|
||||
});
|
||||
|
||||
it('should call dispatch on store with correct parameter if selected agent was changed', async () => {
|
||||
@@ -388,26 +413,13 @@ describe('SearchAiInputComponent', () => {
|
||||
});
|
||||
submittingTrigger();
|
||||
|
||||
expect(store.dispatch).toHaveBeenCalledOnceWith(
|
||||
expect(store.dispatch).toHaveBeenCalledWith(
|
||||
new SearchByTermAiAction({
|
||||
searchTerm: query,
|
||||
agentId: '1'
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
it('should reset query input', () => {
|
||||
spyOn(component.queryControl, 'reset');
|
||||
submittingTrigger();
|
||||
|
||||
expect(component.queryControl.reset).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should emit searchSubmitted event', () => {
|
||||
spyOn(component.searchSubmitted, 'emit');
|
||||
submittingTrigger();
|
||||
|
||||
expect(component.searchSubmitted.emit).toHaveBeenCalled();
|
||||
expect(store.dispatch).toHaveBeenCalledWith(new ToggleAISearchInput('1', 'some query'));
|
||||
});
|
||||
|
||||
it('should call open modal if there was a previous search phrase in url', () => {
|
||||
@@ -418,13 +430,11 @@ describe('SearchAiInputComponent', () => {
|
||||
|
||||
it('should open Unsaved Changes Modal and run callback successfully', () => {
|
||||
const modalAiSpy = spyOn(modalAiService, 'openUnsavedChangesModal').and.callThrough();
|
||||
spyOn(component.searchSubmitted, 'emit');
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
submittingTrigger();
|
||||
expect(modalAiSpy).toHaveBeenCalledWith(jasmine.any(Function));
|
||||
expect(component.searchSubmitted.emit).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@@ -22,7 +22,7 @@
|
||||
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { Component, EventEmitter, Input, OnDestroy, OnInit, Output, ViewEncapsulation } from '@angular/core';
|
||||
import { Component, Input, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { TranslateModule, TranslateService } from '@ngx-translate/core';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
@@ -34,7 +34,7 @@ import { AvatarComponent, IconComponent, NotificationService, UserPreferencesSer
|
||||
import { FormControl, FormsModule, ReactiveFormsModule } from '@angular/forms';
|
||||
import { Subject } from 'rxjs';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { AiSearchByTermPayload, AppStore, getAppSelection, SearchByTermAiAction } from '@alfresco/aca-shared/store';
|
||||
import { AiSearchByTermPayload, AppStore, getAppSelection, SearchByTermAiAction, ToggleAISearchInput } from '@alfresco/aca-shared/store';
|
||||
import { takeUntil } from 'rxjs/operators';
|
||||
import { SelectionState } from '@alfresco/adf-extensions';
|
||||
import { MatSelectModule } from '@angular/material/select';
|
||||
@@ -49,6 +49,7 @@ import {
|
||||
import { ModalAiService } from '../../../../services/modal-ai.service';
|
||||
import { Agent } from '@alfresco/js-api';
|
||||
import { getAgentsWithMockedAvatars } from '../search-ai-utils';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
|
||||
const MatTooltipOptions: MatTooltipDefaultOptions = {
|
||||
...MAT_TOOLTIP_DEFAULT_OPTIONS_FACTORY(),
|
||||
@@ -89,8 +90,8 @@ export class SearchAiInputComponent implements OnInit, OnDestroy {
|
||||
@Input()
|
||||
useStoredNodes: boolean;
|
||||
|
||||
@Output()
|
||||
searchSubmitted = new EventEmitter<void>();
|
||||
@Input()
|
||||
searchTerm: string;
|
||||
|
||||
private readonly storedNodesKey = 'knowledgeRetrievalNodes';
|
||||
|
||||
@@ -126,10 +127,19 @@ export class SearchAiInputComponent implements OnInit, OnDestroy {
|
||||
private agentService: AgentService,
|
||||
private userPreferencesService: UserPreferencesService,
|
||||
private translateService: TranslateService,
|
||||
private modalAiService: ModalAiService
|
||||
private modalAiService: ModalAiService,
|
||||
private route: ActivatedRoute
|
||||
) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
if (this.searchTerm) {
|
||||
this.queryControl.setValue(this.searchTerm);
|
||||
} else if (this.route.snapshot?.queryParams?.query?.length > 0) {
|
||||
this.queryControl.setValue(this.route.snapshot.queryParams.query);
|
||||
} else {
|
||||
this.queryControl.setValue(null);
|
||||
}
|
||||
|
||||
if (!this.useStoredNodes) {
|
||||
this.store
|
||||
.select(getAppSelection)
|
||||
@@ -180,8 +190,7 @@ export class SearchAiInputComponent implements OnInit, OnDestroy {
|
||||
};
|
||||
this.userPreferencesService.set(this.storedNodesKey, JSON.stringify(this.selectedNodesState));
|
||||
this.store.dispatch(new SearchByTermAiAction(payload));
|
||||
this.queryControl.reset();
|
||||
this.searchSubmitted.emit();
|
||||
this.store.dispatch(new ToggleAISearchInput(this.agentControl.value.id, this.queryControl.value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -26,15 +26,7 @@ import { Component, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { PageComponent, PageLayoutComponent, ToolbarActionComponent, ToolbarComponent } from '@alfresco/aca-shared';
|
||||
import { concatMap, delay, filter, finalize, retryWhen, skipWhile, switchMap, takeUntil } from 'rxjs/operators';
|
||||
import {
|
||||
AvatarComponent,
|
||||
ClipboardService,
|
||||
EmptyContentComponent,
|
||||
ThumbnailService,
|
||||
ToolbarModule,
|
||||
UnsavedChangesGuard,
|
||||
UserPreferencesService
|
||||
} from '@alfresco/adf-core';
|
||||
import { AvatarComponent, ClipboardService, EmptyContentComponent, ThumbnailService, ToolbarModule, UnsavedChangesGuard } from '@alfresco/adf-core';
|
||||
import { AiAnswer, Node } from '@alfresco/js-api';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { SearchAiInputContainerComponent } from '../search-ai-input-container/search-ai-input-container.component';
|
||||
@@ -124,7 +116,6 @@ export class SearchAiResultsComponent extends PageComponent implements OnInit, O
|
||||
private clipboardService: ClipboardService,
|
||||
private thumbnailService: ThumbnailService,
|
||||
private nodesApiService: NodesApiService,
|
||||
private userPreferencesService: UserPreferencesService,
|
||||
private translateService: TranslateService,
|
||||
private unsavedChangesGuard: UnsavedChangesGuard,
|
||||
private modalAiService: ModalAiService,
|
||||
|
@@ -18,6 +18,7 @@
|
||||
[navigate]="false"
|
||||
[sorting]="['title', 'asc']"
|
||||
[sortingMode]="'client'"
|
||||
[preselectNodes]="selectedNodesState?.nodes"
|
||||
[imageResolver]="imageResolver"
|
||||
[displayCheckboxesOnHover]="true"
|
||||
[isResizingEnabled]="true"
|
||||
|
@@ -25,6 +25,7 @@
|
||||
[multiselect]="true"
|
||||
[navigate]="false"
|
||||
[sorting]="['modifiedAt', 'desc']"
|
||||
[preselectNodes]="selectedNodesState?.nodes"
|
||||
[sortingMode]="'client'"
|
||||
[imageResolver]="imageResolver"
|
||||
[isResizingEnabled]="true"
|
||||
|
@@ -47,6 +47,7 @@
|
||||
[multiselect]="true"
|
||||
[sortingMode]="'server'"
|
||||
[sorting]="sorting"
|
||||
[preselectNodes]="selectedNodesState?.nodes"
|
||||
[displayCheckboxesOnHover]="true"
|
||||
[imageResolver]="imageResolver"
|
||||
[isResizingEnabled]="true"
|
||||
|
@@ -26,6 +26,7 @@
|
||||
[multiselect]="true"
|
||||
[sorting]="['modifiedAt', 'desc']"
|
||||
[imageResolver]="imageResolver"
|
||||
[preselectNodes]="selectedNodesState?.nodes"
|
||||
[sortingMode]="'client'"
|
||||
[isResizingEnabled]="true"
|
||||
[displayCheckboxesOnHover]="true"
|
||||
|
@@ -26,17 +26,22 @@ import { NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { TestBed, ComponentFixture } from '@angular/core/testing';
|
||||
import { SidenavComponent } from './sidenav.component';
|
||||
import { AppTestingModule } from '../../testing/app-testing.module';
|
||||
import { AppExtensionService, AppService } from '@alfresco/aca-shared';
|
||||
import { AppExtensionService, AppService, NavigationHistoryService } from '@alfresco/aca-shared';
|
||||
import { BehaviorSubject, Subject } from 'rxjs';
|
||||
import { SidenavLayoutComponent } from '@alfresco/adf-core';
|
||||
import { NavigationEnd } from '@angular/router';
|
||||
|
||||
describe('SidenavComponent', () => {
|
||||
let fixture: ComponentFixture<SidenavComponent>;
|
||||
let component: SidenavComponent;
|
||||
let extensionService: AppExtensionService;
|
||||
let sidenavLayoutComponent: SidenavLayoutComponent;
|
||||
let navigationHistoryService: jasmine.SpyObj<NavigationHistoryService>;
|
||||
let routerEvents$: Subject<NavigationEnd>;
|
||||
|
||||
beforeEach(() => {
|
||||
const navigationHistoryServiceSpy = jasmine.createSpyObj('NavigationHistoryService', ['listenToRouteChanges', 'setHistory']);
|
||||
|
||||
TestBed.configureTestingModule({
|
||||
imports: [AppTestingModule, SidenavComponent],
|
||||
providers: [
|
||||
@@ -48,6 +53,7 @@ describe('SidenavComponent', () => {
|
||||
setAppNavbarMode: jasmine.createSpy('setAppNavbarMode')
|
||||
}
|
||||
},
|
||||
{ provide: NavigationHistoryService, useValue: navigationHistoryServiceSpy },
|
||||
SidenavLayoutComponent
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
@@ -73,6 +79,11 @@ describe('SidenavComponent', () => {
|
||||
component.data = {
|
||||
layout: sidenavLayoutComponent
|
||||
};
|
||||
|
||||
navigationHistoryService = TestBed.inject(NavigationHistoryService) as jasmine.SpyObj<NavigationHistoryService>;
|
||||
|
||||
routerEvents$ = new Subject<NavigationEnd>();
|
||||
navigationHistoryService.listenToRouteChanges.and.returnValue(routerEvents$.asObservable());
|
||||
});
|
||||
|
||||
it('should set the sidenav data', async () => {
|
||||
@@ -89,4 +100,13 @@ describe('SidenavComponent', () => {
|
||||
title: 'item-1'
|
||||
});
|
||||
});
|
||||
|
||||
it('should call setHistory when a NavigationEnd event occurs', () => {
|
||||
const mockNavigationEnd = new NavigationEnd(1, '/path', '/redirect');
|
||||
|
||||
component.ngOnInit();
|
||||
routerEvents$.next(mockNavigationEnd);
|
||||
|
||||
expect(navigationHistoryService.setHistory).toHaveBeenCalledWith(mockNavigationEnd, 3);
|
||||
});
|
||||
});
|
||||
|
@@ -28,12 +28,13 @@ import { Store } from '@ngrx/store';
|
||||
import { AppStore, getSideNavState } from '@alfresco/aca-shared/store';
|
||||
import { Subject } from 'rxjs';
|
||||
import { takeUntil, distinctUntilChanged, debounceTime } from 'rxjs/operators';
|
||||
import { AppExtensionService, AppService } from '@alfresco/aca-shared';
|
||||
import { AppExtensionService, AppService, NavigationHistoryService } from '@alfresco/aca-shared';
|
||||
import { SidenavLayoutComponent } from '@alfresco/adf-core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { SidenavHeaderComponent } from './components/sidenav-header.component';
|
||||
import { MatListModule } from '@angular/material/list';
|
||||
import { ExpandMenuComponent } from './components/expand-menu.component';
|
||||
import { NavigationEnd } from '@angular/router';
|
||||
|
||||
@Component({
|
||||
standalone: true,
|
||||
@@ -54,7 +55,12 @@ export class SidenavComponent implements OnInit, OnDestroy {
|
||||
groups: Array<NavBarGroupRef> = [];
|
||||
private onDestroy$ = new Subject<boolean>();
|
||||
|
||||
constructor(private store: Store<AppStore>, private extensions: AppExtensionService, private appService: AppService) {}
|
||||
constructor(
|
||||
private store: Store<AppStore>,
|
||||
private extensions: AppExtensionService,
|
||||
private appService: AppService,
|
||||
private navigationHistoryService: NavigationHistoryService
|
||||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.store
|
||||
@@ -67,6 +73,12 @@ export class SidenavComponent implements OnInit, OnDestroy {
|
||||
this.appService.setAppNavbarMode(this.data.mode);
|
||||
this.appService.toggleAppNavBar$.pipe(takeUntil(this.onDestroy$)).subscribe(() => this.toggleNavBar());
|
||||
this.data.layout.expanded.pipe(takeUntil(this.onDestroy$)).subscribe(() => this.setNavBarMode());
|
||||
this.navigationHistoryService
|
||||
.listenToRouteChanges()
|
||||
.pipe(takeUntil(this.onDestroy$))
|
||||
.subscribe((event: NavigationEnd) => {
|
||||
this.navigationHistoryService.setHistory(event, 3);
|
||||
});
|
||||
}
|
||||
|
||||
trackByGroupId(_: number, obj: NavBarGroupRef): string {
|
||||
|
@@ -18,6 +18,7 @@
|
||||
[multiselect]="true"
|
||||
[navigate]="false"
|
||||
[sortingMode]="'client'"
|
||||
[preselectNodes]="selectedNodesState?.nodes"
|
||||
[imageResolver]="imageResolver"
|
||||
[displayCheckboxesOnHover]="true"
|
||||
(selectedItemsCountChanged)="onSelectedItemsCountChanged($event)"
|
||||
|
Reference in New Issue
Block a user