Skip to content

Commit eb2d1ab

Browse files
committed
fix: in react ui, detail for 'Output of Program' should also show 'Output of Program'
Signed-off-by: Nick Mitchell <[email protected]>
1 parent e2efe36 commit eb2d1ab

File tree

2 files changed

+12
-15
lines changed

2 files changed

+12
-15
lines changed

pdl-live-react/src/view/breadcrumbs/BreadcrumbBarForBlockId.tsx

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,23 +33,18 @@ export default function BreadcrumbBarForBlockId({
3333
const [searchParams] = useSearchParams()
3434
const s = searchParams.toString().length === 0 ? "" : "&" + searchParams
3535
const onClick = useCallback(
36-
() =>
37-
navigate(
38-
`?detail&type=block&id=${id.replace(/\.Output of Program$/, "")}${s}${hash}`,
39-
),
36+
() => navigate(`?detail&type=block&id=${id}${s}${hash}`),
4037
[id, hash, s, navigate],
4138
)
4239

4340
// Notes:
44-
// 1) in "compact" mode, don't show Text.3.If.1; instead show Text.If
45-
// 2) also always strip of initial Text.
46-
// 3) always simplify the presentation of the final output
47-
const crumbs = (
48-
isCompact
49-
? id.replace(/(text|empty|if)\.\d+/g, "$1").replace(/^text\./, "")
50-
: id
51-
)
52-
.replace(/^.*(Output of Program)$/, "$1")
41+
// 1) in compact mode, don't show "Text.3.If.1"; instead show "Text.If"
42+
// 2) also in compact mode, always strip of initial "Text."
43+
// 3) replace ids within dots (i.e. roots) with "Output of Program"
44+
const crumbs = id
45+
.replace(/^[^.]+$/, "Output of Program")
46+
.replace(/(text|empty|if)\.\d+/g, (p0, p1) => (isCompact ? p1 : p0))
47+
.replace(/^text\./, (p0) => (isCompact ? "" : p0))
5348
.split(/\./)
5449

5550
if (def) {

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function result(block: import("../../pdl_ast").PdlBlock) {
1717
if (hasResult(block) && hasTimingInformation(block)) {
1818
return [
1919
{
20-
id: block.id + ".Output of Program",
20+
id: block.id ?? "",
2121
depth: 0,
2222
parent: null,
2323
block,
@@ -72,7 +72,9 @@ export default function computeModel(block: import("../../pdl_ast").PdlBlock) {
7272
return []
7373
})
7474
.filter(removeFluff)
75-
.sort((a, b) => a.id.localeCompare(b.id))
75+
.sort((a, b) => (!/\./.test(a.id) ? 1 : a.id.localeCompare(b.id)))
76+
// ^^^ re: the regexp test, we want to place the "final output"
77+
// (i.e. blocks without a "." in their id) at the end
7678

7779
const numbering = masonry.reduce(
7880
(N, node, idx) => {

0 commit comments

Comments
 (0)