diff --git a/src-ui/messages.xlf b/src-ui/messages.xlf index b75991ed1..8bd52760e 100644 --- a/src-ui/messages.xlf +++ b/src-ui/messages.xlf @@ -253,6 +253,10 @@ src/app/app.component.ts 87 + + src/app/components/admin/trash/trash.component.ts + 118 + src/app/components/dashboard/widgets/saved-view-widget/saved-view-widget.component.html 37 @@ -1480,11 +1484,11 @@ src/app/components/admin/trash/trash.component.ts - 57 + 59 src/app/components/admin/trash/trash.component.ts - 86 + 88 src/app/components/admin/users-groups/users-groups.component.html @@ -2216,11 +2220,11 @@ Confirm delete src/app/components/admin/trash/trash.component.ts - 53 + 55 src/app/components/admin/trash/trash.component.ts - 80 + 82 src/app/components/manage/management-list/management-list.component.ts @@ -2235,18 +2239,18 @@ This operation will permanently delete this document. src/app/components/admin/trash/trash.component.ts - 54 + 56 This operation cannot be undone. src/app/components/admin/trash/trash.component.ts - 55 + 57 src/app/components/admin/trash/trash.component.ts - 84 + 86 src/app/components/admin/users-groups/users-groups.component.ts @@ -2281,14 +2285,14 @@ Document deleted src/app/components/admin/trash/trash.component.ts - 64 + 66 Error deleting document src/app/components/admin/trash/trash.component.ts - 69 + 71 src/app/components/document-detail/document-detail.component.ts @@ -2299,56 +2303,56 @@ This operation will permanently delete the selected documents. src/app/components/admin/trash/trash.component.ts - 82 + 84 This operation will permanently delete all documents in the trash. src/app/components/admin/trash/trash.component.ts - 83 + 85 Document(s) deleted src/app/components/admin/trash/trash.component.ts - 94 + 96 Error deleting document(s) src/app/components/admin/trash/trash.component.ts - 101 + 103 Document restored src/app/components/admin/trash/trash.component.ts - 113 + 116 Error restoring document src/app/components/admin/trash/trash.component.ts - 117 + 126 Document(s) restored src/app/components/admin/trash/trash.component.ts - 127 + 136 Error restoring document(s) src/app/components/admin/trash/trash.component.ts - 133 + 142 diff --git a/src-ui/src/app/components/admin/trash/trash.component.spec.ts b/src-ui/src/app/components/admin/trash/trash.component.spec.ts index c9e797a1f..9ac89d9a5 100644 --- a/src-ui/src/app/components/admin/trash/trash.component.spec.ts +++ b/src-ui/src/app/components/admin/trash/trash.component.spec.ts @@ -16,6 +16,7 @@ import { ConfirmDialogComponent } from '../../common/confirm-dialog/confirm-dial import { By } from '@angular/platform-browser' import { SafeHtmlPipe } from 'src/app/pipes/safehtml.pipe' import { ToastService } from 'src/app/services/toast.service' +import { Router } from '@angular/router' const documentsInTrash = [ { @@ -38,6 +39,7 @@ describe('TrashComponent', () => { let trashService: TrashService let modalService: NgbModal let toastService: ToastService + let router: Router beforeEach(async () => { await TestBed.configureTestingModule({ @@ -61,6 +63,7 @@ describe('TrashComponent', () => { trashService = TestBed.inject(TrashService) modalService = TestBed.inject(NgbModal) toastService = TestBed.inject(ToastService) + router = TestBed.inject(Router) component = fixture.componentInstance fixture.detectChanges() }) @@ -161,6 +164,22 @@ describe('TrashComponent', () => { expect(restoreSpy).toHaveBeenCalledWith([1, 2]) }) + it('should offer link to restored document', () => { + let toasts + const navigateSpy = jest.spyOn(router, 'navigate') + toastService.getToasts().subscribe((allToasts) => { + toasts = [...allToasts] + }) + jest.spyOn(trashService, 'restoreDocuments').mockReturnValue(of('OK')) + component.restore(documentsInTrash[0]) + expect(toasts.length).toEqual(1) + toasts[0].action() + expect(navigateSpy).toHaveBeenCalledWith([ + 'documents', + documentsInTrash[0].id, + ]) + }) + it('should support toggle all items in view', () => { component.documentsInTrash = documentsInTrash expect(component.selectedDocuments.size).toEqual(0) diff --git a/src-ui/src/app/components/admin/trash/trash.component.ts b/src-ui/src/app/components/admin/trash/trash.component.ts index cf807e831..9364d4cce 100644 --- a/src-ui/src/app/components/admin/trash/trash.component.ts +++ b/src-ui/src/app/components/admin/trash/trash.component.ts @@ -7,6 +7,7 @@ import { ConfirmDialogComponent } from '../../common/confirm-dialog/confirm-dial import { Subject, takeUntil } from 'rxjs' import { SettingsService } from 'src/app/services/settings.service' import { SETTINGS_KEYS } from 'src/app/data/ui-settings' +import { Router } from '@angular/router' @Component({ selector: 'pngx-trash', @@ -26,7 +27,8 @@ export class TrashComponent implements OnDestroy { private trashService: TrashService, private toastService: ToastService, private modalService: NgbModal, - private settingsService: SettingsService + private settingsService: SettingsService, + private router: Router ) { this.reload() } @@ -110,7 +112,14 @@ export class TrashComponent implements OnDestroy { restore(document: Document) { this.trashService.restoreDocuments([document.id]).subscribe({ next: () => { - this.toastService.showInfo($localize`Document restored`) + this.toastService.show({ + content: $localize`Document restored`, + delay: 5000, + actionName: $localize`Open document`, + action: () => { + this.router.navigate(['documents', document.id]) + }, + }) this.reload() }, error: (err) => {