Skip to content

Commit f5740f8

Browse files
abolliniatarix83
authored andcommitted
Merged in DSC-1403 (pull request DSpace#1066)
[CST-12522] removed isAuthenticated from context-menu.component.html Approved-by: Giuseppe Digilio
2 parents 53906d1 + 0eb4104 commit f5740f8

File tree

3 files changed

+13
-41
lines changed

3 files changed

+13
-41
lines changed

src/app/shared/context-menu/context-menu.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div class="d-flex space-children-mr justify-content-end" *ngIf="((isAuthenticated | async) || isItem()) && contextMenuObject">
1+
<div class="d-flex space-children-mr justify-content-end" *ngIf="contextMenuObject">
22
<ng-container *ngFor="let entry of (getStandAloneMenuEntries() | async)">
33
<ng-container *ngComponentOutlet="entry; injector: objectInjector;"></ng-container>
44
</ng-container>

src/app/shared/context-menu/context-menu.component.spec.ts

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/t
44
import { By } from '@angular/platform-browser';
55

66
import { NgbDropdownModule } from '@ng-bootstrap/ng-bootstrap';
7-
import { cold } from 'jasmine-marbles';
87
import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
98
import { Store } from '@ngrx/store';
109
import { of } from 'rxjs';
@@ -155,13 +154,13 @@ describe('ContextMenuComponent', () => {
155154
done();
156155
});
157156

158-
it('should display d-none', (done) => {
157+
it('should use d-none', (done) => {
159158
const menu = fixture.debugElement.query(By.css('div.d-none'));
160159
expect(menu).not.toBeNull();
161160
done();
162161
});
163162

164-
it('should not display d-inline-block', (done) => {
163+
it('should not use d-inline-block', (done) => {
165164
const menu = fixture.debugElement.query(By.css('div.d-inline-block'));
166165
expect(menu).toBeNull();
167166
done();
@@ -173,11 +172,6 @@ describe('ContextMenuComponent', () => {
173172
done();
174173
});
175174

176-
it('should check the authorization of the current user', (done) => {
177-
expect(component.isAuthenticated).toBeObservable(cold('a', { a: true }));
178-
done();
179-
});
180-
181175
it('should not have menu entries when are disabled on rest side', (done) => {
182176
component.contextMenuObjectType = DSpaceObjectType.COMMUNITY;
183177
configurationDataService.findByPropertyName.and.returnValues(
@@ -218,34 +212,29 @@ describe('ContextMenuComponent', () => {
218212
done();
219213
});
220214

221-
it('should not display context menu', (done) => {
215+
it('should display context menu', (done) => {
222216
const menu = fixture.debugElement.query(By.css('button#context-menu'));
223217
expect(menu).not.toBeNull();
224218
done();
225219
});
226220

227-
it('should display d-none', (done) => {
221+
it('should use d-none', (done) => {
228222
const menu = fixture.debugElement.query(By.css('div.d-none'));
229223
expect(menu).not.toBeNull();
230224
done();
231225
});
232226

233-
it('should not display d-inline-block', (done) => {
227+
it('should not use d-inline-block', (done) => {
234228
const menu = fixture.debugElement.query(By.css('div.d-inline-block'));
235229
expect(menu).toBeNull();
236230
done();
237231
});
238232

239-
it('should not display stand alone buttons', (done) => {
233+
it('should display stand alone buttons', (done) => {
240234
const menu = fixture.debugElement.query(By.css('button.btn-primary'));
241235
expect(menu).not.toBeNull();
242236
done();
243237
});
244-
245-
it('should check the authorization of the current user', (done) => {
246-
expect(component.isAuthenticated).toBeObservable(cold('a', { a: false }));
247-
done();
248-
});
249238
});
250239

251240
describe('and the object type is not ITEM', () => {
@@ -259,9 +248,9 @@ describe('ContextMenuComponent', () => {
259248
done();
260249
});
261250

262-
it('should not display context menu', (done) => {
251+
it('should display context menu', (done) => {
263252
const menu = fixture.debugElement.query(By.css('button#context-menu'));
264-
expect(menu).toBeNull();
253+
expect(menu).not.toBeNull();
265254
done();
266255
});
267256

@@ -271,14 +260,9 @@ describe('ContextMenuComponent', () => {
271260
done();
272261
});
273262

274-
it('should not display d-none', (done) => {
263+
it('should display d-none', (done) => {
275264
const menu = fixture.debugElement.query(By.css('div.d-none'));
276-
expect(menu).toBeNull();
277-
done();
278-
});
279-
280-
it('should check the authorization of the current user', (done) => {
281-
expect(component.isAuthenticated).toBeObservable(cold('a', { a: false }));
265+
expect(menu).not.toBeNull();
282266
done();
283267
});
284268
});

src/app/shared/context-menu/context-menu.component.ts

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
import { ChangeDetectorRef, Component, Inject, Injector, Input, OnInit } from '@angular/core';
22
import { DOCUMENT } from '@angular/common';
33

4-
import { select, Store } from '@ngrx/store';
54
import { from, Observable } from 'rxjs';
65
import { concatMap, filter, map, reduce, take } from 'rxjs/operators';
76

8-
import { CoreState } from '../../core/core-state.model';
9-
import { isAuthenticated } from '../../core/auth/selectors';
107
import { DSpaceObject } from '../../core/shared/dspace-object.model';
118
import { DSpaceObjectType } from '../../core/shared/dspace-object-type.model';
129
import { ContextMenuEntryRenderOptions, getContextMenuEntriesForDSOType } from './context-menu.decorator';
@@ -39,12 +36,6 @@ export class ContextMenuComponent implements OnInit {
3936
*/
4037
@Input() contextMenuObjectType: DSpaceObjectType;
4138

42-
/**
43-
* Whether user is authenticated.
44-
* @type {Observable<string>}
45-
*/
46-
public isAuthenticated: Observable<boolean>;
47-
4839
/**
4940
* Injector to inject a menu entry component with the @Input parameters
5041
* @type {Injector}
@@ -61,16 +52,15 @@ export class ContextMenuComponent implements OnInit {
6152
* Initialize instance variables
6253
*
6354
* @param {Document} _document
55+
* @param {ChangeDetectorRef} cdr
6456
* @param {ConfigurationDataService} configurationService
6557
* @param {Injector} injector
66-
* @param {Store<CoreState>} store
6758
*/
6859
constructor(
6960
@Inject(DOCUMENT) private _document: Document,
7061
private cdr: ChangeDetectorRef,
7162
private configurationService: ConfigurationDataService,
72-
private injector: Injector,
73-
private store: Store<CoreState>
63+
private injector: Injector
7464
) {
7565
}
7666

@@ -82,8 +72,6 @@ export class ContextMenuComponent implements OnInit {
8272
],
8373
parent: this.injector
8474
});
85-
// set isAuthenticated
86-
this.isAuthenticated = this.store.pipe(select(isAuthenticated));
8775
}
8876

8977
/**

0 commit comments

Comments
 (0)