diff --git a/src/app/item-page/alerts/item-alerts.component.spec.ts b/src/app/item-page/alerts/item-alerts.component.spec.ts index 3ba8801784..474621f14f 100644 --- a/src/app/item-page/alerts/item-alerts.component.spec.ts +++ b/src/app/item-page/alerts/item-alerts.component.spec.ts @@ -109,7 +109,7 @@ describe('ItemAlertsComponent', () => { }); }); - it('should return true when user is not an admin and there is at least one correction with topic REQUEST_REINSTATE', fakeAsync(() => { + it('should return true when user is not an admin and there is at least one correction with topic REQUEST_REINSTATE', fakeAsync((done) => { const isAdmin = false; const correction = [{ topic: 'REQUEST_REINSTATE' }]; authorizationService.isAuthorized.and.returnValue(of(isAdmin)); @@ -119,6 +119,7 @@ describe('ItemAlertsComponent', () => { tick(); result$.subscribe((result) => { expect(result).toBeTrue(); + done(); }); })); }); diff --git a/src/app/item-page/simple/qa-event-notification/qa-event-notification.component.html b/src/app/item-page/simple/qa-event-notification/qa-event-notification.component.html index 169fe00950..5b3bb021f2 100644 --- a/src/app/item-page/simple/qa-event-notification/qa-event-notification.component.html +++ b/src/app/item-page/simple/qa-event-notification/qa-event-notification.component.html @@ -1,24 +1,21 @@
+
+ +
- - - {{ - (isAdmin$ | async) ? ('qa-event-notification.check.notification-withdrawn.admin' | translate : { source: (source.id | dsSplit: ':')[0], num: source.totalEvents }) - : ('qa-event-notification.check.notification-withdrawn.user' | translate : { num: source.totalEvents }) - }} - - - - {{ 'qa-event-notification.check.notification-reinstate' | translate: { num: source.totalEvents } }} - + {{'item.qa-event-notification.check.notification-info' | translate : {num: source.totalEvents } }}
+ class="btn btn-primary align-self-center"> + {{'item.qa-event-notification-info.check.button' | translate}} +
diff --git a/src/app/item-page/simple/qa-event-notification/qa-event-notification.component.spec.ts b/src/app/item-page/simple/qa-event-notification/qa-event-notification.component.spec.ts index a9d16440a8..ce231affee 100644 --- a/src/app/item-page/simple/qa-event-notification/qa-event-notification.component.spec.ts +++ b/src/app/item-page/simple/qa-event-notification/qa-event-notification.component.spec.ts @@ -13,7 +13,6 @@ import { RemoteDataBuildService } from '../../../core/cache/builders/remote-data import { provideMockStore } from '@ngrx/store/testing'; import { HALEndpointService } from '../../../core/shared/hal-endpoint.service'; import { HALEndpointServiceStub } from '../../../shared/testing/hal-endpoint-service.stub'; -import { AuthorizationDataService } from '../../../core/data/feature-authorization/authorization-data.service'; import { of } from 'rxjs'; import { By } from '@angular/platform-browser'; import { SplitPipe } from 'src/app/shared/utils/split.pipe'; @@ -22,7 +21,6 @@ describe('QaEventNotificationComponent', () => { let component: QaEventNotificationComponent; let fixture: ComponentFixture; let qualityAssuranceSourceDataServiceStub: any; - let authorizationService: AuthorizationDataService; const obj = Object.assign(new QualityAssuranceSourceObject(), { id: 'sourceName:target', @@ -34,9 +32,6 @@ describe('QaEventNotificationComponent', () => { const objPL = createSuccessfulRemoteDataObject$(createPaginatedList([obj])); const item = Object.assign({ uuid: '1234' }); beforeEach(async () => { - authorizationService = jasmine.createSpyObj('authorizationService', { - isAuthorized: of(true) - }); qualityAssuranceSourceDataServiceStub = { getSourcesByTarget: () => objPL @@ -49,7 +44,6 @@ describe('QaEventNotificationComponent', () => { { provide: RequestService, useValue: {} }, { provide: NotificationsService, useValue: {} }, { provide: HALEndpointService, useValue: new HALEndpointServiceStub('test') }, - { provide: AuthorizationDataService, useValue: authorizationService }, ObjectCacheService, RemoteDataBuildService, provideMockStore({}) diff --git a/src/app/item-page/simple/qa-event-notification/qa-event-notification.component.ts b/src/app/item-page/simple/qa-event-notification/qa-event-notification.component.ts index 6f8e55c9d2..1557a65a0e 100644 --- a/src/app/item-page/simple/qa-event-notification/qa-event-notification.component.ts +++ b/src/app/item-page/simple/qa-event-notification/qa-event-notification.component.ts @@ -9,9 +9,7 @@ import { QualityAssuranceSourceObject } from '../../../core/notifications/qa/mod import { catchError, map } from 'rxjs/operators'; import { RemoteData } from '../../../core/data/remote-data'; import { getNotificatioQualityAssuranceRoute } from '../../../admin/admin-routing-paths'; -import { PaginatedList } from 'src/app/core/data/paginated-list.model'; -import { AuthorizationDataService } from 'src/app/core/data/feature-authorization/authorization-data.service'; -import { FeatureID } from 'src/app/core/data/feature-authorization/feature-id'; +import { PaginatedList } from '../../../core/data/paginated-list.model'; @Component({ selector: 'ds-qa-event-notification', @@ -33,17 +31,10 @@ export class QaEventNotificationComponent implements OnChanges { * An observable that emits an array of QualityAssuranceSourceObject. */ sources$: Observable; - /** - * An observable that emits a boolean representing whether the current user is an admin. - */ - isAdmin$: Observable; constructor( private qualityAssuranceSourceDataService: QualityAssuranceSourceDataService, - private authService: AuthorizationDataService, - ) { - this.isAdmin$ = this.authService.isAuthorized(FeatureID.AdministratorOf); - } + ) {} /** * Detect changes to the item input and update the sources$ observable. diff --git a/src/app/menu.resolver.ts b/src/app/menu.resolver.ts index 94b56ba99d..9272ed06ea 100644 --- a/src/app/menu.resolver.ts +++ b/src/app/menu.resolver.ts @@ -171,7 +171,8 @@ export class MenuResolver implements Resolve { this.authorizationService.isAuthorized(FeatureID.AdministratorOf), this.authorizationService.isAuthorized(FeatureID.CanSubmit), this.authorizationService.isAuthorized(FeatureID.CanEditItem), - ]).subscribe(([isCollectionAdmin, isCommunityAdmin, isSiteAdmin, canSubmit, canEditItem]) => { + this.authorizationService.isAuthorized(FeatureID.CanSeeQA) + ]).subscribe(([isCollectionAdmin, isCommunityAdmin, isSiteAdmin, canSubmit, canEditItem, canSeeQa]) => { const newSubMenuList = [ { id: 'new_community', @@ -362,6 +363,40 @@ export class MenuResolver implements Resolve { icon: 'heartbeat', index: 11 }, + /* Notifications */ + { + id: 'notifications', + active: false, + visible: canSeeQa || isSiteAdmin, + model: { + type: MenuItemType.TEXT, + text: 'menu.section.notifications' + } as TextMenuItemModel, + icon: 'bell', + index: 4 + }, + { + id: 'notifications_quality-assurance', + parentID: 'notifications', + active: false, + visible: canSeeQa, + model: { + type: MenuItemType.LINK, + text: 'menu.section.quality-assurance', + link: '/notifications/quality-assurance' + } as LinkMenuItemModel, + }, + { + id: 'notifications_publication-claim', + parentID: 'notifications', + active: false, + visible: isSiteAdmin, + model: { + type: MenuItemType.LINK, + text: 'menu.section.notifications_publication-claim', + link: '/notifications/' + PUBLICATION_CLAIMS_PATH + } as LinkMenuItemModel, + }, ]; menuList.forEach((menuSection) => this.menuService.addSection(MenuID.ADMIN, Object.assign(menuSection, { shouldPersistOnRouteChange: true @@ -531,46 +566,9 @@ export class MenuResolver implements Resolve { * Create menu sections dependent on whether or not the current user is a site administrator */ createSiteAdministratorMenuSections() { - combineLatest([ - this.authorizationService.isAuthorized(FeatureID.AdministratorOf), - this.authorizationService.isAuthorized(FeatureID.CanSeeQA) - ]) - .subscribe(([authorized, canSeeQA]) => { + this.authorizationService.isAuthorized(FeatureID.AdministratorOf) + .subscribe((authorized) => { const menuList = [ - /* Notifications */ - { - id: 'notifications', - active: false, - visible: authorized && canSeeQA, - model: { - type: MenuItemType.TEXT, - text: 'menu.section.notifications' - } as TextMenuItemModel, - icon: 'bell', - index: 4 - }, - { - id: 'notifications_quality-assurance', - parentID: 'notifications', - active: false, - visible: authorized, - model: { - type: MenuItemType.LINK, - text: 'menu.section.quality-assurance', - link: '/notifications/quality-assurance' - } as LinkMenuItemModel, - }, - { - id: 'notifications_publication-claim', - parentID: 'notifications', - active: false, - visible: authorized, - model: { - type: MenuItemType.LINK, - text: 'menu.section.notifications_publication-claim', - link: '/admin/notifications/' + PUBLICATION_CLAIMS_PATH - } as LinkMenuItemModel, - }, /* Admin Search */ { id: 'admin_search', diff --git a/src/app/my-dspace-page/my-dspace-page.component.html b/src/app/my-dspace-page/my-dspace-page.component.html index 70bcf1b7bc..cfae8e07a8 100644 --- a/src/app/my-dspace-page/my-dspace-page.component.html +++ b/src/app/my-dspace-page/my-dspace-page.component.html @@ -1,7 +1,7 @@
+ -