Skip to content

Commit 64dd288

Browse files
committed
PD-5112 update deprecation process
1 parent 02aa368 commit 64dd288

5 files changed

Lines changed: 116 additions & 86 deletions

File tree

src/app/account-settings/components/settings-actions-duplicated/settings-actions-duplicated.component.html

Lines changed: 54 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,28 @@
11
<app-settings-panels-data>
2+
@if (success) {
3+
<app-alert-message type="success" class="mb-4.5">
4+
<h4 title i18n>Duplicate account removed</h4>
5+
<p
6+
content
7+
class="mt-0.5"
8+
i18n="
9+
successful deprecation message|orcidToDeprecate=accound id that was
10+
deprecated
11+
"
12+
>
13+
<span>The record</span>&nbsp;<strong>{{ orcidToDeprecate }}</strong
14+
>&nbsp;<span>has been deprecated.</span>
15+
</p>
16+
</app-alert-message>
17+
} @if (cancelAuthentication) {
18+
<app-alert-message type="warning" class="mb-4.5">
19+
<h4 title i18n>Duplicate account not removed</h4>
20+
<p content class="mt-0.5" i18n>
21+
We could not verify your ORCID account details. The duplicate record has
22+
not been deprecated.
23+
</p>
24+
</app-alert-message>
25+
}
226
<p i18n="@@account.ifYouHaveTwoorMore" class="mb-0 leading-5.25">
327
If you have two or more ORCID records you can easily remove any unwanted
428
duplicates.
@@ -16,97 +40,45 @@
1640
</p>
1741

1842
<app-alert-message class="row mb-8">
19-
<h3 title i18n>What happens when you remove a duplicate ORCID account?</h3>
43+
<h4 title i18n>What happens when you remove a duplicate ORCID account?</h4>
2044

