Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@
<h3>{{'share.submission.page.title' | translate}}</h3>
<span>{{'share.submission.page.share-link.message.start' | translate}}</span>
<a [href]="changeSubmitterLink">{{changeSubmitterLink}}</a>
<span>{{'share.submission.page.share-link.message.end' | translate}}</span>
@if (emailSent) {
<span>{{'share.submission.page.share-link.message.end' | translate}}</span>
} @else {
<span>{{'share.submission.page.share-link.message.end.not-sent' | translate}}</span>
}
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,12 +250,19 @@ export class WorkspaceitemActionsComponent extends MyDSpaceActionsComponent<Work
response.pipe(getFirstCompletedRemoteData()).subscribe((rd: RemoteData<ShareSubmissionLink>) => {
// 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
Expand All @@ -269,4 +276,5 @@ export class WorkspaceitemActionsComponent extends MyDSpaceActionsComponent<Work

export interface ShareSubmissionLink {
shareLink: string;
emailSent?: boolean;
}
6 changes: 6 additions & 0 deletions src/assets/i18n/cs.json5
Original file line number Diff line number Diff line change
Expand Up @@ -10241,6 +10241,9 @@
// "submission.workflow.share-submission.email.error": "Cannot send the email with share link",
"submission.workflow.share-submission.email.error": "Nelze odeslat e-mail s odkazem na sdílení",

// "submission.workflow.share-submission.email.not-sent": "The share link is ready, but the email with it could not be sent. Copy the link from this page.",
"submission.workflow.share-submission.email.not-sent": "Odkaz na sdílení je připraven, ale e-mail s ním se nepodařilo odeslat. Zkopírujte odkaz z této stránky.",

// "submission.workflow.share-submission.email.successful": "The email with the share link has been sent successfully",
"submission.workflow.share-submission.email.successful": "E-mail s odkazem na sdílení byl úspěšně odeslán",

Expand Down Expand Up @@ -11564,6 +11567,9 @@
// "share.submission.page.share-link.message.end": ". You will also receive an email with this link.",
"share.submission.page.share-link.message.end": ". Odkaz vám také přijde e-mailem (v angličtině).",

// "share.submission.page.share-link.message.end.not-sent": ". The email with this link could not be sent.",
"share.submission.page.share-link.message.end.not-sent": ". E-mail s tímto odkazem se nepodařilo odeslat.",

// "share.submission.page.share-link.message.start": "To pass your submission to another user give them the following link: ",
"share.submission.page.share-link.message.start": "Chcete-li tento záznam předat někomu jinému, předejte tento odkaz: ",

Expand Down
2 changes: 2 additions & 0 deletions src/assets/i18n/en.json5
Original file line number Diff line number Diff line change
Expand Up @@ -7837,6 +7837,7 @@
"submission.workflow.generic.add-url-bitstream.submit": "Add",
"submission.workflow.share-submission.email.successful": "The email with the share link has been sent successfully",
"submission.workflow.share-submission.email.error": "Cannot send the email with share link",
"submission.workflow.share-submission.email.not-sent": "The share link is ready, but the email with it could not be sent. Copy the link from this page.",
"language.english": "English",
"language.czech": "Czech",
"repository.policy.page": "Change me: policy page",
Expand All @@ -7857,6 +7858,7 @@
"share.submission.page.title": "Share link",
"share.submission.page.share-link.message.start": "To pass your submission to another user give them the following link: ",
"share.submission.page.share-link.message.end": ". You will also receive an email with this link.",
"share.submission.page.share-link.message.end.not-sent": ". The email with this link could not be sent.",
"change.submitter.breadcrumbs": "Change submitter",
"change.submitter.page.title": "Change submitter",
"change.submitter.page.message": "This items currently belongs to: ",
Expand Down
Loading