From 3a496a95e7310befe65620d531c781175048303a Mon Sep 17 00:00:00 2001 From: Femke Reunes Date: Fri, 28 Aug 2026 14:17:49 +0200 Subject: [PATCH] ARC-3892: pass getIeObjectPath in admin config and use that to navigate where possible --- .../react-admin/core/config/config.types.ts | 6 ++++ .../IeObjectMetadata/IeObjectMetadata.tsx | 7 ++++- .../BlockObjectsGrid.service.ts | 2 ++ .../BlockObjectsGrid/BlockObjectsGrid.tsx | 6 +++- .../BlockObjectsGrid.types.ts | 2 ++ .../BlockThemeReels/BlockThemeReelSection.tsx | 12 ++++++-- .../modules/ie-objects/ie-objects.service.ts | 28 ++++++++++++++++++- .../shared/components/SmartLink/SmartLink.tsx | 11 ++++++-- .../modules/shared/helpers/routing/link.tsx | 2 +- .../ie-objects-service/ie-objects.types.ts | 1 + .../services/themes-service/themes.types.ts | 1 + 11 files changed, 70 insertions(+), 8 deletions(-) diff --git a/ui/src/react-admin/core/config/config.types.ts b/ui/src/react-admin/core/config/config.types.ts index d4d3b61a4..98fb7a048 100644 --- a/ui/src/react-admin/core/config/config.types.ts +++ b/ui/src/react-admin/core/config/config.types.ts @@ -123,6 +123,12 @@ export interface AdminConfig { // admin-core needing to depend on the client package. clientSearchUrlToApiSearchUrl: (searchQuery: string) => IeObjectsSearchBody; }; + getIeObjectDetailPath?: ( + locale: string, + maintainerSlug: string, + schemaIdentifier: string, + name: string | null | undefined + ) => string; }; components: { loader: { diff --git a/ui/src/react-admin/modules/content-page/components/IeObjectMetadata/IeObjectMetadata.tsx b/ui/src/react-admin/modules/content-page/components/IeObjectMetadata/IeObjectMetadata.tsx index dcd4e7b55..af09d6295 100644 --- a/ui/src/react-admin/modules/content-page/components/IeObjectMetadata/IeObjectMetadata.tsx +++ b/ui/src/react-admin/modules/content-page/components/IeObjectMetadata/IeObjectMetadata.tsx @@ -15,6 +15,7 @@ import { tText } from '~shared/helpers/translation-functions'; import type { PlayableDisplayIeObject } from '~shared/services/ie-objects-service/ie-objects.types.ts'; import { HET_ARCHIEF } from '~shared/types'; import './IeObjectMetadata.scss'; +import { IeObjectsService } from '~modules/ie-objects/ie-objects.service.ts'; // The call to action names the kind of object it links to, so a newspaper isn't announced as a fragment. const getCallToActionLabel = (format: IeObjectType | null): string => { @@ -70,7 +71,11 @@ export const IeObjectMetadata: FunctionComponent<{ { return { schemaIdentifier: raw.schemaIdentifier, name: raw.name || '', + maintainerSlug: raw.maintainerSlug || '', maintainerName: raw.maintainerName, type, thumbnailUrl: isAudioFormat(type) diff --git a/ui/src/react-admin/modules/content-page/components/blocks/BlockObjectsGrid/BlockObjectsGrid.tsx b/ui/src/react-admin/modules/content-page/components/blocks/BlockObjectsGrid/BlockObjectsGrid.tsx index 1592f499b..07e3be997 100644 --- a/ui/src/react-admin/modules/content-page/components/blocks/BlockObjectsGrid/BlockObjectsGrid.tsx +++ b/ui/src/react-admin/modules/content-page/components/blocks/BlockObjectsGrid/BlockObjectsGrid.tsx @@ -208,7 +208,11 @@ export const BlockObjectsGrid: FunctionComponent = ({ )} {theme.ieObjects.map( - ({ id, format, maintainerName, schemaIdentifier, thumbnailUrl, name }, index) => { + ( + { id, format, maintainerSlug, maintainerName, schemaIdentifier, thumbnailUrl, name }, + index + ) => { const componentClassName = clsx('c-block-theme-reels-section__slide'); return ( = ({ const anchorId = fullUrl.split('#')[1]; document.getElementById(anchorId)?.scrollIntoView({ behavior: 'instant' }); } else { - scrollTo({ top: 0 }); + const targetPathname = fullUrl.split('?')[0].split('#')[0]; + // Only scroll to top if we are navigating to the same page (otherwise this will happen by default) + if (window.location.pathname === targetPathname) { + scrollTo({ top: 0 }); + } } }} onKeyUp={(evt) => onKeyUpHandler(evt as unknown as KeyboardEvent)} @@ -216,7 +220,10 @@ export const SmartLink: FunctionComponent = ({ // ie-objects only exist on hetarchief, render the children unwrapped break; } - return renderLink(IeObjectsService.getObjectDetailPath(String(value)), resolvedTarget); + return renderLink( + IeObjectsService.getObjectDetailPathViaPid(String(value)), + resolvedTarget + ); } case 'ASSIGNMENT': { diff --git a/ui/src/react-admin/modules/shared/helpers/routing/link.tsx b/ui/src/react-admin/modules/shared/helpers/routing/link.tsx index e01056f2b..eeda8dd30 100644 --- a/ui/src/react-admin/modules/shared/helpers/routing/link.tsx +++ b/ui/src/react-admin/modules/shared/helpers/routing/link.tsx @@ -165,7 +165,7 @@ export const navigateToContentType = (action: ButtonAction) => { break; } navigateToAbsoluteOrRelativeUrl( - IeObjectsService.getObjectDetailPath(String(value)), + IeObjectsService.getObjectDetailPathViaPid(String(value)), resolvedTarget ); break; diff --git a/ui/src/react-admin/modules/shared/services/ie-objects-service/ie-objects.types.ts b/ui/src/react-admin/modules/shared/services/ie-objects-service/ie-objects.types.ts index c4b332133..2a2b059e6 100644 --- a/ui/src/react-admin/modules/shared/services/ie-objects-service/ie-objects.types.ts +++ b/ui/src/react-admin/modules/shared/services/ie-objects-service/ie-objects.types.ts @@ -6,6 +6,7 @@ export interface PlayableDisplayIeObject { thumbnailUrl: string | null; dctermsFormat: IeObjectType; maintainerId: string; + maintainerSlug: string; maintainerName: string; maintainerLogo?: string; maintainerOverlay: boolean; diff --git a/ui/src/react-admin/modules/shared/services/themes-service/themes.types.ts b/ui/src/react-admin/modules/shared/services/themes-service/themes.types.ts index b603d7aa3..92a29c936 100644 --- a/ui/src/react-admin/modules/shared/services/themes-service/themes.types.ts +++ b/ui/src/react-admin/modules/shared/services/themes-service/themes.types.ts @@ -20,6 +20,7 @@ export interface ThemeWithObjects extends Theme { format: IeObjectType; thumbnailUrl: string; maintainerId: string; + maintainerSlug: string; maintainerName: string; }[]; // The number of ie-objects linked to the theme, which is more than the objects in `ieObjects`