Skip to content

A community-supported supercharged document management system: scan, index and archive all your documents

Hide delete button on detail page if no perms, fix error display & allow retry confirm button (#3020)

shamoonf2fb06e6f320
diff --git a/src-ui/src/app/components/document-detail/document-detail.component.html b/src-ui/src/app/components/document-detail/document-detail.component.html
index c88dc7e98..cad0f715a 100644
--- a/src-ui/src/app/components/document-detail/document-detail.component.html
+++ b/src-ui/src/app/components/document-detail/document-detail.component.html
@@ -5,7 +5,7 @@
<div class="input-group-text" i18n>of {{previewNumPages}}</div>
</div>
- <button type="button" class="btn btn-sm btn-outline-danger me-2 ms-auto" (click)="delete()" [disabled]="!userIsOwner">
+ <button type="button" class="btn btn-sm btn-outline-danger me-2 ms-auto" (click)="delete()" [disabled]="!userIsOwner" *appIfPermissions="{ action: PermissionAction.Delete, type: PermissionType.Document }">
<svg class="buttonicon" fill="currentColor">
<use xlink:href="assets/bootstrap-icons.svg#trash" />
</svg><span class="d-none d-lg-inline ps-1" i18n>Delete</span>
diff --git a/src-ui/src/app/components/document-detail/document-detail.component.ts b/src-ui/src/app/components/document-detail/document-detail.component.ts
index 31e600b7d..d9e813c6a 100644
--- a/src-ui/src/app/components/document-detail/document-detail.component.ts
+++ b/src-ui/src/app/components/document-detail/document-detail.component.ts
@@ -496,7 +496,7 @@ export class DocumentDetailComponent
this.toastService.showError(
$localize`Error saving document` +
': ' +
- (error.message ?? error.toString())
+ (error.error?.detail ?? error.message ?? JSON.stringify(error))
)
}
},
@@ -541,7 +541,7 @@ export class DocumentDetailComponent
this.toastService.showError(
$localize`Error saving document` +
': ' +
- (error.message ?? error.toString())
+ (error.error?.detail ?? error.message ?? JSON.stringify(error))
)
},
})
@@ -573,6 +573,10 @@ export class DocumentDetailComponent
modal.componentInstance.message = $localize`The files for this document will be deleted permanently. This operation cannot be undone.`
modal.componentInstance.btnClass = 'btn-danger'
modal.componentInstance.btnCaption = $localize`Delete document`
+ this.subscribeModalDelete(modal) // so can be re-subscribed if error
+ }
+
+ subscribeModalDelete(modal) {
modal.componentInstance.confirmClicked
.pipe(
switchMap(() => {
@@ -581,18 +585,21 @@ export class DocumentDetailComponent
})
)
.pipe(takeUntil(this.unsubscribeNotifier))
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
modal.close()
this.close()
},
- (error) => {
+ error: (error) => {
this.toastService.showError(
- $localize`Error deleting document: ${JSON.stringify(error)}`
+ $localize`Error deleting document: ${
+ error.error?.detail ?? error.message ?? JSON.stringify(error)
+ }`
)
modal.componentInstance.buttonsEnabled = true
- }
- )
+ this.subscribeModalDelete(modal)
+ },
+ })
}
moreLike() {