diff --git a/src/app/app-routes.ts b/src/app/app-routes.ts index 29a78364b53..51101f5a2d8 100644 --- a/src/app/app-routes.ts +++ b/src/app/app-routes.ts @@ -63,7 +63,7 @@ export const APP_ROUTES: Route[] = [ path: 'home', loadChildren: () => import('./home-page/home-page-routes') .then((m) => m.ROUTES), - data: { showBreadcrumbs: false }, + data: { showBreadcrumbs: false, enableRSS: true }, providers: [provideSuggestionNotificationsState()], canActivate: [endUserAgreementCurrentUserGuard], }, @@ -101,12 +101,14 @@ export const APP_ROUTES: Route[] = [ path: COMMUNITY_MODULE_PATH, loadChildren: () => import('./community-page/community-page-routes') .then((m) => m.ROUTES), + data: { enableRSS: true }, canActivate: [endUserAgreementCurrentUserGuard], }, { path: COLLECTION_MODULE_PATH, loadChildren: () => import('./collection-page/collection-page-routes') .then((m) => m.ROUTES), + data: { showBreadcrumbs: false, enableRSS: true }, canActivate: [endUserAgreementCurrentUserGuard], }, { @@ -137,6 +139,7 @@ export const APP_ROUTES: Route[] = [ path: 'mydspace', loadChildren: () => import('./my-dspace-page/my-dspace-page-routes') .then((m) => m.ROUTES), + data: { enableRSS: true }, providers: [provideSuggestionNotificationsState()], canActivate: [authenticatedGuard, endUserAgreementCurrentUserGuard], }, @@ -144,6 +147,7 @@ export const APP_ROUTES: Route[] = [ path: 'search', loadChildren: () => import('./search-page/search-page-routes') .then((m) => m.ROUTES), + data: { enableRSS: true }, canActivate: [endUserAgreementCurrentUserGuard], }, { @@ -156,6 +160,7 @@ export const APP_ROUTES: Route[] = [ path: ADMIN_MODULE_PATH, loadChildren: () => import('./admin/admin-routes') .then((m) => m.ROUTES), + data: { enableRSS: true }, canActivate: [siteAdministratorGuard, endUserAgreementCurrentUserGuard], }, { @@ -200,6 +205,7 @@ export const APP_ROUTES: Route[] = [ providers: [provideSubmissionState()], loadChildren: () => import('./workflowitems-edit-page/workflowitems-edit-page-routes') .then((m) => m.ROUTES), + data: { enableRSS: true }, canActivate: [endUserAgreementCurrentUserGuard], }, { diff --git a/src/app/shared/rss-feed/rss.component.html b/src/app/shared/rss-feed/rss.component.html index d2cd6e0ca11..133880c593a 100644 --- a/src/app/shared/rss-feed/rss.component.html +++ b/src/app/shared/rss-feed/rss.component.html @@ -1,5 +1,5 @@ + *ngIf="(isEnabled$ | async) && (isActivated$ | async)">
diff --git a/src/app/shared/rss-feed/rss.component.spec.ts b/src/app/shared/rss-feed/rss.component.spec.ts index 09d9863a28b..0a813bb4ea4 100644 --- a/src/app/shared/rss-feed/rss.component.spec.ts +++ b/src/app/shared/rss-feed/rss.component.spec.ts @@ -3,7 +3,7 @@ import { TestBed, waitForAsync, } from '@angular/core/testing'; -import { Router } from '@angular/router'; +import { ActivatedRoute, Router } from '@angular/router'; import { TranslateService } from '@ngx-translate/core'; import { of as observableOf } from 'rxjs'; @@ -32,6 +32,7 @@ import { PaginationServiceStub } from '../testing/pagination-service.stub'; import { SearchConfigurationServiceStub } from '../testing/search-configuration-service.stub'; import { createPaginatedList } from '../testing/utils.test'; import { RSSComponent } from './rss.component'; +import { MockActivatedRoute } from '../mocks/active-router.mock'; describe('RssComponent', () => { let comp: RSSComponent; @@ -94,6 +95,7 @@ describe('RssComponent', () => { { provide: SearchConfigurationService, useValue: new SearchConfigurationServiceStub() }, { provide: PaginationService, useValue: paginationService }, { provide: Router, useValue: new RouterMock() }, + { provide: ActivatedRoute, useValue: new MockActivatedRoute }, { provide: TranslateService, useValue: getMockTranslateService() }, ], declarations: [], diff --git a/src/app/shared/rss-feed/rss.component.ts b/src/app/shared/rss-feed/rss.component.ts index 376bd7ad536..216526a103c 100644 --- a/src/app/shared/rss-feed/rss.component.ts +++ b/src/app/shared/rss-feed/rss.component.ts @@ -9,7 +9,7 @@ import { OnInit, ViewEncapsulation, } from '@angular/core'; -import { Router } from '@angular/router'; +import { ActivatedRoute, Router } from '@angular/router'; import { TranslateModule, TranslateService, @@ -34,6 +34,8 @@ import { getFirstCompletedRemoteData } from '../../core/shared/operators'; import { SearchConfigurationService } from '../../core/shared/search/search-configuration.service'; import { PaginatedSearchOptions } from '../search/models/paginated-search-options.model'; import { SearchFilter } from '../search/models/search-filter.model'; +import { hasValue } from '../empty.util'; +import { isUndefined } from 'lodash'; /** * The Rss feed button component. */ @@ -53,6 +55,8 @@ export class RSSComponent implements OnInit, OnDestroy { isEnabled$: BehaviorSubject = new BehaviorSubject(null); + isActivated$: BehaviorSubject = new BehaviorSubject(false); + uuid: string; subs: Subscription[] = []; @@ -62,6 +66,7 @@ export class RSSComponent implements OnInit, OnDestroy { private configurationService: ConfigurationDataService, private searchConfigurationService: SearchConfigurationService, private router: Router, + private route: ActivatedRoute, protected paginationService: PaginationService, protected translateService: TranslateService) { } @@ -80,6 +85,11 @@ export class RSSComponent implements OnInit, OnDestroy { * Generates the link tags and the url to opensearch when the component is loaded. */ ngOnInit(): void { + if (hasValue(this.route.snapshot.data?.enableRSS)) { + this.isActivated$.next(this.route.snapshot.data.enableRSS); + } else if (isUndefined(this.route.snapshot.data?.enableRSS)) { + this.isActivated$.next(false); + } this.subs.push(this.configurationService.findByPropertyName('websvc.opensearch.enable').pipe( getFirstCompletedRemoteData(), ).subscribe((result) => {