Skip to content

Commit fb19b18

Browse files
authored
Merge pull request #5724 from oscar-escire/Issue/3572-DSpace-7.x
[Port dspace-7_x] Fix browse-by pages sending unnecessary request to author index
2 parents 16312d7 + f427ce1 commit fb19b18

6 files changed

Lines changed: 12 additions & 18 deletions

File tree

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ describe('BrowseByDatePageComponent', () => {
7474
findById: () => createSuccessfulRemoteDataObject$(mockCommunity)
7575
};
7676

77-
const activatedRouteStub = Object.assign(new ActivatedRouteStub(), {
78-
params: observableOf({}),
77+
const activatedRouteStub = Object.assign(new ActivatedRouteStub({ id: 'dateissued' }), {
78+
params: observableOf({ id: 'dateissued' }),
7979
queryParams: observableOf({}),
8080
data: observableOf({ metadata: 'dateissued', metadataField: 'dc.date.issued' })
8181
});
@@ -110,9 +110,8 @@ describe('BrowseByDatePageComponent', () => {
110110
fixture = TestBed.createComponent(BrowseByDatePageComponent);
111111
const browseService = fixture.debugElement.injector.get(BrowseService);
112112
spyOn(browseService, 'getFirstItemFor')
113-
// ok to expect the default browse as first param since we just need the mock items obtained via sort direction.
114-
.withArgs('author', undefined, SortDirection.ASC).and.returnValue(createSuccessfulRemoteDataObject$(firstItem))
115-
.withArgs('author', undefined, SortDirection.DESC).and.returnValue(createSuccessfulRemoteDataObject$(lastItem));
113+
.withArgs('dateissued', undefined, SortDirection.ASC).and.returnValue(createSuccessfulRemoteDataObject$(firstItem))
114+
.withArgs('dateissued', undefined, SortDirection.DESC).and.returnValue(createSuccessfulRemoteDataObject$(lastItem));
116115
comp = fixture.componentInstance;
117116
route = (comp as any).route;
118117
fixture.detectChanges();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export class BrowseByDatePageComponent extends BrowseByMetadataPageComponent {
7575
this.currentSort$,
7676
]).subscribe(([params, currentPage, currentSort]: [Params, PaginationComponentOptions, SortOptions]) => {
7777
const metadataKeys = params.browseDefinition ? params.browseDefinition.metadataKeys : this.defaultMetadataKeys;
78-
this.browseId = params.id || this.defaultBrowseId;
78+
this.browseId = params.id;
7979
this.startsWith = +params.startsWith || params.startsWith;
8080
const searchOptions = browseParamsToOptions(params, currentPage, currentSort, this.browseId, this.fetchThumbnails);
8181
this.updatePageWithItems(searchOptions, this.value, undefined);

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

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

98-
const activatedRouteStub = Object.assign(new ActivatedRouteStub(), {
99-
params: observableOf({})
98+
const activatedRouteStub = Object.assign(new ActivatedRouteStub({ id: 'author' }), {
99+
params: observableOf({ id: 'author' }),
100100
});
101101

102102
paginationService = new PaginationServiceStub();

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

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,10 @@ export class BrowseByMetadataPageComponent implements OnInit, OnDestroy {
8383
*/
8484
subs: Subscription[] = [];
8585

86-
/**
87-
* The default browse id to resort to when none is provided
88-
*/
89-
defaultBrowseId = 'author';
90-
9186
/**
9287
* The current browse id
9388
*/
94-
browseId = this.defaultBrowseId;
89+
browseId: string;
9590

9691
/**
9792
* The type of StartsWith options to render
@@ -177,7 +172,7 @@ export class BrowseByMetadataPageComponent implements OnInit, OnDestroy {
177172
this.currentPagination$,
178173
this.currentSort$,
179174
]).subscribe(([params, currentPage, currentSort]: [Params, PaginationComponentOptions, SortOptions]) => {
180-
this.browseId = params.id || this.defaultBrowseId;
175+
this.browseId = params.id;
181176
this.authority = params.authority;
182177

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

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ describe('BrowseByTitlePageComponent', () => {
6262
findById: () => createSuccessfulRemoteDataObject$(mockCommunity)
6363
};
6464

65-
const activatedRouteStub = Object.assign(new ActivatedRouteStub(), {
66-
params: observableOf({}),
65+
const activatedRouteStub = Object.assign(new ActivatedRouteStub({ id: 'title' }), {
66+
params: observableOf({ id: 'title' }),
6767
queryParams: observableOf({}),
6868
data: observableOf({ metadata: 'title' }),
6969
});

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export class BrowseByTitlePageComponent extends BrowseByMetadataPageComponent {
6262
this.currentSort$,
6363
]).subscribe(([params, currentPage, currentSort]: [Params, PaginationComponentOptions, SortOptions]) => {
6464
this.startsWith = +params.startsWith || params.startsWith;
65-
this.browseId = params.id || this.defaultBrowseId;
65+
this.browseId = params.id;
6666
this.updatePageWithItems(browseParamsToOptions(params, currentPage, currentSort, this.browseId, this.fetchThumbnails), undefined, undefined);
6767
this.updateParent(params.scope);
6868
this.updateLogo();

0 commit comments

Comments
 (0)