Skip to content

Commit e778549

Browse files
committed
fix: ui Source tab shows pdl__usage field
This also cleans up that logic to avoid the explicit `delete` calls. Signed-off-by: Nick Mitchell <[email protected]>
1 parent 0f2f4f0 commit e778549

File tree

1 file changed

+11
-18
lines changed

1 file changed

+11
-18
lines changed

pdl-live-react/src/view/code/Code.tsx

+11-18
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import { lazy, Suspense } from "react"
2-
32
import { stringify } from "yaml"
4-
import { match, P } from "ts-pattern"
53

64
import { tryJsonPrettyPrint } from "../../helpers"
75
import { type PdlBlock } from "../../pdl_ast"
@@ -52,23 +50,20 @@ export default function Code({
5250
}
5351

5452
function block_code_cleanup(data: string | PdlBlock): string | PdlBlock {
55-
if (
56-
data === null ||
57-
typeof data === "boolean" ||
58-
typeof data === "number" ||
59-
typeof data === "string"
60-
) {
53+
if (data === null || typeof data !== "object") {
6154
return data
6255
}
6356
// remove pdl__result
64-
const new_data = { ...data, pdl__result: undefined, pdl__is_leaf: undefined }
65-
// remove trace
66-
match(new_data).with({ pdl__trace: P._ }, (data) => {
67-
delete data.pdl__trace
68-
})
69-
// remove other trace artifacts
70-
delete new_data.pdl__id
71-
delete new_data.pdl__timing
57+
const new_data = {
58+
...data,
59+
pdl__result: undefined,
60+
pdl__is_leaf: undefined,
61+
pdl__usage: undefined,
62+
pdl__trace: undefined,
63+
pdl__id: undefined,
64+
pdl__timing: undefined,
65+
pdl__location: undefined,
66+
}
7267
// remove contribute: ["result", context]
7368
if (
7469
new_data?.contribute?.includes("result") &&
@@ -80,8 +75,6 @@ function block_code_cleanup(data: string | PdlBlock): string | PdlBlock {
8075
if (Object.keys(data?.defs ?? {}).length === 0) {
8176
delete new_data.defs
8277
}
83-
// remove location info
84-
delete new_data.pdl__location
8578
// recursive cleanup
8679
return map_block_children(block_code_cleanup, new_data)
8780
}

0 commit comments

Comments
 (0)