From 283bcb4c91178efc8c78d1370160c1aecc7295b3 Mon Sep 17 00:00:00 2001
From: shamoon <4887959+shamoon@users.noreply.github.com>
Date: Thu, 16 Jan 2025 00:59:27 -0800
Subject: [PATCH] Fix: handle page out of range in mgmt lists after delete
(#8771)
---
src-ui/messages.xlf | 36 +++++++++----------
.../management-list.component.spec.ts | 21 ++++++++++-
.../management-list.component.ts | 15 ++++++--
3 files changed, 50 insertions(+), 22 deletions(-)
diff --git a/src-ui/messages.xlf b/src-ui/messages.xlf
index ac79752b5..0b5d6b7da 100644
--- a/src-ui/messages.xlf
+++ b/src-ui/messages.xlf
@@ -2130,7 +2130,7 @@
src/app/components/manage/management-list/management-list.component.ts
- 216
+ 225
src/app/components/manage/saved-views/saved-views.component.html
@@ -2164,11 +2164,11 @@
src/app/components/manage/management-list/management-list.component.ts
- 212
+ 221
src/app/components/manage/management-list/management-list.component.ts
- 329
+ 338
@@ -2210,7 +2210,7 @@
src/app/components/manage/management-list/management-list.component.ts
- 331
+ 340
src/app/components/manage/workflows/workflows.component.ts
@@ -2549,7 +2549,7 @@
src/app/components/manage/management-list/management-list.component.ts
- 333
+ 342
src/app/components/manage/workflows/workflows.component.ts
@@ -8289,7 +8289,7 @@
src/app/components/manage/management-list/management-list.component.ts
- 316
+ 325
@@ -8372,7 +8372,7 @@
Automatic
src/app/components/manage/management-list/management-list.component.ts
- 116
+ 117
src/app/data/matching-model.ts
@@ -8383,7 +8383,7 @@
None
src/app/components/manage/management-list/management-list.component.ts
- 118
+ 119
src/app/data/matching-model.ts
@@ -8394,70 +8394,70 @@
Successfully created .
src/app/components/manage/management-list/management-list.component.ts
- 169
+ 178
Error occurred while creating .
src/app/components/manage/management-list/management-list.component.ts
- 174
+ 183
Successfully updated .
src/app/components/manage/management-list/management-list.component.ts
- 189
+ 198
Error occurred while saving .
src/app/components/manage/management-list/management-list.component.ts
- 194
+ 203
Associated documents will not be deleted.
src/app/components/manage/management-list/management-list.component.ts
- 214
+ 223
Error while deleting element
src/app/components/manage/management-list/management-list.component.ts
- 230
+ 239
Permissions updated successfully
src/app/components/manage/management-list/management-list.component.ts
- 309
+ 318
This operation will permanently delete all objects.
src/app/components/manage/management-list/management-list.component.ts
- 330
+ 339
Objects deleted successfully
src/app/components/manage/management-list/management-list.component.ts
- 344
+ 353
Error deleting objects
src/app/components/manage/management-list/management-list.component.ts
- 350
+ 359
diff --git a/src-ui/src/app/components/manage/management-list/management-list.component.spec.ts b/src-ui/src/app/components/manage/management-list/management-list.component.spec.ts
index b058446cd..291a71fa3 100644
--- a/src-ui/src/app/components/manage/management-list/management-list.component.spec.ts
+++ b/src-ui/src/app/components/manage/management-list/management-list.component.spec.ts
@@ -1,5 +1,9 @@
import { DatePipe } from '@angular/common'
-import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http'
+import {
+ HttpErrorResponse,
+ provideHttpClient,
+ withInterceptorsFromDi,
+} from '@angular/common/http'
import { provideHttpClientTesting } from '@angular/common/http/testing'
import {
ComponentFixture,
@@ -243,6 +247,21 @@ describe('ManagementListComponent', () => {
expect(reloadSpy).toHaveBeenCalled()
})
+ it('should fall back to first page if error is page is out of range', () => {
+ jest.spyOn(tagService, 'listFiltered').mockReturnValueOnce(
+ throwError(
+ () =>
+ new HttpErrorResponse({
+ status: 404,
+ error: { detail: 'Invalid page' },
+ })
+ )
+ )
+ component.page = 2
+ component.reloadData()
+ expect(component.page).toEqual(1)
+ })
+
it('should support toggle all items in view', () => {
expect(component.selectedObjects.size).toEqual(0)
const toggleAllSpy = jest.spyOn(component, 'toggleAll')
diff --git a/src-ui/src/app/components/manage/management-list/management-list.component.ts b/src-ui/src/app/components/manage/management-list/management-list.component.ts
index 4c2189e88..ecb3e2519 100644
--- a/src-ui/src/app/components/manage/management-list/management-list.component.ts
+++ b/src-ui/src/app/components/manage/management-list/management-list.component.ts
@@ -1,3 +1,4 @@
+import { HttpErrorResponse } from '@angular/common/http'
import {
Directive,
OnDestroy,
@@ -152,9 +153,17 @@ export abstract class ManagementListComponent
}),
delay(100)
)
- .subscribe(() => {
- this.show = true
- this.loading = false
+ .subscribe({
+ error: (error: HttpErrorResponse) => {
+ if (error.error?.detail?.includes('Invalid page')) {
+ this.page = 1
+ this.reloadData()
+ }
+ },
+ next: () => {
+ this.show = true
+ this.loading = false
+ },
})
}