From febfecd1a12f20798bcd15e65c2cfe9fdceee35f Mon Sep 17 00:00:00 2001 From: Jalinson Diaz Date: Thu, 13 Jul 2023 19:04:05 -0300 Subject: [PATCH] reload listing when deactivating router outlet --- .../dot-pages/dot-pages.component.html | 5 +--- .../dot-pages/dot-pages.component.spec.ts | 21 ++------------- .../portlets/dot-pages/dot-pages.component.ts | 27 ++++--------------- 3 files changed, 8 insertions(+), 45 deletions(-) diff --git a/core-web/apps/dotcms-ui/src/app/portlets/dot-pages/dot-pages.component.html b/core-web/apps/dotcms-ui/src/app/portlets/dot-pages/dot-pages.component.html index 8bdbbebecfa9..f8618ed40ca5 100644 --- a/core-web/apps/dotcms-ui/src/app/portlets/dot-pages/dot-pages.component.html +++ b/core-web/apps/dotcms-ui/src/app/portlets/dot-pages/dot-pages.component.html @@ -34,7 +34,4 @@ - + diff --git a/core-web/apps/dotcms-ui/src/app/portlets/dot-pages/dot-pages.component.spec.ts b/core-web/apps/dotcms-ui/src/app/portlets/dot-pages/dot-pages.component.spec.ts index e43539fedd3a..54446367cdcd 100644 --- a/core-web/apps/dotcms-ui/src/app/portlets/dot-pages/dot-pages.component.spec.ts +++ b/core-web/apps/dotcms-ui/src/app/portlets/dot-pages/dot-pages.component.spec.ts @@ -13,7 +13,6 @@ import { of } from 'rxjs/internal/observable/of'; import { DotIframeService } from '@components/_common/iframe/service/dot-iframe/dot-iframe.service'; import { IframeOverlayService } from '@components/_common/iframe/service/iframe-overlay.service'; -import { DotCreateContentletComponent } from '@components/dot-contentlet-editor/components/dot-create-contentlet/dot-create-contentlet.component'; import { DotContentletEditorService } from '@components/dot-contentlet-editor/services/dot-contentlet-editor.service'; import { DotMessageDisplayServiceMock } from '@components/dot-message-display/dot-message-display.component.spec'; import { DotMessageSeverity, DotMessageType } from '@components/dot-message-display/model'; @@ -394,30 +393,14 @@ describe('DotPagesComponent', () => { }); }); - it('should get pages after closing DotCreateContentletComponent', () => { - const dialogComponentFixture = TestBed.createComponent(DotCreateContentletComponent); - fixture.detectChanges(); - - const dialogComponent = dialogComponentFixture.componentInstance; - + it('should trigger getPages when deactivating the router-outlet', () => { const routerOutlet = de.query(By.css('router-outlet')); - routerOutlet.triggerEventHandler('activate', dialogComponent); - fixture.detectChanges(); - - dialogComponent.shutdown.emit(); - fixture.detectChanges(); - expect(store.getPages).toHaveBeenCalled(); - }); - it('should trigger unsubscribeToShutdown when deactivating the router-outlet', () => { - const routerOutlet = de.query(By.css('router-outlet')); - spyOn(component, 'unsubscribeToShutdown'); - routerOutlet.triggerEventHandler('activate'); fixture.detectChanges(); routerOutlet.triggerEventHandler('deactivate'); fixture.detectChanges(); - expect(component.unsubscribeToShutdown).toHaveBeenCalled(); + expect(store.getPages).toHaveBeenCalled(); }); }); diff --git a/core-web/apps/dotcms-ui/src/app/portlets/dot-pages/dot-pages.component.ts b/core-web/apps/dotcms-ui/src/app/portlets/dot-pages/dot-pages.component.ts index 7b0c60079e60..938b0e210fbd 100644 --- a/core-web/apps/dotcms-ui/src/app/portlets/dot-pages/dot-pages.component.ts +++ b/core-web/apps/dotcms-ui/src/app/portlets/dot-pages/dot-pages.component.ts @@ -1,4 +1,4 @@ -import { Subject, Subscription } from 'rxjs'; +import { Subject } from 'rxjs'; import { HttpErrorResponse, HttpResponse } from '@angular/common/http'; import { @@ -15,7 +15,6 @@ import { Menu } from 'primeng/menu'; import { Observable } from 'rxjs/internal/Observable'; import { filter, take, takeUntil } from 'rxjs/operators'; -import { DotCreateContentletComponent } from '@components/dot-contentlet-editor/components/dot-create-contentlet/dot-create-contentlet.component'; import { DotMessageSeverity, DotMessageType } from '@components/dot-message-display/model'; import { DotMessageDisplayService } from '@components/dot-message-display/services'; import { DotHttpErrorManagerService } from '@dotcms/app/api/services/dot-http-error-manager/dot-http-error-manager.service'; @@ -48,7 +47,6 @@ export class DotPagesComponent implements AfterViewInit, OnDestroy { private domIdMenuAttached = ''; private destroy$: Subject = new Subject(); - private contentletDialogShutdown: Subscription; constructor( private store: DotPageStore, @@ -200,28 +198,13 @@ export class DotPagesComponent implements AfterViewInit, OnDestroy { } /** - * Subscribe to the shutdown event of the contentlet dialog + * Load pages on deactivation * - * @param {*} componentRef - * @return {*} * @memberof DotPagesComponent */ - subscribeToShutdown(componentRef: Component): void { - if (!(componentRef instanceof DotCreateContentletComponent)) return; - - this.contentletDialogShutdown = componentRef.shutdown.subscribe(() => { - this.store.getPages({ - offset: 0 - }); + loadPagesOnDeactivation() { + this.store.getPages({ + offset: 0 }); } - - /** - * Unsubscribe to the shutdown event of the contentlet dialog - * - * @memberof DotPagesComponent - */ - unsubscribeToShutdown() { - if (this.contentletDialogShutdown) this.contentletDialogShutdown.unsubscribe(); - } }