Skip to content

Commit 7fe191d

Browse files
Merge branch 'dspace-cris-2023_02_x' into task/dspace-cris-2023_02_x/DSC-1650-davide
# Conflicts: # src/app/shared/browse-most-elements/browse-most-elements.component.html # src/app/shared/browse-most-elements/browse-most-elements.component.ts # src/app/shared/browse-most-elements/themed-browse-most-elements.component.ts # src/app/shared/explore/section-component/top-section/top-section.component.html # src/app/shared/explore/section-component/top-section/top-section.component.ts
2 parents 107dfdd + 0ff731c commit 7fe191d

127 files changed

Lines changed: 1426 additions & 515 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.

config/config.example.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,8 @@ browseBy:
275275
fiveYearLimit: 30
276276
# The absolute lowest year to display in the dropdown (only used when no lowest date can be found for all items)
277277
defaultLowerLimit: 1900
278+
# Whether to add item badges to BOTH browse and search result lists.
279+
showLabels: true
278280
# If true, thumbnail images for items will be added to BOTH search and browse result lists.
279281
showThumbnails: true
280282
# Whether to add item thumbnail images to BOTH browse and search result lists.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dspace-angular",
3-
"version": "2023.02.05-SNAPSHOT",
3+
"version": "2023.02.06-SNAPHOT",
44
"scripts": {
55
"ng": "ng",
66
"config:watch": "nodemon",

src/app/app-routing.module.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import {
4343
import { ServerCheckGuard } from './core/server-check/server-check.guard';
4444
import { MenuResolver } from './menu.resolver';
4545
import { ThemedPageErrorComponent } from './page-error/themed-page-error.component';
46+
import { ForgotPasswordCheckGuard } from './core/rest-property/forgot-password-check-guard.guard';
4647
import { SUGGESTION_MODULE_PATH } from './suggestions-page/suggestions-page-routing-paths';
4748
import { RedirectService } from './redirect/redirect.service';
4849

@@ -99,7 +100,10 @@ import { RedirectService } from './redirect/redirect.service';
99100
path: FORGOT_PASSWORD_PATH,
100101
loadChildren: () => import('./forgot-password/forgot-password.module')
101102
.then((m) => m.ForgotPasswordModule),
102-
canActivate: [EndUserAgreementCurrentUserGuard]
103+
canActivate: [
104+
ForgotPasswordCheckGuard,
105+
EndUserAgreementCurrentUserGuard
106+
]
103107
},
104108
{
105109
path: COMMUNITY_MODULE_PATH,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export enum FeatureID {
3636
CanEditItem = 'canEditItem',
3737
CanRegisterDOI = 'canRegisterDOI',
3838
CanSubscribe = 'canSubscribeDso',
39+
EPersonForgotPassword = 'epersonForgotPassword',
3940
ShowClaimItem = 'showClaimItem',
4041
CanCorrectItem = 'canCorrectItem',
4142
}

src/app/core/data/processes/process-data.service.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,7 @@ export class ProcessDataService extends IdentifiableDataService<Process> impleme
123123
* @param processId The ID of the process
124124
*/
125125
getProcess(processId: string): Observable<RemoteData<Process>> {
126-
const href$ = this.getProcessEndpoint(processId);
127-
return this.findByHref(href$,false);
126+
return this.findById(processId, false);
128127
}
129128

130129
/**

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ export class LocaleService {
5353
this.routeService.getQueryParameterValue('lang').subscribe(lang => {
5454
if (lang && this.translate.getLangs().includes(lang)) {
5555
this.setCurrentLanguageCode(lang);
56+
this.routeService.removeQueryParam('lang');
5657
}
5758
});
5859
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { Injectable } from '@angular/core';
2+
import { ActivatedRouteSnapshot, Router, RouterStateSnapshot } from '@angular/router';
3+
import { Observable, of } from 'rxjs';
4+
import { AuthorizationDataService } from '../data/feature-authorization/authorization-data.service';
5+
import { FeatureID } from '../data/feature-authorization/feature-id';
6+
import {
7+
SingleFeatureAuthorizationGuard
8+
} from '../data/feature-authorization/feature-authorization-guard/single-feature-authorization.guard';
9+
import { AuthService } from '../auth/auth.service';
10+
11+
@Injectable({
12+
providedIn: 'root'
13+
})
14+
/**
15+
* Guard that checks if the forgot-password feature is enabled
16+
*/
17+
export class ForgotPasswordCheckGuard extends SingleFeatureAuthorizationGuard {
18+
19+
constructor(
20+
protected readonly authorizationService: AuthorizationDataService,
21+
protected readonly router: Router,
22+
protected readonly authService: AuthService
23+
) {
24+
super(authorizationService, router, authService);
25+
}
26+
27+
getFeatureID(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<FeatureID> {
28+
return of(FeatureID.EPersonForgotPassword);
29+
}
30+
31+
}

src/app/core/services/internal-link.service.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ describe('InternalLinkService', () => {
5858

5959
it('should return unchanged link for external link', () => {
6060
const result = service.getRelativePath('https://externalDomain/my-link');
61-
expect(result).toBe('https://externalDomain/my-link');
61+
expect(result).toBe('/https://externalDomain/my-link');
6262
});
6363

6464
it('should return unchanged link for internal link with leading "/"', () => {

src/app/core/services/internal-link.service.ts

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,41 @@ export class InternalLinkService {
3939
* @returns The relative path for the given internal link.
4040
*/
4141
public getRelativePath(link: string): string {
42-
// Create a Domain object for the provided link
42+
// Obtaining the base URL, disregarding query parameters
43+
const baseUrl = link.split('?')[0];
4344
const currentDomain = new URL(this.currentURL).hostname;
4445

45-
if (link.startsWith(this.currentURL)) {
46-
const currentSegments = link.substring(this.currentURL.length);
46+
if (baseUrl.startsWith(this.currentURL) || baseUrl.startsWith(currentDomain)) {
47+
const base = baseUrl.startsWith(this.currentURL) ? this.currentURL : currentDomain;
48+
const currentSegments = baseUrl.substring(base.length);
4749
return currentSegments.startsWith('/') ? currentSegments : `/${currentSegments}`;
4850
}
4951

50-
if (link.startsWith(currentDomain)) {
51-
const currentSegments = link.substring(currentDomain.length);
52-
return currentSegments.startsWith('/') ? currentSegments : `/${currentSegments}`;
52+
return baseUrl.startsWith('/') ? baseUrl : `/${baseUrl}`;
53+
}
54+
55+
/**
56+
* Parse the query parameters from a given URL link.
57+
*
58+
* @param link The URL link containing query parameters.
59+
* @returns An object containing the parsed query parameters.
60+
*/
61+
public getQueryParams(link: string): Record<string, string> {
62+
const queryParams: Record<string, string> = {};
63+
64+
const queryStringStartIndex = link.indexOf('?');
65+
if (queryStringStartIndex !== -1) {
66+
const paramsString = link.substring(queryStringStartIndex + 1);
67+
const paramsArray = paramsString.split('&');
68+
69+
paramsArray.forEach(param => {
70+
const [key, value] = param.split('=');
71+
if (key && value) {
72+
queryParams[key] = decodeURIComponent(value.replace(/\+/g, ' '));
73+
}
74+
});
5375
}
5476

55-
return link;
77+
return queryParams;
5678
}
5779
}

src/app/core/services/route.service.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,4 +225,23 @@ export class RouteService {
225225
}
226226
);
227227
}
228+
229+
/**
230+
* Remove a parameter from the current route
231+
* @param key The parameter name
232+
*/
233+
removeQueryParam(key: string) {
234+
let queryParams = { ...this.route.snapshot.queryParams };
235+
delete queryParams[key];
236+
237+
// Navigate to the same route with the updated queryParams
238+
this.router.navigate(
239+
[],
240+
{
241+
relativeTo: this.route,
242+
queryParams: queryParams,
243+
}
244+
);
245+
246+
}
228247
}

0 commit comments

Comments
 (0)