mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-07-28 18:24:38 -05:00
Tweak: more verbose toast messages
This commit is contained in:
@@ -86,12 +86,17 @@ export class TrashComponent
|
||||
modal.componentInstance.buttonsEnabled = false
|
||||
this.trashService.emptyTrash([document.id]).subscribe({
|
||||
next: () => {
|
||||
this.toastService.showInfo($localize`Document deleted`)
|
||||
this.toastService.showInfo(
|
||||
$localize`Document "${document.title}" deleted`
|
||||
)
|
||||
modal.close()
|
||||
this.reload()
|
||||
},
|
||||
error: (err) => {
|
||||
this.toastService.showError($localize`Error deleting document`, err)
|
||||
this.toastService.showError(
|
||||
$localize`Error deleting document "${document.title}"`,
|
||||
err
|
||||
)
|
||||
modal.close()
|
||||
},
|
||||
})
|
||||
@@ -136,7 +141,7 @@ export class TrashComponent
|
||||
this.trashService.restoreDocuments([document.id]).subscribe({
|
||||
next: () => {
|
||||
this.toastService.show({
|
||||
content: $localize`Document restored`,
|
||||
content: $localize`Document "${document.title}" restored`,
|
||||
delay: 5000,
|
||||
actionName: $localize`Open document`,
|
||||
action: () => {
|
||||
@@ -146,7 +151,10 @@ export class TrashComponent
|
||||
this.reload()
|
||||
},
|
||||
error: (err) => {
|
||||
this.toastService.showError($localize`Error restoring document`, err)
|
||||
this.toastService.showError(
|
||||
$localize`Error restoring document "${document.title}"`,
|
||||
err
|
||||
)
|
||||
},
|
||||
})
|
||||
}
|
||||
|
@@ -134,7 +134,7 @@ describe('UsersAndGroupsComponent', () => {
|
||||
deleteSpy.mockReturnValueOnce(of(true))
|
||||
deleteDialog.confirm()
|
||||
expect(listAllSpy).toHaveBeenCalled()
|
||||
expect(toastInfoSpy).toHaveBeenCalledWith('Deleted user')
|
||||
expect(toastInfoSpy).toHaveBeenCalledWith('Deleted user "user1"')
|
||||
})
|
||||
|
||||
it('should logout current user if password changed, after delay', fakeAsync(() => {
|
||||
@@ -178,7 +178,7 @@ describe('UsersAndGroupsComponent', () => {
|
||||
completeSetup()
|
||||
let modal: NgbModalRef
|
||||
modalService.activeInstances.subscribe((refs) => (modal = refs[0]))
|
||||
component.deleteGroup(users[0])
|
||||
component.deleteGroup(groups[0])
|
||||
const deleteDialog = modal.componentInstance as ConfirmDialogComponent
|
||||
const deleteSpy = jest.spyOn(groupService, 'delete')
|
||||
const toastErrorSpy = jest.spyOn(toastService, 'showError')
|
||||
@@ -192,7 +192,7 @@ describe('UsersAndGroupsComponent', () => {
|
||||
deleteSpy.mockReturnValueOnce(of(true))
|
||||
deleteDialog.confirm()
|
||||
expect(listAllSpy).toHaveBeenCalled()
|
||||
expect(toastInfoSpy).toHaveBeenCalledWith('Deleted group')
|
||||
expect(toastInfoSpy).toHaveBeenCalledWith('Deleted group "group1"')
|
||||
})
|
||||
|
||||
it('should get group name', () => {
|
||||
|
@@ -129,13 +129,16 @@ export class UsersAndGroupsComponent
|
||||
this.usersService.delete(user).subscribe({
|
||||
next: () => {
|
||||
modal.close()
|
||||
this.toastService.showInfo($localize`Deleted user`)
|
||||
this.toastService.showInfo($localize`Deleted user "${user.username}"`)
|
||||
this.usersService.listAll().subscribe((r) => {
|
||||
this.users = r.results
|
||||
})
|
||||
},
|
||||
error: (e) => {
|
||||
this.toastService.showError($localize`Error deleting user.`, e)
|
||||
this.toastService.showError(
|
||||
$localize`Error deleting user "${user.username}".`,
|
||||
e
|
||||
)
|
||||
},
|
||||
})
|
||||
})
|
||||
@@ -179,13 +182,16 @@ export class UsersAndGroupsComponent
|
||||
this.groupsService.delete(group).subscribe({
|
||||
next: () => {
|
||||
modal.close()
|
||||
this.toastService.showInfo($localize`Deleted group`)
|
||||
this.toastService.showInfo($localize`Deleted group "${group.name}"`)
|
||||
this.groupsService.listAll().subscribe((r) => {
|
||||
this.groups = r.results
|
||||
})
|
||||
},
|
||||
error: (e) => {
|
||||
this.toastService.showError($localize`Error deleting group.`, e)
|
||||
this.toastService.showError(
|
||||
$localize`Error deleting group "${group.name}".`,
|
||||
e
|
||||
)
|
||||
},
|
||||
})
|
||||
})
|
||||
|
@@ -454,7 +454,9 @@ describe('DocumentDetailComponent', () => {
|
||||
component.save(true)
|
||||
expect(updateSpy).toHaveBeenCalled()
|
||||
expect(closeSpy).toHaveBeenCalled()
|
||||
expect(toastSpy).toHaveBeenCalledWith('Document saved successfully.')
|
||||
expect(toastSpy).toHaveBeenCalledWith(
|
||||
'Document "Doc 3" saved successfully.'
|
||||
)
|
||||
})
|
||||
|
||||
it('should support save without close and show success toast', () => {
|
||||
@@ -467,7 +469,9 @@ describe('DocumentDetailComponent', () => {
|
||||
component.save()
|
||||
expect(updateSpy).toHaveBeenCalled()
|
||||
expect(closeSpy).not.toHaveBeenCalled()
|
||||
expect(toastSpy).toHaveBeenCalledWith('Document saved successfully.')
|
||||
expect(toastSpy).toHaveBeenCalledWith(
|
||||
'Document "Doc 3" saved successfully.'
|
||||
)
|
||||
})
|
||||
|
||||
it('should show toast error on save if error occurs', () => {
|
||||
@@ -482,7 +486,10 @@ describe('DocumentDetailComponent', () => {
|
||||
component.save()
|
||||
expect(updateSpy).toHaveBeenCalled()
|
||||
expect(closeSpy).not.toHaveBeenCalled()
|
||||
expect(toastSpy).toHaveBeenCalledWith('Error saving document', error)
|
||||
expect(toastSpy).toHaveBeenCalledWith(
|
||||
'Error saving document "Doc 3"',
|
||||
error
|
||||
)
|
||||
})
|
||||
|
||||
it('should show error toast on save but close if user can no longer edit', () => {
|
||||
@@ -498,7 +505,9 @@ describe('DocumentDetailComponent', () => {
|
||||
component.save(true)
|
||||
expect(updateSpy).toHaveBeenCalled()
|
||||
expect(closeSpy).toHaveBeenCalled()
|
||||
expect(toastSpy).toHaveBeenCalledWith('Document saved successfully.')
|
||||
expect(toastSpy).toHaveBeenCalledWith(
|
||||
'Document "Doc 3" saved successfully.'
|
||||
)
|
||||
})
|
||||
|
||||
it('should allow save and next', () => {
|
||||
|
@@ -808,7 +808,9 @@ export class DocumentDetailComponent
|
||||
this.store.next(newValues)
|
||||
this.openDocumentService.setDirty(this.document, false)
|
||||
this.openDocumentService.save()
|
||||
this.toastService.showInfo($localize`Document saved successfully.`)
|
||||
this.toastService.showInfo(
|
||||
$localize`Document "${newValues.title}" saved successfully.`
|
||||
)
|
||||
this.networkActive = false
|
||||
this.error = null
|
||||
if (close) {
|
||||
@@ -822,11 +824,16 @@ export class DocumentDetailComponent
|
||||
error: (error) => {
|
||||
this.networkActive = false
|
||||
if (!this.userCanEdit) {
|
||||
this.toastService.showInfo($localize`Document saved successfully.`)
|
||||
this.toastService.showInfo(
|
||||
$localize`Document "${this.document.title}" saved successfully.`
|
||||
)
|
||||
close && this.close()
|
||||
} else {
|
||||
this.error = error.error
|
||||
this.toastService.showError($localize`Error saving document`, error)
|
||||
this.toastService.showError(
|
||||
$localize`Error saving document "${this.document.title}"`,
|
||||
error
|
||||
)
|
||||
}
|
||||
},
|
||||
})
|
||||
@@ -955,7 +962,7 @@ export class DocumentDetailComponent
|
||||
.subscribe({
|
||||
next: () => {
|
||||
this.toastService.showInfo(
|
||||
$localize`Reprocess operation will begin in the background. Close and re-open or reload this document after the operation has completed to see new content.`
|
||||
$localize`Reprocess operation for "${this.document.title}" will begin in the background. Close and re-open or reload this document after the operation has completed to see new content.`
|
||||
)
|
||||
if (modal) {
|
||||
modal.close()
|
||||
@@ -1315,7 +1322,7 @@ export class DocumentDetailComponent
|
||||
.subscribe({
|
||||
next: () => {
|
||||
this.toastService.showInfo(
|
||||
$localize`Split operation will begin in the background.`
|
||||
$localize`Split operation for "${this.document.title}" will begin in the background.`
|
||||
)
|
||||
modal.close()
|
||||
},
|
||||
@@ -1354,7 +1361,7 @@ export class DocumentDetailComponent
|
||||
.subscribe({
|
||||
next: () => {
|
||||
this.toastService.show({
|
||||
content: $localize`Rotation will begin in the background. Close and re-open the document after the operation has completed to see the changes.`,
|
||||
content: $localize`Rotation of "${this.document.title}" will begin in the background. Close and re-open the document after the operation has completed to see the changes.`,
|
||||
delay: 8000,
|
||||
action: this.close.bind(this),
|
||||
actionName: $localize`Close`,
|
||||
@@ -1394,7 +1401,7 @@ export class DocumentDetailComponent
|
||||
.subscribe({
|
||||
next: () => {
|
||||
this.toastService.showInfo(
|
||||
$localize`Delete pages operation will begin in the background. Close and re-open or reload this document after the operation has completed to see the changes.`
|
||||
$localize`Delete pages operation for "${this.document.title}" will begin in the background. Close and re-open or reload this document after the operation has completed to see the changes.`
|
||||
)
|
||||
modal.close()
|
||||
},
|
||||
|
@@ -108,13 +108,16 @@ export class CustomFieldsComponent
|
||||
this.customFieldsService.delete(field).subscribe({
|
||||
next: () => {
|
||||
modal.close()
|
||||
this.toastService.showInfo($localize`Deleted field`)
|
||||
this.toastService.showInfo($localize`Deleted field "${field.name}"`)
|
||||
this.customFieldsService.clearCache()
|
||||
this.settingsService.initializeDisplayFields()
|
||||
this.reload()
|
||||
},
|
||||
error: (e) => {
|
||||
this.toastService.showError($localize`Error deleting field.`, e)
|
||||
this.toastService.showError(
|
||||
$localize`Error deleting field "${field.name}".`,
|
||||
e
|
||||
)
|
||||
},
|
||||
})
|
||||
})
|
||||
|
@@ -214,7 +214,7 @@ describe('MailComponent', () => {
|
||||
deleteSpy.mockReturnValueOnce(of(true))
|
||||
deleteDialog.confirm()
|
||||
expect(listAllSpy).toHaveBeenCalled()
|
||||
expect(toastInfoSpy).toHaveBeenCalledWith('Deleted mail account')
|
||||
expect(toastInfoSpy).toHaveBeenCalledWith('Deleted mail account "account1"')
|
||||
})
|
||||
|
||||
it('should support process mail account, show error if needed', () => {
|
||||
@@ -231,7 +231,9 @@ describe('MailComponent', () => {
|
||||
expect(toastErrorSpy).toHaveBeenCalled()
|
||||
processSpy.mockReturnValueOnce(of(true))
|
||||
component.processAccount(mailAccounts[0] as MailAccount)
|
||||
expect(toastInfoSpy).toHaveBeenCalledWith('Processing mail account')
|
||||
expect(toastInfoSpy).toHaveBeenCalledWith(
|
||||
'Processing mail account "account1"'
|
||||
)
|
||||
})
|
||||
|
||||
it('should support edit / create mail rule, show error if needed', () => {
|
||||
@@ -274,14 +276,14 @@ describe('MailComponent', () => {
|
||||
const toastInfoSpy = jest.spyOn(toastService, 'showInfo')
|
||||
const listAllSpy = jest.spyOn(mailRuleService, 'listAll')
|
||||
deleteSpy.mockReturnValueOnce(
|
||||
throwError(() => new Error('error deleting mail rule'))
|
||||
throwError(() => new Error('error deleting mail rule "rule1"'))
|
||||
)
|
||||
deleteDialog.confirm()
|
||||
expect(toastErrorSpy).toBeCalled()
|
||||
deleteSpy.mockReturnValueOnce(of(true))
|
||||
deleteDialog.confirm()
|
||||
expect(listAllSpy).toHaveBeenCalled()
|
||||
expect(toastInfoSpy).toHaveBeenCalledWith('Deleted mail rule')
|
||||
expect(toastInfoSpy).toHaveBeenCalledWith('Deleted mail rule "rule1"')
|
||||
})
|
||||
|
||||
it('should support edit permissions on mail rule objects', () => {
|
||||
|
@@ -200,7 +200,9 @@ export class MailComponent
|
||||
this.mailAccountService.delete(account).subscribe({
|
||||
next: () => {
|
||||
modal.close()
|
||||
this.toastService.showInfo($localize`Deleted mail account`)
|
||||
this.toastService.showInfo(
|
||||
$localize`Deleted mail account "${account.name}"`
|
||||
)
|
||||
this.mailAccountService.clearCache()
|
||||
this.mailAccountService
|
||||
.listAll(null, null, { full_perms: true })
|
||||
@@ -210,7 +212,7 @@ export class MailComponent
|
||||
},
|
||||
error: (e) => {
|
||||
this.toastService.showError(
|
||||
$localize`Error deleting mail account.`,
|
||||
$localize`Error deleting mail account "${account.name}".`,
|
||||
e
|
||||
)
|
||||
},
|
||||
@@ -221,10 +223,15 @@ export class MailComponent
|
||||
processAccount(account: MailAccount) {
|
||||
this.mailAccountService.processAccount(account).subscribe({
|
||||
next: () => {
|
||||
this.toastService.showInfo($localize`Processing mail account`)
|
||||
this.toastService.showInfo(
|
||||
$localize`Processing mail account "${account.name}"`
|
||||
)
|
||||
},
|
||||
error: (e) => {
|
||||
this.toastService.showError($localize`Error processing mail account`, e)
|
||||
this.toastService.showError(
|
||||
$localize`Error processing mail account "${account.name}")`,
|
||||
e
|
||||
)
|
||||
},
|
||||
})
|
||||
}
|
||||
@@ -272,7 +279,10 @@ export class MailComponent
|
||||
)
|
||||
},
|
||||
error: (e) => {
|
||||
this.toastService.showError($localize`Error toggling rule.`, e)
|
||||
this.toastService.showError(
|
||||
$localize`Error toggling rule "${rule.name}".`,
|
||||
e
|
||||
)
|
||||
},
|
||||
})
|
||||
}
|
||||
@@ -291,7 +301,9 @@ export class MailComponent
|
||||
this.mailRuleService.delete(rule).subscribe({
|
||||
next: () => {
|
||||
modal.close()
|
||||
this.toastService.showInfo($localize`Deleted mail rule`)
|
||||
this.toastService.showInfo(
|
||||
$localize`Deleted mail rule "${rule.name}"`
|
||||
)
|
||||
this.mailRuleService.clearCache()
|
||||
this.mailRuleService
|
||||
.listAll(null, null, { full_perms: true })
|
||||
@@ -300,7 +312,10 @@ export class MailComponent
|
||||
})
|
||||
},
|
||||
error: (e) => {
|
||||
this.toastService.showError($localize`Error deleting mail rule.`, e)
|
||||
this.toastService.showError(
|
||||
$localize`Error deleting mail rule "${rule.name}".`,
|
||||
e
|
||||
)
|
||||
},
|
||||
})
|
||||
})
|
||||
|
@@ -142,12 +142,17 @@ export class WorkflowsComponent
|
||||
this.workflowService.delete(workflow).subscribe({
|
||||
next: () => {
|
||||
modal.close()
|
||||
this.toastService.showInfo($localize`Deleted workflow`)
|
||||
this.toastService.showInfo(
|
||||
$localize`Deleted workflow "${workflow.name}".`
|
||||
)
|
||||
this.workflowService.clearCache()
|
||||
this.reload()
|
||||
},
|
||||
error: (e) => {
|
||||
this.toastService.showError($localize`Error deleting workflow.`, e)
|
||||
this.toastService.showError(
|
||||
$localize`Error deleting workflow "${workflow.name}".`,
|
||||
e
|
||||
)
|
||||
},
|
||||
})
|
||||
})
|
||||
@@ -158,14 +163,17 @@ export class WorkflowsComponent
|
||||
next: () => {
|
||||
this.toastService.showInfo(
|
||||
workflow.enabled
|
||||
? $localize`Enabled workflow`
|
||||
: $localize`Disabled workflow`
|
||||
? $localize`Enabled workflow "${workflow.name}"`
|
||||
: $localize`Disabled workflow "${workflow.name}"`
|
||||
)
|
||||
this.workflowService.clearCache()
|
||||
this.reload()
|
||||
},
|
||||
error: (e) => {
|
||||
this.toastService.showError($localize`Error toggling workflow.`, e)
|
||||
this.toastService.showError(
|
||||
$localize`Error toggling workflow "${workflow.name}".`,
|
||||
e
|
||||
)
|
||||
},
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user