mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 18:14:17 +00:00
99053: Invalidate cache by default when performing the WorkflowItemActionPageComponent action
This commit is contained in:
12
src/app/shared/testing/request-service.stub.ts
Normal file
12
src/app/shared/testing/request-service.stub.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { Observable, of as observableOf } from 'rxjs';
|
||||
|
||||
/**
|
||||
* Stub service for {@link RequestService}.
|
||||
*/
|
||||
export class RequestServiceStub {
|
||||
|
||||
removeByHrefSubstring(_href: string): Observable<boolean> {
|
||||
return observableOf(true);
|
||||
}
|
||||
|
||||
}
|
@@ -26,6 +26,8 @@ import { Item } from '../../../core/shared/item.model';
|
||||
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { ProcessTaskResponse } from '../../../core/tasks/models/process-task-response';
|
||||
import { RatingAdvancedWorkflowInfo } from '../../../core/tasks/models/rating-advanced-workflow-info.model';
|
||||
import { RequestService } from '../../../core/data/request.service';
|
||||
import { RequestServiceStub } from '../../../shared/testing/request-service.stub';
|
||||
|
||||
const claimedTaskId = '2';
|
||||
const workflowId = '1';
|
||||
@@ -80,6 +82,7 @@ describe('AdvancedWorkflowActionRatingComponent', () => {
|
||||
{ provide: Router, useValue: new RouterStub() },
|
||||
{ provide: WorkflowActionDataService, useValue: workflowActionDataService },
|
||||
{ provide: WorkflowItemDataService, useValue: workflowItemDataService },
|
||||
{ provide: RequestService, useClass: RequestServiceStub },
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA],
|
||||
}).compileComponents();
|
||||
|
@@ -23,6 +23,8 @@ import { Item } from '../../../core/shared/item.model';
|
||||
import { EPersonMock, EPersonMock2 } from '../../../shared/testing/eperson.mock';
|
||||
import { ProcessTaskResponse } from '../../../core/tasks/models/process-task-response';
|
||||
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { RequestService } from '../../../core/data/request.service';
|
||||
import { RequestServiceStub } from '../../../shared/testing/request-service.stub';
|
||||
|
||||
const claimedTaskId = '2';
|
||||
const workflowId = '1';
|
||||
@@ -73,6 +75,7 @@ describe('AdvancedWorkflowActionSelectReviewerComponent', () => {
|
||||
{ provide: RouteService, useValue: routeServiceStub },
|
||||
{ provide: WorkflowActionDataService, useValue: workflowActionDataService },
|
||||
{ provide: WorkflowItemDataService, useValue: workflowItemDataService },
|
||||
{ provide: RequestService, useClass: RequestServiceStub },
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA],
|
||||
}).compileComponents();
|
||||
|
@@ -20,6 +20,7 @@ import { TranslateService } from '@ngx-translate/core';
|
||||
import { WorkflowActionDataService } from '../../../core/data/workflow-action-data.service';
|
||||
import { ClaimedTaskDataService } from '../../../core/tasks/claimed-task-data.service';
|
||||
import { ReviewersListComponent } from './reviewers-list/reviewers-list.component';
|
||||
import { RequestService } from 'src/app/core/data/request.service';
|
||||
|
||||
export const ADVANCED_WORKFLOW_TASK_OPTION_SELECT_REVIEWER = 'submit_select_reviewer';
|
||||
export const ADVANCED_WORKFLOW_ACTION_SELECT_REVIEWER = 'selectrevieweraction';
|
||||
@@ -60,8 +61,9 @@ export class AdvancedWorkflowActionSelectReviewerComponent extends AdvancedWorkf
|
||||
protected translationService: TranslateService,
|
||||
protected workflowActionService: WorkflowActionDataService,
|
||||
protected claimedTaskDataService: ClaimedTaskDataService,
|
||||
protected requestService: RequestService,
|
||||
) {
|
||||
super(route, workflowItemService, router, routeService, notificationsService, translationService, workflowActionService, claimedTaskDataService);
|
||||
super(route, workflowItemService, router, routeService, notificationsService, translationService, workflowActionService, claimedTaskDataService, requestService);
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
|
@@ -18,6 +18,8 @@ import { TranslateModule } from '@ngx-translate/core';
|
||||
import { WorkflowActionDataServiceStub } from '../../../shared/testing/workflow-action-data-service.stub';
|
||||
import { ProcessTaskResponse } from '../../../core/tasks/models/process-task-response';
|
||||
import { WorkflowItemDataServiceStub } from '../../../shared/testing/workflow-item-data-service.stub';
|
||||
import { RequestService } from '../../../core/data/request.service';
|
||||
import { RequestServiceStub } from '../../../shared/testing/request-service.stub';
|
||||
|
||||
const workflowId = '1';
|
||||
|
||||
@@ -65,6 +67,7 @@ describe('AdvancedWorkflowActionComponent', () => {
|
||||
{ provide: RouteService, useValue: routeServiceStub },
|
||||
{ provide: WorkflowActionDataService, useValue: workflowActionDataService },
|
||||
{ provide: WorkflowItemDataService, useValue: workflowItemDataService },
|
||||
{ provide: RequestService, useClass: RequestServiceStub },
|
||||
],
|
||||
}).compileComponents();
|
||||
});
|
||||
|
@@ -12,6 +12,7 @@ import { getFirstSucceededRemoteDataPayload } from '../../../core/shared/operato
|
||||
import { ClaimedTaskDataService } from '../../../core/tasks/claimed-task-data.service';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { ProcessTaskResponse } from '../../../core/tasks/models/process-task-response';
|
||||
import { RequestService } from '../../../core/data/request.service';
|
||||
|
||||
/**
|
||||
* Abstract component for rendering an advanced claimed task's workflow page
|
||||
@@ -36,8 +37,9 @@ export abstract class AdvancedWorkflowActionComponent extends WorkflowItemAction
|
||||
protected translationService: TranslateService,
|
||||
protected workflowActionService: WorkflowActionDataService,
|
||||
protected claimedTaskDataService: ClaimedTaskDataService,
|
||||
protected requestService: RequestService,
|
||||
) {
|
||||
super(route, workflowItemService, router, routeService, notificationsService, translationService);
|
||||
super(route, workflowItemService, router, routeService, notificationsService, translationService, requestService);
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
|
@@ -16,6 +16,8 @@ import { TranslateLoaderMock } from '../shared/mocks/translate-loader.mock';
|
||||
import { ActivatedRouteStub } from '../shared/testing/active-router.stub';
|
||||
import { RouterStub } from '../shared/testing/router.stub';
|
||||
import { NotificationsServiceStub } from '../shared/testing/notifications-service.stub';
|
||||
import { RequestService } from '../core/data/request.service';
|
||||
import { RequestServiceStub } from '../shared/testing/request-service.stub';
|
||||
|
||||
const type = 'testType';
|
||||
describe('WorkflowItemActionPageComponent', () => {
|
||||
@@ -52,6 +54,7 @@ describe('WorkflowItemActionPageComponent', () => {
|
||||
{ provide: RouteService, useValue: {} },
|
||||
{ provide: NotificationsService, useClass: NotificationsServiceStub },
|
||||
{ provide: WorkflowItemDataService, useValue: wfiService },
|
||||
{ provide: RequestService, useClass: RequestServiceStub },
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
})
|
||||
@@ -110,8 +113,10 @@ class TestComponent extends WorkflowItemActionPageComponent {
|
||||
protected router: Router,
|
||||
protected routeService: RouteService,
|
||||
protected notificationsService: NotificationsService,
|
||||
protected translationService: TranslateService) {
|
||||
super(route, workflowItemService, router, routeService, notificationsService, translationService);
|
||||
protected translationService: TranslateService,
|
||||
protected requestService: RequestService,
|
||||
) {
|
||||
super(route, workflowItemService, router, routeService, notificationsService, translationService, requestService);
|
||||
}
|
||||
|
||||
getType(): string {
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { Observable, forkJoin } from 'rxjs';
|
||||
import { map, switchMap, take } from 'rxjs/operators';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { WorkflowItem } from '../core/submission/models/workflowitem.model';
|
||||
@@ -11,6 +11,7 @@ import { NotificationsService } from '../shared/notifications/notifications.serv
|
||||
import { RemoteData } from '../core/data/remote-data';
|
||||
import { getAllSucceededRemoteData, getRemoteDataPayload } from '../core/shared/operators';
|
||||
import { isEmpty } from '../shared/empty.util';
|
||||
import { RequestService } from '../core/data/request.service';
|
||||
|
||||
/**
|
||||
* Abstract component representing a page to perform an action on a workflow item
|
||||
@@ -29,7 +30,9 @@ export abstract class WorkflowItemActionPageComponent implements OnInit {
|
||||
protected router: Router,
|
||||
protected routeService: RouteService,
|
||||
protected notificationsService: NotificationsService,
|
||||
protected translationService: TranslateService) {
|
||||
protected translationService: TranslateService,
|
||||
protected requestService: RequestService,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -45,9 +48,9 @@ export abstract class WorkflowItemActionPageComponent implements OnInit {
|
||||
* Performs the action and shows a notification based on the outcome of the action
|
||||
*/
|
||||
performAction() {
|
||||
this.wfi$.pipe(
|
||||
forkJoin([this.wfi$, this.requestService.removeByHrefSubstring('/discover')]).pipe(
|
||||
take(1),
|
||||
switchMap((wfi: WorkflowItem) => this.sendRequest(wfi.id))
|
||||
switchMap(([wfi]) => this.sendRequest(wfi.id))
|
||||
).subscribe((successful: boolean) => {
|
||||
if (successful) {
|
||||
const title = this.translationService.get('workflow-item.' + this.type + '.notification.success.title');
|
||||
|
@@ -27,7 +27,7 @@ export class WorkflowItemDeleteComponent extends WorkflowItemActionPageComponent
|
||||
protected notificationsService: NotificationsService,
|
||||
protected translationService: TranslateService,
|
||||
protected requestService: RequestService) {
|
||||
super(route, workflowItemService, router, routeService, notificationsService, translationService);
|
||||
super(route, workflowItemService, router, routeService, notificationsService, translationService, requestService);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -42,7 +42,6 @@ export class WorkflowItemDeleteComponent extends WorkflowItemActionPageComponent
|
||||
* @param id The id of the WorkflowItem
|
||||
*/
|
||||
sendRequest(id: string): Observable<boolean> {
|
||||
this.requestService.removeByHrefSubstring('/discover');
|
||||
return this.workflowItemService.delete(id).pipe(
|
||||
getFirstCompletedRemoteData(),
|
||||
map((response: RemoteData<NoContent>) => response.hasSucceeded)
|
||||
|
@@ -23,7 +23,7 @@ export class WorkflowItemSendBackComponent extends WorkflowItemActionPageCompone
|
||||
protected notificationsService: NotificationsService,
|
||||
protected translationService: TranslateService,
|
||||
protected requestService: RequestService) {
|
||||
super(route, workflowItemService, router, routeService, notificationsService, translationService);
|
||||
super(route, workflowItemService, router, routeService, notificationsService, translationService, requestService);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -38,7 +38,6 @@ export class WorkflowItemSendBackComponent extends WorkflowItemActionPageCompone
|
||||
* @param id The id of the WorkflowItem
|
||||
*/
|
||||
sendRequest(id: string): Observable<boolean> {
|
||||
this.requestService.removeByHrefSubstring('/discover');
|
||||
return this.workflowItemService.sendBack(id);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user