Skip to content

Commit 85d7253

Browse files
committed
feat: consolidate Show Source + Output of Program
We have been showing program output in the masonry view and program source under the top-level toolbar Show Source button. This consolidates these: we aleady have the capability to show source+output of any block in the drawer/detail view. So: remove output from masonry, and update Show Source button so that, rather than special case a "source" object type, just show the root block detail. Also: fixes a few react eslint warnings. Signed-off-by: Nick Mitchell <[email protected]>
1 parent 22b296d commit 85d7253

File tree

7 files changed

+19
-32
lines changed

7 files changed

+19
-32
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export default function PageBreadcrumbDropdownItem({
1919

2020
const onClick = useCallback(
2121
() => navigate("/" + url + "/" + name + search + hash),
22-
[name],
22+
[name, url, hash, search, navigate],
2323
)
2424
return (
2525
<DropdownItem onClick={onClick} isDisabled={name === current}>

pdl-live-react/src/view/detail/DrawerContent.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@ type Props = {
2828

2929
function header(objectType: string) {
3030
switch (objectType) {
31-
case "source":
32-
case "rawtrace":
33-
return "Application Code"
3431
case "def":
3532
return "Variable Definition"
3633
default:

pdl-live-react/src/view/detail/DrawerContentBody.tsx

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,6 @@ import {
1414
type NonScalarPdlBlock as Model,
1515
} from "../../helpers"
1616

17-
function sourceBody(value: string) {
18-
return [
19-
<Tab key={0} eventKey={0} title={<TabTitleText>Source</TabTitleText>}>
20-
<Suspense>
21-
<SourceTabContent block={JSON.parse(value)} />
22-
</Suspense>
23-
</Tab>,
24-
<Tab key={1} eventKey={1} title={<TabTitleText>Raw Trace</TabTitleText>}>
25-
<Suspense>
26-
<RawTraceTabContent block={JSON.parse(value)} />
27-
</Suspense>
28-
</Tab>,
29-
]
30-
}
31-
3217
function defBody(_def: string | null, block: Model) {
3318
const value = hasResult(block) ? block.result : undefined
3419
return (
@@ -88,9 +73,6 @@ export default function DrawerContentBody({
8873
model,
8974
}: Props) {
9075
switch (objectType) {
91-
case "source":
92-
case "rawtrace":
93-
return sourceBody(value)
9476
case "def":
9577
if (!model) {
9678
return (

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export default function MasonryTile({
9090
</>
9191
),
9292
}),
93-
[myRun, start_nanos, end_nanos, timezone, sml],
93+
[isRunning, tileActions, myRun, start_nanos, end_nanos, timezone, sml],
9494
)
9595

9696
const maxHeight =

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import ToolbarSMLToggle from "./ToolbarSMLToggle"
55
import ToolbarReplayButton from "./ToolbarReplayButton"
66
import ToolbarShowSourceButton from "./ToolbarShowSourceButton"
77

8+
import { isNonScalarPdlBlock } from "../../helpers"
9+
810
const alignEnd = { default: "alignEnd" as const }
911

1012
export type SML = "s" | "m" | "l" | "xl"
@@ -25,7 +27,9 @@ export default function MasonryToolbar({ block, run, sml, setSML }: Props) {
2527
<ToolbarReplayButton block={block} run={run} />
2628
</ToolbarGroup>
2729
<ToolbarGroup align={alignEnd} variant="action-group">
28-
<ToolbarShowSourceButton />
30+
{isNonScalarPdlBlock(block) && (
31+
<ToolbarShowSourceButton root={block.id ?? ""} />
32+
)}
2933
<ToolbarSMLToggle sml={sml} setSML={setSML} />
3034
<DarkModeToggle />
3135
</ToolbarGroup>

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@ import { useLocation, useNavigate, useSearchParams } from "react-router"
44
import { Button, Tooltip } from "@patternfly/react-core"
55
import Icon from "@patternfly/react-icons/dist/esm/icons/code-icon"
66

7-
export default function ToolbarShowSourceButton() {
7+
type Props = {
8+
/** Root of the program */
9+
root: string
10+
}
11+
12+
export default function ToolbarShowSourceButton({ root }: Props) {
813
const { hash } = useLocation()
914
const navigate = useNavigate()
1015
const [searchParams] = useSearchParams()
@@ -15,12 +20,12 @@ export default function ToolbarShowSourceButton() {
1520
navigate(hash)
1621
} else {
1722
// open detail
18-
navigate("?detail&type=source" + hash)
23+
navigate(`?detail&type=block&id=${root}${hash}`)
1924
}
20-
}, [hash, navigate, searchParams])
25+
}, [hash, navigate, searchParams, root])
2126

2227
return (
23-
<Tooltip content="Show program source">
28+
<Tooltip content="Show program source and program output">
2429
<Button size="sm" variant="secondary" icon={<Icon />} onClick={onClick} />
2530
</Tooltip>
2631
)

pdl-live-react/src/view/masonry/model.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {
66
hasInput,
77
hasMessage,
88
hasParser,
9-
hasResult,
109
hasScalarResult,
1110
hasTimingInformation,
1211
capitalizeAndUnSnakeCase,
@@ -17,7 +16,7 @@ import {
1716
import type Tile from "./Tile"
1817

1918
/** The final result of the block */
20-
function result(block: import("../../pdl_ast").PdlBlock) {
19+
/* function result(block: import("../../pdl_ast").PdlBlock) {
2120
if (hasResult(block) && hasTimingInformation(block)) {
2221
return [
2322
{
@@ -31,7 +30,7 @@ function result(block: import("../../pdl_ast").PdlBlock) {
3130
}
3231
3332
return []
34-
}
33+
} */
3534

3635
/** Remove objects from the Masonry model that aren't helpful to display */
3736
function removeFluff({ kind }: { kind?: string }) {
@@ -44,7 +43,7 @@ export default function computeModel(block: import("../../pdl_ast").PdlBlock) {
4443
const base = computeBaseModel(block)
4544

4645
const masonry: Tile[] = base
47-
.concat(result(block))
46+
// .concat(result(block))
4847
.flatMap(({ id, block, children }) => {
4948
if (children.length === 0 && hasTimingInformation(block)) {
5049
const { resultForDisplay, meta, lang } = isLLMBlock(block)

0 commit comments

Comments
 (0)