Skip to content

Commit

Permalink
[DSC-1601] - Added new implementation when bitstream is restricted
Browse files Browse the repository at this point in the history
  • Loading branch information
Simone-Ramundi committed Apr 27, 2024
1 parent 604f37c commit 0920964
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ <h5 class="simple-view-element-header">{{"item.page.filesection.original.bundle"
</dl>
</div>
<div *ngIf="!hasNoDownload(file)" class="col-2">
<ds-themed-file-download-link [bitstream]="file" [item]="item">
{{"item.page.filesection.download" | translate}}
<ds-themed-file-download-link [showIcon]="(canDownload(file) | async)" [bitstream]="file" [item]="item">
{{"item.page.filesection.download" | translate}}
</ds-themed-file-download-link>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@ import { FileSectionComponent } from '../../../simple/field-components/file-sect
import { PaginationComponentOptions } from '../../../../shared/pagination/pagination-component-options.model';
import { PaginatedList } from '../../../../core/data/paginated-list.model';
import { RemoteData } from '../../../../core/data/remote-data';
import { switchMap, tap } from 'rxjs/operators';
import { map, switchMap, tap } from 'rxjs/operators';
import { NotificationsService } from '../../../../shared/notifications/notifications.service';
import { TranslateService } from '@ngx-translate/core';
import { hasValue, isEmpty } from '../../../../shared/empty.util';
import { PaginationService } from '../../../../core/pagination/pagination.service';
import { DSONameService } from '../../../../core/breadcrumbs/dso-name.service';
import { AppConfig, APP_CONFIG } from 'src/config/app-config.interface';
import { UUIDService } from '../../../../core/shared/uuid.service';
import { AuthorizationDataService } from '../../../../core/data/feature-authorization/authorization-data.service';
import { FeatureID } from '../../../../core/data/feature-authorization/feature-id';

/**
* This component renders the file section of the item
Expand Down Expand Up @@ -56,6 +58,7 @@ export class FullFileSectionComponent extends FileSectionComponent implements On
protected paginationService: PaginationService,
public dsoNameService: DSONameService,
protected uuidService: UUIDService,
public authorizationService: AuthorizationDataService,
@Inject(APP_CONFIG) protected appConfig: AppConfig
) {
super(bitstreamDataService, notificationsService, translateService, dsoNameService, appConfig);
Expand Down Expand Up @@ -112,6 +115,12 @@ export class FullFileSectionComponent extends FileSectionComponent implements On
return bitstream?.allMetadataValues('bitstream.viewer.provider').includes('nodownload');
}

canDownload(file: Bitstream): Observable<boolean> {
return this.authorizationService.isAuthorized(FeatureID.CanDownload, file.self).pipe(
map(value => !value),
);
}

ngOnDestroy(): void {
this.paginationService.clearPagination(this.originalOptions.id);
this.paginationService.clearPagination(this.licenseOptions.id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ export class ThemedFileDownloadLinkComponent extends ThemedComponent<FileDownloa

@Input() enableRequestACopy: boolean;

protected inAndOutputNames: (keyof FileDownloadLinkComponent & keyof this)[] = ['bitstream', 'item', 'cssClasses', 'isBlank', 'enableRequestACopy'];
@Input() showIcon: boolean;

protected inAndOutputNames: (keyof FileDownloadLinkComponent & keyof this)[] = ['bitstream', 'item', 'cssClasses', 'isBlank', 'enableRequestACopy', 'showIcon'];

protected getComponentName(): string {
return 'FileDownloadLinkComponent';
Expand Down

0 comments on commit 0920964

Please sign in to comment.