Skip to content

Commit 77b027a

Browse files
[CST-15074][DSpace#3355] PR review
1 parent c2701c4 commit 77b027a

12 files changed

Lines changed: 130 additions & 174 deletions

File tree

src/app/external-log-in/email-confirmation/confirm-email/confirm-email.component.ts

Lines changed: 10 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,18 @@
11
import { NgIf } from '@angular/common';
2-
import {
3-
ChangeDetectionStrategy,
4-
Component,
5-
Inject,
6-
Input,
7-
OnDestroy,
8-
OnInit,
9-
} from '@angular/core';
10-
import {
11-
FormBuilder,
12-
FormGroup,
13-
ReactiveFormsModule,
14-
Validators,
15-
} from '@angular/forms';
16-
import {
17-
TranslateModule,
18-
TranslateService,
19-
} from '@ngx-translate/core';
2+
import { ChangeDetectionStrategy, Component, Inject, Input, OnDestroy, OnInit, } from '@angular/core';
3+
import { FormBuilder, FormGroup, ReactiveFormsModule, Validators, } from '@angular/forms';
4+
import { TranslateModule, TranslateService, } from '@ngx-translate/core';
205
import isEqual from 'lodash/isEqual';
21-
import {
22-
combineLatest,
23-
Subscription,
24-
take,
25-
} from 'rxjs';
6+
import { combineLatest, Subscription, take, } from 'rxjs';
267

278
import { AuthService } from '../../../core/auth/auth.service';
289
import { EPersonDataService } from '../../../core/eperson/eperson-data.service';
2910
import { EPerson } from '../../../core/eperson/models/eperson.model';
3011
import { HardRedirectService } from '../../../core/services/hard-redirect.service';
31-
import {
32-
NativeWindowRef,
33-
NativeWindowService,
34-
} from '../../../core/services/window.service';
35-
import {
36-
getFirstCompletedRemoteData,
37-
getRemoteDataPayload,
38-
} from '../../../core/shared/operators';
12+
import { NativeWindowRef, NativeWindowService, } from '../../../core/services/window.service';
13+
import { getFirstCompletedRemoteData, getRemoteDataPayload, } from '../../../core/shared/operators';
3914
import { Registration } from '../../../core/shared/registration.model';
40-
import {
41-
hasNoValue,
42-
hasValue,
43-
} from '../../../shared/empty.util';
15+
import { hasNoValue, hasValue, } from '../../../shared/empty.util';
4416
import { NotificationsService } from '../../../shared/notifications/notifications.service';
4517
import { ExternalLoginService } from '../../services/external-login.service';
4618

@@ -56,6 +28,9 @@ import { ExternalLoginService } from '../../services/external-login.service';
5628
ReactiveFormsModule,
5729
],
5830
})
31+
/**
32+
* Email confirmation component that will check for user email confirmation after account creation.
33+
*/
5934
export class ConfirmEmailComponent implements OnInit, OnDestroy {
6035
/**
6136
* The form containing the email input
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
import {
2-
ChangeDetectionStrategy,
3-
Component,
4-
} from '@angular/core';
1+
import { ChangeDetectionStrategy, Component, } from '@angular/core';
52
import { TranslateModule } from '@ngx-translate/core';
63

74
@Component({
@@ -13,4 +10,7 @@ import { TranslateModule } from '@ngx-translate/core';
1310
standalone: true,
1411

1512
})
13+
/**
14+
* Simple component that shows up a confirmation to the user.
15+
*/
1616
export class ConfirmationSentComponent { }

src/app/external-log-in/email-confirmation/provide-email/provide-email.component.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ <h4 class="mb-3">
88
type="email"
99
id="email"
1010
formControlName="email"
11-
placeholder="Input box"
1211
class="form-control form-control-lg position-relative"
1312
/>
1413

src/app/external-log-in/email-confirmation/provide-email/provide-email.component.spec.ts

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
import { CommonModule } from '@angular/common';
22
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
3-
import {
4-
ComponentFixture,
5-
TestBed,
6-
} from '@angular/core/testing';
3+
import { ComponentFixture, TestBed, } from '@angular/core/testing';
74
import { FormBuilder } from '@angular/forms';
8-
import {
9-
TranslateLoader,
10-
TranslateModule,
11-
} from '@ngx-translate/core';
5+
import { TranslateLoader, TranslateModule, } from '@ngx-translate/core';
126

137
import { TranslateLoaderMock } from '../../../shared/mocks/translate-loader.mock';
148
import { ExternalLoginService } from '../../services/external-login.service';
@@ -53,16 +47,16 @@ describe('ProvideEmailComponent', () => {
5347
expect(component).toBeTruthy();
5448
});
5549

56-
// it('should call externalLoginService.patchUpdateRegistration when form is submitted with valid email', () => {
57-
// const email = 'test@example.com';
58-
// component.emailForm.setValue({ email });
59-
// component.registrationId = '123';
60-
// component.token = '456';
61-
// fixture.detectChanges();
50+
it('should call externalLoginService.patchUpdateRegistration when form is submitted with valid email', () => {
51+
const email = 'test@example.com';
52+
component.emailForm.setValue({ email });
53+
component.registrationId = '123';
54+
component.token = '456';
55+
fixture.detectChanges();
6256

63-
// const button = fixture.nativeElement.querySelector('button[type="submit"]');
64-
// button.click();
57+
const button = fixture.nativeElement.querySelector('button[type="submit"]');
58+
button.click();
6559

66-
// expect(externalLoginServiceSpy.patchUpdateRegistration).toHaveBeenCalledWith([email], 'email', component.registrationId, component.token, 'add');
67-
// });
60+
expect(externalLoginServiceSpy.patchUpdateRegistration).toHaveBeenCalledWith([email], 'email', component.registrationId, component.token, 'add');
61+
});
6862
});

