mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-24 17:31:52 +00:00
ACS-8572: Switch to using ADF document list reload (#4021)
This commit is contained in:
@@ -22,7 +22,7 @@
|
||||
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { DocumentListComponent, ShareDataRow, UploadService } from '@alfresco/adf-content-services';
|
||||
import { DocumentListComponent, DocumentListService, ShareDataRow, UploadService } from '@alfresco/adf-content-services';
|
||||
import { ShowHeaderMode } from '@alfresco/adf-core';
|
||||
import { ContentActionRef, DocumentListPresetRef, SelectionState } from '@alfresco/adf-extensions';
|
||||
import { OnDestroy, OnInit, OnChanges, ViewChild, SimpleChanges, Directive, inject, HostListener } from '@angular/core';
|
||||
@@ -33,7 +33,6 @@ import { takeUntil } from 'rxjs/operators';
|
||||
import { DocumentBasePageService } from './document-base-page.service';
|
||||
import {
|
||||
AppStore,
|
||||
ReloadDocumentListAction,
|
||||
getCurrentFolder,
|
||||
getAppSelection,
|
||||
isInfoDrawerOpened,
|
||||
@@ -71,6 +70,7 @@ export abstract class PageComponent implements OnInit, OnDestroy, OnChanges {
|
||||
isSmallScreen = false;
|
||||
selectedRowItemsCount = 0;
|
||||
|
||||
protected documentListService = inject(DocumentListService);
|
||||
protected settings = inject(AppSettingsService);
|
||||
protected extensions = inject(AppExtensionService);
|
||||
protected content = inject(DocumentBasePageService);
|
||||
@@ -187,7 +187,7 @@ export abstract class PageComponent implements OnInit, OnDestroy, OnChanges {
|
||||
return;
|
||||
}
|
||||
|
||||
this.store.dispatch(new ReloadDocumentListAction());
|
||||
this.documentListService.reload();
|
||||
if (selectedNode) {
|
||||
this.store.dispatch(new SetSelectedNodesAction([selectedNode]));
|
||||
}
|
||||
@@ -217,7 +217,7 @@ export abstract class PageComponent implements OnInit, OnDestroy, OnChanges {
|
||||
onAllFilterCleared() {
|
||||
if (!this.isOutletPreviewUrl()) {
|
||||
this.documentList.node = null;
|
||||
this.store.dispatch(new ReloadDocumentListAction());
|
||||
this.documentListService.reload();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -24,18 +24,15 @@
|
||||
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { PageComponent } from './document-base-page.component';
|
||||
import { AppState, ReloadDocumentListAction, SetSelectedNodesAction, ViewNodeAction } from '@alfresco/aca-shared/store';
|
||||
import { AppState, SetSelectedNodesAction, ViewNodeAction } from '@alfresco/aca-shared/store';
|
||||
import { AppExtensionService, LibTestingModule, discoveryApiServiceMockValue, DocumentBasePageServiceMock } from '@alfresco/aca-shared';
|
||||
import { NodeEntry, NodePaging } from '@alfresco/js-api';
|
||||
import { DocumentBasePageService } from './document-base-page.service';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { Component } from '@angular/core';
|
||||
import { DiscoveryApiService, DocumentListComponent } from '@alfresco/adf-content-services';
|
||||
import { DiscoveryApiService, DocumentListComponent, DocumentListService } from '@alfresco/adf-content-services';
|
||||
import { MockStore, provideMockStore } from '@ngrx/store/testing';
|
||||
import { AuthModule } from '@alfresco/adf-core';
|
||||
import { HttpClientModule } from '@angular/common/http';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { Subscription } from 'rxjs';
|
||||
import { MatDialogModule } from '@angular/material/dialog';
|
||||
|
||||
@@ -59,6 +56,7 @@ describe('PageComponent', () => {
|
||||
let component: TestComponent;
|
||||
let store: Store<AppState>;
|
||||
let fixture: ComponentFixture<TestComponent>;
|
||||
let documentListService: DocumentListService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
@@ -72,6 +70,7 @@ describe('PageComponent', () => {
|
||||
});
|
||||
|
||||
store = TestBed.inject(Store);
|
||||
documentListService = TestBed.inject(DocumentListService);
|
||||
fixture = TestBed.createComponent(TestComponent);
|
||||
component = fixture.componentInstance;
|
||||
});
|
||||
@@ -110,10 +109,10 @@ describe('PageComponent', () => {
|
||||
});
|
||||
|
||||
it('should reload if url does not contain viewer outlet', () => {
|
||||
spyOn(store, 'dispatch');
|
||||
spyOn(documentListService, 'reload');
|
||||
|
||||
component.reload();
|
||||
expect(store.dispatch).toHaveBeenCalledWith(new ReloadDocumentListAction());
|
||||
expect(documentListService.reload).toHaveBeenCalledWith();
|
||||
});
|
||||
|
||||
it('should set selection after reload if node is passed', () => {
|
||||
@@ -129,6 +128,8 @@ describe('PageComponent', () => {
|
||||
});
|
||||
|
||||
it('should clear results onAllFilterCleared event', () => {
|
||||
spyOn(documentListService, 'reload');
|
||||
|
||||
component.documentList = {
|
||||
node: {
|
||||
list: {
|
||||
@@ -141,7 +142,7 @@ describe('PageComponent', () => {
|
||||
|
||||
component.onAllFilterCleared();
|
||||
expect(component.documentList.node).toBe(null);
|
||||
expect(store.dispatch['calls'].mostRecent().args[0]).toEqual(new ReloadDocumentListAction());
|
||||
expect(documentListService.reload).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should call onAllFilterCleared event if page is viewer outlet', () => {
|
||||
@@ -212,7 +213,7 @@ describe('Info Drawer state', () => {
|
||||
};
|
||||
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopAnimationsModule, HttpClientModule, RouterTestingModule, AuthModule.forRoot(), MatDialogModule],
|
||||
imports: [LibTestingModule, AuthModule.forRoot(), MatDialogModule],
|
||||
declarations: [TestComponent],
|
||||
providers: [
|
||||
{ provide: DocumentBasePageService, useClass: DocumentBasePageServiceMock },
|
||||
|
@@ -30,16 +30,6 @@ import { SiteEntry } from '@alfresco/js-api';
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class AppHookService {
|
||||
/**
|
||||
* Gets emitted when reloads event fired
|
||||
*/
|
||||
reload = new Subject<any>();
|
||||
|
||||
/**
|
||||
* Gets emitted when user reset the node
|
||||
*/
|
||||
reset = new Subject<any>();
|
||||
|
||||
/**
|
||||
* Gets emitted when user delete the node
|
||||
*/
|
||||
@@ -86,7 +76,7 @@ export class AppHookService {
|
||||
linksUnshared = new Subject<any>();
|
||||
|
||||
/**
|
||||
* Gets emitted when user mark the the favorite library
|
||||
* Gets emitted when user mark the favorite library
|
||||
*/
|
||||
favoriteLibraryToggle = new Subject<any>();
|
||||
}
|
||||
|
Reference in New Issue
Block a user