Skip to content

Commit 0b3cb79

Browse files
authored
Merge branch 'main' into w2p-121534_removed-metadata-export-search-request-for-non-admins-on-search_contribute-main
2 parents feceb21 + 3ca56c3 commit 0b3cb79

File tree

10 files changed

+254
-142
lines changed

10 files changed

+254
-142
lines changed

package-lock.json

Lines changed: 37 additions & 88 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@
196196
"compression-webpack-plugin": "^9.2.0",
197197
"copy-webpack-plugin": "^6.4.1",
198198
"cross-env": "^7.0.3",
199-
"cypress": "^13.15.1",
199+
"cypress": "^13.16.0",
200200
"cypress-axe": "^1.5.0",
201201
"deep-freeze": "0.0.1",
202202
"eslint": "^8.39.0",

src/app/item-page/orcid-page/orcid-auth/orcid-auth.component.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
} from '@ngx-translate/core';
2020
import {
2121
BehaviorSubject,
22+
catchError,
2223
Observable,
2324
} from 'rxjs';
2425
import { map } from 'rxjs/operators';
@@ -34,6 +35,7 @@ import { Item } from '../../../core/shared/item.model';
3435
import { getFirstCompletedRemoteData } from '../../../core/shared/operators';
3536
import { AlertComponent } from '../../../shared/alert/alert.component';
3637
import { NotificationsService } from '../../../shared/notifications/notifications.service';
38+
import { createFailedRemoteDataObjectFromError$ } from '../../../shared/remote-data.utils';
3739

3840
@Component({
3941
selector: 'ds-orcid-auth',
@@ -203,13 +205,14 @@ export class OrcidAuthComponent implements OnInit, OnChanges {
203205
this.unlinkProcessing.next(true);
204206
this.orcidAuthService.unlinkOrcidByItem(this.item).pipe(
205207
getFirstCompletedRemoteData(),
208+
catchError(createFailedRemoteDataObjectFromError$<ResearcherProfile>),
206209
).subscribe((remoteData: RemoteData<ResearcherProfile>) => {
207210
this.unlinkProcessing.next(false);
208-
if (remoteData.isSuccess) {
211+
if (remoteData.hasFailed) {
212+
this.notificationsService.error(this.translateService.get('person.page.orcid.unlink.error'));
213+
} else {
209214
this.notificationsService.success(this.translateService.get('person.page.orcid.unlink.success'));
210215
this.unlink.emit();
211-
} else {
212-
this.notificationsService.error(this.translateService.get('person.page.orcid.unlink.error'));
213216
}
214217
});
215218
}

src/app/item-page/orcid-page/orcid-page.component.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
combineLatest,
2121
} from 'rxjs';
2222
import {
23+
filter,
2324
map,
2425
take,
2526
} from 'rxjs/operators';
@@ -187,8 +188,20 @@ export class OrcidPageComponent implements OnInit {
187188
*/
188189
private clearRouteParams(): void {
189190
// update route removing the code from query params
190-
const redirectUrl = this.router.url.split('?')[0];
191-
this.router.navigate([redirectUrl]);
191+
this.route.queryParamMap
192+
.pipe(
193+
filter((paramMap: ParamMap) => isNotEmpty(paramMap.keys)),
194+
map(_ => Object.assign({})),
195+
take(1),
196+
).subscribe(queryParams =>
197+
this.router.navigate(
198+
[],
199+
{
200+
relativeTo: this.route,
201+
queryParams,
202+
},
203+
),
204+
);
192205
}
193206

194207
}

src/app/item-page/orcid-page/orcid-sync-settings/orcid-sync-settings.component.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ describe('OrcidSyncSettingsComponent test suite', () => {
180180
scheduler = getTestScheduler();
181181
fixture = TestBed.createComponent(OrcidSyncSettingsComponent);
182182
comp = fixture.componentInstance;
183+
researcherProfileService.findByRelatedItem.and.returnValue(createSuccessfulRemoteDataObject$(mockResearcherProfile));
183184
comp.item = mockItemLinkedToOrcid;
184185
fixture.detectChanges();
185186
}));
@@ -216,7 +217,6 @@ describe('OrcidSyncSettingsComponent test suite', () => {
216217
});
217218

218219
it('should call updateByOrcidOperations properly', () => {
219-
researcherProfileService.findByRelatedItem.and.returnValue(createSuccessfulRemoteDataObject$(mockResearcherProfile));
220220
researcherProfileService.patch.and.returnValue(createSuccessfulRemoteDataObject$(mockResearcherProfile));
221221
const expectedOps: Operation[] = [
222222
{
@@ -245,7 +245,6 @@ describe('OrcidSyncSettingsComponent test suite', () => {
245245
});
246246

247247
it('should show notification on success', () => {
248-
researcherProfileService.findByRelatedItem.and.returnValue(createSuccessfulRemoteDataObject$(mockResearcherProfile));
249248
researcherProfileService.patch.and.returnValue(createSuccessfulRemoteDataObject$(mockResearcherProfile));
250249

251250
scheduler.schedule(() => comp.onSubmit(formGroup));
@@ -257,6 +256,8 @@ describe('OrcidSyncSettingsComponent test suite', () => {
257256

258257
it('should show notification on error', () => {
259258
researcherProfileService.findByRelatedItem.and.returnValue(createFailedRemoteDataObject$());
259+
comp.item = mockItemLinkedToOrcid;
260+
fixture.detectChanges();
260261

261262
scheduler.schedule(() => comp.onSubmit(formGroup));
262263
scheduler.flush();
@@ -266,7 +267,6 @@ describe('OrcidSyncSettingsComponent test suite', () => {
266267
});
267268

268269
it('should show notification on error', () => {
269-
researcherProfileService.findByRelatedItem.and.returnValue(createSuccessfulRemoteDataObject$(mockResearcherProfile));
270270
researcherProfileService.patch.and.returnValue(createFailedRemoteDataObject$());
271271

272272
scheduler.schedule(() => comp.onSubmit(formGroup));

0 commit comments

Comments
 (0)