]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
Disable suggestions for read-only docs 2813/head
authorshamoon <4887959+shamoon@users.noreply.github.com>
Fri, 3 Mar 2023 23:21:02 +0000 (15:21 -0800)
committershamoon <4887959+shamoon@users.noreply.github.com>
Fri, 3 Mar 2023 23:21:02 +0000 (15:21 -0800)
src-ui/src/app/components/document-detail/document-detail.component.ts

index 33a0d41142364ca1dd0b00ef3893c47657d85825..8103cc374b91f7f054b33aae0d3bfde5bd665bd5 100644 (file)
@@ -306,20 +306,27 @@ export class DocumentDetailComponent
           )
         },
       })
-    this.documentsService
-      .getSuggestions(doc.id)
-      .pipe(first())
-      .subscribe({
-        next: (result) => {
-          this.suggestions = result
-        },
-        error: (error) => {
-          this.suggestions = null
-          this.toastService.showError(
-            $localize`Error retrieving suggestions` + ': ' + error.toString()
-          )
-        },
-      })
+    if (
+      this.permissionsService.currentUserHasObjectPermissions(
+        PermissionAction.Change,
+        doc
+      )
+    ) {
+      this.documentsService
+        .getSuggestions(doc.id)
+        .pipe(first())
+        .subscribe({
+          next: (result) => {
+            this.suggestions = result
+          },
+          error: (error) => {
+            this.suggestions = null
+            this.toastService.showError(
+              $localize`Error retrieving suggestions` + ': ' + error.toString()
+            )
+          },
+        })
+    }
     this.title = this.documentTitlePipe.transform(doc.title)
     const docFormValues = Object.assign({}, doc)
     docFormValues['permissions_form'] = {