Skip to content

Commit 99da927

Browse files
authored
Merge pull request #5726 from oscar-escire/Issue/3572-DSpace-9.x
[Port dspace-9_x] Fix browse-by pages sending unnecessary request to author index
2 parents 448840a + b418c17 commit 99da927

6 files changed

Lines changed: 12 additions & 19 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: of({}),
98+
const activatedRouteStub = Object.assign(new ActivatedRouteStub({ id: 'dateissued' }), {
99+
params: of({ id: 'dateissued' }),
100100
queryParams: of({}),
101101
data: of({ 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
@@ -115,7 +115,7 @@ export class BrowseByDateComponent extends BrowseByMetadataComponent implements
115115
this.currentSort$,
116116
]).subscribe(([params, scope, currentPage, currentSort]: [Params, string, PaginationComponentOptions, SortOptions]) => {
117117
const metadataKeys = params.browseDefinition ? params.browseDefinition.metadataKeys : this.defaultMetadataKeys;
118-
this.browseId = params.id || this.defaultBrowseId;
118+
this.browseId = params.id;
119119
this.startsWith = +params.startsWith || params.startsWith;
120120
const searchOptions = browseParamsToOptions(params, scope, currentPage, currentSort, this.browseId, this.fetchThumbnails);
121121
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: of({}),
126+
const activatedRouteStub = Object.assign(new ActivatedRouteStub({ id: 'author' }), {
127+
params: of({ id: 'author' }),
128128
});
129129

130130
paginationService = new PaginationServiceStub();

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -137,16 +137,10 @@ export class BrowseByMetadataComponent implements OnInit, OnChanges, OnDestroy {
137137
* List of subscriptions
138138
*/
139139
subs: Subscription[] = [];
140-
141-
/**
142-
* The default browse id to resort to when none is provided
143-
*/
144-
defaultBrowseId = 'author';
145-
146140
/**
147141
* The current browse id
148142
*/
149-
browseId = this.defaultBrowseId;
143+
browseId: string;
150144

151145
/**
152146
* The type of StartsWith options to render
@@ -232,7 +226,7 @@ export class BrowseByMetadataComponent implements OnInit, OnChanges, OnDestroy {
232226
this.currentPagination$,
233227
this.currentSort$,
234228
]).subscribe(([params, scope, currentPage, currentSort]: [Params, string, PaginationComponentOptions, SortOptions]) => {
235-
this.browseId = params.id || this.defaultBrowseId;
229+
this.browseId = params.id;
236230
this.authority = params.authority;
237231

238232
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: of({}),
85+
const activatedRouteStub = Object.assign(new ActivatedRouteStub({ id: 'title' }), {
86+
params: of({ id: 'title' }),
8787
queryParams: of({}),
8888
data: of({ 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
@@ -70,7 +70,7 @@ export class BrowseByTitleComponent extends BrowseByMetadataComponent implements
7070
this.currentSort$,
7171
]).subscribe(([params, scope, currentPage, currentSort]: [Params, string, PaginationComponentOptions, SortOptions]) => {
7272
this.startsWith = +params.startsWith || params.startsWith;
73-
this.browseId = params.id || this.defaultBrowseId;
73+
this.browseId = params.id;
7474
this.updatePageWithItems(browseParamsToOptions(params, scope, currentPage, currentSort, this.browseId, this.fetchThumbnails), undefined, undefined);
7575
}));
7676
this.updateStartsWithTextOptions();

0 commit comments

Comments
 (0)