Skip to content

Commit 5a6c6a8

Browse files
committed
fix: in react ui, traces with empty topology model render as empty space
This also fixes some react eslint warnings. Signed-off-by: Nick Mitchell <[email protected]>
1 parent 637edad commit 5a6c6a8

File tree

5 files changed

+17
-38
lines changed

5 files changed

+17
-38
lines changed

pdl-live-react/src/view/masonry/MasonryCombo.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { useEffect, useMemo, useState } from "react"
22
import { BackToTop, PageSection } from "@patternfly/react-core"
33

4-
import Memory from "../memory/Memory"
4+
import Topology from "../memory/Topology"
5+
import extractVariables from "../memory/model"
56
import Timeline from "../timeline/TimelineFromModel"
67

78
import Masonry from "./Masonry"
@@ -50,6 +51,10 @@ export default function MasonryCombo({ value, setValue }: Props) {
5051
[block],
5152
)
5253

54+
// This is the <Topology/> model. We compute this here, so we can
55+
// nicely not render anything if we have an empty topology model.
56+
const { nodes, edges } = useMemo(() => extractVariables(block), [block])
57+
5358
if (!block) {
5459
return "Invalid trace content"
5560
}
@@ -74,8 +79,13 @@ export default function MasonryCombo({ value, setValue }: Props) {
7479
>
7580
<Masonry model={masonry} as={as} sml={sml}>
7681
{sml !== "s" && <Timeline model={base} numbering={numbering} />}
77-
{(as !== "list" || sml !== "s") && (
78-
<Memory block={block} numbering={numbering} sml={sml} />
82+
{(as !== "list" || sml !== "s") && nodes.length > 0 && (
83+
<Topology
84+
nodes={nodes}
85+
edges={edges}
86+
numbering={numbering}
87+
sml={sml}
88+
/>
7989
)}
8090
</Masonry>
8191
</PageSection>

pdl-live-react/src/view/masonry/MasonryTile.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export default function MasonryTile({
5252
),
5353
}
5454
: undefined,
55-
[start_nanos, end_nanos, timezone, as],
55+
[start_nanos, end_nanos, timezone, as, sml],
5656
)
5757

5858
return (

pdl-live-react/src/view/masonry/ToolbarReplayButton.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
1-
import { useCallback, useState } from "react"
2-
import { useLocation, useNavigate } from "react-router"
3-
41
import { invoke } from "@tauri-apps/api/core"
5-
62
import { Button, Tooltip } from "@patternfly/react-core"
3+
import { useCallback, useState } from "react"
74

85
type Props = {
96
block: import("../../pdl_ast").PdlBlock
107
setValue(value: string): void
118
}
129

1310
export default function ToolbarReplayButton({ block, setValue }: Props) {
14-
const { hash } = useLocation()
15-
const navigate = useNavigate()
1611
const [isReplaying, setIsReplaying] = useState(false)
1712

1813
const handleClickSource = useCallback(async () => {
@@ -28,7 +23,7 @@ export default function ToolbarReplayButton({ block, setValue }: Props) {
2823
} finally {
2924
setIsReplaying(false)
3025
}
31-
}, [hash, navigate, setIsReplaying])
26+
}, [block, setValue, setIsReplaying])
3227

3328
return (
3429
<Tooltip content="Re-run this program">

pdl-live-react/src/view/memory/Memory.tsx

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

pdl-live-react/src/view/memory/Topology.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export default function Topology({ sml, nodes, edges, numbering }: Props) {
7474
}
7575

7676
controller.fromModel(model, false)
77-
}, [sml, nodes, edges, controller])
77+
}, [sml, nodes, edges, numbering, controller])
7878

7979
return (
8080
<div className="pdl-memory-topology">

0 commit comments

Comments
 (0)