Skip to content

Commit

Permalink
Merged in task/dspace-cris-2023_02_x/DSC-1893 (pull request DSpace#2275)
Browse files Browse the repository at this point in the history
[DSC-1893] item-alert: hide redirect to home button for administrators

Approved-by: Francesco Molinaro
  • Loading branch information
alisaismailati authored and FrancescoMolinaro committed Sep 18, 2024
2 parents dd06969 + 9746d2a commit ae3b249
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/app/item-page/alerts/item-alerts.component.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div>
<div class="pb-3">
<div *ngIf="item && !item.isDiscoverable" class="private-warning">
<ds-alert [type]="AlertTypeEnum.Warning" [content]="'item.alerts.private' | translate"></ds-alert>
</div>
Expand All @@ -8,7 +8,7 @@
<span class="align-self-center">{{'item.alerts.withdrawn' | translate}}</span>
</div>
</ds-alert>
<p class="text-center">
<p class="text-center" *ngIf="!(isAdministrator$ | async)">
<a routerLink="/home" class="btn btn-primary">{{"410.link.home-page" | translate}}</a>
</p>
</div>
Expand Down
7 changes: 6 additions & 1 deletion src/app/item-page/alerts/item-alerts.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { TranslateModule } from '@ngx-translate/core';
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { Item } from '../../core/shared/item.model';
import { By } from '@angular/platform-browser';
import {AuthorizationDataService} from '../../core/data/feature-authorization/authorization-data.service';
import {AuthorizationDataServiceStub} from '../../shared/testing/authorization-service.stub';

describe('ItemAlertsComponent', () => {
let component: ItemAlertsComponent;
Expand All @@ -14,7 +16,10 @@ describe('ItemAlertsComponent', () => {
TestBed.configureTestingModule({
declarations: [ItemAlertsComponent],
imports: [TranslateModule.forRoot()],
schemas: [NO_ERRORS_SCHEMA]
schemas: [NO_ERRORS_SCHEMA],
providers: [
{ provide: AuthorizationDataService, useClass: AuthorizationDataServiceStub }
]
})
.compileComponents();
}));
Expand Down
16 changes: 14 additions & 2 deletions src/app/item-page/alerts/item-alerts.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { Component, Input } from '@angular/core';
import {Component, Input, OnInit} from '@angular/core';
import { Item } from '../../core/shared/item.model';
import { AlertType } from '../../shared/alert/alert-type';
import {Observable} from 'rxjs';
import {FeatureID} from '../../core/data/feature-authorization/feature-id';
import {AuthorizationDataService} from '../../core/data/feature-authorization/authorization-data.service';

@Component({
selector: 'ds-item-alerts',
Expand All @@ -10,7 +13,7 @@ import { AlertType } from '../../shared/alert/alert-type';
/**
* Component displaying alerts for an item
*/
export class ItemAlertsComponent {
export class ItemAlertsComponent implements OnInit {
/**
* The Item to display alerts for
*/
Expand All @@ -21,4 +24,13 @@ export class ItemAlertsComponent {
* @type {AlertType}
*/
public AlertTypeEnum = AlertType;

isAdministrator$: Observable<boolean>;

constructor(private authorizationService: AuthorizationDataService) {
}

ngOnInit() {
this.isAdministrator$ = this.authorizationService.isAuthorized(FeatureID.AdministratorOf);
}
}

0 comments on commit ae3b249

Please sign in to comment.