Skip to content

Commit 4303b63

Browse files
FrancescoMolinarovins01-4science
authored andcommitted
Merged in task/dspace-cris-2024_02_x/DSC-2469 (pull request DSpace#3520)
[DSC-2469] add fix for custom url edit page, adapt loading Approved-by: Andrea Barbasso
2 parents a96e60e + 4414b0c commit 4303b63

3 files changed

Lines changed: 12 additions & 2 deletions

File tree

src/app/app.component.spec.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ const initialState = {
7171
};
7272

7373
const itemPageUrl = '/entities/publication/3b6ef8e8-15a1-4607-abf8-2a6fbd572346';
74+
const itemPageCustomUrl = '/entities/publication/aCustomUrl';
7475

7576
export function getMockLocaleService(): LocaleService {
7677
return jasmine.createSpyObj('LocaleService', {
@@ -206,6 +207,14 @@ describe('App component', () => {
206207
expect(comp.isRouteLoading$.value).toBeTrue();
207208
}));
208209

210+
it('should show loading for item page administrative edit if custom url is used', fakeAsync(() => {
211+
routeServiceMock.getCurrentUrl.and.returnValue(of(itemPageCustomUrl));
212+
routerEventsObs.next(new NavigationStart(2, itemPageCustomUrl + '/edit'));
213+
fixture.detectChanges();
214+
tick();
215+
expect(comp.isRouteLoading$.value).toBeTrue();
216+
}));
217+
209218
it('should not show loading navigating between item pages in administrative edit', fakeAsync(() => {
210219
routeServiceMock.getCurrentUrl.and.returnValue(of(itemPageUrl + '/edit'));
211220
routerEventsObs.next(new NavigationStart(2, itemPageUrl + '/edit/status'));

src/app/app.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ export class AppComponent implements OnInit, AfterViewInit {
224224
}
225225

226226
private isAdministrativeEditItemPageRoute(nextUrl: string, currentUrl: string): boolean {
227-
const editPageRegEx = /\/(entities\/[^\/]+|items)\/[0-9a-f-]{36}\/edit(?:\/.*)?$/;
227+
const editPageRegEx = /\/(entities\/[^/]+|items)\/[^/]+\/edit(?:\/.*)?$/;
228228
return editPageRegEx.test(nextUrl) && !editPageRegEx.test(currentUrl);
229229
}
230230

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ export const itemPageResolver: ResolveFn<RemoteData<Item>> = (
7575
map((rd: RemoteData<Item>) => {
7676
store.dispatch(new ResolvedAction(state.url, rd.payload));
7777
if (rd.hasSucceeded && hasValue(rd.payload)) {
78-
const itemRoute = router.parseUrl(getItemPageRoute(rd.payload)).toString();
78+
const isItemEditPage = state.url.includes('/edit');
79+
const itemRoute = isItemEditPage ? state.url : router.parseUrl(getItemPageRoute(rd.payload)).toString();
7980
// Check if custom url not empty and if the current id parameter is different from the custom url redirect to custom url
8081
if (hasValue(rd.payload.metadata) && isNotEmpty(rd.payload.metadata['cris.customurl'])) {
8182
if (route.params.id !== rd.payload.metadata['cris.customurl'][0].value) {

0 commit comments

Comments
 (0)