Skip to content

Commit 0821082

Browse files
committedFeb 13, 2025·
test i dev fjerne oppdater url direkte i versjonsvelgeren
1 parent a18f0be commit 0821082

File tree

3 files changed

+7
-16
lines changed

3 files changed

+7
-16
lines changed
 

‎xp-archive/client/content/Content.tsx

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import React, { useState, useEffect } from 'react';
22
import { SidebarRightIcon } from '@navikt/aksel-icons';
3+
import { xpArchiveConfig } from '@common/shared/siteConfigs';
34
import { Button, Detail, Heading, Label } from '@navikt/ds-react';
45
import { useFetchContent } from '../hooks/useFetchContent';
56
import { useAppState } from '../context/appState/useAppState';
67
import { ViewSelector, ViewVariant } from 'client/viewSelector/ViewSelector';
78
import { VersionSelector } from 'client/versionSelector/VersionSelector';
8-
import { updateContentUrl } from 'client/contentTree/contentTreeEntry/NavigationItem';
99
import { ContentView } from '../contentView/ContentView';
1010
import { formatTimestamp } from '@common/shared/timestamp';
1111
import { EmptyState } from '@common/shared/EmptyState/EmptyState';
@@ -18,6 +18,11 @@ const getDefaultView = (isWebpage: boolean, hasAttachment: boolean): ViewVariant
1818
return undefined;
1919
};
2020

21+
const updateContentUrl = (nodeId: string, locale: string, versionId?: string) => {
22+
const newUrl = `${xpArchiveConfig.basePath}/${nodeId}/${locale}/${versionId ?? ''}`;
23+
window.history.pushState({}, '', newUrl);
24+
};
25+
2126
export const Content = () => {
2227
const { selectedContentId, selectedLocale, selectedVersion, setSelectedVersion } =
2328
useAppState();

‎xp-archive/client/contentTree/contentTreeEntry/NavigationItem.tsx

-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React from 'react';
22
import { ContentTreeEntryData } from '../../../shared/types';
3-
import { xpArchiveConfig } from '@common/shared/siteConfigs';
43
import { useAppState } from '../../context/appState/useAppState';
54
import { TreeItem } from '@mui/x-tree-view';
65
import { useContentTree } from 'client/hooks/useContentTree';
@@ -13,11 +12,6 @@ type Props = {
1312
export const getContentIconUrl = (type: string) =>
1413
`${import.meta.env.VITE_APP_ORIGIN}/xp/api/contentIcon?type=${type}`;
1514

16-
export const updateContentUrl = (nodeId: string, locale: string, versionId?: string) => {
17-
const newUrl = `${xpArchiveConfig.basePath}/${nodeId}/${locale}/${versionId ?? ''}`;
18-
window.history.pushState({}, '', newUrl);
19-
};
20-
2115
export const NavigationItem = ({ entry }: Props) => {
2216
const { setSelectedContentId } = useAppState();
2317

‎xp-archive/client/versionSelector/VersionSelector.tsx

+1-9
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { Heading, Button, Search } from '@navikt/ds-react';
33
import { VersionReference } from 'shared/types';
44
import { formatTimestamp } from '@common/shared/timestamp';
55
import { useAppState } from 'client/context/appState/useAppState';
6-
import { updateContentUrl } from 'client/contentTree/contentTreeEntry/NavigationItem';
76
import { SlidePanel } from './SlidePanel/SlidePanel';
87
import { classNames } from '@common/client/utils/classNames';
98
import style from './VersionSelector.module.css';
@@ -35,13 +34,7 @@ const VersionButton = ({ isSelected, onClick, children }: VersionButtonProps) =>
3534

3635
export const VersionSelector = ({ versions, isOpen, onClose }: Props) => {
3736
const [searchQuery, setSearchQuery] = useState('');
38-
const {
39-
selectedContentId,
40-
setSelectedContentId,
41-
selectedVersion,
42-
setSelectedVersion,
43-
selectedLocale,
44-
} = useAppState();
37+
const { setSelectedContentId, selectedVersion, setSelectedVersion } = useAppState();
4538

4639
const handleClose = () => {
4740
setSearchQuery('');
@@ -51,7 +44,6 @@ export const VersionSelector = ({ versions, isOpen, onClose }: Props) => {
5144
const selectVersion = (versionId: string) => {
5245
const nodeId = versions.find((v) => v.versionId === versionId)?.nodeId;
5346
if (nodeId) setSelectedContentId(nodeId);
54-
updateContentUrl(selectedContentId ?? '', selectedLocale, versionId);
5547
setSelectedVersion(versionId);
5648
handleClose();
5749
};

0 commit comments

Comments
 (0)
Please sign in to comment.