Skip to content

Commit 5a53cc9

Browse files
authored
Merge pull request DSpace#3882 from nibou230/2413-bitstream-access-status
Display the access status (embargo) for the bitstream
2 parents 5b7d246 + 0976147 commit 5a53cc9

26 files changed

Lines changed: 277 additions & 78 deletions

File tree

config/config.example.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,8 @@ item:
350350
# Rounded to the nearest size in the list of selectable sizes on the
351351
# settings menu. See pageSizeOptions in 'pagination-component-options.model.ts'.
352352
pageSize: 5
353+
# Show the bitstream access status label on the item page
354+
showAccessStatuses: false
353355

354356
# Community Page Config
355357
community:

src/app/admin/admin-search-page/admin-search-results/admin-search-result-grid-element/item-search-result/item-admin-search-result-grid-element.component.spec.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import { TranslateModule } from '@ngx-translate/core';
1010
import { Observable } from 'rxjs';
1111

1212
import { AuthService } from '../../../../../core/auth/auth.service';
13-
import { AccessStatusDataService } from '../../../../../core/data/access-status-data.service';
1413
import { BitstreamDataService } from '../../../../../core/data/bitstream-data.service';
1514
import { AuthorizationDataService } from '../../../../../core/data/feature-authorization/authorization-data.service';
1615
import { RemoteData } from '../../../../../core/data/remote-data';
@@ -22,7 +21,6 @@ import { ViewMode } from '../../../../../core/shared/view-mode.model';
2221
import { mockTruncatableService } from '../../../../../shared/mocks/mock-trucatable.service';
2322
import { getMockThemeService } from '../../../../../shared/mocks/theme-service.mock';
2423
import { CollectionElementLinkType } from '../../../../../shared/object-collection/collection-element-link.type';
25-
import { AccessStatusObject } from '../../../../../shared/object-collection/shared/badges/access-status-badge/access-status.model';
2624
import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model';
2725
import { createSuccessfulRemoteDataObject$ } from '../../../../../shared/remote-data.utils';
2826
import { AuthServiceStub } from '../../../../../shared/testing/auth-service.stub';
@@ -44,12 +42,6 @@ describe('ItemAdminSearchResultGridElementComponent', () => {
4442
},
4543
};
4644

47-
const mockAccessStatusDataService = {
48-
findAccessStatusFor(item: Item): Observable<RemoteData<AccessStatusObject>> {
49-
return createSuccessfulRemoteDataObject$(new AccessStatusObject());
50-
},
51-
};
52-
5345
const mockThemeService = getMockThemeService();
5446

