Skip to content

Commit b709ee0

Browse files
118944: Embed the accessStatus link on collection, browse, recent item submissions & the item page related items & delete tab when enabled
1 parent 4af8899 commit b709ee0

File tree

14 files changed

+67
-55
lines changed

14 files changed

+67
-55
lines changed

src/app/collection-page/collection-page.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import { AuthorizationDataService } from '../core/data/feature-authorization/aut
2828
import { FeatureID } from '../core/data/feature-authorization/feature-id';
2929
import { getCollectionPageRoute } from './collection-page-routing-paths';
3030
import { redirectOn4xx } from '../core/shared/authorized.operators';
31-
import { BROWSE_LINKS_TO_FOLLOW } from '../core/browse/browse.service';
31+
import { getBrowseLinksToFollow } from '../core/browse/browse.service';
3232
import { DSONameService } from '../core/breadcrumbs/dso-name.service';
3333
import { APP_CONFIG, AppConfig } from '../../../src/config/app-config.interface';
3434

@@ -115,7 +115,7 @@ export class CollectionPageComponent implements OnInit {
115115
pagination: currentPagination,
116116
sort: currentSort,
117117
dsoTypes: [DSpaceObjectType.ITEM]
118-
}), null, true, true, ...BROWSE_LINKS_TO_FOLLOW)
118+
}), null, true, true, ...getBrowseLinksToFollow())
119119
.pipe(toDSpaceObjectListRD()) as Observable<RemoteData<PaginatedList<Item>>>;
120120
}),
121121
startWith(undefined) // Make sure switching pages shows loading component

src/app/core/breadcrumbs/item-breadcrumb.resolver.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { ItemDataService } from '../data/item-data.service';
44
import { Item } from '../shared/item.model';
55
import { DSOBreadcrumbResolver } from './dso-breadcrumb.resolver';
66
import { FollowLinkConfig } from '../../shared/utils/follow-link-config.model';
7-
import { ITEM_PAGE_LINKS_TO_FOLLOW } from '../../item-page/item.resolver';
7+
import { getItemPageLinksToFollow } from '../../item-page/item.resolver';
88

99
/**
1010
* The class that resolves the BreadcrumbConfig object for an Item
@@ -23,6 +23,6 @@ export class ItemBreadcrumbResolver extends DSOBreadcrumbResolver<Item> {
2323
* Requesting them as embeds will limit the number of requests
2424
*/
2525
get followLinks(): FollowLinkConfig<Item>[] {
26-
return ITEM_PAGE_LINKS_TO_FOLLOW;
26+
return getItemPageLinksToFollow();
2727
}
2828
}

