Skip to content

Commit 3202d2c

Browse files
Merged dspace-cris-2023_02_x into task/dspace-cris-2023_02_x/DSC-2599
2 parents 95cb3b4 + 2576cb2 commit 3202d2c

42 files changed

Lines changed: 393 additions & 58 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.

cypress/e2e/my-dspace.cy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ describe('My DSpace page', () => {
119119
// Open the New Import dropdown
120120
cy.get('button[data-test="import-dropdown"]').click();
121121
// Click on the "Item" type in that dropdown
122-
cy.get('#importControlsDropdownMenu button[title="Equipment"]').click();
122+
cy.get('#importControlsDropdownMenu button[title="Funding"]').click();
123123

124124
// New URL should include /import-external, as we've moved to the import page
125125
cy.url().should('include', '/import-external');

cypress/support/e2e.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ before(() => {
5151
cy.task('saveRestBaseDomain', baseDomain);
5252

5353
});
54+
55+
// We might receive uncaught exceptions from external libraries (e.g. it happened before with a broken
56+
// version of the addToAny plugin). These should not cause our tests to fail, so we catch them here.
57+
Cypress.on('uncaught:exception', (err, runnable) => {
58+
// returning false here prevents Cypress from failing the test
59+
return false;
60+
});
5461
});
5562

5663
// Runs once before the first test in each "block"

server.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,11 @@ export function app() {
274274
*/
275275
server.get('/app/client/health', clientHealthCheck);
276276

277+
/**
278+
* Redirecting old manifest
279+
*/
280+
server.get('/json/iiif/**/manifest', redirectManifest);
281+
277282
/**
278283
* Default sending all incoming requests to ngApp() function, after first checking for a cached
279284
* copy of the page (see cacheCheck())
@@ -704,6 +709,39 @@ function healthCheck(req, res) {
704709
});
705710
}
706711

712+
/*
713+
* The callback function to redirect old manifest
714+
*/
715+
function redirectManifest(req, res) {
716+
console.info('Redirecting old manifest');
717+
const url = req.url;
718+
const regex = /json\/iiif\/([^\/]+\/[^\/]+)(?:\/([^\/]+))?\/manifest/;
719+
const match = url.match(regex);
720+
let handle;
721+
let id;
722+
723+
if (match) {
724+
handle = match[1];
725+
const baseUrl = `${environment.rest.baseUrl}/api/pid/find?id=${handle}`;
726+
axios.get(baseUrl)
727+
.then((response) => {
728+
if (response.status === 200) {
729+
const newUrl = `${environment.rest.baseUrl}/iiif/${response.data.id}/manifest`;
730+
console.info('Manifest found, redirect to ', newUrl);
731+
res.redirect(newUrl);
732+
}
733+
})
734+
.catch((error) => {
735+
res.status(error.response.status).send({
736+
error: error.message
737+
});
738+
});
739+
} else {
740+
res.status(422).send({
741+
error: 'Wrong handle'
742+
});
743+
}
744+
}
707745

708746
// Webpack will replace 'require' with '__webpack_require__'
709747
// '__non_webpack_require__' is a proxy to Node 'require'

src/app/admin/admin-sidebar/admin-sidebar-section/admin-sidebar-section.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export class AdminSidebarSectionComponent extends MenuSectionComponent implement
4242
}
4343

4444
ngOnInit(): void {
45-
this.isDisabled = this.itemModel?.disabled || isEmpty(this.itemModel?.link);
45+
this.isDisabled = this.itemModel?.disabled || (isEmpty(this.itemModel?.link) && isEmpty(this.itemModel?.href));
4646
super.ngOnInit();
4747
}
4848

src/app/breadcrumbs/breadcrumbs.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
</ng-template>
1515

1616
<ng-template #activeBreadcrumb let-text="text">
17-
<li class="breadcrumb-item active" aria-current="page"><div class="breadcrumb-item-limiter"><span class="text-truncate" [innerHTML]="text | translate"></span></div></li>
17+
<li class="breadcrumb-item active" aria-current="page"><div class="breadcrumb-item-limiter"><span class="text-truncate" [innerHTML]="text | translate | dsEscapeHtml"></span></div></li>
1818
</ng-template>
1919
</ng-container>
2020

src/app/breadcrumbs/breadcrumbs.component.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { TranslateLoaderMock } from '../shared/testing/translate-loader.mock';
1010
import { RouterTestingModule } from '@angular/router/testing';
1111
import { of as observableOf } from 'rxjs';
1212
import { DebugElement } from '@angular/core';
13+
import {EscapeHtmlPipe} from '../shared/utils/escape-html.pipe';
1314

