Skip to content

Commit cfb3f06

Browse files
committed
Merge branch 'dspace-cris-2023_02_x' into ux-plus-2023_02_x
2 parents 8663c1f + 640bf63 commit cfb3f06

8 files changed

Lines changed: 31 additions & 16 deletions

File tree

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ export class CollectionPageComponent implements OnInit {
119119
pagination: currentPagination,
120120
sort: currentSort,
121121
dsoTypes: [DSpaceObjectType.ITEM],
122-
forcedEmbeddedKeys: ['metrics']
122+
forcedEmbeddedKeys: ['metrics'],
123+
projection: 'preventMetadataSecurity'
123124
}), null, true, true, ...BROWSE_LINKS_TO_FOLLOW)
124125
.pipe(toDSpaceObjectListRD()) as Observable<RemoteData<PaginatedList<Item>>>;
125126
}),

src/app/core/browse/browse-entry-search-options.model.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ export class BrowseEntrySearchOptions {
1616
public sort?: SortOptions,
1717
public startsWith?: string,
1818
public scope?: string,
19-
public fetchThumbnail?: boolean) {
19+
public fetchThumbnail?: boolean,
20+
public projection?: string,
21+
) {
2022
}
2123
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,9 @@ export class BrowseService {
148148
if (isNotEmpty(filterAuthority)) {
149149
args.push(`filterAuthority=${encodeURIComponent(filterAuthority)}`);
150150
}
151+
if (isNotEmpty(options.projection)) {
152+
args.push(`projection=${options.projection}`);
153+
}
151154
if (isNotEmpty(args)) {
152155
href = new URLCombiner(href, `?${args.join('&')}`).toString();
153156
}

src/app/core/browse/search-manager.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ export class SearchManager {
4545
* @returns {Observable<RemoteData<PaginatedList<Item>>>}
4646
*/
4747
getBrowseItemsFor(filterValue: string, filterAuthority: string, options: BrowseEntrySearchOptions, ...linksToFollow: FollowLinkConfig<any>[]): Observable<RemoteData<PaginatedList<Item>>> {
48-
return this.browseService.getBrowseItemsFor(filterValue, filterAuthority, options, ...linksToFollow)
48+
const browseOptions = Object.assign({}, options, { projection: 'preventMetadataSecurity' });
49+
return this.browseService.getBrowseItemsFor(filterValue, filterAuthority, browseOptions, ...linksToFollow)
4950
.pipe(this.completeWithExtraData());
5051
}
5152

src/app/core/browse/search.manager.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,13 @@ describe('SearchManager', () => {
130130

131131
const filterValue = 'filterValue';
132132
const filterAuthority = null;
133-
const options: BrowseEntrySearchOptions = { options: null} as any;
133+
const browseOptions: BrowseEntrySearchOptions = Object.assign({}, { projection: 'preventMetadataSecurity' }) as BrowseEntrySearchOptions;
134134
const followLink: FollowLinkConfig<any> = {} as any;
135135

136-
scheduler.schedule(() => service.getBrowseItemsFor(filterValue, filterAuthority, options, followLink).subscribe());
136+
scheduler.schedule(() => service.getBrowseItemsFor(filterValue, filterAuthority, browseOptions, followLink).subscribe());
137137
scheduler.flush();
138138

139-
expect(mockBrowseService.getBrowseItemsFor).toHaveBeenCalledWith(filterValue, null, options, followLink);
139+
expect(mockBrowseService.getBrowseItemsFor).toHaveBeenCalledWith(filterValue, null, browseOptions, followLink);
140140
expect(mockItemService.findAllById).toHaveBeenCalledWith([validAuthority, validAuthority2]);
141141

142142
});
@@ -145,13 +145,13 @@ describe('SearchManager', () => {
145145

146146
const filterValue = 'filterValue';
147147
const filterAuthority = 'filterAuthority';
148-
const options: BrowseEntrySearchOptions = { options: null} as any;
148+
const browseOptions: BrowseEntrySearchOptions = Object.assign({}, { projection: 'preventMetadataSecurity' }) as BrowseEntrySearchOptions;
149149
const followLink: FollowLinkConfig<any> = {} as any;
150150

151-
scheduler.schedule(() => service.getBrowseItemsFor(filterValue, filterAuthority, options, followLink).subscribe());
151+
scheduler.schedule(() => service.getBrowseItemsFor(filterValue, filterAuthority, browseOptions, followLink).subscribe());
152152
scheduler.flush();
153153

154-
expect(mockBrowseService.getBrowseItemsFor).toHaveBeenCalledWith(filterValue, filterAuthority, options, followLink);
154+
expect(mockBrowseService.getBrowseItemsFor).toHaveBeenCalledWith(filterValue, filterAuthority, browseOptions, followLink);
155155
expect(mockItemService.findAllById).toHaveBeenCalledWith([validAuthority, validAuthority2]);
156156

157157
});

src/app/item-page/alerts/item-alerts.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div class="pb-3">
1+
<div class="py-3">
22
<div *ngIf="item && !item.isDiscoverable" class="private-warning">
33
<ds-alert [type]="AlertTypeEnum.Warning" [content]="'item.alerts.private' | translate"></ds-alert>
44
</div>

src/app/lucky-search/search/lucky-search.component.spec.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ describe('LuckySearchComponent', () => {
7878
index: 'test',
7979
'value': 'test'
8080
};
81-
const routerStub = new RouterMock();
81+
let routerStub = new RouterMock();
8282

8383
const bitstreamMetadata = {
8484
'dc.title': [{value: 'test.pdf'} as MetadataValue],
@@ -106,10 +106,8 @@ describe('LuckySearchComponent', () => {
106106
.compileComponents();
107107
});
108108

109-
beforeEach(() => {
110-
fixture = TestBed.createComponent(LuckySearchComponent);
111-
component = fixture.componentInstance;
112-
fixture.detectChanges();
109+
afterEach(() => {
110+
routerStub = new RouterMock();
113111
});
114112

115113
describe('should search items', () => {
@@ -284,6 +282,12 @@ describe('LuckySearchComponent', () => {
284282
});
285283
});
286284

285+
describe('', () => {
286+
beforeEach(() => {
287+
fixture = TestBed.createComponent(LuckySearchComponent);
288+
component = fixture.componentInstance;
289+
});
290+
287291
it('should not redirect when no bitstreams are found', () => {
288292
const item = Object.assign(new Item(), {uuid: 'item-uuid-1', name: 'Test item 1'});
289293
const data = createSuccessfulRemoteDataObject(createPaginatedList([
@@ -298,6 +302,7 @@ describe('LuckySearchComponent', () => {
298302
});
299303

300304
it('should update showEmptySearchSection$ when no results are found', () => {
305+
fixture.detectChanges();
301306
const emptyResults = createSuccessfulRemoteDataObject(createPaginatedList([]));
302307

303308
spyOn(component as any, 'getLuckySearchResults').and.returnValue(observableOf(emptyResults));
@@ -307,4 +312,6 @@ describe('LuckySearchComponent', () => {
307312

308313
expect(component.showEmptySearchSection$.getValue()).toBe(true);
309314
});
315+
316+
});
310317
});

src/app/shared/search/models/paginated-search-options.model.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@ export class PaginatedSearchOptions extends SearchOptions {
1414
sort?: SortOptions;
1515
forcedEmbeddedKeys?: string[];
1616

17-
constructor(options: {configuration?: string, scope?: string, query?: string, dsoTypes?: DSpaceObjectType[], filters?: SearchFilter[], fixedFilter?: any, pagination?: PaginationComponentOptions, sort?: SortOptions, view?: ViewMode, forcedEmbeddedKeys?: string[]}) {
17+
constructor(options: {configuration?: string, scope?: string, query?: string, dsoTypes?: DSpaceObjectType[], filters?: SearchFilter[], fixedFilter?: any, pagination?: PaginationComponentOptions, sort?: SortOptions, view?: ViewMode, forcedEmbeddedKeys?: string[], projection?: string}) {
1818
super(options);
1919
this.pagination = options.pagination;
2020
this.sort = options.sort;
2121
this.view = options.view;
2222
this.forcedEmbeddedKeys = options.forcedEmbeddedKeys;
23+
this.projection = options.projection; // optional projection parameter for the search results
2324
}
2425

2526
/**

0 commit comments

Comments
 (0)