5547
function init() {
@@ -74,7 +66,6 @@ describe('ItemAdminSearchResultGridElementComponent', () => {
7466
{ provide: TruncatableService, useValue: mockTruncatableService },
7567
{ provide: BitstreamDataService, useValue: mockBitstreamDataService },
7668
{ provide: ThemeService, useValue: mockThemeService },
77-
{ provide: AccessStatusDataService, useValue: mockAccessStatusDataService },
7869
{ provide: AuthService, useClass: AuthServiceStub },
7970
{ provide: FileService, useClass: FileServiceStub },
8071
{ provide: AuthorizationDataService, useClass: AuthorizationDataServiceStub },

src/app/core/data/access-status-data.service.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ describe('AccessStatusDataService', () => {
4646
createService();
4747
});
4848

49-
describe('when calling findAccessStatusFor', () => {
49+
describe('when calling findItemAccessStatusFor', () => {
5050
let contentSource$;
5151

5252
beforeEach(() => {
53-
contentSource$ = service.findAccessStatusFor(mockItem);
53+
contentSource$ = service.findItemAccessStatusFor(mockItem);
5454
});
5555

5656
it('should send a new GetRequest', fakeAsync(() => {

src/app/core/data/access-status-data.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export class AccessStatusDataService extends BaseDataService<AccessStatusObject>
2929
* Returns {@link RemoteData} of {@link AccessStatusObject} that is the access status of the given item
3030
* @param item Item we want the access status of
3131
*/
32-
findAccessStatusFor(item: Item): Observable<RemoteData<AccessStatusObject>> {
32+
findItemAccessStatusFor(item: Item): Observable<RemoteData<AccessStatusObject>> {
3333
return this.findByHref(item._links.accessStatus.href);
3434
}
3535
}

src/app/core/provide-core.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@ export const models =
176176
ResearcherProfile,
177177
OrcidQueue,
178178
OrcidHistory,
179-
AccessStatusObject,
180179
IdentifierData,
181180
Subscription,
182181
ItemRequest,

src/app/core/shared/bitstream.model.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import {
44
inheritSerialization,
55
} from 'cerialize';
66
import { Observable } from 'rxjs';
7+
import { AccessStatusObject } from 'src/app/shared/object-collection/shared/badges/access-status-badge/access-status.model';
8+
import { ACCESS_STATUS } from 'src/app/shared/object-collection/shared/badges/access-status-badge/access-status.resource-type';
79

810
import {
911
link,
@@ -52,6 +54,7 @@ export class Bitstream extends DSpaceObject implements ChildHALResource {
5254
format: HALLink;
5355
content: HALLink;
5456
thumbnail: HALLink;
57+
accessStatus: HALLink;
5558
};
5659

5760
/**
@@ -75,6 +78,13 @@ export class Bitstream extends DSpaceObject implements ChildHALResource {
7578
@link(BUNDLE)
7679
bundle?: Observable<RemoteData<Bundle>>;
7780

81+
/**
82+
* The access status for this Bitstream
83+
* Will be undefined unless the access status {@link HALLink} has been resolved.
84+
*/
85+
@link(ACCESS_STATUS, false, 'accessStatus')
86+
accessStatus?: Observable<RemoteData<AccessStatusObject>>;
87+
7888
getParentLinkKey(): keyof this['_links'] {
7989
return 'format';
8090
}

src/app/core/shared/item.model.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ export class Item extends DSpaceObject implements ChildHALResource, HandleObject
130130
* The access status for this Item
131131
* Will be undefined unless the access status {@link HALLink} has been resolved.
132132
*/
133-
@link(ACCESS_STATUS)
133+
@link(ACCESS_STATUS, false, 'accessStatus')
134134
accessStatus?: Observable<RemoteData<AccessStatusObject>>;
135135

136136
/**

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ export class FullFileSectionComponent extends FileSectionComponent implements On
109109
true,
110110
followLink('format'),
111111
followLink('thumbnail'),
112+
followLink('accessStatus'),
112113
)),
113114
tap((rd: RemoteData<PaginatedList<Bitstream>>) => {
114115
if (hasValue(rd.errorMessage)) {
@@ -127,6 +128,7 @@ export class FullFileSectionComponent extends FileSectionComponent implements On
127128
true,
128129
followLink('format'),
129130
followLink('thumbnail'),
131+
followLink('accessStatus'),
130132
)),
131133
tap((rd: RemoteData<PaginatedList<Bitstream>>) => {
132134
if (hasValue(rd.errorMessage)) {

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import { ThemedLoadingComponent } from '../../../../shared/loading/themed-loadin
2828
import { MetadataFieldWrapperComponent } from '../../../../shared/metadata-field-wrapper/metadata-field-wrapper.component';
2929
import { NotificationsService } from '../../../../shared/notifications/notifications.service';
3030
import { FileSizePipe } from '../../../../shared/utils/file-size-pipe';
31+
import { followLink } from '../../../../shared/utils/follow-link-config.model';
3132
import { VarDirective } from '../../../../shared/utils/var.directive';
3233

3334
/**
@@ -109,7 +110,7 @@ export class FileSectionComponent implements OnInit {
109110
this.bitstreamDataService.findAllByItemAndBundleName(this.item, 'ORIGINAL', {
110111
currentPage: this.currentPage,
111112
elementsPerPage: this.pageSize,
112-
}).pipe(
113+
}, true, true, followLink('accessStatus')).pipe(
113114
getFirstCompletedRemoteData(),
114115
).subscribe((bitstreamsRD: RemoteData<PaginatedList<Bitstream>>) => {
115116
if (bitstreamsRD.errorMessage) {

src/app/process-page/detail/process-detail.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ <h1 class="flex-grow-1">
2929
[title]="'process.detail.output-files'">
3030
<div class="d-flex flex-column">
3131
@for (file of files; track file; let last = $last) {
32-
<ds-file-download-link [bitstream]="file">
32+
<ds-file-download-link [bitstream]="file" [showAccessStatusBadge]="false">
3333
<span>{{getFileName(file)}}</span>
3434
<span>({{(file?.sizeBytes) | dsFileSize }})</span>
3535
</ds-file-download-link>

0 commit comments

Comments
 (0)