[CSTPER-3620] Workflow Actions refresh entire MyDSpace page instead of just WorkflowItem

Lint
This commit is contained in:
Alessandro Martelli
2021-01-29 19:31:54 +01:00
parent c65dfc7303
commit 54c405994c
12 changed files with 34 additions and 34 deletions

View File

@@ -101,7 +101,7 @@ export class ClaimedTaskActionsComponent extends MyDSpaceActionsComponent<Claime
} }
ngOnDestroy() { ngOnDestroy() {
console.log('Destroy of ClaimedTaskActionComponent', this.object) console.log('Destroy of ClaimedTaskActionComponent', this.object);
} }
} }

View File

@@ -16,8 +16,8 @@ import { BehaviorSubject, Subscription } from 'rxjs';
import { SearchService } from '../../core/shared/search/search.service'; import { SearchService } from '../../core/shared/search/search.service';
export interface MyDSpaceActionsResult { export interface MyDSpaceActionsResult {
result: boolean, result: boolean;
reloadedObject: DSpaceObject, reloadedObject: DSpaceObject;
} }
/** /**
@@ -86,7 +86,6 @@ export abstract class MyDSpaceActionsComponent<T extends DSpaceObject, TService
* Refresh current page * Refresh current page
*/ */
reload(): void { reload(): void {
debugger;
this.router.navigated = false; this.router.navigated = false;
const url = decodeURIComponent(this.router.url); const url = decodeURIComponent(this.router.url);
@@ -106,7 +105,6 @@ export abstract class MyDSpaceActionsComponent<T extends DSpaceObject, TService
* Override the target object with a refreshed one * Override the target object with a refreshed one
*/ */
refresh(): void { refresh(): void {
debugger;
// find object by id // find object by id
this.objectDataService.findById(this.object.id).pipe( this.objectDataService.findById(this.object.id).pipe(

View File

@@ -1,5 +1,5 @@
import { ChangeDetectionStrategy, Injector, NO_ERRORS_SCHEMA } from '@angular/core'; import { ChangeDetectionStrategy, Injector, NO_ERRORS_SCHEMA } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import {ComponentFixture, fakeAsync, TestBed} from '@angular/core/testing';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { of as observableOf } from 'rxjs'; import { of as observableOf } from 'rxjs';
import { TranslateLoader, TranslateModule } from '@ngx-translate/core'; import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
@@ -69,8 +69,8 @@ const rdWorkflowitem = createSuccessfulRemoteDataObject(workflowitem);
mockObject = Object.assign(new PoolTask(), { workflowitem: observableOf(rdWorkflowitem), id: '1234' }); mockObject = Object.assign(new PoolTask(), { workflowitem: observableOf(rdWorkflowitem), id: '1234' });
describe('MyDSpaceReloadableActionsComponent', () => { describe('MyDSpaceReloadableActionsComponent', () => {
beforeEach(async(() => { beforeEach(fakeAsync(() => {
mockDataService = new PoolTaskDataService(null, null, null, null, null, null, null, null) mockDataService = new PoolTaskDataService(null, null, null, null, null, null, null, null);
mockClaimedTaskDataService = new ClaimedTaskDataService(null, null, null, null, null, null, null, null); mockClaimedTaskDataService = new ClaimedTaskDataService(null, null, null, null, null, null, null, null);
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [ imports: [
@@ -118,7 +118,7 @@ describe('MyDSpaceReloadableActionsComponent', () => {
spyOn(component, 'initObjects'); spyOn(component, 'initObjects');
}); });
it('should call initReloadAnchor and initObjects on init', async(() => { it('should call initReloadAnchor and initObjects on init', fakeAsync(() => {
component.ngOnInit(); component.ngOnInit();
fixture.detectChanges(); fixture.detectChanges();
@@ -130,7 +130,7 @@ describe('MyDSpaceReloadableActionsComponent', () => {
})); }));
}) });
describe('on action execution fail', () => { describe('on action execution fail', () => {
@@ -158,7 +158,7 @@ describe('MyDSpaceReloadableActionsComponent', () => {
component.startActionExecution().subscribe( (result) => { component.startActionExecution().subscribe( (result) => {
expect(notificationsServiceStub.error).toHaveBeenCalled(); expect(notificationsServiceStub.error).toHaveBeenCalled();
done(); done();
}) });
}); });
it('should not call reloadObject', (done) => { it('should not call reloadObject', (done) => {
@@ -166,7 +166,7 @@ describe('MyDSpaceReloadableActionsComponent', () => {
component.startActionExecution().subscribe( (result) => { component.startActionExecution().subscribe( (result) => {
expect(component.reloadObjectExecution).not.toHaveBeenCalled(); expect(component.reloadObjectExecution).not.toHaveBeenCalled();
done(); done();
}) });
}); });
@@ -175,7 +175,7 @@ describe('MyDSpaceReloadableActionsComponent', () => {
component.startActionExecution().subscribe( (result) => { component.startActionExecution().subscribe( (result) => {
expect(component.processCompleted.emit).not.toHaveBeenCalled(); expect(component.processCompleted.emit).not.toHaveBeenCalled();
done(); done();
}) });
}); });
@@ -206,7 +206,7 @@ describe('MyDSpaceReloadableActionsComponent', () => {
component.startActionExecution().subscribe( (result) => { component.startActionExecution().subscribe( (result) => {
expect(component.reloadObjectExecution).toHaveBeenCalled(); expect(component.reloadObjectExecution).toHaveBeenCalled();
done(); done();
}) });
}); });
it('should convert the reloaded object', (done) => { it('should convert the reloaded object', (done) => {
@@ -214,7 +214,7 @@ describe('MyDSpaceReloadableActionsComponent', () => {
component.startActionExecution().subscribe( (result) => { component.startActionExecution().subscribe( (result) => {
expect(component.convertReloadedObject).toHaveBeenCalled(); expect(component.convertReloadedObject).toHaveBeenCalled();
done(); done();
}) });
}); });
it('should emit the reloaded object in case of success', (done) => { it('should emit the reloaded object in case of success', (done) => {
@@ -222,7 +222,7 @@ describe('MyDSpaceReloadableActionsComponent', () => {
component.startActionExecution().subscribe( (result) => { component.startActionExecution().subscribe( (result) => {
expect(component.processCompleted.emit).toHaveBeenCalledWith({result: true, reloadedObject: result as any}); expect(component.processCompleted.emit).toHaveBeenCalledWith({result: true, reloadedObject: result as any});
done(); done();
}) });
}); });
}); });
@@ -252,7 +252,7 @@ describe('MyDSpaceReloadableActionsComponent', () => {
component.startActionExecution().subscribe( (result) => { component.startActionExecution().subscribe( (result) => {
expect(component.reload).toHaveBeenCalled(); expect(component.reload).toHaveBeenCalled();
done(); done();
}) });
}); });
}); });

View File

@@ -1,5 +1,5 @@
import { ChangeDetectionStrategy, Injector, NO_ERRORS_SCHEMA } from '@angular/core'; import { ChangeDetectionStrategy, Injector, NO_ERRORS_SCHEMA } from '@angular/core';
import { waitForAsync, ComponentFixture, fakeAsync, TestBed } from '@angular/core/testing'; import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { By } from '@angular/platform-browser'; import { By } from '@angular/platform-browser';
@@ -75,7 +75,7 @@ mockObject = Object.assign(new PoolTask(), { workflowitem: observableOf(rdWorkfl
describe('PoolTaskActionsComponent', () => { describe('PoolTaskActionsComponent', () => {
beforeEach(waitForAsync(() => { beforeEach(waitForAsync(() => {
mockDataService = new PoolTaskDataService(null, null, null, null, null, null, null, null) mockDataService = new PoolTaskDataService(null, null, null, null, null, null, null, null);
mockClaimedTaskDataService = new ClaimedTaskDataService(null, null, null, null, null, null, null, null); mockClaimedTaskDataService = new ClaimedTaskDataService(null, null, null, null, null, null, null, null);
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [ imports: [
@@ -160,7 +160,7 @@ describe('PoolTaskActionsComponent', () => {
expect(notificationsServiceStub.success).toHaveBeenCalled(); expect(notificationsServiceStub.success).toHaveBeenCalled();
done(); done();
}) });
})); }));

View File

@@ -92,7 +92,7 @@ export class PoolTaskActionsComponent extends MyDSpaceReloadableActionsComponent
return this.objectDataService.getPoolTaskEndpointById(this.object.id) return this.objectDataService.getPoolTaskEndpointById(this.object.id)
.pipe(switchMap((poolTaskHref) => { .pipe(switchMap((poolTaskHref) => {
return this.claimedTaskService.claimTask(this.object.id, poolTaskHref); return this.claimedTaskService.claimTask(this.object.id, poolTaskHref);
})) }));
} }
reloadObjectExecution(): Observable<RemoteData<DSpaceObject> | DSpaceObject> { reloadObjectExecution(): Observable<RemoteData<DSpaceObject> | DSpaceObject> {
@@ -111,12 +111,12 @@ export class PoolTaskActionsComponent extends MyDSpaceReloadableActionsComponent
)) ))
.subscribe((item: Item) => { .subscribe((item: Item) => {
this.itemUuid = item.uuid; this.itemUuid = item.uuid;
}) });
} }
ngOnDestroy() { ngOnDestroy() {
this.subs.forEach((sub) => sub.unsubscribe()); this.subs.forEach((sub) => sub.unsubscribe());
console.log('Destroy of PoolTaskActionsComponent', this.object) console.log('Destroy of PoolTaskActionsComponent', this.object);
} }
} }

View File

@@ -162,7 +162,9 @@ export class ListableObjectComponentLoaderComponent implements OnInit, OnDestroy
* Fetch the component depending on the item's relationship type, view mode and context * Fetch the component depending on the item's relationship type, view mode and context
* @returns {GenericConstructor<Component>} * @returns {GenericConstructor<Component>}
*/ */
getComponent(object, viewMode: ViewMode, context: Context): GenericConstructor<Component> { getComponent(renderTypes: (string | GenericConstructor<ListableObject>)[],
return getListableObjectComponent(object.getRenderTypes(), viewMode, context); viewMode: ViewMode,
context: Context): GenericConstructor<Component> {
return getListableObjectComponent(renderTypes, viewMode, context);
} }
} }

View File

@@ -105,7 +105,7 @@ describe('PoolSearchResultDetailElementComponent', () => {
spyOn(component.reloadedObject, 'emit').and.callThrough(); spyOn(component.reloadedObject, 'emit').and.callThrough();
const actionPayload: any = { reloadedObject: {}}; const actionPayload: any = { reloadedObject: {}};
const actionsComponents = fixture.debugElement.query(By.css('ds-pool-task-actions')); const actionsComponents = fixture.debugElement.query(By.css('ds-pool-task-actions'));
actionsComponents.triggerEventHandler('processCompleted', actionPayload) actionsComponents.triggerEventHandler('processCompleted', actionPayload);
tick(); tick();
expect(component.reloadedObject.emit).toHaveBeenCalledWith(actionPayload.reloadedObject); expect(component.reloadedObject.emit).toHaveBeenCalledWith(actionPayload.reloadedObject);

View File

@@ -1,5 +1,5 @@
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
import { async, ComponentFixture, fakeAsync, TestBed, tick, waitForAsync } from '@angular/core/testing'; import { ComponentFixture, fakeAsync, TestBed, tick, waitForAsync } from '@angular/core/testing';
import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { of as observableOf } from 'rxjs'; import { of as observableOf } from 'rxjs';
@@ -104,7 +104,7 @@ describe('ClaimedSearchResultListElementComponent', () => {
const actionPayload: any = { reloadedObject: {}}; const actionPayload: any = { reloadedObject: {}};
const actionsComponent = fixture.debugElement.query(By.css('ds-claimed-task-actions')); const actionsComponent = fixture.debugElement.query(By.css('ds-claimed-task-actions'));
actionsComponent.triggerEventHandler('processCompleted', actionPayload) actionsComponent.triggerEventHandler('processCompleted', actionPayload);
tick(); tick();
expect(component.reloadedObject.emit).toHaveBeenCalledWith(actionPayload.reloadedObject); expect(component.reloadedObject.emit).toHaveBeenCalledWith(actionPayload.reloadedObject);

View File

@@ -80,7 +80,7 @@ describe('ItemMyDSpaceResultListElementComponent', () => {
const actionPayload: any = { reloadedObject: {}}; const actionPayload: any = { reloadedObject: {}};
const actionsComponent = fixture.debugElement.query(By.css('ds-item-actions')); const actionsComponent = fixture.debugElement.query(By.css('ds-item-actions'));
actionsComponent.triggerEventHandler('processCompleted', actionPayload) actionsComponent.triggerEventHandler('processCompleted', actionPayload);
tick(); tick();
expect(component.reloadedObject.emit).toHaveBeenCalledWith(actionPayload.reloadedObject); expect(component.reloadedObject.emit).toHaveBeenCalledWith(actionPayload.reloadedObject);

View File

@@ -1,4 +1,4 @@
import { ChangeDetectionStrategy, Injector, NO_ERRORS_SCHEMA } from '@angular/core'; import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
import { waitForAsync, ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing'; import { waitForAsync, ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing';
import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import { NoopAnimationsModule } from '@angular/platform-browser/animations';
@@ -103,7 +103,7 @@ describe('PoolSearchResultListElementComponent', () => {
spyOn(component.reloadedObject, 'emit').and.callThrough(); spyOn(component.reloadedObject, 'emit').and.callThrough();
const actionPayload: any = { reloadedObject: {}}; const actionPayload: any = { reloadedObject: {}};
const actionsComponents = fixture.debugElement.query(By.css('ds-pool-task-actions')); const actionsComponents = fixture.debugElement.query(By.css('ds-pool-task-actions'));
actionsComponents.triggerEventHandler('processCompleted', actionPayload) actionsComponents.triggerEventHandler('processCompleted', actionPayload);
tick(); tick();
expect(component.reloadedObject.emit).toHaveBeenCalledWith(actionPayload.reloadedObject); expect(component.reloadedObject.emit).toHaveBeenCalledWith(actionPayload.reloadedObject);

View File

@@ -101,7 +101,7 @@ describe('WorkflowItemSearchResultListElementComponent', () => {
const actionPayload: any = { reloadedObject: {}}; const actionPayload: any = { reloadedObject: {}};
const actionsComponent = fixture.debugElement.query(By.css('ds-workflowitem-actions')); const actionsComponent = fixture.debugElement.query(By.css('ds-workflowitem-actions'));
actionsComponent.triggerEventHandler('processCompleted', actionPayload) actionsComponent.triggerEventHandler('processCompleted', actionPayload);
tick(); tick();
expect(component.reloadedObject.emit).toHaveBeenCalledWith(actionPayload.reloadedObject); expect(component.reloadedObject.emit).toHaveBeenCalledWith(actionPayload.reloadedObject);

View File

@@ -101,7 +101,7 @@ describe('WorkspaceItemSearchResultListElementComponent', () => {
const actionPayload: any = { reloadedObject: {}}; const actionPayload: any = { reloadedObject: {}};
const actionsComponent = fixture.debugElement.query(By.css('ds-workspaceitem-actions')); const actionsComponent = fixture.debugElement.query(By.css('ds-workspaceitem-actions'));
actionsComponent.triggerEventHandler('processCompleted', actionPayload) actionsComponent.triggerEventHandler('processCompleted', actionPayload);
tick(); tick();
expect(component.reloadedObject.emit).toHaveBeenCalledWith(actionPayload.reloadedObject); expect(component.reloadedObject.emit).toHaveBeenCalledWith(actionPayload.reloadedObject);