Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add alert for layerredirect #144

Merged
merged 1 commit into from
Mar 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions xp-archive/client/contentView/ContentView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@ const getDisplayComponent = (viewVariant?: ViewVariant, data?: ContentServiceRes
const components: Record<ViewVariant, React.ReactElement> = {
html: (
<HtmlView
nodeId={content._id}
content={content}
locale={
data.versions.find((v) => v.versionId === content._versionKey)?.locale || 'no'
}
versionId={content._versionKey}
originalContentTypeName={content.originalContentTypeName}
/>
),
filepreview: <FilePreviewWrapper content={content} />,
Expand Down
22 changes: 15 additions & 7 deletions xp-archive/client/contentView/htmlView/HtmlView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,30 @@ import React, { useState } from 'react';
import style from './HtmlView.module.css';
import { xpArchiveConfig } from '@common/shared/siteConfigs';
import { Alert, Loader } from '@navikt/ds-react';
import { Content } from '../../../shared/types';

type Props = {
nodeId: string;
content: Content;
locale: string;
versionId: string;
originalContentTypeName: string | undefined;
};
const localeNames: Record<string, string> = {
no: 'norsk (bokmål)',
nn: 'nynorsk',
en: 'engelsk',
se: 'samisk',
};

export const HtmlView = ({ nodeId, locale, versionId, originalContentTypeName }: Props) => {
export const HtmlView = ({ content, locale }: Props) => {
const [isLoading, setIsLoading] = useState(true);
const htmlPath = `${xpArchiveConfig.basePath}/html/${nodeId}/${locale}/${versionId}`;
const htmlPath = `${xpArchiveConfig.basePath}/html/${content._id}/${locale}/${content._versionKey}`;

return (
<div className={style.wrapper}>
{originalContentTypeName ? (
<Alert variant="warning">{`Obs! Denne siden var opprinnelig en "${originalContentTypeName}" og inneholder versjonshistorikk.`}</Alert>
{content.originalContentTypeName ? (
<Alert variant="warning">{`Obs! Denne siden var opprinnelig en "${content.originalContentTypeName}" og inneholder versjonshistorikk.`}</Alert>
) : null}
{content.x['no-nav-navno'].redirectToLayer.locale ? (
<Alert variant="warning">{`Obs! Denne siden er satt som redirect til språkversjonen for "${localeNames[content.x['no-nav-navno'].redirectToLayer.locale]}". Husk å velge riktig språkversjon for å se korrekt historikk.`}</Alert>
) : null}
{isLoading && (
<div className={style.loaderWrapper}>
Expand Down
7 changes: 7 additions & 0 deletions xp-archive/shared/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ export type Content = {
to?: string;
};
data: Record<string, unknown>;
x: {
'no-nav-navno': {
redirectToLayer: {
locale: string;
};
};
};
attachment?: Attachment;
originalContentTypeName?: string;
};
Expand Down
Loading