diff --git a/src/app/profile-page/profile-page-researcher-form/profile-page-researcher-form.component.spec.ts b/src/app/profile-page/profile-page-researcher-form/profile-page-researcher-form.component.spec.ts index 00a3f4bc94..aa0d1d187d 100644 --- a/src/app/profile-page/profile-page-researcher-form/profile-page-researcher-form.component.spec.ts +++ b/src/app/profile-page/profile-page-researcher-form/profile-page-researcher-form.component.spec.ts @@ -156,9 +156,15 @@ describe('ProfilePageResearcherFormComponent', () => { }); describe('deleteProfile', () => { + beforeEach(() => { + const modalService = (component as any).modalService; + spyOn(modalService, 'open').and.returnValue(Object.assign({ componentInstance: Object.assign({ response: observableOf(true) }) })); + component.deleteProfile(profile); + fixture.detectChanges(); + }); it('should delete the profile', () => { - component.deleteProfile(profile); + expect(researcherProfileService.delete).toHaveBeenCalledWith(profile); }); diff --git a/src/app/profile-page/profile-page-researcher-form/profile-page-researcher-form.component.ts b/src/app/profile-page/profile-page-researcher-form/profile-page-researcher-form.component.ts index f0235c6423..1e8b5fc432 100644 --- a/src/app/profile-page/profile-page-researcher-form/profile-page-researcher-form.component.ts +++ b/src/app/profile-page/profile-page-researcher-form/profile-page-researcher-form.component.ts @@ -17,6 +17,7 @@ import { ProfileClaimService } from '../profile-claim/profile-claim.service'; import { RemoteData } from '../../core/data/remote-data'; import { isNotEmpty } from '../../shared/empty.util'; import { followLink } from '../../shared/utils/follow-link-config.model'; +import { ConfirmationModalComponent } from '../../shared/confirmation-modal/confirmation-modal.component'; @Component({ selector: 'ds-profile-page-researcher-form', @@ -113,15 +114,26 @@ export class ProfilePageResearcherFormComponent implements OnInit { * @param researcherProfile the profile to delete */ deleteProfile(researcherProfile: ResearcherProfile): void { - this.processingDelete$.next(true); - this.researcherProfileService.delete(researcherProfile) - .subscribe((deleted) => { - if (deleted) { - this.researcherProfile$.next(null); - this.researcherProfileItemId = null; - } - this.processingDelete$.next(false); - }); + const modalRef = this.modalService.open(ConfirmationModalComponent); + modalRef.componentInstance.headerLabel = 'confirmation-modal.delete-profile.header'; + modalRef.componentInstance.infoLabel = 'confirmation-modal.delete-profile.info'; + modalRef.componentInstance.cancelLabel = 'confirmation-modal.delete-profile.cancel'; + modalRef.componentInstance.confirmLabel = 'confirmation-modal.delete-profile.confirm'; + modalRef.componentInstance.brandColor = 'danger'; + modalRef.componentInstance.confirmIcon = 'fas fa-trash'; + modalRef.componentInstance.response.pipe(take(1)).subscribe((confirm: boolean) => { + if (confirm) { + this.processingDelete$.next(true); + this.researcherProfileService.delete(researcherProfile) + .subscribe((deleted) => { + if (deleted) { + this.researcherProfile$.next(null); + this.researcherProfileItemId = null; + } + this.processingDelete$.next(false); + }); + } + }); } /** diff --git a/src/assets/i18n/en.json5 b/src/assets/i18n/en.json5 index c630c46b55..637754ccde 100644 --- a/src/assets/i18n/en.json5 +++ b/src/assets/i18n/en.json5 @@ -1361,6 +1361,14 @@ "confirmation-modal.delete-eperson.confirm": "Delete", + "confirmation-modal.delete-profile.header": "Delete Profile", + + "confirmation-modal.delete-profile.info": "Are you sure you want to delete your profile", + + "confirmation-modal.delete-profile.cancel": "Cancel", + + "confirmation-modal.delete-profile.confirm": "Delete", + "error.bitstream": "Error fetching bitstream", @@ -3666,7 +3674,7 @@ "submission.import-external.preview.title.OrgUnit": "Organizational Unit Preview", "submission.import-external.preview.title.Person": "Person Preview", - + "submission.import-external.preview.title.Project": "Project Preview", "submission.import-external.preview.subtitle": "The metadata below was imported from an external source. It will be pre-filled when you start the submission.",