Skip to content

Commit 2fbe7c5

Browse files
committed
refactor: in react ui, consolidate Viewer and MasonryCombo
Signed-off-by: Nick Mitchell <[email protected]>
1 parent 3cae86c commit 2fbe7c5

File tree

4 files changed

+17
-22
lines changed

4 files changed

+17
-22
lines changed
File renamed without changes.

pdl-live-react/src/page/Page.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import { useEffect, useState } from "react"
33

44
import { Page, PageSection } from "@patternfly/react-core"
55

6-
import Viewer from "./Viewer"
76
import Sidebar from "./Sidebar"
87
import Masthead from "./Masthead"
8+
import MasonryCombo from "../view/masonry/MasonryCombo"
99
import DrawerContent from "../view/detail/DrawerContent"
1010
import PageBreadcrumbs, { type PageBreadcrumbProps } from "./PageBreadcrumbs"
1111

@@ -14,6 +14,8 @@ import DarkModeContext, {
1414
getDarkModeUserSetting,
1515
} from "./DarkModeContext"
1616

17+
import "./Page.css"
18+
1719
const withPadding = { default: "padding" as const }
1820
const withoutPadding = { default: "noPadding" as const }
1921

@@ -65,7 +67,7 @@ export default function PDLPage(props: Props) {
6567
}
6668
>
6769
{!children ? (
68-
value && value.length > 0 && <Viewer value={value} />
70+
value && value.length > 0 && <MasonryCombo value={value} />
6971
) : (
7072
<PageSection
7173
isFilled

pdl-live-react/src/page/Viewer.tsx

Lines changed: 0 additions & 18 deletions
This file was deleted.

pdl-live-react/src/view/masonry/MasonryTimelineCombo.tsx renamed to pdl-live-react/src/view/masonry/MasonryCombo.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import Toolbar, { type As, type SML } from "./Toolbar"
1010
import "./Masonry.css"
1111

1212
type Props = {
13-
block: import("../../pdl_ast").PdlBlock
13+
value: string
1414
}
1515

1616
const asLocalStorageKey = "pdl-viewer.masonry.as"
@@ -29,7 +29,14 @@ function setSMLUserSetting(sml: SML) {
2929
localStorage.setItem(smlLocalStorageKey, sml)
3030
}
3131

32-
export default function MasonryTimelineCombo({ block }: Props) {
32+
/** Combines <Masonry/>, <Timeline/>, ... */
33+
export default function MasonryCombo({ value }: Props) {
34+
const block = useMemo(
35+
() =>
36+
value ? (JSON.parse(value) as import("../../pdl_ast").PdlBlock) : null,
37+
[value],
38+
)
39+
3340
const [as, setAs] = useState<As>(getAsUserSetting())
3441
const [sml, setSML] = useState<SML>(getSMLUserSetting())
3542

@@ -41,6 +48,10 @@ export default function MasonryTimelineCombo({ block }: Props) {
4148
[block],
4249
)
4350

51+
if (!block) {
52+
return "Invalid trace content"
53+
}
54+
4455
return (
4556
<>
4657
<PageSection type="subnav">

0 commit comments

Comments
 (0)