From ce35c4d875c3cb036ce3bf318f43d015f0d616c5 Mon Sep 17 00:00:00 2001 From: Sushmitha V <58967843+Sushmitha-Vk@users.noreply.github.com> Date: Mon, 19 Jul 2021 18:20:38 +0530 Subject: [PATCH] =?UTF-8?q?[AAE-4585]=20Resolved=20-=20Disable=20actions?= =?UTF-8?q?=20that=20can=20not=20happen=20when=20naviga=E2=80=A6=20(#2223)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [AAE-4585] Resolved - Disable actions that can not happen when navigating to an extension (upload, create folder etc) * [AAE-4585] Resolved failing unit test --- src/app/components/files/files.component.ts | 2 +- src/app/components/page.component.spec.ts | 7 +++++++ src/app/components/page.component.ts | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/app/components/files/files.component.ts b/src/app/components/files/files.component.ts index 34c18544b..310b7a42e 100644 --- a/src/app/components/files/files.component.ts +++ b/src/app/components/files/files.component.ts @@ -118,8 +118,8 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy { } ngOnDestroy() { - super.ngOnDestroy(); this.store.dispatch(new SetCurrentFolderAction(null)); + super.ngOnDestroy(); } navigate(nodeId: string = null) { diff --git a/src/app/components/page.component.spec.ts b/src/app/components/page.component.spec.ts index 46f7723ab..4a545306c 100644 --- a/src/app/components/page.component.spec.ts +++ b/src/app/components/page.component.spec.ts @@ -42,6 +42,7 @@ import { Store } from '@ngrx/store'; import { AppTestingModule } from '../testing/app-testing.module'; import { Component } from '@angular/core'; import { DocumentListComponent } from '@alfresco/adf-content-services'; +import { of } from 'rxjs'; @Component({ selector: 'aca-test', @@ -72,6 +73,10 @@ describe('PageComponent', () => { component = fixture.componentInstance; }); + afterEach(() => { + fixture.destroy(); + }); + describe('getParentNodeId()', () => { it('returns parent node id when node is set', () => { component.node = { id: 'node-id' }; @@ -94,6 +99,7 @@ describe('PageComponent', () => { }); it('should open info drawer on action event', (done) => { + spyOn(store, 'select').and.returnValue(of(true)); window.history.pushState({}, null, `${locationHref}#test`); fixture.detectChanges(); @@ -108,6 +114,7 @@ describe('PageComponent', () => { }); it('should not open info drawer if viewer outlet is active', (done) => { + spyOn(store, 'select').and.returnValue(of(false)); window.history.pushState({}, null, `${locationHref}#test(viewer:view)`); fixture.detectChanges(); diff --git a/src/app/components/page.component.ts b/src/app/components/page.component.ts index 04c0408a8..9efd2b754 100644 --- a/src/app/components/page.component.ts +++ b/src/app/components/page.component.ts @@ -112,6 +112,7 @@ export abstract class PageComponent implements OnInit, OnDestroy, OnChanges { this.onDestroy$.next(true); this.onDestroy$.complete(); + this.store.dispatch(new SetSelectedNodesAction([])); } showPreview(node: MinimalNodeEntity, extras?: ViewNodeExtras) {