From 6c4637245cb0aa9f061f01b043e012f90d874152 Mon Sep 17 00:00:00 2001 From: Mykyta Maliarchuk Date: Wed, 18 Oct 2023 09:21:02 +0200 Subject: [PATCH] [ACS-6106] linter --- .../components/details/details.component.html | 2 +- .../details/details.component.spec.ts | 20 +++++++++++++++---- .../components/details/details.component.ts | 7 ++++++- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/projects/aca-content/src/lib/components/details/details.component.html b/projects/aca-content/src/lib/components/details/details.component.html index 2d9dda876a..3c6abe85f1 100644 --- a/projects/aca-content/src/lib/components/details/details.component.html +++ b/projects/aca-content/src/lib/components/details/details.component.html @@ -1,6 +1,6 @@
- +
diff --git a/projects/aca-content/src/lib/components/details/details.component.spec.ts b/projects/aca-content/src/lib/components/details/details.component.spec.ts index 0988ca7033..a4563dae66 100644 --- a/projects/aca-content/src/lib/components/details/details.component.spec.ts +++ b/projects/aca-content/src/lib/components/details/details.component.spec.ts @@ -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; @@ -45,7 +46,7 @@ describe('DetailsComponent', () => { const mockStream = new Subject(); const storeMock = { - dispatch: jasmine.createSpy('dispatch'), + dispatch: jasmine.createSpy('dispatch').and.stub(), select: () => mockStream }; @@ -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])); diff --git a/projects/aca-content/src/lib/components/details/details.component.ts b/projects/aca-content/src/lib/components/details/details.component.ts index a025c0409c..a5e8ee0eb9 100644 --- a/projects/aca-content/src/lib/components/details/details.component.ts +++ b/projects/aca-content/src/lib/components/details/details.component.ts @@ -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'; @@ -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, @@ -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();