src/app/external-log-in/email-confirmation/provide-email/provide-email.component.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,6 @@
11
import { NgIf } from '@angular/common';
2-
import {
3-
ChangeDetectionStrategy,
4-
Component,
5-
Input,
6-
OnDestroy,
7-
} from '@angular/core';
8-
import {
9-
FormBuilder,
10-
FormGroup,
11-
ReactiveFormsModule,
12-
Validators,
13-
} from '@angular/forms';
2+
import { ChangeDetectionStrategy, Component, Input, OnDestroy, } from '@angular/core';
3+
import { FormBuilder, FormGroup, ReactiveFormsModule, Validators, } from '@angular/forms';
144
import { TranslateModule } from '@ngx-translate/core';
155
import { Subscription } from 'rxjs';
166

@@ -29,6 +19,9 @@ import { ExternalLoginService } from '../../services/external-login.service';
2919
],
3020
standalone: true,
3121
})
22+
/**
23+
* This component provides a proper field to submit the email that will be updated for its registration token
24+
*/
3225
export class ProvideEmailComponent implements OnDestroy {
3326
/**
3427
* The form group for the email input

src/app/external-log-in/external-log-in/external-log-in.component.ts

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,15 @@
1-
import {
2-
NgComponentOutlet,
3-
NgIf,
4-
} from '@angular/common';
5-
import {
6-
ChangeDetectionStrategy,
7-
Component,
8-
Injector,
9-
Input,
10-
OnDestroy,
11-
OnInit,
12-
} from '@angular/core';
13-
import {
14-
NgbModal,
15-
NgbModalRef,
16-
} from '@ng-bootstrap/ng-bootstrap';
17-
import {
18-
TranslateModule,
19-
TranslateService,
20-
} from '@ngx-translate/core';
1+
import { NgComponentOutlet, NgIf, } from '@angular/common';
2+
import { ChangeDetectionStrategy, Component, Injector, Input, OnDestroy, OnInit, } from '@angular/core';
3+
import { NgbModal, NgbModalRef, } from '@ng-bootstrap/ng-bootstrap';
4+
import { TranslateModule, TranslateService, } from '@ngx-translate/core';
215

226
import { AuthService } from '../../core/auth/auth.service';
237
import { AuthMethodType } from '../../core/auth/models/auth.method-type';
248
import { AuthRegistrationType } from '../../core/auth/models/auth.registration-type';
259
import { Registration } from '../../core/shared/registration.model';
2610
import { AlertComponent } from '../../shared/alert/alert.component';
2711
import { AlertType } from '../../shared/alert/alert-type';
28-
import {
29-
hasValue,
30-
isEmpty,
31-
} from '../../shared/empty.util';
12+
import { hasValue, isEmpty, } from '../../shared/empty.util';
3213
import { ThemedLogInComponent } from '../../shared/log-in/themed-log-in.component';
3314
import {
3415
ExternalLoginTypeComponent,
@@ -53,6 +34,9 @@ import { ProvideEmailComponent } from '../email-confirmation/provide-email/provi
5334
],
5435
standalone: true,
5536
})
37+
/**
38+
* This component is responsible to handle the external-login depending on the RegistrationData details provided
39+
*/
5640
export class ExternalLogInComponent implements OnInit, OnDestroy {
5741
/**
5842
* The AlertType enumeration for access in the component's template

src/app/external-log-in/registration-types/orcid-confirmation/orcid-confirmation.component.ts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
11
import { NgIf } from '@angular/common';
2-
import {
3-
ChangeDetectionStrategy,
4-
Component,
5-
Inject,
6-
OnInit,
7-
} from '@angular/core';
8-
import {
9-
FormBuilder,
10-
FormGroup,
11-
ReactiveFormsModule,
12-
} from '@angular/forms';
2+
import { ChangeDetectionStrategy, Component, Inject, OnInit, } from '@angular/core';
3+
import { FormBuilder, FormGroup, ReactiveFormsModule, } from '@angular/forms';
134
import { TranslateModule } from '@ngx-translate/core';
145

156
import { Registration } from '../../../core/shared/registration.model';
@@ -29,6 +20,9 @@ import { ExternalLoginMethodEntryComponent } from '../../decorators/external-log
2920
],
3021
standalone: true,
3122
})
23+
/**
24+
* This component is responsible to show the registered data inside the registration token to the user
25+
*/
3226
export class OrcidConfirmationComponent extends ExternalLoginMethodEntryComponent implements OnInit {
3327

3428
/**

src/app/external-log-in/services/external-login.service.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
11
import { Injectable } from '@angular/core';
22
import { Router } from '@angular/router';
3-
import {
4-
select,
5-
Store,
6-
} from '@ngrx/store';
3+
import { select, Store, } from '@ngrx/store';
74
import { TranslateService } from '@ngx-translate/core';
8-
import {
9-
filter,
10-
map,
11-
Observable,
12-
} from 'rxjs';
5+
import { filter, map, Observable, } from 'rxjs';
136
import { AuthMethod } from 'src/app/core/auth/models/auth.method';
147
import { getAuthenticationMethods } from 'src/app/core/auth/selectors';
158
import { CoreState } from 'src/app/core/core-state.model';
@@ -23,6 +16,10 @@ import { NotificationsService } from '../../shared/notifications/notifications.s
2316
@Injectable({
2417
providedIn: 'root',
2518
})
19+
/**
20+
* This service is responsible to communicate with the epersonRegistrationService to update the RegistrationData
21+
* provided by the user.
22+
*/
2623
export class ExternalLoginService {
2724

2825
constructor(

src/app/external-login-page/external-login-page.component.ts

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,8 @@
1-
import {
2-
AsyncPipe,
3-
NgIf,
4-
} from '@angular/common';
5-
import {
6-
Component,
7-
OnInit,
8-
} from '@angular/core';
1+
import { AsyncPipe, NgIf, } from '@angular/common';
2+
import { Component, OnInit, } from '@angular/core';
93
import { ActivatedRoute } from '@angular/router';
104
import { TranslateModule } from '@ngx-translate/core';
11-
import {
12-
first,
13-
map,
14-
Observable,
15-
tap,
16-
} from 'rxjs';
5+
import { first, map, Observable, tap, } from 'rxjs';
176

187
import { RemoteData } from '../core/data/remote-data';
198
import { Registration } from '../core/shared/registration.model';
@@ -34,6 +23,9 @@ import { hasNoValue } from '../shared/empty.util';
3423
],
3524
standalone: true,
3625
})
26+
/**
27+
* This component is a wrapper of the external-login component that loads up the RegistrationData.
28+
*/
3729
export class ExternalLoginPageComponent implements OnInit {
3830
/**
3931
* The token used to get the registration data,

src/app/external-login-review-account-info-page/external-login-review-account-info-page.component.ts

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,7 @@
1-
import {
2-
AsyncPipe,
3-
NgIf,
4-
} from '@angular/common';
5-
import {
6-
Component,
7-
OnInit,
8-
} from '@angular/core';
1+
import { AsyncPipe, NgIf, } from '@angular/common';
2+
import { Component, OnInit, } from '@angular/core';
93
import { ActivatedRoute } from '@angular/router';
10-
import {
11-
first,
12-
map,
13-
Observable,
14-
tap,
15-
} from 'rxjs';
4+
import { first, map, Observable, tap, } from 'rxjs';
165

176
import { RemoteData } from '../core/data/remote-data';
187
import { Registration } from '../core/shared/registration.model';
@@ -32,6 +21,9 @@ import { ReviewAccountInfoComponent } from './review-account-info/review-account
3221
],
3322
standalone: true,
3423
})
24+
/**
25+
* This component is a wrapper for review-account-info component responsible to provide RegistrationData.
26+
*/
3527
export class ExternalLoginReviewAccountInfoPageComponent implements OnInit {
3628
/**
3729
* The token used to get the registration data

0 commit comments

Comments
 (0)