1415
describe('BreadcrumbsComponent', () => {
1516
let component: BreadcrumbsComponent;
@@ -43,6 +44,7 @@ describe('BreadcrumbsComponent', () => {
4344
declarations: [
4445
BreadcrumbsComponent,
4546
VarDirective,
47+
EscapeHtmlPipe
4648
],
4749
imports: [
4850
RouterTestingModule.withRoutes([]),

src/app/core/locale/locale.service.spec.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { NativeWindowRef } from '../services/window.service';
1111
import { RouteService } from '../services/route.service';
1212
import { routeServiceStub } from '../../shared/testing/route-service.stub';
1313
import { of as observableOf } from 'rxjs';
14+
import { PLATFORM_ID } from '@angular/core';
1415

1516
describe('LocaleService test suite', () => {
1617
let service: LocaleService;
@@ -24,6 +25,7 @@ describe('LocaleService test suite', () => {
2425
let routeService;
2526
let document;
2627
let spyOnGetLanguage;
28+
const platformId = 'browser';
2729

2830

2931
const translateServiceStub: any = {
@@ -62,6 +64,7 @@ describe('LocaleService test suite', () => {
6264
{ provide: RouteService, useValue: routeServiceStub },
6365
{ provide: TranslateService, useValue: translateServiceStub },
6466
{ provide: Document, useValue: document },
67+
{ provide: PLATFORM_ID, useValue: platformId },
6568
]
6669
});
6770
}));
@@ -72,7 +75,7 @@ describe('LocaleService test suite', () => {
7275
routeService = TestBed.inject(RouteService);
7376
window = new NativeWindowRef();
7477
document = { documentElement: { lang: 'en' } };
75-
service = new LocaleService(window, cookieService, translateService, authService, routeService, document);
78+
service = new LocaleService(window, cookieService, translateService, authService, routeService, document, platformId);
7679
serviceAsAny = service;
7780
spyOnGet = spyOn(cookieService, 'get');
7881
spyOnSet = spyOn(cookieService, 'set');

src/app/core/locale/locale.service.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Inject, Injectable } from '@angular/core';
1+
import { Inject, Injectable, PLATFORM_ID } from '@angular/core';
22

33
import { TranslateService } from '@ngx-translate/core';
44

@@ -10,7 +10,7 @@ import { combineLatest, Observable, of as observableOf } from 'rxjs';
1010
import { map, mergeMap, take } from 'rxjs/operators';
1111
import { NativeWindowRef, NativeWindowService } from '../services/window.service';
1212
import { RouteService } from '../services/route.service';
13-
import { DOCUMENT } from '@angular/common';
13+
import { DOCUMENT, isPlatformBrowser } from '@angular/common';
1414
import { LangConfig } from '../../../config/lang-config.interface';
1515

1616
export const LANG_COOKIE = 'dsLanguage';
@@ -41,7 +41,8 @@ export class LocaleService {
4141
protected translate: TranslateService,
4242
protected authService: AuthService,
4343
protected routeService: RouteService,
44-
@Inject(DOCUMENT) protected document: any
44+
@Inject(DOCUMENT) protected document: any,
45+
@Inject(PLATFORM_ID) protected platformId: string,
4546
) {
4647
this.initDefaults();
4748
}
@@ -53,7 +54,9 @@ export class LocaleService {
5354
this.routeService.getQueryParameterValue('lang').subscribe(lang => {
5455
if (lang && this.translate.getLangs().includes(lang)) {
5556
this.setCurrentLanguageCode(lang);
56-
this.routeService.removeQueryParam('lang');
57+
if (isPlatformBrowser(this.platformId)) {
58+
this.routeService.removeQueryParam('lang');
59+
}
5760
}
5861
});
5962
}

src/app/core/locale/server-locale.service.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { LANG_ORIGIN, LocaleService } from './locale.service';
2-
import { Inject, Injectable } from '@angular/core';
2+
import { Inject, Injectable, PLATFORM_ID } from '@angular/core';
33
import { combineLatest, Observable, of as observableOf } from 'rxjs';
44
import { map, mergeMap, take } from 'rxjs/operators';
55
import { hasValue, isEmpty, isNotEmpty } from '../../shared/empty.util';
@@ -21,9 +21,10 @@ export class ServerLocaleService extends LocaleService {
2121
protected translate: TranslateService,
2222
protected authService: AuthService,
2323
protected routeService: RouteService,
24-
@Inject(DOCUMENT) protected document: any
24+
@Inject(DOCUMENT) protected document: any,
25+
@Inject(PLATFORM_ID) protected platformId: string,
2526
) {
26-
super(_window, cookie, translate, authService, routeService, document);
27+
super(_window, cookie, translate, authService, routeService, document, platformId);
2728
}
2829

2930
/**

src/app/cris-layout/cris-layout-matrix/cris-layout-box-container/boxes/metadata/rendering-types/longtext/longtext.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div class="{{field.styleValue}}">
33
<ds-truncatable [id]="truncableId">
44
<ds-truncatable-part [id]="truncableId" [minLines]="3">
5-
<span [innerHTML]="formatText(metadataValue.value)" data-test="formatted-text"></span>
5+
<span [innerHTML]="metadataValue.value | dsEscapeHtml" data-test="formatted-text"></span>
66
</ds-truncatable-part>
77
</ds-truncatable>
88
</div>

0 commit comments

Comments
 (0)