Skip to content

Commit 395dab5

Browse files
committed
Remove json-view
1 parent b039813 commit 395dab5

File tree

5 files changed

+8
-35
lines changed

5 files changed

+8
-35
lines changed

xp-archive/client/content/Content.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import { ContentView } from '../contentView/ContentView';
77

88
import style from './Content.module.css';
99

10-
const getDefaultView = (isWebpage: boolean, hasAttachment: boolean): ViewVariant => {
10+
const getDefaultView = (isWebpage: boolean, hasAttachment: boolean): ViewVariant | undefined => {
1111
if (isWebpage) return 'html';
1212
if (hasAttachment) return 'filepreview';
13-
return 'json';
13+
return undefined;
1414
};
1515

1616
export const Content = () => {
@@ -26,7 +26,7 @@ export const Content = () => {
2626

2727
const isWebpage = !!data?.html && !data.json.attachment;
2828
const hasAttachment = !!data?.json.attachment;
29-
const [selectedView, setSelectedView] = useState<ViewVariant>(
29+
const [selectedView, setSelectedView] = useState<ViewVariant | undefined>(
3030
getDefaultView(isWebpage, hasAttachment)
3131
);
3232

@@ -36,7 +36,7 @@ export const Content = () => {
3636

3737
return (
3838
<>
39-
{selectedContentId ? (
39+
{selectedContentId && selectedView ? (
4040
<div className={style.content}>
4141
<div className={style.top}>
4242
<ViewSelector

xp-archive/client/contentView/ContentView.tsx

-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { ContentServiceResponse } from 'shared/types';
55
import { Loader } from '@navikt/ds-react';
66
import { HtmlView } from './htmlView/HtmlView';
77
import { FilePreviewWrapper } from './filePreview/FilePreviewWrapper';
8-
import { ContentJsonView } from './contentJsonView/contentJsonView';
98

109
import style from './ContentView.module.css';
1110

@@ -15,7 +14,6 @@ const getDisplayComponent = (viewVariant: ViewVariant, data?: ContentServiceResp
1514
html: <HtmlView html={data.html} versionId={data.json._id} locale={data.json.language} />,
1615
filepreview: <FilePreviewWrapper content={data.json} />,
1716
pdf: <PdfExport versions={data.versions} />,
18-
json: <ContentJsonView json={data.json} />,
1917
};
2018
return components[viewVariant];
2119
};

xp-archive/client/contentView/contentJsonView/ContentJsonView.module.css

-4
This file was deleted.

xp-archive/client/contentView/contentJsonView/contentJsonView.tsx

-20
This file was deleted.

xp-archive/client/viewSelector/ViewSelector.tsx

+4-5
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,21 @@ import React from 'react';
22
import { ToggleGroup } from '@navikt/ds-react';
33
import style from './ViewSelector.module.css';
44

5-
export type ViewVariant = 'html' | 'pdf' | 'json' | 'filepreview';
5+
export type ViewVariant = 'html' | 'pdf' | 'filepreview';
66

77
const getDisplayname = (viewVariant: ViewVariant) => {
88
const translations: Record<ViewVariant, string> = {
99
html: 'HTML',
1010
filepreview: 'Forhåndsvisning',
1111
pdf: 'PDF',
12-
json: 'JSON',
1312
};
1413
return translations[viewVariant];
1514
};
1615

1716
function getRelevantViewVariants(isWebpage: boolean, hasAttachment: boolean): ViewVariant[] {
18-
if (isWebpage) return ['html', 'pdf', 'json'];
19-
if (hasAttachment) return ['filepreview', 'json'];
20-
return ['json'];
17+
if (isWebpage) return ['html', 'pdf'];
18+
if (hasAttachment) return ['filepreview'];
19+
return [];
2120
}
2221

2322
type Props = {

0 commit comments

Comments
 (0)