2145
<ul content i18n>
22-
<li class="list-disc">
46+
<li class="list-disc!">
2347
The email addresses are transferred from the duplicate account to
2448
<strong>{{ orcid }}</strong>
2549
</li>
26-
<li class="list-disc">
50+
<li class="list-disc!">
2751
All information on the duplicate account is permanently deleted
2852
</li>
2953
</ul>
3054
</app-alert-message>
3155
@if (authenticated) {
3256
<form [formGroup]="form" (ngSubmit)="onSubmit()">
33-
<ng-container *ngIf="data.deprecatingAccountName">
34-
<strong
35-
>{{ data.deprecatingAccountName }}
36-
<a
37-
id="cy-deprecating-orcid"
38-
class="underline"
39-
routerLink="/"
40-
+
41-
data.deprecatingOrcid
42-
rel="noopener noreferrer"
43-
target="_blank"
44-
>({{ data.deprecatingOrcid }})</a
45-
></strong
46-
>
47-
</ng-container>
48-
<ng-container *ngIf="!data.deprecatingAccountName">
49-
<strong
50-
><ng-container i18n="@@account.nameIsPri">Name is private</ng-container>
51-
<a
52-
id="cy-deprecating-orcid"
53-
class="underline"
54-
routerLink="/"
55-
+
56-
data.deprecatingOrcid
57-
rel="noopener noreferrer"
58-
target="_blank"
59-
>{{ data.deprecatingOrcid }}</a
60-
></strong
61-
>
62-
</ng-container>
63-
<div *ngFor="let email of data.deprecatingEmails">{{ email }}</div>
64-
65-
<h2 class="keep">
66-
<strong class="orc-font-body-large" i18n="@@account.keepThisRecord"
67-
>Keep this record</strong
68-
>
69-
</h2>
70-
71-
<ng-container *ngIf="data.primaryAccountName">
72-
<strong
73-
>{{ data.primaryAccountName }}
74-
<a
75-
id="cy-primary-orcid"
76-
class="underline"
77-
routerLink="/"
78-
+
79-
data.primaryOrcid
80-
rel="noopener noreferrer"
81-
target="_blank"
82-
>({{ data.primaryOrcid }})</a
83-
></strong
84-
>
85-
</ng-container>
86-
<ng-container *ngIf="!data.primaryAccountName">
87-
<strong>
88-
<a
89-
id="cy-primary-orcid"
90-
class="underline"
91-
routerLink="/"
92-
+
93-
data.primaryOrcid
94-
rel="noopener noreferrer"
95-
target="_blank"
96-
>{{ data.primaryOrcid }}</a
97-
></strong
98-
>
99-
</ng-container>
100-
<div *ngFor="let email of data.primaryEmails">{{ email }}</div>
57+
<h3 i18n class="mb-2 mt-0">You are removing this duplicate account</h3>
58+
@if (data.deprecatingAccountName) {
59+
<p class="leading-5.25">{{ data.deprecatingAccountName }}</p>
60+
} @else {
61+
<p class="leading-5.25" i18n="@@account.nameIsPri">Name is private</p>
62+
}
63+
<p class="mb-6! leading-5.25">
64+
https:{{ baseUrl + data.deprecatingOrcid }}
65+
</p>
10166

67+
<strong i18n class="leading-5.25"
68+
>Email addresses to be transferred to this account</strong
69+
>&nbsp;<strong>({{ orcid }})</strong>
70+
<div class="mb-6!">{{ data.deprecatingEmails?.join(', ') }}</div>
71+
<em class="block mb-8!" i18n
72+
>All other information on this account will be permanently deleted.</em
73+
>
10274
<button
10375
mat-raised-button
10476
color="warn"
105-
(click)="onSubmit()"
106-
i18n="@@account.removeDuplicatedRecord"
77+
type="submit"
78+
i18n
10779
id="cy-remove-duplicate-record"
10880
>
109-
Remove duplicate record
81+
Remove duplicate account
11082
</button>
11183
</form>
11284
} @else {
@@ -129,7 +101,8 @@ <h3 i18n class="mt-0 mb-2">Which account do you want to remove?</h3>
129101
</label>
130102
<mat-form-field
131103
appearance="outline"
132-
class="mat-form-field-min input-container"
104+
subscriptSizing="dynamic"
105+
class="mat-form-field-min input-container mb-6!"
133106
>
134107
<input
135108
formControlName="deprecatingOrcidOrEmail"
@@ -152,7 +125,8 @@ <h3 i18n class="mt-0 mb-2">Which account do you want to remove?</h3>
152125
</label>
153126
<mat-form-field
154127
appearance="outline"
155-
class="mat-form-field-min input-container mb-8"
128+
subscriptSizing="dynamic"
129+
class="mat-form-field-min input-container mb-8!"
156130
>
157131
<input
158132
formControlName="password"
@@ -164,14 +138,16 @@ <h3 i18n class="mt-0 mb-2">Which account do you want to remove?</h3>
164138
/>
165139
</mat-form-field>
166140

167-
<mat-error *ngFor="let error of errors">{{ error }}</mat-error>
141+
<mat-error class="mb-4! -mt-2!" *ngFor="let error of errors">{{
142+
error
143+
}}</mat-error>
168144

169145
<div class="button-container">
170146
<button
171147
mat-raised-button
172148
i18n
173149
type="submit"
174-
[disabled]="form.invalid"
150+
[disabled]="form.invalid || loadingVerify"
175151
class="cy-remove-duplicated-record"
176152
>
177153
Verify duplicate account details

src/app/account-settings/components/settings-actions-duplicated/settings-actions-duplicated.component.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ ul {
1111
.button-container {
1212
display: flex;
1313
align-items: row;
14-
margin-top: 16px;
1514
}
1615

1716
:host {
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
@use '@angular/material' as mat;
2+
@import 'src/assets/scss/material.orcid-theme.scss';
3+
4+
@mixin settings-actions-duplicated($theme) {
5+
$primary: map-get($theme, primary);
6+
$accent: map-get($theme, accent);
7+
$warn: map-get($theme, accent);
8+
$foreground: map-get($theme, foreground);
9+
$background: map-get($theme, background);
10+
11+
.cy-remove-duplicated-record {
12+
background: $brand-secondary-dark !important;
13+
color: white !important;
14+
}
15+
16+
.cy-remove-duplicated-record[disabled] {
17+
opacity: 30%;
18+
}
19+
20+
#cy-remove-duplicate-record {
21+
background-color: $state-warning-darkest !important;
22+
color: white !important;
23+
}
24+
}
25+
26+
@include settings-actions-duplicated($orcid-app-theme);

src/app/account-settings/components/settings-actions-duplicated/settings-actions-duplicated.component.ts

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'
22
import {
3+
FormGroupDirective,
4+
NgForm,
35
UntypedFormBuilder,
6+
UntypedFormControl,
47
UntypedFormGroup,
58
Validators,
69
} from '@angular/forms'
@@ -15,16 +18,27 @@ import { AuthChallengeComponent } from '@orcid/registry-ui'
1518
import { AuthChallengeFormData } from '../../../types/common.endpoint'
1619
import { DuplicateRemoveEndpoint } from '../../../types/account-actions-duplicated'
1720
import { ErrorStateMatcherForTwoFactorFields } from '../../../sign-in/ErrorStateMatcherForTwoFactorFields'
18-
21+
import { ErrorStateMatcher } from '@angular/material/core'
22+
export class NeverShowErrorMatcher implements ErrorStateMatcher {
23+
isErrorState(
24+
control: UntypedFormControl | null,
25+
form: FormGroupDirective | NgForm | null
26+
): boolean {
27+
return false
28+
}
29+
}
1930
@Component({
2031
selector: 'app-settings-actions-duplicated',
2132
templateUrl: './settings-actions-duplicated.component.html',
22-
styleUrls: ['./settings-actions-duplicated.component.scss'],
33+
styleUrls: [
34+
'./settings-actions-duplicated.component.scss',
35+
'./settings-actions-duplicated.component.scss-theme.scss',
36+
],
2337
preserveWhitespaces: true,
2438
standalone: false,
2539
})
2640
export class SettingsActionsDuplicatedComponent implements OnInit {
27-
errorMatcher = new ErrorStateMatcherForTwoFactorFields()
41+
errorMatcher = new NeverShowErrorMatcher()
2842
userSession: UserSession
2943
constructor(
3044
private _duplicateService: AccountActionsDuplicatedService,
@@ -44,10 +58,13 @@ export class SettingsActionsDuplicatedComponent implements OnInit {
4458
showBadVerificationCode = false
4559
show2FA = true
4660
authenticated = false
61+
loadingVerify = false
4762
cancelAuthentication = false
4863
success = false
64+
orcidToDeprecate = ''
4965
orcid = ''
5066
data: DuplicateRemoveEndpoint
67+
baseUrl = runtimeEnvironment.BASE_URL
5168

5269
ngOnInit(): void {
5370
this.form = this._form.group({
@@ -68,15 +85,15 @@ export class SettingsActionsDuplicatedComponent implements OnInit {
6885
})
6986
}
7087

71-
openAuthChallenge(orcid: string) {
88+
openAuthChallenge(orcidOrEmail: string) {
7289
const dialogRef = this._dialog.open<AuthChallengeComponent>(
7390
AuthChallengeComponent,
7491
{
7592
data: {
7693
parentForm: this.form,
7794
showPasswordField: false,
7895
actionDescription: this.authChallengeLeadingText,
79-
boldText: orcid,
96+
boldText: orcidOrEmail,
8097
trailingText: this.authChallengeTrailingText,
8198
} as AuthChallengeFormData,
8299
}
@@ -88,6 +105,7 @@ export class SettingsActionsDuplicatedComponent implements OnInit {
88105
this._duplicateService.validateDeprecation(this.form.value).subscribe({
89106
next: (response: any) => {
90107
if (response.success) {
108+
this.orcidToDeprecate = response.deprecatingOrcid
91109
this.data = response
92110
dialogRef.close(true)
93111
} else {
@@ -102,6 +120,7 @@ export class SettingsActionsDuplicatedComponent implements OnInit {
102120
if (document.activeElement instanceof HTMLElement) {
103121
document.activeElement.blur()
104122
}
123+
this.loadingVerify = false
105124
this.form.reset()
106125
if (success) {
107126
this.authenticated = true
@@ -113,21 +132,30 @@ export class SettingsActionsDuplicatedComponent implements OnInit {
113132

114133
submitVerify() {
115134
if (this.form.valid) {
135+
this.cancelAuthentication = false
136+
this.success = false
137+
this.loadingVerify = true
116138
this._duplicateService.validateDeprecation(this.form.value).subscribe({
117139
next: (response: any) => {
118140
this.errors = []
119141
this.loading.next(false)
120142
if (response.success) {
143+
this.loadingVerify = false
144+
this.orcidToDeprecate = response.deprecatingOrcid
121145
this.data = response
122146
this.authenticated = true
123147
} else {
124148
if (response.errors?.length) {
149+
this.loadingVerify = false
125150
this.errors = response.errors
126151
} else if (response.twoFactorEnabled) {
127-
this.openAuthChallenge(response.deprecatingOrcid)
152+
this.openAuthChallenge(response.deprecatingOrcidOrEmail)
128153
}
129154
}
130155
},
156+
error: () => {
157+
this.loadingVerify = false
158+
},
131159
})
132160
}
133161
}
@@ -144,7 +172,7 @@ export class SettingsActionsDuplicatedComponent implements OnInit {
144172
this.form.reset()
145173
this.success = true
146174
}
147-
if (data.errors?.length) {
175+
if (data.errors?.length || !data.twoFactorToken) {
148176
this.errors = data.errors
149177
this.cancelAuthentication = true
150178
}

src/app/types/account-actions-duplicated.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ export interface DuplicateRemoveEndpoint extends AuthChallenge {
1010
primaryEmails?: string[]
1111
primaryOrcid?: string
1212
primaryAccountName?: string
13+
twoFactorToken?: string
1314
verificationCodeRequired?: boolean
1415
}

0 commit comments

Comments
 (0)