Skip to content

Commit 31fcca9

Browse files
authored
Merge pull request #5725 from oscar-escire/Issue/3572-DSpace-8.x
[Port dspace-8_x] Fix browse-by pages sending unnecessary request to author index
2 parents 672d358 + a3fa08f commit 31fcca9

6 files changed

Lines changed: 12 additions & 18 deletions

File tree

src/app/browse-by/browse-by-date/browse-by-date.component.spec.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ describe('BrowseByDateComponent', () => {
9595
findById: () => createSuccessfulRemoteDataObject$(mockCommunity),
9696
};
9797

98-
const activatedRouteStub = Object.assign(new ActivatedRouteStub(), {
99-
params: observableOf({}),
98+
const activatedRouteStub = Object.assign(new ActivatedRouteStub({ id: 'dateissued' }), {
99+
params: observableOf({ id: 'dateissued' }),
100100
queryParams: observableOf({}),
101101
data: observableOf({ metadata: 'dateissued', metadataField: 'dc.date.issued' }),
102102
});
@@ -151,9 +151,8 @@ describe('BrowseByDateComponent', () => {
151151
fixture = TestBed.createComponent(BrowseByDateComponent);
152152
const browseService = fixture.debugElement.injector.get(BrowseService);
153153
spyOn(browseService, 'getFirstItemFor')
154-
// ok to expect the default browse as first param since we just need the mock items obtained via sort direction.
155-
.withArgs('author', undefined, SortDirection.ASC).and.returnValue(createSuccessfulRemoteDataObject$(firstItem))
156-
.withArgs('author', undefined, SortDirection.DESC).and.returnValue(createSuccessfulRemoteDataObject$(lastItem));
154+
.withArgs('dateissued', undefined, SortDirection.ASC).and.returnValue(createSuccessfulRemoteDataObject$(firstItem))
155+
.withArgs('dateissued', undefined, SortDirection.DESC).and.returnValue(createSuccessfulRemoteDataObject$(lastItem));
157156
comp = fixture.componentInstance;
158157
route = (comp as any).route;
159158
fixture.detectChanges();

src/app/browse-by/browse-by-date/browse-by-date.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ export class BrowseByDateComponent extends BrowseByMetadataComponent implements
118118
this.currentSort$,
119119
]).subscribe(([params, scope, currentPage, currentSort]: [Params, string, PaginationComponentOptions, SortOptions]) => {
120120
const metadataKeys = params.browseDefinition ? params.browseDefinition.metadataKeys : this.defaultMetadataKeys;
121-
this.browseId = params.id || this.defaultBrowseId;
121+
this.browseId = params.id;
122122
this.startsWith = +params.startsWith || params.startsWith;
123123
const searchOptions = browseParamsToOptions(params, scope, currentPage, currentSort, this.browseId, this.fetchThumbnails);
124124
this.updatePageWithItems(searchOptions, this.value, undefined);

src/app/browse-by/browse-by-metadata/browse-by-metadata.component.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ describe('BrowseByMetadataComponent', () => {
123123
findById: () => createSuccessfulRemoteDataObject$(mockCommunity),
124124
};
125125

126-
const activatedRouteStub = Object.assign(new ActivatedRouteStub(), {
127-
params: observableOf({}),
126+
const activatedRouteStub = Object.assign(new ActivatedRouteStub({ id: 'author' }), {
127+
params: observableOf({ id: 'author' }),
128128
});
129129

130130
paginationService = new PaginationServiceStub();

src/app/browse-by/browse-by-metadata/browse-by-metadata.component.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -141,15 +141,10 @@ export class BrowseByMetadataComponent implements OnInit, OnChanges, OnDestroy {
141141
*/
142142
subs: Subscription[] = [];
143143

144-
/**
145-
* The default browse id to resort to when none is provided
146-
*/
147-
defaultBrowseId = 'author';
148-
149144
/**
150145
* The current browse id
151146
*/
152-
browseId = this.defaultBrowseId;
147+
browseId: string;
153148

154149
/**
155150
* The type of StartsWith options to render
@@ -235,7 +230,7 @@ export class BrowseByMetadataComponent implements OnInit, OnChanges, OnDestroy {
235230
this.currentPagination$,
236231
this.currentSort$,
237232
]).subscribe(([params, scope, currentPage, currentSort]: [Params, string, PaginationComponentOptions, SortOptions]) => {
238-
this.browseId = params.id || this.defaultBrowseId;
233+
this.browseId = params.id;
239234
this.authority = params.authority;
240235

241236
if (typeof params.value === 'string') {

src/app/browse-by/browse-by-title/browse-by-title.component.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ describe('BrowseByTitleComponent', () => {
8282
findById: () => createSuccessfulRemoteDataObject$(mockCommunity),
8383
};
8484

85-
const activatedRouteStub = Object.assign(new ActivatedRouteStub(), {
86-
params: observableOf({}),
85+
const activatedRouteStub = Object.assign(new ActivatedRouteStub({ id: 'title' }), {
86+
params: observableOf({ id: 'title' }),
8787
queryParams: observableOf({}),
8888
data: observableOf({ metadata: 'title' }),
8989
});

src/app/browse-by/browse-by-title/browse-by-title.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export class BrowseByTitleComponent extends BrowseByMetadataComponent implements
7373
this.currentSort$,
7474
]).subscribe(([params, scope, currentPage, currentSort]: [Params, string, PaginationComponentOptions, SortOptions]) => {
7575
this.startsWith = +params.startsWith || params.startsWith;
76-
this.browseId = params.id || this.defaultBrowseId;
76+
this.browseId = params.id;
7777
this.updatePageWithItems(browseParamsToOptions(params, scope, currentPage, currentSort, this.browseId, this.fetchThumbnails), undefined, undefined);
7878
}));
7979
this.updateStartsWithTextOptions();

0 commit comments

Comments
 (0)