Skip to content

Commit 517adb1

Browse files
Merged dspace-cris-2023_02_x into task/dspace-cris-2023_02_x/IIIF-188
2 parents 2d5ee5b + 8b1ac9c commit 517adb1

48 files changed

Lines changed: 444 additions & 88 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/app/bitstream-page/bitstream-download-redirect.guard.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export const bitstreamDownloadRedirectGuard: CanActivateFn = (
3535
): Observable<UrlTree | boolean> => {
3636

3737
const bitstreamId = route.params.id;
38+
const accessToken: string = route.queryParams.accessToken;
3839

3940
return bitstreamDataService.findById(bitstreamId, true, false, ...BITSTREAM_PAGE_LINKS_TO_FOLLOW).pipe(
4041
getFirstCompletedRemoteData(),
@@ -67,14 +68,21 @@ export const bitstreamDownloadRedirectGuard: CanActivateFn = (
6768
if (isAuthorized && isLoggedIn && isNotEmpty(fileLink)) {
6869
hardRedirectService.redirect(fileLink);
6970
return false;
70-
} else if (isAuthorized && !isLoggedIn) {
71+
} else if (isAuthorized && !isLoggedIn && !hasValue(accessToken)) {
7172
hardRedirectService.redirect(bitstream._links.content.href);
7273
return false;
73-
} else if (!isAuthorized && isLoggedIn) {
74-
return router.createUrlTree([getForbiddenRoute()]);
75-
} else if (!isAuthorized && !isLoggedIn) {
76-
auth.setRedirectUrl(router.url);
77-
return router.createUrlTree(['login']);
74+
} else if (!isAuthorized) {
75+
// Either we have an access token, or we are logged in, or we are not logged in.
76+
// For now, the access token does not care if we are logged in or not.
77+
if (hasValue(accessToken)) {
78+
hardRedirectService.redirect(bitstream._links.content.href + '?accessToken=' + accessToken);
79+
return false;
80+
} else if (isLoggedIn) {
81+
return router.createUrlTree([getForbiddenRoute()]);
82+
} else if (!isLoggedIn) {
83+
auth.setRedirectUrl(router.url);
84+
return router.createUrlTree(['login']);
85+
}
7886
}
7987
})
8088
);

src/app/core/auth/server-auth-request.service.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
import { map } from 'rxjs/operators';
1818
import { Observable } from 'rxjs';
1919
import { XSRFService } from '../xsrf/xsrf.service';
20+
import { RESTURLCombiner } from '../url-combiner/rest-url-combiner';
2021

