Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions src/app/shared/auth-nav-menu/user-menu/user-menu.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@
[routerLink]="[mydspaceRoute]"
routerLinkActive="active">{{'nav.mydspace' | translate}}</a>
</li>
<li class="ds-menu-item-wrapper" role="presentation" (click)="onMenuItemClick()">
<a class="ds-menu-item" role="menuitem"
[routerLink]="[subscriptionsRoute]"
routerLinkActive="active">{{'nav.subscriptions' | translate}}</a>
</li>
@if (subscribeFeature$ | async) {
<li class="ds-menu-item-wrapper" role="presentation" (click)="onMenuItemClick()">
<a class="ds-menu-item" role="menuitem"
[routerLink]="[subscriptionsRoute]"
routerLinkActive="active">{{'nav.subscriptions' | translate}}</a>
</li>
}
@if (!inExpandableNavbar) {
<li class="dropdown-divider" aria-hidden="true"></li>
<li class="ds-menu-item-wrapper" role="presentation">
Expand Down
14 changes: 14 additions & 0 deletions src/app/shared/auth-nav-menu/user-menu/user-menu.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@ import {
} from '@dspace/core/auth/auth.reducer';
import { AuthService } from '@dspace/core/auth/auth.service';
import { AuthTokenInfo } from '@dspace/core/auth/models/auth-token-info.model';
import { ConfigurationDataService } from '@dspace/core/data/configuration-data.service';
import { APP_DATA_SERVICES_MAP } from '@dspace/core/data-services-map-type';
import { ConfigurationProperty } from '@dspace/core/shared/configuration-property.model';
import { ActivatedRouteStub } from '@dspace/core/testing/active-router.stub';
import { EPersonMock } from '@dspace/core/testing/eperson.mock';
import { TranslateLoaderMock } from '@dspace/core/testing/translate-loader.mock';
import { createSuccessfulRemoteDataObject$ } from '@dspace/core/utilities/remote-data.utils';
import { XSRFService } from '@dspace/core/xsrf/xsrf.service';
import {
Store,
Expand All @@ -44,11 +47,21 @@ describe('UserMenuComponent', () => {
let authState: AuthState;
let authStateLoading: AuthState;
let authService: AuthService;
let configurationDataService: ConfigurationDataService;

function serviceInit() {
authService = jasmine.createSpyObj('authService', {
getAuthenticatedUserFromStore: of(EPersonMock),
});

configurationDataService = jasmine.createSpyObj('configurationDataService', {
findByPropertyName: createSuccessfulRemoteDataObject$(Object.assign(new ConfigurationProperty(), {
name: 'can-subscribe-feature.enable',
values: [
'can-subscribe-feature.enable = true',
],
})),
});
}

function init() {
Expand Down Expand Up @@ -96,6 +109,7 @@ describe('UserMenuComponent', () => {
{ provide: XSRFService, useValue: {} },
{ provide: APP_DATA_SERVICES_MAP, useValue: {} },
{ provide: APP_CONFIG, useValue: { cache: { msToLive: { default: 15 * 60 * 1000 } } } },
{ provide: ConfigurationDataService, useValue: configurationDataService },
],
schemas: [
NO_ERRORS_SCHEMA,
Expand Down
12 changes: 12 additions & 0 deletions src/app/shared/auth-nav-menu/user-menu/user-menu.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,16 @@ import {
} from '@ngrx/store';
import { TranslateModule } from '@ngx-translate/core';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';

import { AppState } from '../../../app.reducer';
import {
getProfileModuleRoute,
getSubscriptionsModuleRoute,
} from '../../../app-routing-paths';
import { ConfigurationDataService } from '../../../core/data/configuration-data.service';
import { ConfigurationProperty } from '../../../core/shared/configuration-property.model';
import { getFirstSucceededRemoteDataPayload } from '../../../core/shared/operators';
import { MYDSPACE_ROUTE } from '../../../my-dspace-page/my-dspace-page.component';
import { ThemedLoadingComponent } from '../../loading/themed-loading.component';
import { LogOutComponent } from '../../log-out/log-out.component';
Expand Down Expand Up @@ -90,10 +94,14 @@ export class UserMenuComponent implements OnInit {
*/
public subscriptionsRoute = getSubscriptionsModuleRoute();

subscribeFeature$: Observable<boolean>;


constructor(
protected store: Store<AppState>,
protected authService: AuthService,
public dsoNameService: DSONameService,
protected configService: ConfigurationDataService,
) {
}

Expand All @@ -108,6 +116,10 @@ export class UserMenuComponent implements OnInit {
// set user
this.user$ = this.authService.getAuthenticatedUserFromStore();

this.subscribeFeature$ = this.configService.findByPropertyName('can-subscribe-feature.enable').pipe(
getFirstSucceededRemoteDataPayload(),
map((res: ConfigurationProperty) => res?.values[0].toLowerCase() === 'true'),
);
}

/**
Expand Down
Loading