]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
Fix: global search filtering links broken in 2.8.4 (#6726)
authorshamoon <4887959+shamoon@users.noreply.github.com>
Wed, 15 May 2024 04:37:55 +0000 (21:37 -0700)
committerGitHub <noreply@github.com>
Wed, 15 May 2024 04:37:55 +0000 (21:37 -0700)
src-ui/src/app/components/app-frame/global-search/global-search.component.spec.ts
src-ui/src/app/components/app-frame/global-search/global-search.component.ts

index 54ea735b65da06ecf35e10c24f66be31dea2cc71..20e39ee57c2b1203619f619f19e36986ead94552 100644 (file)
@@ -287,48 +287,44 @@ describe('GlobalSearchComponent', () => {
     modalService.activeInstances.subscribe((m) => (modal = m[m.length - 1]))
 
     component.primaryAction(DataType.Document, object)
-    expect(routerSpy).toHaveBeenCalledWith(['/documents', object.id])
+    expect(routerSpy).toHaveBeenCalledWith(['/documents', object.id], {})
 
     component.primaryAction(DataType.SavedView, object)
-    expect(routerSpy).toHaveBeenCalledWith(['/view', object.id])
+    expect(routerSpy).toHaveBeenCalledWith(['/view', object.id], {})
 
     component.primaryAction(DataType.Correspondent, object)
-    expect(routerSpy).toHaveBeenCalledWith([
-      '/documents',
-      queryParamsFromFilterRules([
+    expect(routerSpy).toHaveBeenCalledWith(['/documents'], {
+      queryParams: queryParamsFromFilterRules([
         {
           rule_type: FILTER_HAS_CORRESPONDENT_ANY,
           value: object.id.toString(),
         },
       ]),
-    ])
+    })
 
     component.primaryAction(DataType.DocumentType, object)
-    expect(routerSpy).toHaveBeenCalledWith([
-      '/documents',
-      queryParamsFromFilterRules([
+    expect(routerSpy).toHaveBeenCalledWith(['/documents'], {
+      queryParams: queryParamsFromFilterRules([
         {
           rule_type: FILTER_HAS_DOCUMENT_TYPE_ANY,
           value: object.id.toString(),
         },
       ]),
-    ])
+    })
 
     component.primaryAction(DataType.StoragePath, object)
-    expect(routerSpy).toHaveBeenCalledWith([
-      '/documents',
-      queryParamsFromFilterRules([
+    expect(routerSpy).toHaveBeenCalledWith(['/documents'], {
+      queryParams: queryParamsFromFilterRules([
         { rule_type: FILTER_HAS_STORAGE_PATH_ANY, value: object.id.toString() },
       ]),
-    ])
+    })
 
     component.primaryAction(DataType.Tag, object)
-    expect(routerSpy).toHaveBeenCalledWith([
-      '/documents',
-      queryParamsFromFilterRules([
+    expect(routerSpy).toHaveBeenCalledWith(['/documents'], {
+      queryParams: queryParamsFromFilterRules([
         { rule_type: FILTER_HAS_TAGS_ANY, value: object.id.toString() },
       ]),
-    ])
+    })
 
     component.primaryAction(DataType.User, object)
     expect(modalSpy).toHaveBeenCalledWith(UserEditDialogComponent, {
index 2b1a078c454b634cdd29f59e3027a71b69dd56d6..837a8f39d708dc86762fb875a407a59782f841bc 100644 (file)
@@ -163,7 +163,9 @@ export class GlobalSearchComponent implements OnInit {
       let params = queryParamsFromFilterRules([
         { rule_type: filterRuleType, value: object.id.toString() },
       ])
-      this.navigateOrOpenInNewWindow(['/documents', params], newWindow)
+      this.navigateOrOpenInNewWindow(['/documents'], newWindow, {
+        queryParams: params,
+      })
     } else if (editDialogComponent) {
       const modalRef: NgbModalRef = this.modalService.open(
         editDialogComponent,
@@ -378,12 +380,18 @@ export class GlobalSearchComponent implements OnInit {
     this.reset(true)
   }
 
-  private navigateOrOpenInNewWindow(commands: any, newWindow: boolean = false) {
+  private navigateOrOpenInNewWindow(
+    commands: any,
+    newWindow: boolean = false,
+    extras: Object = {}
+  ) {
     if (newWindow) {
-      const url = this.router.serializeUrl(this.router.createUrlTree(commands))
+      const url = this.router.serializeUrl(
+        this.router.createUrlTree(commands, extras)
+      )
       window.open(url, '_blank')
     } else {
-      this.router.navigate(commands)
+      this.router.navigate(commands, extras)
     }
   }
 }