Skip to content

Commit 255bcb9

Browse files
committed
Merge branch 'ux-plus-2023_02_x' into task/ux-plus-2023_02_x/UXP-34-rework
2 parents b4454d1 + a50dece commit 255bcb9

11 files changed

Lines changed: 48 additions & 27 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/core/data/site-data.service.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,27 @@ export class SiteDataService extends IdentifiableDataService<Site> implements Fi
4646

4747
/**
4848
* Retrieve the Site Object
49+
*
50+
* @param options Find list options object
51+
* @param useCachedVersionIfAvailable If this is true, the request will only be sent if there's
52+
* no valid cached version. Defaults to true
53+
* @param reRequestOnStale Whether or not the request should automatically be re-
54+
* requested after the response becomes stale
55+
* @param linksToFollow List of {@link FollowLinkConfig} that indicate which
56+
* {@link HALLink}s should be automatically resolved
57+
* @return {Observable<RemoteData<PaginatedList<T>>>}
58+
* Return an observable that emits object list
4959
*/
50-
find(): Observable<Site> {
60+
find(options?: FindListOptions, useCachedVersionIfAvailable?: boolean, reRequestOnStale?: boolean, ...linksToFollow: FollowLinkConfig<Site>[]): Observable<Site> {
5161
const searchParams: RequestParam[] = [new RequestParam('projection', 'allLanguages')];
52-
const options = Object.assign(new FindListOptions(), { searchParams });
53-
return this.findAll(options).pipe(
62+
const findOptions = Object.assign(new FindListOptions(), options, { searchParams });
63+
return this.findAll(findOptions, useCachedVersionIfAvailable, reRequestOnStale, ...linksToFollow).pipe(
5464
getFirstCompletedRemoteData(),
5565
switchMap((remoteData: RemoteData<PaginatedList<Site>>) => {
5666
if (remoteData.hasSucceeded) {
5767
return of(remoteData.payload.page[0]);
5868
} else {
59-
return this.findAll().pipe(
69+
return this.findAll(options, useCachedVersionIfAvailable, reRequestOnStale, ...linksToFollow).pipe(
6070
getFirstCompletedRemoteData(),
6171
map((rd: RemoteData<PaginatedList<Site>>) => rd.hasSucceeded ? rd.payload.page[0] : null)
6272
);

src/app/home-page/home-page.resolver.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ export class HomePageResolver implements Resolve<Site> {
2020
* @returns Observable<Site> Emits the found Site object, or an error if something went wrong
2121
*/
2222
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<Site> | Promise<Site> | Site {
23-
return this.siteService.find().pipe(take(1));
23+
return this.siteService.find(null, false).pipe(take(1));
2424
}
2525
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
<div class="pb-3">
2-
<div *ngIf="item && !item.isDiscoverable" class="private-warning">
1+
<div *ngIf="item && (!item.isDiscoverable || item.isWithdrawn)" class="pb-3">
2+
<div *ngIf="!item.isDiscoverable" class="private-warning">
33
<ds-alert [type]="AlertTypeEnum.Warning" [content]="'item.alerts.private' | translate"></ds-alert>
44
</div>
5-
<div *ngIf="item && item.isWithdrawn" class="withdrawn-warning">
5+
<div *ngIf="item.isWithdrawn" class="withdrawn-warning">
66
<ds-alert [type]="AlertTypeEnum.Warning">
77
<div class="d-flex justify-content-between flex-wrap flex-column">
88
<span class="align-self-center">{{'item.alerts.withdrawn' | translate}}</span>

src/app/item-page/simple/item-page.component.scss

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,3 @@
44
max-width: none;
55
}
66
}
7-
8-
.container {
9-
margin-top: calc(-1 * var(--ds-content-spacing));
10-
}

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
});

0 commit comments

Comments
 (0)