mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-31 17:38:28 +00:00
reload active doclist via NgRx actions (#978)
* doclist reload action and effect * deprecate folderEdited event * deprecate "favoriteToggle" event * deprecate "favoriteRemoved" event * update docs * unified reload function * deprecate "nodesRestored" event * deprecate "nodesPurged" event * test fixes * deprecate "nodesMoved" event * reduce the use of "nodesDeleted"
This commit is contained in:
@@ -34,8 +34,6 @@ import {
|
||||
AppConfigPipe
|
||||
} from '@alfresco/adf-core';
|
||||
import { DocumentListComponent } from '@alfresco/adf-content-services';
|
||||
import { ContentManagementService } from '../../services/content-management.service';
|
||||
|
||||
import { RecentFilesComponent } from './recent-files.component';
|
||||
import { AppTestingModule } from '../../testing/app-testing.module';
|
||||
|
||||
@@ -43,7 +41,6 @@ describe('RecentFilesComponent', () => {
|
||||
let fixture: ComponentFixture<RecentFilesComponent>;
|
||||
let component: RecentFilesComponent;
|
||||
let alfrescoApi: AlfrescoApiService;
|
||||
let contentService: ContentManagementService;
|
||||
let page;
|
||||
|
||||
beforeEach(() => {
|
||||
@@ -73,7 +70,6 @@ describe('RecentFilesComponent', () => {
|
||||
fixture = TestBed.createComponent(RecentFilesComponent);
|
||||
component = fixture.componentInstance;
|
||||
|
||||
contentService = TestBed.get(ContentManagementService);
|
||||
alfrescoApi = TestBed.get(AlfrescoApiService);
|
||||
alfrescoApi.reset();
|
||||
|
||||
@@ -88,44 +84,14 @@ describe('RecentFilesComponent', () => {
|
||||
);
|
||||
});
|
||||
|
||||
describe('OnInit()', () => {
|
||||
beforeEach(() => {
|
||||
spyOn(component, 'reload').and.stub();
|
||||
});
|
||||
|
||||
it('should reload nodes on onDeleteNode event', () => {
|
||||
fixture.detectChanges();
|
||||
|
||||
contentService.nodesDeleted.next();
|
||||
|
||||
expect(component.reload).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should reload on onRestoreNode event', () => {
|
||||
fixture.detectChanges();
|
||||
|
||||
contentService.nodesRestored.next();
|
||||
|
||||
expect(component.reload).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should reload on move node event', () => {
|
||||
fixture.detectChanges();
|
||||
|
||||
contentService.nodesMoved.next();
|
||||
|
||||
expect(component.reload).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe('refresh', () => {
|
||||
it('should call document list reload', () => {
|
||||
spyOn(component.documentList, 'reload');
|
||||
spyOn(component, 'reload');
|
||||
fixture.detectChanges();
|
||||
|
||||
component.reload();
|
||||
|
||||
expect(component.documentList.reload).toHaveBeenCalled();
|
||||
expect(component.reload).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -31,7 +31,7 @@ import { PageComponent } from '../page.component';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { AppStore } from '../../store/states/app.state';
|
||||
import { AppExtensionService } from '../../extensions/extension.service';
|
||||
import { FileUploadEvent, UploadService } from '@alfresco/adf-core';
|
||||
import { UploadService } from '@alfresco/adf-core';
|
||||
import { debounceTime } from 'rxjs/operators';
|
||||
|
||||
@Component({
|
||||
@@ -56,16 +56,12 @@ export class RecentFilesComponent extends PageComponent implements OnInit {
|
||||
super.ngOnInit();
|
||||
|
||||
this.subscriptions = this.subscriptions.concat([
|
||||
this.content.nodesDeleted.subscribe(() => this.reload()),
|
||||
this.content.nodesMoved.subscribe(() => this.reload()),
|
||||
this.content.nodesRestored.subscribe(() => this.reload()),
|
||||
|
||||
this.uploadService.fileUploadComplete
|
||||
.pipe(debounceTime(300))
|
||||
.subscribe(file => this.onFileUploadedEvent(file)),
|
||||
.subscribe(() => this.onFileUploadedEvent()),
|
||||
this.uploadService.fileUploadDeleted
|
||||
.pipe(debounceTime(300))
|
||||
.subscribe(file => this.onFileUploadedEvent(file)),
|
||||
.subscribe(() => this.onFileUploadedEvent()),
|
||||
|
||||
this.breakpointObserver
|
||||
.observe([Breakpoints.HandsetPortrait, Breakpoints.HandsetLandscape])
|
||||
@@ -83,7 +79,7 @@ export class RecentFilesComponent extends PageComponent implements OnInit {
|
||||
}
|
||||
}
|
||||
|
||||
private onFileUploadedEvent(event: FileUploadEvent) {
|
||||
this.documentList.reload();
|
||||
private onFileUploadedEvent() {
|
||||
this.reload();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user