mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2026-09-09 18:02:54 +00:00
[ACA-866] Trash - Undo deleted node notification not reflected (#88)
This commit is contained in:
committed by
Denys Vuika
parent
b1b9e04db6
commit
319594d63b
@@ -20,11 +20,13 @@ import { CoreModule, AlfrescoApiService } from '@alfresco/adf-core';
|
||||
import { TrashcanComponent } from './trashcan.component';
|
||||
import { CommonModule } from '../../common/common.module';
|
||||
import { LocationLinkComponent } from '../location-link/location-link.component';
|
||||
import { ContentManagementService } from '../../common/services/content-management.service';
|
||||
|
||||
describe('TrashcanComponent', () => {
|
||||
let fixture;
|
||||
let component;
|
||||
let alfrescoApi: AlfrescoApiService;
|
||||
let contentService: ContentManagementService;
|
||||
let page;
|
||||
|
||||
beforeEach(() => {
|
||||
@@ -45,6 +47,9 @@ describe('TrashcanComponent', () => {
|
||||
declarations: [
|
||||
LocationLinkComponent,
|
||||
TrashcanComponent
|
||||
],
|
||||
providers: [
|
||||
ContentManagementService
|
||||
]
|
||||
})
|
||||
.compileComponents()
|
||||
@@ -53,6 +58,7 @@ describe('TrashcanComponent', () => {
|
||||
component = fixture.componentInstance;
|
||||
|
||||
alfrescoApi = TestBed.get(AlfrescoApiService);
|
||||
contentService = TestBed.get(ContentManagementService);
|
||||
|
||||
component.documentList = {
|
||||
loadTrashcan: jasmine.createSpy('loadTrashcan'),
|
||||
@@ -65,6 +71,17 @@ describe('TrashcanComponent', () => {
|
||||
spyOn(alfrescoApi.nodesApi, 'getDeletedNodes').and.returnValue(Promise.resolve(page));
|
||||
});
|
||||
|
||||
describe('onRestoreNode()', () => {
|
||||
it('should call refresh()', () => {
|
||||
spyOn(component, 'refresh');
|
||||
fixture.detectChanges();
|
||||
|
||||
contentService.restoreNode.next();
|
||||
|
||||
expect(component.refresh).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe('refresh()', () => {
|
||||
it('calls child component to reload', () => {
|
||||
component.refresh();
|
||||
|
||||
@@ -15,17 +15,32 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Component, ViewChild } from '@angular/core';
|
||||
import { Component, ViewChild, OnInit, OnDestroy } from '@angular/core';
|
||||
import { Subscription } from 'rxjs/Rx';
|
||||
|
||||
import { DocumentListComponent } from '@alfresco/adf-content-services';
|
||||
import { ContentManagementService } from '../../common/services/content-management.service';
|
||||
|
||||
@Component({
|
||||
templateUrl: './trashcan.component.html'
|
||||
})
|
||||
export class TrashcanComponent {
|
||||
export class TrashcanComponent implements OnInit, OnDestroy {
|
||||
private subscriptions: Subscription[] = [];
|
||||
|
||||
@ViewChild(DocumentListComponent) documentList;
|
||||
|
||||
constructor(private contentManagementService: ContentManagementService) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.subscriptions.push(this.contentManagementService.restoreNode.subscribe(() => this.refresh()));
|
||||
}
|
||||
|
||||
refresh(): void {
|
||||
this.documentList.loadTrashcan();
|
||||
this.documentList.resetSelection();
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.subscriptions.forEach(s => s.unsubscribe());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user