Skip to content

Commit 0920964

Browse files
[DSC-1601] - Added new implementation when bitstream is restricted
1 parent 604f37c commit 0920964

3 files changed

Lines changed: 15 additions & 4 deletions

File tree

src/app/item-page/full/field-components/file-section/full-file-section.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ <h5 class="simple-view-element-header">{{"item.page.filesection.original.bundle"
3434
</dl>
3535
</div>
3636
<div *ngIf="!hasNoDownload(file)" class="col-2">
37-
<ds-themed-file-download-link [bitstream]="file" [item]="item">
38-
{{"item.page.filesection.download" | translate}}
37+
<ds-themed-file-download-link [showIcon]="(canDownload(file) | async)" [bitstream]="file" [item]="item">
38+
{{"item.page.filesection.download" | translate}}
3939
</ds-themed-file-download-link>
4040
</div>
4141
</div>

src/app/item-page/full/field-components/file-section/full-file-section.component.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,16 @@ import { FileSectionComponent } from '../../../simple/field-components/file-sect
99
import { PaginationComponentOptions } from '../../../../shared/pagination/pagination-component-options.model';
1010
import { PaginatedList } from '../../../../core/data/paginated-list.model';
1111
import { RemoteData } from '../../../../core/data/remote-data';
12-
import { switchMap, tap } from 'rxjs/operators';
12+
import { map, switchMap, tap } from 'rxjs/operators';
1313
import { NotificationsService } from '../../../../shared/notifications/notifications.service';
1414
import { TranslateService } from '@ngx-translate/core';
1515
import { hasValue, isEmpty } from '../../../../shared/empty.util';
1616
import { PaginationService } from '../../../../core/pagination/pagination.service';
1717
import { DSONameService } from '../../../../core/breadcrumbs/dso-name.service';
1818
import { AppConfig, APP_CONFIG } from 'src/config/app-config.interface';
1919
import { UUIDService } from '../../../../core/shared/uuid.service';
20+
import { AuthorizationDataService } from '../../../../core/data/feature-authorization/authorization-data.service';
21+
import { FeatureID } from '../../../../core/data/feature-authorization/feature-id';
2022

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

118+
canDownload(file: Bitstream): Observable<boolean> {
119+
return this.authorizationService.isAuthorized(FeatureID.CanDownload, file.self).pipe(
120+
map(value => !value),
121+
);
122+
}
123+
115124
ngOnDestroy(): void {
116125
this.paginationService.clearPagination(this.originalOptions.id);
117126
this.paginationService.clearPagination(this.licenseOptions.id);

src/app/shared/file-download-link/themed-file-download-link.component.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ export class ThemedFileDownloadLinkComponent extends ThemedComponent<FileDownloa
2121

2222
@Input() enableRequestACopy: boolean;
2323

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

2628
protected getComponentName(): string {
2729
return 'FileDownloadLinkComponent';

0 commit comments

Comments
 (0)