2122
/**
2223
* Server side version of the service to send authentication requests
@@ -41,8 +42,8 @@ export class ServerAuthRequestService extends AuthRequestService {
4142
* @protected
4243
*/
4344
protected createShortLivedTokenRequest(href: string): Observable<PostRequest> {
44-
// First do a call to the root endpoint in order to get an XSRF token
45-
return this.httpClient.get(this.halService.getRootHref(), { observe: 'response' }).pipe(
45+
// First do a call to the csrf endpoint in order to get an XSRF token
46+
return this.httpClient.get(new RESTURLCombiner('/security/csrf').toString(), { observe: 'response' }).pipe(
4647
// retrieve the XSRF token from the response header
4748
map((response: HttpResponse<any>) => response.headers.get(XSRF_RESPONSE_HEADER)),
4849
map((xsrfToken: string) => {

src/app/core/data/bitstream-data.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ export class BitstreamDataService extends IdentifiableDataService<Bitstream> imp
174174
const searchParams = [];
175175
searchParams.push(new RequestParam('handle', handle));
176176
if (hasValue(sequenceId)) {
177-
searchParams.push(new RequestParam('sequenceId', sequenceId));
177+
searchParams.push(new RequestParam('sequence', sequenceId));
178178
}
179179
if (hasValue(filename)) {
180180
searchParams.push(new RequestParam('filename', filename));

src/app/core/data/feature-authorization/feature-id.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,5 @@ export enum FeatureID {
3939
EPersonForgotPassword = 'epersonForgotPassword',
4040
ShowClaimItem = 'showClaimItem',
4141
CanCorrectItem = 'canCorrectItem',
42+
CanViewInWorkflowSinceStatistics = 'canViewInWorkflowSinceStatistics',
4243
}

src/app/my-dspace-page/my-dspace-page.component.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
[selectionConfig]="{ repeatable: true, listId: listId }"
1515
(deselectObject)="onDeselectObject($event)"
1616
(selectObject)="onSelectObject($event)"
17-
>
18-
<ds-my-dspace-bulk-action
17+
[showWorkflowStatistics]="true">
18+
<!-- Using *ngIf breaks the projection, so we are using hidden instead -->
19+
<ds-my-dspace-bulk-action [hidden]="(currentConfiguration$ | async) !== workflowType"
1920
bulkActions
2021
[listId]="listId"
21-
*ngIf="(currentConfiguration$ | async) === workflowType"
2222
></ds-my-dspace-bulk-action>
2323
<ds-my-dspace-new-bulk-import additionalSearchFormOptions></ds-my-dspace-new-bulk-import>
2424
</ds-search>

src/app/shared/form/vocabulary-treeview/vocabulary-treeview.service.spec.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,25 @@ describe('VocabularyTreeviewService test suite', () => {
269269
expect(serviceAsAny.dataChange.value).toEqual(treeNodeListWithChildren);
270270
});
271271

272+
it('should not add more children if already present and is loadAll is true and onlyFirstTime is true', () => {
273+
pageInfo = Object.assign(new PageInfo(), {
274+
elementsPerPage: 1,
275+
totalElements: 2,
276+
totalPages: 2,
277+
currentPage: 2
278+
});
279+
spyOn(serviceAsAny, 'getChildrenNodesByParent').and.returnValue(hot('a', {
280+
a: buildPaginatedList(pageInfo, [])
281+
}));
282+
283+
serviceAsAny.dataChange.next(treeNodeListWithLoadMore);
284+
serviceAsAny.nodeMap = nodeMapWithChildren;
285+
scheduler.schedule(() => service.loadMore(item, [], true, true));
286+
scheduler.flush();
287+
288+
expect(serviceAsAny.getChildrenNodesByParent).not.toHaveBeenCalled();
289+
});
290+
272291
it('should add loadMore node properly', () => {
273292
pageInfo = Object.assign(new PageInfo(), {
274293
elementsPerPage: 1,

src/app/shared/form/vocabulary-treeview/vocabulary-treeview.service.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,10 @@ export class VocabularyTreeviewService {
146146
}
147147
const parent: TreeviewNode = this.nodeMap.get(item.otherInformation.id)!;
148148
const children = this.nodeMap.get(item.otherInformation.id)!.children || [];
149+
// If there are children and is invoked with loadAll true we skip the call as it means the node has loaded already all the children
150+
if (children.length && loadAll && onlyFirstTime) {
151+
return;
152+
}
149153
this.getChildrenNodesByParent(item.otherInformation.id, parent.pageInfo, (loadAll && selectedItems.length > 0)).subscribe((list: PaginatedList<VocabularyEntryDetail>) => {
150154
if (onlyFirstTime && parent.children!.length > 0 && !loadAll) {
151155
return;

src/app/shared/loading/loading.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { AlertType } from '../alert/alert-type';
88
import { Router } from '@angular/router';
99
import { isPlatformBrowser, Location } from '@angular/common';
1010

11-
enum MessageType {
11+
export enum MessageType {
1212
LOADING = 'loading',
1313
WARNING = 'warning',
1414
ERROR = 'error'

src/app/shared/object-collection/object-collection.component.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
[showPaginator]="showPaginator"
1313
[showThumbnails]="showThumbnails"
1414
[showCorrection]="showCorrection"
15+
[showWorkflowStatistics]="showWorkflowStatistics"
1516
(paginationChange)="onPaginationChange($event)"
1617
(pageChange)="onPageChange($event)"
1718
(pageSizeChange)="onPageSizeChange($event)"
@@ -43,6 +44,7 @@
4344
[showMetrics]="showMetrics"
4445
[showPaginator]="showPaginator"
4546
[showThumbnails]="showThumbnails"
47+
[showWorkflowStatistics]="showWorkflowStatistics"
4648
(paginationChange)="onPaginationChange($event)"
4749
(pageChange)="onPageChange($event)"
4850
(pageSizeChange)="onPageSizeChange($event)"
@@ -62,6 +64,7 @@
6264
[showMetrics]="showMetrics"
6365
[showPaginator]="showPaginator"
6466
[showThumbnails]="showThumbnails"
67+
[showWorkflowStatistics]="showWorkflowStatistics"
6568
(contentChange)="contentChange.emit($event)"
6669
*ngIf="(currentMode$ | async) === viewModeEnum.DetailedListElement">
6770
</ds-object-detail>

src/app/shared/object-collection/object-collection.component.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,11 @@ export class ObjectCollectionComponent implements OnInit {
135135
*/
136136
@Input() showCorrection = false;
137137

138+
/**
139+
* A boolean representing if to show workflow statistics
140+
*/
141+
@Input() showWorkflowStatistics;
142+
138143
/**
139144
* Whether or not to show an alert for hidden related items
140145
*/

0 commit comments

Comments
 (0)