From b3f1d0aad279b728d04aefabe1d3869ca7a7d7f4 Mon Sep 17 00:00:00 2001 From: milanmajchrak Date: Thu, 26 Nov 2026 15:12:51 +0100 Subject: [PATCH] Warn when the share link e-mail was not sent The share response now says whether the mail went out. On false the page shows a warning, not success, and the share page does not promise an e-mail. Co-Authored-By: Claude Opus 5.5 --- .../share-submission-page.component.html | 6 +++- .../share-submission-page.component.spec.ts | 12 +++++++ .../share-submission-page.component.ts | 6 ++++ .../workspaceitem-actions.component.spec.ts | 31 +++++++++++++++++++ .../workspaceitem-actions.component.ts | 14 +++++++-- src/assets/i18n/cs.json5 | 6 ++++ src/assets/i18n/en.json5 | 2 ++ 7 files changed, 73 insertions(+), 4 deletions(-) diff --git a/src/app/share-submission/share-submission-page/share-submission-page.component.html b/src/app/share-submission/share-submission-page/share-submission-page.component.html index cb6d4b6663e..aa05aef0149 100644 --- a/src/app/share-submission/share-submission-page/share-submission-page.component.html +++ b/src/app/share-submission/share-submission-page/share-submission-page.component.html @@ -2,5 +2,9 @@

{{'share.submission.page.title' | translate}}

{{'share.submission.page.share-link.message.start' | translate}} {{changeSubmitterLink}} - {{'share.submission.page.share-link.message.end' | translate}} + @if (emailSent) { + {{'share.submission.page.share-link.message.end' | translate}} + } @else { + {{'share.submission.page.share-link.message.end.not-sent' | translate}} + } diff --git a/src/app/share-submission/share-submission-page/share-submission-page.component.spec.ts b/src/app/share-submission/share-submission-page/share-submission-page.component.spec.ts index 24b9bb701ad..2fc5953ac16 100644 --- a/src/app/share-submission/share-submission-page/share-submission-page.component.spec.ts +++ b/src/app/share-submission/share-submission-page/share-submission-page.component.spec.ts @@ -40,4 +40,16 @@ describe('ShareSubmissionPageComponent', () => { it('should create', () => { expect(component).toBeTruthy(); }); + + it('should say the email with the link was sent', () => { + expect(fixture.nativeElement.textContent).toContain('share.submission.page.share-link.message.end'); + expect(fixture.nativeElement.textContent).not.toContain('share.submission.page.share-link.message.end.not-sent'); + }); + + it('should not promise an email when it was not sent', () => { + activatedRoute.snapshot.queryParams = { changeSubmitterLink: 'https://share.link', emailSent: 'false' }; + fixture = TestBed.createComponent(ShareSubmissionPageComponent); + fixture.detectChanges(); + expect(fixture.nativeElement.textContent).toContain('share.submission.page.share-link.message.end.not-sent'); + }); }); diff --git a/src/app/share-submission/share-submission-page/share-submission-page.component.ts b/src/app/share-submission/share-submission-page/share-submission-page.component.ts index aaf45025175..dc1476bb4c5 100644 --- a/src/app/share-submission/share-submission-page/share-submission-page.component.ts +++ b/src/app/share-submission/share-submission-page/share-submission-page.component.ts @@ -21,10 +21,16 @@ export class ShareSubmissionPageComponent implements OnInit { */ changeSubmitterLink: string; + /** + * False when the backend could not send the email with the link. + */ + emailSent: boolean; + constructor(private route: ActivatedRoute) {} ngOnInit(): void { // Load `share-token` param value from the url this.changeSubmitterLink = this.route.snapshot.queryParams.changeSubmitterLink; + this.emailSent = this.route.snapshot.queryParams.emailSent !== 'false'; } } diff --git a/src/app/shared/mydspace-actions/workspaceitem/workspaceitem-actions.component.spec.ts b/src/app/shared/mydspace-actions/workspaceitem/workspaceitem-actions.component.spec.ts index 3159299ab2b..8b50cb92bba 100644 --- a/src/app/shared/mydspace-actions/workspaceitem/workspaceitem-actions.component.spec.ts +++ b/src/app/shared/mydspace-actions/workspaceitem/workspaceitem-actions.component.spec.ts @@ -316,6 +316,37 @@ describe('WorkspaceitemActionsComponent', () => { expect(closeModal).not.toHaveBeenCalled(); }); + describe('shareSubmission', () => { + beforeEach(() => { + (component as any).halService.getRootHref = () => 'https://rest.api/server/api'; + }); + + it('should show a success notification when the email was sent', () => { + spyOn((component as any).rdbService, 'buildFromRequestUUID').and.returnValue( + createSuccessfulRemoteDataObject$({ shareLink: 'https://share.link', emailSent: true })); + + component.shareSubmission(); + + expect(notificationsServiceStub.success).toHaveBeenCalled(); + expect(notificationsServiceStub.warning).not.toHaveBeenCalled(); + }); + + it('should show a warning and still open the share link when the email was not sent', () => { + const router = TestBed.inject(Router); + spyOn((component as any).rdbService, 'buildFromRequestUUID').and.returnValue( + createSuccessfulRemoteDataObject$({ shareLink: 'https://share.link', emailSent: false })); + + component.shareSubmission(); + + expect(notificationsServiceStub.warning).toHaveBeenCalledWith('submission.workflow.share-submission.email.not-sent'); + expect(notificationsServiceStub.success).not.toHaveBeenCalled(); + expect(router.navigate).toHaveBeenCalledWith(['/share-submission'], { queryParams: { + changeSubmitterLink: 'https://share.link', + emailSent: false, + } }); + }); + }); + describe('on discard confirmation', () => { beforeEach((done) => { mockDataService.delete.and.returnValue(of(true)); diff --git a/src/app/shared/mydspace-actions/workspaceitem/workspaceitem-actions.component.ts b/src/app/shared/mydspace-actions/workspaceitem/workspaceitem-actions.component.ts index a62f148ce53..af6017af517 100644 --- a/src/app/shared/mydspace-actions/workspaceitem/workspaceitem-actions.component.ts +++ b/src/app/shared/mydspace-actions/workspaceitem/workspaceitem-actions.component.ts @@ -250,12 +250,19 @@ export class WorkspaceitemActionsComponent extends MyDSpaceActionsComponent) => { // If the request has succeeded if (rd.hasSucceeded) { - // Show success notification - this.notificationsService.success( - this.translate.instant('submission.workflow.share-submission.email.successful')); + const emailSent = rd.payload?.emailSent !== false; + if (emailSent) { + this.notificationsService.success( + this.translate.instant('submission.workflow.share-submission.email.successful')); + } else { + // The link works without the email, so warn and still show it + this.notificationsService.warning( + this.translate.instant('submission.workflow.share-submission.email.not-sent')); + } // Redirect to share-submission page void this.router.navigate(['/share-submission'], { queryParams: { changeSubmitterLink: rd.payload?.shareLink, + emailSent, } }); } else { // Show error notification @@ -269,4 +276,5 @@ export class WorkspaceitemActionsComponent extends MyDSpaceActionsComponent