src/app/core/browse/browse.service.spec.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import { cold, getTestScheduler, hot } from 'jasmine-marbles';
22
import { of as observableOf } from 'rxjs';
33
import { TestScheduler } from 'rxjs/testing';
4-
import { getMockRemoteDataBuildService } from '../../shared/mocks/remote-data-build.service.mock';
54
import { getMockRequestService } from '../../shared/mocks/request.service.mock';
65
import { HALEndpointServiceStub } from '../../shared/testing/hal-endpoint-service.stub';
7-
import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service';
86
import { RequestService } from '../data/request.service';
97
import { BrowseEntrySearchOptions } from './browse-entry-search-options.model';
108
import { BrowseService } from './browse.service';
@@ -20,7 +18,6 @@ describe('BrowseService', () => {
2018
let scheduler: TestScheduler;
2119
let service: BrowseService;
2220
let requestService: RequestService;
23-
let rdbService: RemoteDataBuildService;
2421

2522
const browsesEndpointURL = 'https://rest.api/browses';
2623
const halService: any = new HALEndpointServiceStub(browsesEndpointURL);
@@ -118,7 +115,6 @@ describe('BrowseService', () => {
118115
halService,
119116
browseDefinitionDataService,
120117
hrefOnlyDataService,
121-
rdbService
122118
);
123119
}
124120

@@ -130,11 +126,9 @@ describe('BrowseService', () => {
130126

131127
beforeEach(() => {
132128
requestService = getMockRequestService(getRequestEntry$(true));
133-
rdbService = getMockRemoteDataBuildService();
134129
service = initTestService();
135130
spyOn(halService, 'getEndpoint').and
136131
.returnValue(hot('--a-', { a: browsesEndpointURL }));
137-
spyOn(rdbService, 'buildList').and.callThrough();
138132
});
139133

140134
it('should call BrowseDefinitionDataService to create the RemoteData Observable', () => {
@@ -151,9 +145,7 @@ describe('BrowseService', () => {
151145

152146
beforeEach(() => {
153147
requestService = getMockRequestService(getRequestEntry$(true));
154-
rdbService = getMockRemoteDataBuildService();
155148
service = initTestService();
156-
spyOn(rdbService, 'buildList').and.callThrough();
157149
});
158150

159151
describe('when getBrowseEntriesFor is called with a valid browse definition id', () => {
@@ -204,7 +196,6 @@ describe('BrowseService', () => {
204196
describe('if getBrowseDefinitions fires', () => {
205197
beforeEach(() => {
206198
requestService = getMockRequestService(getRequestEntry$(true));
207-
rdbService = getMockRemoteDataBuildService();
208199
service = initTestService();
209200
spyOn(service, 'getBrowseDefinitions').and
210201
.returnValue(hot('--a-', {
@@ -259,7 +250,6 @@ describe('BrowseService', () => {
259250
describe('if getBrowseDefinitions doesn\'t fire', () => {
260251
it('should return undefined', () => {
261252
requestService = getMockRequestService(getRequestEntry$(true));
262-
rdbService = getMockRemoteDataBuildService();
263253
service = initTestService();
264254
spyOn(service, 'getBrowseDefinitions').and
265255
.returnValue(hot('----'));
@@ -277,9 +267,7 @@ describe('BrowseService', () => {
277267
describe('getFirstItemFor', () => {
278268
beforeEach(() => {
279269
requestService = getMockRequestService();
280-
rdbService = getMockRemoteDataBuildService();
281270
service = initTestService();
282-
spyOn(rdbService, 'buildList').and.callThrough();
283271
});
284272

285273
describe('when getFirstItemFor is called with a valid browse definition id', () => {

src/app/core/browse/browse.service.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { Injectable } from '@angular/core';
22
import { Observable } from 'rxjs';
33
import { distinctUntilChanged, map, startWith } from 'rxjs/operators';
44
import { hasValue, hasValueOperator, isEmpty, isNotEmpty } from '../../shared/empty.util';
5-
import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service';
65
import { PaginatedList } from '../data/paginated-list.model';
76
import { RemoteData } from '../data/remote-data';
87
import { RequestService } from '../data/request.service';
@@ -24,11 +23,18 @@ import { HrefOnlyDataService } from '../data/href-only-data.service';
2423
import { followLink, FollowLinkConfig } from '../../shared/utils/follow-link-config.model';
2524
import { BrowseDefinitionDataService } from './browse-definition-data.service';
2625
import { SortDirection } from '../cache/models/sort-options.model';
26+
import { environment } from '../../../environments/environment';
2727

2828

29-
export const BROWSE_LINKS_TO_FOLLOW: FollowLinkConfig<BrowseEntry | Item>[] = [
30-
followLink('thumbnail')
31-
];
29+
export function getBrowseLinksToFollow(): FollowLinkConfig<BrowseEntry | Item>[] {
30+
const followLinks = [
31+
followLink('thumbnail'),
32+
];
33+
if (environment.item.showAccessStatuses) {
34+
followLinks.push(followLink('accessStatus'));
35+
}
36+
return followLinks;
37+
}
3238

3339
/**
3440
* The service handling all browse requests
@@ -55,7 +61,6 @@ export class BrowseService {
5561
protected halService: HALEndpointService,
5662
private browseDefinitionDataService: BrowseDefinitionDataService,
5763
private hrefOnlyDataService: HrefOnlyDataService,
58-
private rdb: RemoteDataBuildService,
5964
) {
6065
}
6166

@@ -105,7 +110,7 @@ export class BrowseService {
105110
})
106111
);
107112
if (options.fetchThumbnail ) {
108-
return this.hrefOnlyDataService.findListByHref<BrowseEntry>(href$, {}, null, null, ...BROWSE_LINKS_TO_FOLLOW);
113+
return this.hrefOnlyDataService.findListByHref<BrowseEntry>(href$, {}, null, null, ...getBrowseLinksToFollow());
109114
}
110115
return this.hrefOnlyDataService.findListByHref<BrowseEntry>(href$);
111116
}
@@ -153,7 +158,7 @@ export class BrowseService {
153158
}),
154159
);
155160
if (options.fetchThumbnail) {
156-
return this.hrefOnlyDataService.findListByHref<Item>(href$, {}, null, null, ...BROWSE_LINKS_TO_FOLLOW);
161+
return this.hrefOnlyDataService.findListByHref<Item>(href$, {}, null, null, ...getBrowseLinksToFollow());
157162
}
158163
return this.hrefOnlyDataService.findListByHref<Item>(href$);
159164
}

src/app/core/data/relationship-data.service.spec.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { FindListOptions } from './find-list-options.model';
2323
import { testSearchDataImplementation } from './base/search-data.spec';
2424
import { MetadataValue } from '../shared/metadata.models';
2525
import { MetadataRepresentationType } from '../shared/metadata-representation/metadata-representation.model';
26+
import { environment } from '../../../environments/environment.test';
2627

2728
describe('RelationshipDataService', () => {
2829
let service: RelationshipDataService;
@@ -137,6 +138,7 @@ describe('RelationshipDataService', () => {
137138
itemService,
138139
null,
139140
jasmine.createSpy('paginatedRelationsToItems').and.returnValue((v) => v),
141+
environment,
140142
);
141143
}
142144

@@ -152,7 +154,7 @@ describe('RelationshipDataService', () => {
152154
});
153155

154156
describe('composition', () => {
155-
const initService = () => new RelationshipDataService(null, null, null, null, null, null, null);
157+
const initService = () => new RelationshipDataService(null, null, null, null, null, null, null, environment);
156158

157159
testSearchDataImplementation(initService);
158160
});

src/app/core/data/relationship-data.service.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ import { MetadataRepresentation } from '../shared/metadata-representation/metada
5151
import { MetadatumRepresentation } from '../shared/metadata-representation/metadatum/metadatum-representation.model';
5252
import { ItemMetadataRepresentation } from '../shared/metadata-representation/item/item-metadata-representation.model';
5353
import { DSpaceObject } from '../shared/dspace-object.model';
54+
import { APP_CONFIG, AppConfig } from '../../../config/app-config.interface';
5455

5556
const relationshipListsStateSelector = (state: AppState) => state.relationshipLists;
5657

@@ -92,6 +93,7 @@ export class RelationshipDataService extends IdentifiableDataService<Relationshi
9293
protected itemService: ItemDataService,
9394
protected appStore: Store<AppState>,
9495
@Inject(PAGINATED_RELATIONS_TO_ITEMS_OPERATOR) private paginatedRelationsToItems: (thisId: string) => (source: Observable<RemoteData<PaginatedList<Relationship>>>) => Observable<RemoteData<PaginatedList<Item>>>,
96+
@Inject(APP_CONFIG) private appConfig: AppConfig,
9597
) {
9698
super('relationships', requestService, rdbService, objectCache, halService, 15 * 60 * 1000);
9799

@@ -264,7 +266,7 @@ export class RelationshipDataService extends IdentifiableDataService<Relationshi
264266
* @param options
265267
*/
266268
getRelatedItemsByLabel(item: Item, label: string, options?: FindListOptions): Observable<RemoteData<PaginatedList<Item>>> {
267-
let linksToFollow: FollowLinkConfig<Relationship>[] = itemLinksToFollow(options.fetchThumbnail);
269+
let linksToFollow: FollowLinkConfig<Relationship>[] = itemLinksToFollow(options.fetchThumbnail, this.appConfig.item.showAccessStatuses);
268270
linksToFollow.push(followLink('relationshipType'));
269271

270272
return this.getItemRelationshipsByLabel(item, label, options, true, true, ...linksToFollow).pipe(this.paginatedRelationsToItems(item.uuid));

src/app/home-page/recent-item-list/recent-item-list.component.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ export class RecentItemListComponent implements OnInit {
6464
if (this.appConfig.browseBy.showThumbnails) {
6565
linksToFollow.push(followLink('thumbnail'));
6666
}
67+
if (this.appConfig.item.showAccessStatuses) {
68+
linksToFollow.push(followLink('accessStatus'));
69+
}
6770

6871
this.itemRD$ = this.searchService.search(
6972
new PaginatedSearchOptions({

src/app/item-page/edit-item-page/abstract-item-update/abstract-item-update.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { environment } from '../../../../environments/environment';
1313
import { getItemPageRoute } from '../../item-page-routing-paths';
1414
import { getAllSucceededRemoteData } from '../../../core/shared/operators';
1515
import { hasValue } from '../../../shared/empty.util';
16-
import { ITEM_PAGE_LINKS_TO_FOLLOW } from '../../item.resolver';
16+
import { getItemPageLinksToFollow } from '../../item.resolver';
1717
import { FieldUpdate } from '../../../core/data/object-updates/field-update.model';
1818
import { FieldUpdates } from '../../../core/data/object-updates/field-updates.model';
1919

@@ -72,7 +72,7 @@ export class AbstractItemUpdateComponent extends AbstractTrackableComponent impl
7272
this.item = rd.payload;
7373
}),
7474
switchMap((rd: RemoteData<Item>) => {
75-
return this.itemService.findByHref(rd.payload._links.self.href, true, true, ...ITEM_PAGE_LINKS_TO_FOLLOW);
75+
return this.itemService.findByHref(rd.payload._links.self.href, true, true, ...getItemPageLinksToFollow());
7676
}),
7777
getAllSucceededRemoteData()
7878
).subscribe((rd: RemoteData<Item>) => {

src/app/item-page/edit-item-page/item-delete/item-delete.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,8 @@ export class ItemDeleteComponent
236236
this.linkService.resolveLinks(
237237
relationship,
238238
followLink('relationshipType'),
239-
followLink('leftItem'),
240-
followLink('rightItem'),
239+
followLink('leftItem', undefined, followLink<Item>('accessStatus')),
240+
followLink('rightItem', undefined, followLink<Item>('accessStatus')),
241241
);
242242
return relationship.relationshipType.pipe(
243243
getFirstSucceededRemoteData(),

src/app/item-page/edit-item-page/item-relationships/edit-relationship-list/edit-relationship-list.component.spec.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import { ConfigurationProperty } from '../../../../core/shared/configuration-pro
3232
import { Router } from '@angular/router';
3333
import { RouterMock } from '../../../../shared/mocks/router.mock';
3434
import { APP_CONFIG } from '../../../../../config/app-config.interface';
35+
import { environment } from '../../../../../environments/environment.test';
3536

3637
let comp: EditRelationshipListComponent;
3738
let fixture: ComponentFixture<EditRelationshipListComponent>;
@@ -202,11 +203,11 @@ describe('EditRelationshipListComponent', () => {
202203
}))
203204
});
204205

205-
const environmentUseThumbs = {
206+
const environmentUseThumbs = Object.assign({}, environment, {
206207
browseBy: {
207208
showThumbnails: true
208209
}
209-
};
210+
});
210211

211212
TestBed.configureTestingModule({
212213
imports: [SharedModule, TranslateModule.forRoot()],

0 commit comments

Comments
 (0)