Skip to content

Commit

Permalink
Merge branch 'main' into w2p-121534_removed-metadata-export-search-re…
Browse files Browse the repository at this point in the history
…quest-for-non-admins-on-search_contribute-main
  • Loading branch information
alanorth authored Dec 3, 2024
2 parents feceb21 + 3ca56c3 commit 0b3cb79
Show file tree
Hide file tree
Showing 10 changed files with 254 additions and 142 deletions.
125 changes: 37 additions & 88 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@
"compression-webpack-plugin": "^9.2.0",
"copy-webpack-plugin": "^6.4.1",
"cross-env": "^7.0.3",
"cypress": "^13.15.1",
"cypress": "^13.16.0",
"cypress-axe": "^1.5.0",
"deep-freeze": "0.0.1",
"eslint": "^8.39.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
} from '@ngx-translate/core';
import {
BehaviorSubject,
catchError,
Observable,
} from 'rxjs';
import { map } from 'rxjs/operators';
Expand All @@ -34,6 +35,7 @@ import { Item } from '../../../core/shared/item.model';
import { getFirstCompletedRemoteData } from '../../../core/shared/operators';
import { AlertComponent } from '../../../shared/alert/alert.component';
import { NotificationsService } from '../../../shared/notifications/notifications.service';
import { createFailedRemoteDataObjectFromError$ } from '../../../shared/remote-data.utils';

@Component({
selector: 'ds-orcid-auth',
Expand Down Expand Up @@ -203,13 +205,14 @@ export class OrcidAuthComponent implements OnInit, OnChanges {
this.unlinkProcessing.next(true);
this.orcidAuthService.unlinkOrcidByItem(this.item).pipe(
getFirstCompletedRemoteData(),
catchError(createFailedRemoteDataObjectFromError$<ResearcherProfile>),
).subscribe((remoteData: RemoteData<ResearcherProfile>) => {
this.unlinkProcessing.next(false);
if (remoteData.isSuccess) {
if (remoteData.hasFailed) {
this.notificationsService.error(this.translateService.get('person.page.orcid.unlink.error'));
} else {
this.notificationsService.success(this.translateService.get('person.page.orcid.unlink.success'));
this.unlink.emit();
} else {
this.notificationsService.error(this.translateService.get('person.page.orcid.unlink.error'));
}
});
}
Expand Down
17 changes: 15 additions & 2 deletions src/app/item-page/orcid-page/orcid-page.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
combineLatest,
} from 'rxjs';
import {
filter,
map,
take,
} from 'rxjs/operators';
Expand Down Expand Up @@ -187,8 +188,20 @@ export class OrcidPageComponent implements OnInit {
*/
private clearRouteParams(): void {
// update route removing the code from query params
const redirectUrl = this.router.url.split('?')[0];
this.router.navigate([redirectUrl]);
this.route.queryParamMap
.pipe(
filter((paramMap: ParamMap) => isNotEmpty(paramMap.keys)),
map(_ => Object.assign({})),
take(1),
).subscribe(queryParams =>
this.router.navigate(
[],
{
relativeTo: this.route,
queryParams,
},
),
);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ describe('OrcidSyncSettingsComponent test suite', () => {
scheduler = getTestScheduler();
fixture = TestBed.createComponent(OrcidSyncSettingsComponent);
comp = fixture.componentInstance;
researcherProfileService.findByRelatedItem.and.returnValue(createSuccessfulRemoteDataObject$(mockResearcherProfile));
comp.item = mockItemLinkedToOrcid;
fixture.detectChanges();
}));
Expand Down Expand Up @@ -216,7 +217,6 @@ describe('OrcidSyncSettingsComponent test suite', () => {
});

it('should call updateByOrcidOperations properly', () => {
researcherProfileService.findByRelatedItem.and.returnValue(createSuccessfulRemoteDataObject$(mockResearcherProfile));
researcherProfileService.patch.and.returnValue(createSuccessfulRemoteDataObject$(mockResearcherProfile));
const expectedOps: Operation[] = [
{
Expand Down Expand Up @@ -245,7 +245,6 @@ describe('OrcidSyncSettingsComponent test suite', () => {
});

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

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

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

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

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

scheduler.schedule(() => comp.onSubmit(formGroup));
Expand Down
Loading

0 comments on commit 0b3cb79

Please sign in to comment.