Skip to content

Commit

Permalink
[ACS-6106] Breadcrumb navigation fix on Details tab (#3482)
Browse files Browse the repository at this point in the history
  • Loading branch information
nikita-web-ua authored Oct 19, 2023
1 parent 99c27a8 commit 1c222bd
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<aca-page-layout>
<div class="aca-page-layout-header">
<adf-breadcrumb [root]="title" [folderNode]="node" (navigate)="goBack()"> </adf-breadcrumb>
<adf-breadcrumb [root]="title" [folderNode]="node" (navigate)="onBreadcrumbNavigate($event)"> </adf-breadcrumb>
<aca-toolbar [items]="actions"></aca-toolbar>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@ import { of, Subject } from 'rxjs';
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { Store } from '@ngrx/store';
import { ContentApiService } from '@alfresco/aca-shared';
import { STORE_INITIAL_APP_DATA, SetSelectedNodesAction } from '@alfresco/aca-shared/store';
import { NodeEntry } from '@alfresco/js-api';
import { STORE_INITIAL_APP_DATA, SetSelectedNodesAction, NavigateToFolder } from '@alfresco/aca-shared/store';
import { NodeEntry, PathElement } from '@alfresco/js-api';
import { RouterTestingModule } from '@angular/router/testing';
import { AuthenticationService, PageTitleService } from '@alfresco/adf-core';
import { SearchQueryBuilderService } from '@alfresco/adf-content-services';
import { BreadcrumbComponent, SearchQueryBuilderService } from '@alfresco/adf-content-services';
import { By } from '@angular/platform-browser';

describe('DetailsComponent', () => {
let component: DetailsComponent;
Expand All @@ -45,7 +46,7 @@ describe('DetailsComponent', () => {

const mockStream = new Subject();
const storeMock = {
dispatch: jasmine.createSpy('dispatch'),
dispatch: jasmine.createSpy('dispatch').and.stub(),
select: () => mockStream
};

Expand Down Expand Up @@ -124,6 +125,17 @@ describe('DetailsComponent', () => {
expect(contentApiService.getNode).toHaveBeenCalled();
});

it('should dispatch navigation to a given folder', () => {
const breadcrumbComponent: BreadcrumbComponent = fixture.debugElement.query(By.directive(BreadcrumbComponent)).componentInstance;
const pathElement: PathElement = {
id: 'fake-id'
};
breadcrumbComponent.navigate.emit(pathElement);
fixture.detectChanges();

expect(store.dispatch).toHaveBeenCalledWith(new NavigateToFolder({ entry: pathElement } as NodeEntry));
});

it('should dispatch node selection', () => {
fixture.detectChanges();
expect(store.dispatch).toHaveBeenCalledWith(new SetSelectedNodesAction([node]));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import { Component, OnInit, ViewEncapsulation, OnDestroy } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { ContentApiService, PageComponent, PageLayoutComponent, ToolbarComponent } from '@alfresco/aca-shared';
import { NavigateToPreviousPage, SetSelectedNodesAction } from '@alfresco/aca-shared/store';
import { NavigateToFolder, NavigateToPreviousPage, SetSelectedNodesAction } from '@alfresco/aca-shared/store';
import { Subject } from 'rxjs';
import { BreadcrumbModule, PermissionManagerModule } from '@alfresco/adf-content-services';
import { CommonModule } from '@angular/common';
Expand All @@ -36,6 +36,7 @@ import { MatProgressBarModule } from '@angular/material/progress-bar';
import { MatButtonModule } from '@angular/material/button';
import { MetadataTabComponent } from '../info-drawer/metadata-tab/metadata-tab.component';
import { CommentsTabComponent } from '../info-drawer/comments-tab/comments-tab.component';
import { NodeEntry, PathElement } from '@alfresco/js-api';

@Component({
standalone: true,
Expand Down Expand Up @@ -105,6 +106,10 @@ export class DetailsComponent extends PageComponent implements OnInit, OnDestroy
this.store.dispatch(new NavigateToPreviousPage());
}

onBreadcrumbNavigate(path: PathElement) {
this.store.dispatch(new NavigateToFolder({ entry: path } as NodeEntry));
}

ngOnDestroy(): void {
this.store.dispatch(new SetSelectedNodesAction([]));
this.onDestroy$.next();
Expand Down

0 comments on commit 1c222bd

Please sign in to comment.