forked from DSpace/dspace-angular
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request DSpace#1638 from 4Science/CST-5249_suggestion
Openaire suggestions (publication claim)
- Loading branch information
Showing
107 changed files
with
6,494 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
...ons-publication-claim-page/admin-notifications-publication-claim-page-resolver.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { ActivatedRouteSnapshot, Resolve, RouterStateSnapshot } from '@angular/router'; | ||
|
||
/** | ||
* Interface for the route parameters. | ||
*/ | ||
export interface AdminNotificationsPublicationClaimPageParams { | ||
pageId?: string; | ||
pageSize?: number; | ||
currentPage?: number; | ||
} | ||
|
||
/** | ||
* This class represents a resolver that retrieve the route data before the route is activated. | ||
*/ | ||
@Injectable() | ||
export class AdminNotificationsPublicationClaimPageResolver implements Resolve<AdminNotificationsPublicationClaimPageParams> { | ||
|
||
/** | ||
* Method for resolving the parameters in the current route. | ||
* @param {ActivatedRouteSnapshot} route The current ActivatedRouteSnapshot | ||
* @param {RouterStateSnapshot} state The current RouterStateSnapshot | ||
* @returns AdminNotificationsSuggestionTargetsPageParams Emits the route parameters | ||
*/ | ||
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): AdminNotificationsPublicationClaimPageParams { | ||
return { | ||
pageId: route.queryParams.pageId, | ||
pageSize: parseInt(route.queryParams.pageSize, 10), | ||
currentPage: parseInt(route.queryParams.page, 10) | ||
}; | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...ications-publication-claim-page/admin-notifications-publication-claim-page.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<ds-publication-claim [source]="'openaire'"></ds-publication-claim> |
Empty file.
38 changes: 38 additions & 0 deletions
38
...tions-publication-claim-page/admin-notifications-publication-claim-page.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { AdminNotificationsPublicationClaimPageComponent } from './admin-notifications-publication-claim-page.component'; | ||
import { NO_ERRORS_SCHEMA } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
import { TranslateModule } from '@ngx-translate/core'; | ||
|
||
describe('AdminNotificationsPublicationClaimPageComponent', () => { | ||
let component: AdminNotificationsPublicationClaimPageComponent; | ||
let fixture: ComponentFixture<AdminNotificationsPublicationClaimPageComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [ | ||
CommonModule, | ||
TranslateModule.forRoot() | ||
], | ||
declarations: [ | ||
AdminNotificationsPublicationClaimPageComponent | ||
], | ||
providers: [ | ||
AdminNotificationsPublicationClaimPageComponent | ||
], | ||
schemas: [NO_ERRORS_SCHEMA] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(AdminNotificationsPublicationClaimPageComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
10 changes: 10 additions & 0 deletions
10
...ifications-publication-claim-page/admin-notifications-publication-claim-page.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'ds-admin-notifications-publication-claim-page', | ||
templateUrl: './admin-notifications-publication-claim-page.component.html', | ||
styleUrls: ['./admin-notifications-publication-claim-page.component.scss'] | ||
}) | ||
export class AdminNotificationsPublicationClaimPageComponent { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/app/core/breadcrumbs/publication-claim-breadcrumb.resolver.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { PublicationClaimBreadcrumbResolver } from './publication-claim-breadcrumb.resolver'; | ||
|
||
describe('PublicationClaimBreadcrumbResolver', () => { | ||
describe('resolve', () => { | ||
let resolver: PublicationClaimBreadcrumbResolver; | ||
let publicationClaimBreadcrumbService: any; | ||
const fullPath = '/test/publication-claim/openaire:6bee076d-4f2a-4555-a475-04a267769b2a'; | ||
const expectedKey = '6bee076d-4f2a-4555-a475-04a267769b2a'; | ||
const expectedId = 'openaire:6bee076d-4f2a-4555-a475-04a267769b2a'; | ||
let route; | ||
|
||
beforeEach(() => { | ||
route = { | ||
paramMap: { | ||
get: function (param) { | ||
return this[param]; | ||
}, | ||
targetId: expectedId, | ||
} | ||
}; | ||
publicationClaimBreadcrumbService = {}; | ||
resolver = new PublicationClaimBreadcrumbResolver(publicationClaimBreadcrumbService); | ||
}); | ||
|
||
it('should resolve the breadcrumb config', () => { | ||
const resolvedConfig = resolver.resolve(route as any, {url: fullPath } as any); | ||
const expectedConfig = { provider: publicationClaimBreadcrumbService, key: expectedKey }; | ||
expect(resolvedConfig).toEqual(expectedConfig); | ||
}); | ||
}); | ||
}); |
24 changes: 24 additions & 0 deletions
24
src/app/core/breadcrumbs/publication-claim-breadcrumb.resolver.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { ActivatedRouteSnapshot, Resolve, RouterStateSnapshot } from '@angular/router'; | ||
import {BreadcrumbConfig} from '../../breadcrumbs/breadcrumb/breadcrumb-config.model'; | ||
import { PublicationClaimBreadcrumbService } from './publication-claim-breadcrumb.service'; | ||
|
||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class PublicationClaimBreadcrumbResolver implements Resolve<BreadcrumbConfig<string>> { | ||
constructor(protected breadcrumbService: PublicationClaimBreadcrumbService) { | ||
} | ||
|
||
/** | ||
* Method that resolve Publication Claim item into a breadcrumb | ||
* The parameter are retrieved by the url since part of the Publication Claim route config | ||
* @param {ActivatedRouteSnapshot} route The current ActivatedRouteSnapshot | ||
* @param {RouterStateSnapshot} state The current RouterStateSnapshot | ||
* @returns BreadcrumbConfig object | ||
*/ | ||
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): BreadcrumbConfig<string> { | ||
const targetId = route.paramMap.get('targetId').split(':')[1]; | ||
return { provider: this.breadcrumbService, key: targetId }; | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
src/app/core/breadcrumbs/publication-claim-breadcrumb.service.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { TestBed, waitForAsync } from '@angular/core/testing'; | ||
import { Breadcrumb } from '../../breadcrumbs/breadcrumb/breadcrumb.model'; | ||
import { getTestScheduler } from 'jasmine-marbles'; | ||
import { PublicationClaimBreadcrumbService } from './publication-claim-breadcrumb.service'; | ||
import { createSuccessfulRemoteDataObject$ } from '../../shared/remote-data.utils'; | ||
import { of } from 'rxjs'; | ||
|
||
describe('PublicationClaimBreadcrumbService', () => { | ||
let service: PublicationClaimBreadcrumbService; | ||
let dsoNameService: any = { | ||
getName: (str) => str | ||
}; | ||
let translateService: any = { | ||
instant: (str) => str, | ||
}; | ||
|
||
let dataService: any = { | ||
findById: (str) => createSuccessfulRemoteDataObject$(str), | ||
}; | ||
|
||
let authorizationService: any = { | ||
isAuthorized: (str) => of(true), | ||
}; | ||
|
||
let exampleKey; | ||
|
||
const ADMIN_PUBLICATION_CLAIMS_PATH = 'admin/notifications/publication-claim'; | ||
const ADMIN_PUBLICATION_CLAIMS_BREADCRUMB_KEY = 'admin.notifications.publicationclaim.page.title'; | ||
|
||
function init() { | ||
exampleKey = 'suggestion.suggestionFor.breadcrumb'; | ||
} | ||
|
||
beforeEach(waitForAsync(() => { | ||
init(); | ||
TestBed.configureTestingModule({}).compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
service = new PublicationClaimBreadcrumbService(dataService,dsoNameService,translateService, authorizationService); | ||
}); | ||
|
||
describe('getBreadcrumbs', () => { | ||
it('should return a breadcrumb based on a string', () => { | ||
const breadcrumbs = service.getBreadcrumbs(exampleKey); | ||
getTestScheduler().expectObservable(breadcrumbs).toBe('(a|)', { a: [new Breadcrumb(ADMIN_PUBLICATION_CLAIMS_BREADCRUMB_KEY, ADMIN_PUBLICATION_CLAIMS_PATH), | ||
new Breadcrumb(exampleKey, undefined)] | ||
}); | ||
}); | ||
}); | ||
}); |
46 changes: 46 additions & 0 deletions
46
src/app/core/breadcrumbs/publication-claim-breadcrumb.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { Breadcrumb } from '../../breadcrumbs/breadcrumb/breadcrumb.model'; | ||
import { BreadcrumbsProviderService } from './breadcrumbsProviderService'; | ||
import { combineLatest, Observable } from 'rxjs'; | ||
import { Injectable } from '@angular/core'; | ||
import { ItemDataService } from '../data/item-data.service'; | ||
import { getFirstCompletedRemoteData } from '../shared/operators'; | ||
import { map } from 'rxjs/operators'; | ||
import { DSONameService } from './dso-name.service'; | ||
import { TranslateService } from '@ngx-translate/core'; | ||
import { AuthorizationDataService } from '../data/feature-authorization/authorization-data.service'; | ||
import { FeatureID } from '../data/feature-authorization/feature-id'; | ||
|
||
|
||
|
||
/** | ||
* Service to calculate Publication claims breadcrumbs | ||
*/ | ||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class PublicationClaimBreadcrumbService implements BreadcrumbsProviderService<string> { | ||
private ADMIN_PUBLICATION_CLAIMS_PATH = 'admin/notifications/publication-claim'; | ||
private ADMIN_PUBLICATION_CLAIMS_BREADCRUMB_KEY = 'admin.notifications.publicationclaim.page.title'; | ||
|
||
constructor(private dataService: ItemDataService, | ||
private dsoNameService: DSONameService, | ||
private tranlsateService: TranslateService, | ||
protected authorizationService: AuthorizationDataService) { | ||
} | ||
|
||
|
||
/** | ||
* Method to calculate the breadcrumbs | ||
* @param key The key used to resolve the breadcrumb | ||
*/ | ||
getBreadcrumbs(key: string): Observable<Breadcrumb[]> { | ||
return combineLatest([this.dataService.findById(key).pipe(getFirstCompletedRemoteData()),this.authorizationService.isAuthorized(FeatureID.AdministratorOf)]).pipe( | ||
map(([item, isAdmin]) => { | ||
const itemName = this.dsoNameService.getName(item.payload); | ||
return isAdmin ? [new Breadcrumb(this.tranlsateService.instant(this.ADMIN_PUBLICATION_CLAIMS_BREADCRUMB_KEY), this.ADMIN_PUBLICATION_CLAIMS_PATH), | ||
new Breadcrumb(this.tranlsateService.instant('suggestion.suggestionFor.breadcrumb', {name: itemName}), undefined)] : | ||
[new Breadcrumb(this.tranlsateService.instant('suggestion.suggestionFor.breadcrumb', {name: itemName}), undefined)]; | ||
}) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.