diff --git a/src/app/shared/context-menu/context-menu.component.html b/src/app/shared/context-menu/context-menu.component.html index b4c140c6dba..f68bbc697ee 100644 --- a/src/app/shared/context-menu/context-menu.component.html +++ b/src/app/shared/context-menu/context-menu.component.html @@ -1,4 +1,4 @@ -
+
diff --git a/src/app/shared/context-menu/context-menu.component.spec.ts b/src/app/shared/context-menu/context-menu.component.spec.ts index df63e67392c..6f1669d403a 100644 --- a/src/app/shared/context-menu/context-menu.component.spec.ts +++ b/src/app/shared/context-menu/context-menu.component.spec.ts @@ -4,7 +4,6 @@ import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/t import { By } from '@angular/platform-browser'; import { NgbDropdownModule } from '@ng-bootstrap/ng-bootstrap'; -import { cold } from 'jasmine-marbles'; import { TranslateLoader, TranslateModule } from '@ngx-translate/core'; import { Store } from '@ngrx/store'; import { of } from 'rxjs'; @@ -155,13 +154,13 @@ describe('ContextMenuComponent', () => { done(); }); - it('should display d-none', (done) => { + it('should use d-none', (done) => { const menu = fixture.debugElement.query(By.css('div.d-none')); expect(menu).not.toBeNull(); done(); }); - it('should not display d-inline-block', (done) => { + it('should not use d-inline-block', (done) => { const menu = fixture.debugElement.query(By.css('div.d-inline-block')); expect(menu).toBeNull(); done(); @@ -173,11 +172,6 @@ describe('ContextMenuComponent', () => { done(); }); - it('should check the authorization of the current user', (done) => { - expect(component.isAuthenticated).toBeObservable(cold('a', { a: true })); - done(); - }); - it('should not have menu entries when are disabled on rest side', (done) => { component.contextMenuObjectType = DSpaceObjectType.COMMUNITY; configurationDataService.findByPropertyName.and.returnValues( @@ -218,34 +212,29 @@ describe('ContextMenuComponent', () => { done(); }); - it('should not display context menu', (done) => { + it('should display context menu', (done) => { const menu = fixture.debugElement.query(By.css('button#context-menu')); expect(menu).not.toBeNull(); done(); }); - it('should display d-none', (done) => { + it('should use d-none', (done) => { const menu = fixture.debugElement.query(By.css('div.d-none')); expect(menu).not.toBeNull(); done(); }); - it('should not display d-inline-block', (done) => { + it('should not use d-inline-block', (done) => { const menu = fixture.debugElement.query(By.css('div.d-inline-block')); expect(menu).toBeNull(); done(); }); - it('should not display stand alone buttons', (done) => { + it('should display stand alone buttons', (done) => { const menu = fixture.debugElement.query(By.css('button.btn-primary')); expect(menu).not.toBeNull(); done(); }); - - it('should check the authorization of the current user', (done) => { - expect(component.isAuthenticated).toBeObservable(cold('a', { a: false })); - done(); - }); }); describe('and the object type is not ITEM', () => { @@ -259,9 +248,9 @@ describe('ContextMenuComponent', () => { done(); }); - it('should not display context menu', (done) => { + it('should display context menu', (done) => { const menu = fixture.debugElement.query(By.css('button#context-menu')); - expect(menu).toBeNull(); + expect(menu).not.toBeNull(); done(); }); @@ -271,14 +260,9 @@ describe('ContextMenuComponent', () => { done(); }); - it('should not display d-none', (done) => { + it('should display d-none', (done) => { const menu = fixture.debugElement.query(By.css('div.d-none')); - expect(menu).toBeNull(); - done(); - }); - - it('should check the authorization of the current user', (done) => { - expect(component.isAuthenticated).toBeObservable(cold('a', { a: false })); + expect(menu).not.toBeNull(); done(); }); }); diff --git a/src/app/shared/context-menu/context-menu.component.ts b/src/app/shared/context-menu/context-menu.component.ts index 9c047f23b32..25f19813093 100644 --- a/src/app/shared/context-menu/context-menu.component.ts +++ b/src/app/shared/context-menu/context-menu.component.ts @@ -1,12 +1,9 @@ import { ChangeDetectorRef, Component, Inject, Injector, Input, OnInit } from '@angular/core'; import { DOCUMENT } from '@angular/common'; -import { select, Store } from '@ngrx/store'; import { from, Observable } from 'rxjs'; import { concatMap, filter, map, reduce, take } from 'rxjs/operators'; -import { CoreState } from '../../core/core-state.model'; -import { isAuthenticated } from '../../core/auth/selectors'; import { DSpaceObject } from '../../core/shared/dspace-object.model'; import { DSpaceObjectType } from '../../core/shared/dspace-object-type.model'; import { ContextMenuEntryRenderOptions, getContextMenuEntriesForDSOType } from './context-menu.decorator'; @@ -39,12 +36,6 @@ export class ContextMenuComponent implements OnInit { */ @Input() contextMenuObjectType: DSpaceObjectType; - /** - * Whether user is authenticated. - * @type {Observable} - */ - public isAuthenticated: Observable; - /** * Injector to inject a menu entry component with the @Input parameters * @type {Injector} @@ -61,16 +52,15 @@ export class ContextMenuComponent implements OnInit { * Initialize instance variables * * @param {Document} _document + * @param {ChangeDetectorRef} cdr * @param {ConfigurationDataService} configurationService * @param {Injector} injector - * @param {Store} store */ constructor( @Inject(DOCUMENT) private _document: Document, private cdr: ChangeDetectorRef, private configurationService: ConfigurationDataService, - private injector: Injector, - private store: Store + private injector: Injector ) { } @@ -82,8 +72,6 @@ export class ContextMenuComponent implements OnInit { ], parent: this.injector }); - // set isAuthenticated - this.isAuthenticated = this.store.pipe(select(isAuthenticated)); } /**