108915: Fixed issue that redirected you to 404 page when deleting the process on the process page

This commit is contained in:
Alexandre Vryghem
2024-02-08 16:14:38 +01:00
parent c91b99fece
commit 252b3673ee

View File

@@ -2,7 +2,7 @@ import { HttpClient } from '@angular/common/http';
import { Component, Inject, NgZone, OnInit, PLATFORM_ID } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { BehaviorSubject, Observable } from 'rxjs';
import { finalize, map, switchMap, take, tap, find, startWith } from 'rxjs/operators';
import { finalize, map, switchMap, take, tap, find, startWith, filter } from 'rxjs/operators';
import { AuthService } from '../../core/auth/auth.service';
import { DSONameService } from '../../core/breadcrumbs/dso-name.service';
import { BitstreamDataService } from '../../core/data/bitstream-data.service';
@@ -80,6 +80,8 @@ export class ProcessDetailComponent implements OnInit {
isRefreshing$: Observable<boolean>;
isDeleting: boolean;
/**
* Reference to NgbModal
*/
@@ -113,6 +115,7 @@ export class ProcessDetailComponent implements OnInit {
return [data.process as RemoteData<Process>];
}
}),
filter(() => !this.isDeleting),
redirectOn4xx(this.router, this.authService),
);
@@ -203,15 +206,17 @@ export class ProcessDetailComponent implements OnInit {
* @param process
*/
deleteProcess(process: Process) {
this.isDeleting = true;
this.processService.delete(process.processId).pipe(
getFirstCompletedRemoteData()
).subscribe((rd) => {
if (rd.hasSucceeded) {
this.notificationsService.success(this.translateService.get('process.detail.delete.success'));
this.closeModal();
this.router.navigateByUrl(getProcessListRoute());
void this.router.navigateByUrl(getProcessListRoute());
} else {
this.notificationsService.error(this.translateService.get('process.detail.delete.error'));
this.isDeleting = false;
}
});
}